23 #include <QtGui/QGridLayout>
24 #include <QtGui/QLineEdit>
25 #include <QtGui/QDoubleValidator>
26 #include <QtGui/QHBoxLayout>
27 #include <QtGui/QLabel>
32 expr(
"",SeExpr2::ExprType().FP(1))
35 setFixedSize(width, height+30);
36 QVBoxLayout* vbox=
new QVBoxLayout;
39 vbox->addWidget(
view,0,Qt::AlignLeft | Qt::AlignTop);
40 QHBoxLayout* hbox=
new QHBoxLayout;
41 vbox->addLayout(hbox);
44 float xmin,xmax,ymin,ymax,
z;
46 scale=
new QLineEdit();
47 QDoubleValidator *valValidator =
new QDoubleValidator(0.0,10000000.0,6,
scale);
48 scale->setValidator(valValidator);
49 scale->setValidator(valValidator);
57 hbox->addWidget(
new QLabel(
"Width"),0);
58 hbox->addWidget(
scale,0);
63 float xmin,xmax,ymin,ymax,
z;
65 float xdiff=xmax-xmin,ydiff=ymax-ymin;
66 float xcenter=.5*(xmax+xmin),ycenter=.5*(ymin+ymax);
67 float newScale=atof(
scale->text().toStdString().c_str());
69 float aspect=ydiff/xdiff;
71 xmin=xcenter-newScale;
72 xmax=xcenter+newScale;
73 ymin=ycenter-aspect*newScale;
74 ymax=ycenter+aspect*newScale;
80 float xmin,xmax,ymin,ymax,
z;
82 scale->setText(QString(
"%1").arg(.5*(xmax-xmin)));
99 : QGLWidget(parent), widget(widget), _image(NULL), _width(width), _height(height),
100 scaling(false),translating(false)
102 this->setFixedSize(width, height);
108 setCursor(Qt::OpenHandCursor);
140 for (
int row = 0; row <
_height; ++row) {
141 for (
int col = 0; col <
_width; ++col) {
142 int index = 3*row*_width + 3*col;
152 if(event->button()==Qt::MidButton){
153 setCursor(Qt::ClosedHandCursor);
156 if(event->button()==Qt::RightButton){
157 setCursor(Qt::SizeAllCursor);
166 if(event->button()==Qt::LeftButton)
169 setCursor(Qt::OpenHandCursor);
173 int x=
event->x(),
y=
event->y();
185 float offset=(fabs(offsetx)>fabs(offsety))?offsetx:offsety;
192 height*=scale_factor;
193 setWindow(xcenter-width,xcenter+width,ycenter-height,ycenter+height,
z);
219 for(
int row=0;row<
_height;row++,y+=
dy,v+=dv){
223 for(
int col=0;col<
_width;col++,x+=
dy,u+=du){
228 _image[index+1] = value[1];
229 _image[index+2] = value[2];
239 glMatrixMode(GL_PROJECTION);
242 glMatrixMode(GL_MODELVIEW);
245 glDisable(GL_DEPTH_TEST);
247 glClearColor(1,0,0,1);
248 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
251 glDrawPixels(_width, _height, GL_RGB, GL_FLOAT,
_image);
void mouseMoveEvent(QMouseEvent *event)
</pre >< h2 > Evaluating expressions</h2 > Evaluating an expression is pretty easy But before we can do that we need to make an instance< pre > GrapherExpr expr("x+x^2")
void mouseReleaseEvent(QMouseEvent *event)
void setDesiredReturnType(const ExprType &type)
ExprGrapherWidget & widget
void setWindow(float xmin, float xmax, float ymin, float ymax, float z)
ExprGrapherView(ExprGrapherWidget &widget, QWidget *parent, int width, int height)
with numParticles numAttributes A variable block contains variable names and types but doesn t care what the values are< pre > void f(const std::string &s, MyParticleData *p, int outputDim=3)
For any rgb or hsl value(except for negative s values)
void getWindow(float &xmin, float &xmax, float &ymin, float &ymax, float &z)
The result is computed int int< br >< divstyle="margin-left:40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed). 
Vec< double, 3, false > Vec3d
< br > pow($a, 0.5)+$b< br >< br ></div > External variables can also be overridden by local assignment. 
</pre >< h3 > A simple variable reference</h3 > This is not a very interesting subclass of expression until we add some additional variables Variables on some applications may be very dynamic In this we only need x
void mousePressEvent(QMouseEvent *event)
void scaleValueManipulated()
const double * evalFP(VarBlock *varBlock=nullptr) const
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float float z
virtual ~ExprGrapherView()
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y