25 #include <QtGui/QDialog>
26 #include <QtGui/QDoubleValidator>
27 #include <QtGui/QGraphicsSceneMouseEvent>
28 #include <QtGui/QHBoxLayout>
29 #include <QtGui/QLabel>
30 #include <QtGui/QVBoxLayout>
31 #include <QtGui/QPushButton>
32 #include <QtGui/QResizeEvent>
33 #include <QtGui/QDialogButtonBox>
34 #include <QtGui/QMenu>
36 #include <SeExpr2/ExprBuiltins.h>
49 emit
resizeSignal(event->size().width(),
event->size().height());
69 setSceneRect(-9, -7, width, height);
79 for(
unsigned int i=0;i<
_cvs.size();i++)
91 int newIndex=
_cvs.size()-1;
114 if (((event->key() == Qt::Key_Backspace) ||
125 QPointF pos = mouseEvent->scenePos();
127 QList<QGraphicsItem *> itemList = items(pos);
128 if (itemList.empty()) {
132 }
else if (itemList[0]->zValue() == 2) {
135 for (
int i = 0; i < numCircle; i++ ) {
137 if (obj == itemList[0]) {
145 if(mouseEvent->buttons() == Qt::LeftButton){
147 double myx=pos.x()/
_width;
162 QMenu *menu =
new QMenu(event->widget());
163 QAction *deleteAction = menu->addAction(
"Delete Point");
165 QAction *action = menu->exec(event->screenPos());
173 QPointF
point = mouseEvent->scenePos();
192 Q_UNUSED(mouseEvent);
256 _curvePoly = addPolygon(QPolygonF(), QPen(Qt::black, 1.0), QBrush(Qt::darkGray));
260 poly.append(QPointF(
_width, 0));
261 poly.append(QPointF(0, 0));
262 for (
int i = 0; i < 1000; i++) {
266 poly.append(QPointF(
_width, 0));
279 const int numCV =
_cvs.size();
280 for (
int i = 0; i < numCV; i++) {
284 pen = QPen(Qt::white,1.0);
286 pen = QPen(Qt::black,1.0);
290 circle->setFlag(QGraphicsItem::ItemIsMovable,
true);
291 circle->setZValue(2);
296 bool expandable) : QWidget(parent), _scene(0), _selPosEdit(0), _selValEdit(0), _interpComboBox(0)
299 QHBoxLayout *mainLayout =
new QHBoxLayout();
300 mainLayout->setSpacing(2);
301 mainLayout->setMargin(4);
303 QWidget *edits =
new QWidget;
304 QVBoxLayout *editsLayout =
new QVBoxLayout;
305 editsLayout->setAlignment(Qt::AlignTop);
306 editsLayout->setSpacing(0);
307 editsLayout->setMargin(0);
308 edits->setLayout(editsLayout);
310 QWidget *selPos =
new QWidget;
311 QHBoxLayout *selPosLayout =
new QHBoxLayout;
312 selPosLayout->setSpacing(1);
313 selPosLayout->setMargin(1);
314 selPos->setLayout(selPosLayout);
316 QDoubleValidator *posValidator =
new QDoubleValidator(0.0,1.0,6,
_selPosEdit);
318 int editwidth = QFontMetrics(font()).width(
"9.999")+8;
321 selPosLayout->addStretch(50);
323 if (pLabel.isEmpty()) {
324 posLabel =
new QLabel(
"Selected Position: ");
326 posLabel =
new QLabel(pLabel);
328 selPosLayout->addWidget(posLabel);
331 QWidget *selVal =
new QWidget;
332 QBoxLayout *selValLayout =
new QHBoxLayout;
333 selValLayout->setSpacing(1);
334 selValLayout->setMargin(1);
335 selVal->setLayout(selValLayout);
337 QDoubleValidator *valValidator =
new QDoubleValidator(0.0,1.0,6,
_selValEdit);
341 selValLayout->addStretch(50);
343 if (vLabel.isEmpty()) {
344 valLabel =
new QLabel(
"Selected Value: ");
346 valLabel =
new QLabel(vLabel);
348 selValLayout->addWidget(valLabel);
362 editsLayout->addWidget(selPos);
363 editsLayout->addWidget(selVal);
366 QFrame *curveFrame =
new QFrame;
367 curveFrame->setFrameShape(QFrame::Panel);
368 curveFrame->setFrameShadow(QFrame::Sunken);
369 curveFrame->setLineWidth(1);
370 QHBoxLayout *curveFrameLayout =
new QHBoxLayout;
371 curveFrameLayout->setMargin(0);
373 curveView->setFrameShape(QFrame::Panel);
374 curveView->setFrameShadow(QFrame::Sunken);
375 curveView->setLineWidth(1);
376 curveView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
377 curveView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
379 curveView->setScene(
_scene);
380 curveView->setTransform(QTransform().scale(1, -1));
381 curveView->setRenderHints(QPainter::Antialiasing);
382 curveFrameLayout->addWidget(curveView);
383 curveFrame->setLayout(curveFrameLayout);
385 mainLayout->addWidget(edits);
386 mainLayout->addWidget(curveFrame);
388 QPushButton* expandButton=
new QPushButton(
">");
389 expandButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
390 expandButton->setFixedWidth(15);
391 mainLayout->addWidget(expandButton);
393 connect(expandButton, SIGNAL(clicked()),
this, SLOT(
openDetail()));
395 mainLayout->setStretchFactor(curveFrame,100);
396 setLayout(mainLayout);
411 connect(curveView, SIGNAL(resizeSignal(
int,
int)),
_scene, SLOT(resize(
int,
int)));
420 if (pos >= 0.0) posStr.setNum(pos,
'f', 3);
423 if (val >= 0.0) valStr.setNum(val,
'f', 3);
432 double pos = QString(
_selPosEdit->text()).toDouble();
433 _selPosEdit->setText(QString(
"%1").arg(pos, 0,
'f', 3));
441 double val = QString(
_selValEdit->text()).toDouble();
443 _selValEdit->setText(QString(
"%1").arg(val, 0,
'f', 3));
449 QDialog* dialog=
new QDialog();
450 dialog->setMinimumWidth(1024);
451 dialog->setMinimumHeight(400);
455 const std::vector<T_CURVE::CV>& data=
_scene->
_cvs;
456 typedef std::vector<T_CURVE::CV>::const_iterator ITERATOR;
457 for(ITERATOR i=data.begin();i!=data.end();++i)
458 curve->
addPoint(i->_pos,i->_val,i->_interp);
460 QVBoxLayout* layout=
new QVBoxLayout();
461 dialog->setLayout(layout);
462 layout->addWidget(curve);
463 QDialogButtonBox* buttonbar=
new QDialogButtonBox();
464 buttonbar->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
465 connect(buttonbar,SIGNAL(accepted()),dialog,SLOT(accept()));
466 connect(buttonbar,SIGNAL(rejected()),dialog,SLOT(reject()));
467 layout->addWidget(buttonbar);
469 if(dialog->exec()==QDialog::Accepted){
472 const std::vector<T_CURVE::CV>& dataNew=curve->
_scene->
_cvs;
473 typedef std::vector<T_CURVE::CV>::const_iterator ITERATOR;
474 for(ITERATOR i=dataNew.begin();i!=dataNew.end();++i)
475 addPoint(i->_pos,i->_val,i->_interp);
480 if(dialog->exec()==QDialog::Accepted){
483 const std::vector<T_CURVE::CV>& dataNew=curve->
_scene->
_cvs;
484 typedef std::vector<T_CURVE::CV>::const_iterator ITERATOR;
485 for(ITERATOR i=dataNew.begin();i!=dataNew.end();++i)
486 addPoint(i->_pos,i->_val,i->_interp);
void selValChangedSignal(double val)
SeExpr2::CurveFuncX curve
void preparePoints()
Prepares points for evaluation (sorts and computes boundaries, clamps extrema)
std::vector< QGraphicsEllipseItem * > _circleObjects
Interpolation curve class for double->double and double->Vec3D.
void cvSelectedSlot(double pos, double val, T_INTERP interp)
T getValue(const double param) const
Evaluates curve and returns full value.
void resize(const int width, const int height)
CV getLowerBoundCV(const double param) const
void resizeSignal(int width, int height)
QComboBox * _interpComboBox
virtual void resizeEvent(QResizeEvent *event)
virtual void keyPressEvent(QKeyEvent *event)
void selValChanged(double val)
SeExpr2::Curve< double > T_CURVE
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). 
void addPoint(const double x, const double y, const T_INTERP interp, bool select=false)
T_CURVE::InterpType T_INTERP
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
void selPosChangedSignal(double pos)
void addPoint(double x, double y, const T_INTERP interp, const bool select=true)
</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
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
void interpChanged(const int interp)
void selPosChanged(double pos)
void cvSelected(double x, double y, T_INTERP interp)
void removePoint(const int index)
QGraphicsRectItem * _baseRect
double clamp(double x, double lo, double hi)
QGraphicsPolygonItem * _curvePoly
ExprCurve(QWidget *parent=0, QString pLabel="", QString vLabel="", QString iLabel="", bool expandable=true)
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
void addPoint(double position, const T &val, InterpType type)
Adds a point to the curve.
InterpType
Supported interpolation types.
std::vector< T_CURVE::CV > _cvs
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y