230 QByteArray pixmap(len, 127);
232 double paramInc = 1.0 / (
_width - 2);
233 double param = 0.5 * paramInc;
235 char *ptr = pixmap.data();
239 for (
int i = 1; i <
_width - 1; i++) {
241 *ptr++ = char(std::min(std::max(0.0, 255 * color[0]), 255.0) + 0.5);
242 *ptr++ = char(std::min(std::max(0.0, 255 * color[1]), 255.0) + 0.5);
243 *ptr++ = char(std::min(std::max(0.0, 255 * color[2]), 255.0) + 0.5);
251 for (
int i = 1; i <
_height - 1; i++) {
252 memcpy(pixmap.data() + (i *
_width * 3), pixmap.data() + ((i - 1) *
_width * 3),
_width * 3);
256 memset(pixmap.data(), 0,
_width * 3);
347 : QWidget(parent), _scene(0), _selPosEdit(0), _selValEdit(0), _interpComboBox(0) {
349 QHBoxLayout *mainLayout =
new QHBoxLayout();
350 mainLayout->setSpacing(2);
351 mainLayout->setMargin(5);
353 QWidget *edits =
new QWidget;
354 QVBoxLayout *editsLayout =
new QVBoxLayout;
355 editsLayout->setAlignment(Qt::AlignTop);
356 editsLayout->setSpacing(0);
357 editsLayout->setMargin(0);
358 edits->setLayout(editsLayout);
360 QWidget *selPos =
new QWidget;
361 QHBoxLayout *selPosLayout =
new QHBoxLayout;
362 selPosLayout->setSpacing(1);
363 selPosLayout->setMargin(1);
364 selPos->setLayout(selPosLayout);
366 QDoubleValidator *posValidator =
new QDoubleValidator(0.0, 1.0, 6,
_selPosEdit);
370 selPosLayout->addStretch(50);
372 if (pLabel.isEmpty()) {
373 posLabel =
new QLabel(
"Selected Position: ");
375 posLabel =
new QLabel(pLabel);
377 selPosLayout->addWidget(posLabel);
380 QWidget *selVal =
new QWidget;
381 QBoxLayout *selValLayout =
new QHBoxLayout;
382 selValLayout->setSpacing(1);
383 selValLayout->setMargin(1);
384 selVal->setLayout(selValLayout);
388 selValLayout->addStretch(50);
390 if (vLabel.isEmpty()) {
391 valLabel =
new QLabel(
"Selected Color: ");
393 valLabel =
new QLabel(vLabel);
395 selValLayout->addWidget(valLabel);
408 editsLayout->addWidget(selPos);
409 editsLayout->addWidget(selVal);
412 QFrame *curveFrame =
new QFrame;
413 curveFrame->setFrameShape(QFrame::Panel);
414 curveFrame->setFrameShadow(QFrame::Sunken);
415 curveFrame->setLineWidth(1);
416 QHBoxLayout *curveFrameLayout =
new QHBoxLayout;
417 curveFrameLayout->setMargin(0);
419 curveView->setFrameShape(QFrame::Panel);
420 curveView->setFrameShadow(QFrame::Sunken);
421 curveView->setLineWidth(1);
422 curveView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
423 curveView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
425 curveView->setScene(
_scene);
426 curveView->setTransform(QTransform().scale(1, -1));
427 curveView->setRenderHints(QPainter::Antialiasing);
428 curveFrameLayout->addWidget(curveView);
429 curveFrame->setLayout(curveFrameLayout);
431 mainLayout->addWidget(edits);
432 mainLayout->addWidget(curveFrame);
434 QPushButton *expandButton =
new QPushButton(
">");
435 expandButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
436 expandButton->setFixedWidth(15);
437 mainLayout->addWidget(expandButton);
439 connect(expandButton, SIGNAL(clicked()),
this, SLOT(
openDetail()));
441 mainLayout->setStretchFactor(curveFrame, 100);
442 setLayout(mainLayout);
463 connect(curveView, SIGNAL(resizeSignal(
int,
int)),
_scene, SLOT(resize(
int,
int)));
503 QDialog *dialog =
new QDialog();
504 dialog->setMinimumWidth(1024);
505 dialog->setMinimumHeight(400);
509 const std::vector<T_CURVE::CV> &data =
_scene->
_cvs;
510 typedef std::vector<T_CURVE::CV>::const_iterator ITERATOR;
511 for (ITERATOR i = data.begin(); i != data.end(); ++i) curve->addPoint(i->_pos, i->_val, i->_interp);
513 QVBoxLayout *layout =
new QVBoxLayout();
514 dialog->setLayout(layout);
515 layout->addWidget(curve);
517 dialog->setLayout(layout);
518 layout->addWidget(curve);
519 QDialogButtonBox *buttonbar =
new QDialogButtonBox();
520 buttonbar->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
521 connect(buttonbar, SIGNAL(accepted()), dialog, SLOT(accept()));
522 connect(buttonbar, SIGNAL(rejected()), dialog, SLOT(reject()));
523 layout->addWidget(buttonbar);
525 if (dialog->exec() == QDialog::Accepted) {
528 const std::vector<T_CURVE::CV> &dataNew = curve->_scene->_cvs;
529 typedef std::vector<T_CURVE::CV>::const_iterator ITERATOR;
530 for (ITERATOR i = dataNew.begin(); i != dataNew.end(); ++i)
addPoint(i->_pos, i->_val, i->_interp);