25#include <QDoubleValidator>
32 setFixedSize(width, height + 30);
33 QVBoxLayout* vbox =
new QVBoxLayout;
36 vbox->addWidget(
view, 0, Qt::AlignLeft | Qt::AlignTop);
37 QHBoxLayout* hbox =
new QHBoxLayout;
38 vbox->addLayout(hbox);
41 float xmin, xmax, ymin, ymax,
z;
43 scale =
new QLineEdit();
44 QDoubleValidator* valValidator =
new QDoubleValidator(0.0, 10000000.0, 6,
scale);
45 scale->setValidator(valValidator);
46 scale->setValidator(valValidator);
53 hbox->addWidget(
new QLabel(
"Width"), 0);
54 hbox->addWidget(
scale, 0);
58 float xmin, xmax, ymin, ymax,
z;
60 float xdiff = xmax - xmin, ydiff = ymax - ymin;
61 float xcenter = .5 * (xmax + xmin), ycenter = .5 * (ymin + ymax);
62 float newScale = atof(
scale->text().toStdString().c_str());
64 float aspect = ydiff / xdiff;
66 xmin = xcenter - newScale;
67 xmax = xcenter + newScale;
68 ymin = ycenter - aspect * newScale;
69 ymax = ycenter + aspect * newScale;
74 float xmin, xmax, ymin, ymax,
z;
76 scale->setText(QString(
"%1").arg(.5 * (xmax - xmin)));
88 : QGLWidget(parent), widget(widget), _image(NULL), _width(width), _height(height), scaling(false),
90 this->setFixedSize(width, height);
96 setCursor(Qt::OpenHandCursor);
121 for (
int row = 0; row <
_height; ++row) {
122 for (
int col = 0; col <
_width; ++col) {
132 if (event->button() == Qt::MidButton) {
133 setCursor(Qt::ClosedHandCursor);
136 if (event->button() == Qt::RightButton) {
137 setCursor(Qt::SizeAllCursor);
144 if (event->button() == Qt::LeftButton) emit
clicked();
146 setCursor(Qt::OpenHandCursor);
149 int x =
event->x(),
y =
event->y();
161 float offset = (fabs(offsetx) > fabs(offsety)) ? offsetx : offsety;
166 float scale_factor =
pow(10.f, -offset / (
xmax -
xmin));
167 width *= scale_factor;
168 height *= scale_factor;
169 setWindow(xcenter - width, xcenter + width, ycenter - height, ycenter + height,
z);
192 for (
int row = 0; row <
_height; row++,
y +=
dy, v += dv) {
196 for (
int col = 0; col <
_width; col++,
x +=
dy, u += du) {
211 glMatrixMode(GL_PROJECTION);
213 glOrtho(0.0f, (GLfloat)
_width, 0.0, (GLfloat)
_height, -1.0, 1.0);
214 glMatrixMode(GL_MODELVIEW);
217 glDisable(GL_DEPTH_TEST);
219 glClearColor(1, 0, 0, 1);
220 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ExprGrapherView(ExprGrapherWidget &widget, QWidget *parent, int width, int height)
void getWindow(float &xmin, float &xmax, float &ymin, float &ymax, float &z)
void scaleValueManipulated()
virtual ~ExprGrapherView()
void setWindow(float xmin, float xmax, float ymin, float ymax, float z)
void mouseReleaseEvent(QMouseEvent *event)
void mousePressEvent(QMouseEvent *event)
ExprGrapherWidget & widget
void mouseMoveEvent(QMouseEvent *event)
void setDesiredReturnType(const ExprType &type)
const double * evalFP(VarBlock *varBlock=nullptr) const
Vec< double, 3, false > Vec3d
</pre >< h3 > Binding our variable reference</h3 > If we now tried to use the variable would still not be found by our expressions To make it bindable we need to override the resolveVar() function as follows</pre >< h3 > Variable setting</h3 > Next we need to make a way of setting the variable As the controlling code will use the expression it will repeatedly alternate between setting the independent variables that are used and calling evaluate(). What it has to do depends very much on the application. In this case we only need to set the independent variable x as</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")
</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
< br > pow($a, 0.5)+ $b< br >< br ></div > External variables can also be overridden by local assignment.  
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float float z
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed).  
For any rgb or hsl value(except for negative s values)