1 #include "SpecialPixelTool.h"
4 #include <QColorDialog>
12 #include <QPushButton>
14 #include <QToolButton>
15 #include <QVBoxLayout>
18 #include "MainWindow.h"
19 #include "MdiCubeViewport.h"
21 #include "CubeStretch.h"
22 #include "Workspace.h"
36 p_dialog->setWindowTitle(
"Special Pixel Tool");
48 QVBoxLayout *layout =
new QVBoxLayout();
49 layout->addWidget(defaults, 0);
50 layout->addWidget(main, 0);
51 layout->addWidget(buttons, 0);
54 QPushButton *ok =
new QPushButton(
"Ok", buttons);
55 ok->setShortcut(Qt::Key_Enter);
56 connect(ok, SIGNAL(released()),
this, SLOT(
apply()));
57 connect(ok, SIGNAL(released()),
p_dialog, SLOT(hide()));
59 QPushButton *
apply =
new QPushButton(
"Apply", buttons);
60 connect(
apply, SIGNAL(released()),
this, SLOT(
apply()));
62 QPushButton *cancel =
new QPushButton(
"Cancel", buttons);
63 connect(cancel, SIGNAL(released()),
p_dialog, SLOT(hide()));
65 QPushButton *defaultBlackWhite =
new QPushButton(
"Default B&W", defaults);
66 connect(defaultBlackWhite, SIGNAL(released()),
this, SLOT(
defaultBW()));
68 QPushButton *
defaultColor =
new QPushButton(
"Default Color", defaults);
71 QHBoxLayout *hlayout =
new QHBoxLayout();
72 hlayout->addWidget(ok);
73 hlayout->addWidget(
apply);
74 hlayout->addWidget(cancel);
76 buttons->setLayout(hlayout);
78 QHBoxLayout *h2layout =
new QHBoxLayout();
79 h2layout->addWidget(defaultBlackWhite);
81 defaults->setLayout(h2layout);
85 QSize *size =
new QSize(25, 25);
86 QLabel *nullLabel =
new QLabel(
"Null");
91 QLabel *lisLabel =
new QLabel(
"Low Instrument Saturation");
96 QLabel *lrsLabel =
new QLabel(
"Low Representation Saturation");
101 QLabel *ldsLabel =
new QLabel(
"Low Display Saturation");
106 QLabel *hisLabel =
new QLabel(
"High Instrument Saturation");
111 QLabel *hrsLabel =
new QLabel(
"High Representation Saturation");
116 QLabel *hdsLabel =
new QLabel(
"High Display Saturation");
120 connect(
p_bgColor, SIGNAL(released()),
this, SLOT(setBgColor()));
121 QLabel *bgLabel =
new QLabel(
"Background");
127 QVBoxLayout *vlayout =
new QVBoxLayout();
128 vlayout->addWidget(nullLabel);
129 vlayout->addWidget(lisLabel);
130 vlayout->addWidget(hisLabel);
131 vlayout->addWidget(lrsLabel);
132 vlayout->addWidget(hrsLabel);
133 vlayout->addWidget(ldsLabel);
134 vlayout->addWidget(hdsLabel);
135 vlayout->addWidget(bgLabel);
136 labels->setLayout(vlayout);
138 QVBoxLayout *v2layout =
new QVBoxLayout();
147 colors->setLayout(v2layout);
149 QHBoxLayout *mainlayout =
new QHBoxLayout();
150 mainlayout->addWidget(colors);
151 mainlayout->addWidget(labels);
152 main->setLayout(mainlayout);
157 p_action->setText(
"&Special Pixel Tool ...");
159 p_action->setToolTip(
"SpecialPixelTool");
161 "<b>Function:</b> Opens a window that allows you to chose what color to \
162 display each different type of special pixel \
163 <p><b>Shortcut:</b> Ctrl+C</p>";
201 this, SLOT(
apply()));
220 QColor nullColor = palette.color(QPalette::Button);
222 nullColor.getRgb(&r, &g, &b);
229 QColor lisColor = palette.color(QPalette::Button);
230 lisColor.getRgb(&r, &g, &b);
237 QColor lrsColor = palette.color(QPalette::Button);
238 lrsColor.getRgb(&r, &g, &b);
245 QColor ldsColor = palette.color(QPalette::Button);
246 ldsColor.getRgb(&r, &g, &b);
247 redStretch.SetMinimum(r);
248 greenStretch.SetMinimum(g);
249 blueStretch.SetMinimum(b);
253 QColor hisColor = palette.color(QPalette::Button);
254 hisColor.getRgb(&r, &g, &b);
261 QColor hrsColor = palette.color(QPalette::Button);
262 hrsColor.getRgb(&r, &g, &b);
269 QColor hdsColor = palette.color(QPalette::Button);
270 hdsColor.getRgb(&r, &g, &b);
271 redStretch.SetMaximum(r);
272 greenStretch.SetMaximum(g);
273 blueStretch.SetMaximum(b);
277 QColor bgColor = palette.color(QPalette::Button);
278 bgColor.getRgb(&r, &g, &b);
363 void SpecialPixelTool::setBgColor() {
375 QColor color = QColorDialog::getColor();
378 if(color.isValid()) {
379 QPalette *palette =
new QPalette();
380 palette->setColor(QPalette::Button, color);
381 button->setPalette(*palette);
393 QPalette *palette =
new QPalette();
394 palette->setColor(QPalette::Button, Qt::black);
401 palette->setColor(QPalette::Button, Qt::white);
414 QPalette *palette =
new QPalette();
462 QString appName =
p_parent->windowTitle();
465 QString instanceName =
p_dialog->windowTitle();
467 FileName config(
"$HOME/.Isis/" + appName +
"/" + instanceName +
".config");
474 if(
p_settings->value(
"defaultNull", 1).toInt() == 0) {
482 if(
p_settings->value(
"defaultLis", 1).toInt() == 0) {
490 if(
p_settings->value(
"defaultLrs", 1).toInt() == 0) {
498 if(
p_settings->value(
"defaultLds", 1).toInt() == 0) {
506 if(
p_settings->value(
"defaultHis", 1).toInt() == 0) {
514 if(
p_settings->value(
"defaultHrs", 1).toInt() == 0) {
522 if(
p_settings->value(
"defaultHds", 1).toInt() == 0) {
530 if(
p_settings->value(
"defaultBg", 1).toInt() == 0) {
545 QString appName =
p_parent->windowTitle();
548 QString instanceName =
p_dialog->windowTitle();
551 FileName config(
"$HOME/.Isis/" + appName +
"/" + instanceName +
".config");
552 QSettings settings(config.
expanded(), QSettings::NativeFormat);