23 #include <QPushButton>
24 #include <QToolButton>
27 #include <QMouseEvent>
29 #include <QHBoxLayout>
30 #include <QVBoxLayout>
31 #include <QPaintEvent>
33 #include <QScrollArea>
34 #include <QSpacerItem>
35 #include <QSizePolicy>
36 #include <QTextCharFormat>
38 #include <QAbstractItemView>
39 #include <QStandardItemModel>
40 #include <QStringListModel>
41 #include <QFileDialog>
42 #include <QDialogButtonBox>
45 #include <QListWidget>
56 "20 20 4 1",
"# c #303030",
"a c #585858",
"b c #c3c3c3",
57 ". c #dcdcdc",
"....................",
"....................",
"....................",
58 ".......#aaaa#.......",
".....#########......",
"....###bbbbb###.....",
"....##b.....b##.....",
59 "...bb#b.....b##.....",
"...bbbb....aaaaaa...",
"...........aaaaaa...",
"....##......####....",
60 "...####......##.....",
"..######............",
"..aaa#aa............",
"....##......bbb.....",
61 "....##b...bbbab.....",
"....a#abbbb##ab.....",
".....#a####aa#b.....",
".....aaaaaaa#.b.....",
62 "...................."};
66 "20 20 5 1",
"c c #000040",
"a c #303030",
"# c #58a8ff",
67 ". c #dcdcdc",
"b c #ff0000",
"..........#a.a......",
"..........#a.a.....b",
68 "..........#.a.....bb",
"..........#aa....bb.",
"..........#.....bb..",
"..........#....bb...",
69 "..........#....bb...",
"....bbb...#...bb....",
"...bbbbb..#..bbb....",
"...b...bbb#.bbb.....",
70 "..bb....bb#bbb......",
"##bb####bbbbb#######",
".bb......bbb....c.c.",
".bb.......#......c..",
71 ".b........#.....c.c.",
"bb........#.........",
"b.........#.........",
"..........#.........",
72 "..........#.........",
"..........#........."};
76 "20 20 3 1",
". c None",
"# c #000000",
"a c #d8c59e",
77 "....................",
"....................",
"....................",
"....................",
78 "...........#######..",
"...........#aaaaa#..",
"..##########aaaaa#..",
"..#aaaaaaaaaaaaaa#..",
79 "..#aaaaaaaaaaaaaa#..",
"..#aaaaaaaaaaaaaa#..",
"..#aaaaaaaaaaaaaa#..",
"..#aaaaaaaaaaaaaa#..",
80 "..#aaaaa##a##a##a#..",
"..#aaaaa##a##a##a#..",
"..#aaaaaaaaaaaaaa#..",
"..################..",
81 "....................",
"....................",
"....................",
"...................."};
85 "20 20 5 1",
". c None",
"# c #000000",
"c c #303030",
86 "b c #a79b80",
"a c #ddcdaa",
"....................",
"....................",
87 "....#########.......",
"....#aaaaaaa##......",
"....#aaaaaaa#b#.....",
"....#aaaaaaa#bb#....",
88 "....#aaaaaaa####....",
"....#aaaaaaaaaa#....",
"....#aaaaaaaaaa#....",
"....#aaaaaaaaaa#....",
89 "....#aaaaaaaaaa#....",
"....#aaaaaaaaaa#....",
"....#aaaaaaaaaa#....",
"....#aaaaaaaaaa#....",
90 "....#aaaaaaaaaa#....",
"....#accaccacca#....",
"....#accaccacca#....",
"....#aaaaaaaaaa#....",
91 "....############....",
"...................."};
96 float r = maximum() - minimum();
97 float v = ((float)(e->x() - 2) *
r / (width() - 5)) + minimum() + .5f;
107 float r = maximum() - minimum();
108 int linepos = (int)((v - minimum()) /
r * (width() - 5) + 2);
110 QColor qcol = palette().color(QPalette::Dark);
111 QColor bcol = palette().color(QPalette::Midlight);
112 QColor dcol = bcol.lighter(140);
113 QColor bgcol = palette().color(QPalette::Base);
116 bcol = bcol.lighter(110);
117 bgcol = bgcol.lighter(110);
118 int mx = mapFromGlobal(QCursor::pos()).x();
119 if (abs(linepos - mx) < 4) dcol = dcol.lighter(200);
122 p.fillRect(1, 1, width() - 1, height() - 2, bgcol);
123 p.fillRect(1, 1, linepos - 1, height() - 2, bcol);
131 p.drawLine(linepos, 2, linepos, height() - 2);
135 p.drawLine(linepos - 2, 1, linepos - 2, height() - 1);
136 p.drawLine(linepos + 2, 1, linepos + 2, height() - 1);
141 p.drawRect(0, 0, width() - 1, height() - 1);
148 if (_value < 0 || _value > 1)
return;
149 int x = int(
_value * (width() - 3) + 0.5);
151 p.fillRect(contentsRect(),
_col);
152 p.fillRect(
x, 0, 3, height(), QColor(64, 64, 64));
167 : _id(id), _updating(false), _editable(editable) {
168 hbox =
new QHBoxLayout(
this);
178 _label =
new QLabel(QString(
"<b>") + editable->
name.c_str() +
"</b>");
179 _label->setFixedWidth(72);
180 _label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
182 _label->setAutoFillBackground(
true);
185 if (!showColorLink) {
187 _label->setFixedWidth(84);
197 if (state == Qt::Checked) {
214 :
ExprControl(id, editable, false), _numberEditable(editable) {
217 float smin = editable->
min, smax = editable->
max;
222 float srange = smax - smin;
224 _slider->setRange(
int(smin),
int(smax));
230 _slider->setFocusPolicy(Qt::ClickFocus);
234 _edit->setMinimumWidth(0);
235 _edit->setFixedHeight(16);
237 connect(
_edit, SIGNAL(textChanged(
int,
const QString&)), SLOT(
editChanged(
int,
const QString&)));
252 float val = text.toFloat(&ok);
274 :
ExprControl(id, editable, true), _numberEditable(editable) {
283 for (
int i = 0; i < 3; i++) {
284 QVBoxLayout* vbl =
new QVBoxLayout();
285 hbox->addLayout(vbl);
290 vbl->addWidget(edit);
292 edit->setMinimumWidth(0);
293 edit->setFixedHeight(16);
296 vbl->addWidget(slider);
298 slider->setFixedHeight(6);
300 static const QColor rgb[3] = {QColor(128, 64, 64), QColor(64, 128, 64), QColor(64, 64, 128)};
303 connect(edit, SIGNAL(textChanged(
int,
const QString&)), SLOT(
editChanged(
int,
const QString&)));
304 connect(slider, SIGNAL(valueChanged(
int,
float)), SLOT(
sliderChanged(
int,
float)));
319 return QColor::fromRgbF(
338 float val = text.toFloat(&ok);
346 for (
unsigned int i = 0; i < 3; i++)
_edits[i]->setText(QString(
"%1").arg(
_numberEditable->
v[i], 0,
'f', 3));
348 for (
unsigned int i = 0; i < 3; i++) {
354 float r =
clamp(val[0], 0, 1);
355 float g =
clamp(val[1], 0, 1);
356 float b =
clamp(val[2], 0, 1);
357 float lum =
r * .2 + g * .7 +
b * .1;
359 QPalette pal = palette();
360 pal.setColor(QPalette::Window, QColor(
int(
r * 255),
int(g * 255),
int(
b * 255)));
361 pal.setColor(QPalette::WindowText, (lum < 0.5) ? QColor(255, 255, 255) : QColor(0, 0, 0));
368 if (n < 0 || n >= 3)
return;
377 :
ExprControl(id, editable, false), _stringEditable(editable) {
379 _edit =
new QLineEdit();
380 _edit->setFixedHeight(20);
384 QPushButton* button =
new QPushButton();
385 button->setFixedSize(20, 20);
388 hbox->addWidget(button, 1);
393 connect(button, SIGNAL(clicked()), SLOT(
fileBrowse()));
394 button->setIcon(QIcon(QPixmap(
fileXPM)));
407 QString newFilename =
408 dialog.
getOpenFileName(
"Please choose a file",
_edit->text(), tr(
"Images (*.tif *.tx *.jpg *.ptx *.png)"));
409 if (newFilename !=
"")
_edit->setText(newFilename);
416 if (newFilename !=
"")
_edit->setText(newFilename);
428 :
ExprControl(id, editable, false), _curveEditable(editable) {
430 _curve->setFixedHeight(80);
433 for (
int i = 0; i < numVal; i++) {
450 :
ExprControl(id, editable, true), _curveEditable(editable) {
452 _curve->setFixedHeight(80);
455 for (
int i = 0; i < numVal; i++) {
476 std::vector<float>
x,
y;
492 QWidget::paintEvent(event);
493 QPainter painter(
this);
494 painter.setRenderHint(QPainter::Antialiasing,
true);
495 painter.setPen(QColor(255, 255, 255));
508 int x_pad_in_pixels = 25, y_pad_in_pixels = 15;
509 float xpad = x_pad_in_pixels * (
win_xmax -
win_xmin) / (width() - x_pad_in_pixels);
510 float ypad = y_pad_in_pixels * (
win_ymax -
win_ymin) / (height() - y_pad_in_pixels);
520 QBrush darkbrush(QColor(100, 100, 100), Qt::SolidPattern);
522 QBrush brush(QColor(150, 150, 150), Qt::SolidPattern);
527 painter.fillRect(area, brush);
530 for (
int i = 1; i < (int)
x.size(); i++) path.lineTo(
toScreen(
x[i],
y[i]));
535 painter.setPen(QColor(75, 50, 50));
536 painter.drawPath(path);
538 painter.setPen(QPen());
539 painter.drawText(right, Qt::AlignTop | Qt::AlignLeft, QString(
"%1").arg(
ymax, 0,
'f', 1));
540 painter.drawText(right, Qt::AlignBottom | Qt::AlignLeft, QString(
"%1").arg(
ymin, 0,
'f', 1));
541 painter.drawText(bottom, Qt::AlignTop | Qt::AlignLeft, QString(
"%1").arg(
xmin, 0,
'f', 1));
542 painter.drawText(bottom, Qt::AlignTop | Qt::AlignRight, QString(
"%1").arg(
xmax, 0,
'f', 1));
544 painter.setBrush(QBrush(QColor(0, 0, 0), Qt::SolidPattern));
545 for (
size_t i = 0; i <
cpx.size(); i++) {
550 #ifdef SEEXPR_USE_ANIMLIB
551 void sample(
const animlib::AnimCurve&
curve) {
552 int numKeys =
curve.getNumKeys();
558 const animlib::AnimKeyframe* key = &*
curve.getFirstKey();
559 xmin = key[0].getTime();
560 xmax = key[numKeys - 1].getTime();
564 for (
int i = 0; i < numKeys; i++) {
565 cpx.push_back(key[i].getTime());
566 cpy.push_back(key[i].getValue());
572 for (
int i = 0; i < nsamples; i++) {
574 float yeval =
curve.getValue(xeval);
594 :
ExprControl(id, editable, false), _editable(editable) {
603 QPushButton* refreshButton =
new QPushButton();
604 refreshButton->setMaximumWidth(30);
605 refreshButton->setIcon(QIcon(QPixmap(
refreshXPM)));
606 QPushButton* expandButton =
new QPushButton(
">");
607 expandButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
608 expandButton->setFixedWidth(15);
609 hbox->addWidget(expandButton);
612 hbox->addWidget(refreshButton);
614 #ifdef SEEXPR_USE_ANIMLIB
619 connect(refreshButton, SIGNAL(clicked()),
this, SLOT(
refreshClicked()));
622 #ifdef SEEXPR_USE_ANIMLIB
623 #include <CE/CETool.h>
628 #ifdef SEEXPR_USE_ANIMLIB
638 #ifdef SEEXPR_USE_ANIMLIB
639 QDialog* dialog =
new QDialog(
this);
640 CETool* tool =
new CETool;
641 animlib::AnimAttrID attr1(
"",
"");
642 animlib::AnimCurve& anim = *
new animlib::AnimCurve(attr1);
647 QVBoxLayout* layout =
new QVBoxLayout();
648 dialog->resize(QSize(1024, 640));
649 dialog->setLayout(layout);
650 layout->addWidget(widg);
651 tool->addCurve(&anim);
653 QDialogButtonBox* buttonbar =
new QDialogButtonBox();
654 buttonbar->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
655 connect(buttonbar, SIGNAL(accepted()), dialog, SLOT(accept()));
656 connect(buttonbar, SIGNAL(rejected()), dialog, SLOT(reject()));
657 layout->addWidget(buttonbar);
659 if (dialog->exec() == QDialog::Accepted) {
675 :
ExprControl(id, editable, false), _swatchEditable(editable), _indexLabel(false) {
721 :
ExprControl(id, editable, false), _deepWaterEditable(editable) {