10 #include <QMessageBox> 11 #include <QStackedWidget> 12 #include <QToolButton> 15 #include "MainWindow.h" 20 PanTool::PanTool(
QWidget *parent) : Tool(parent) {
21 p_panRight =
new QAction(parent);
22 p_panRight->setShortcut(Qt::CTRL + Qt::Key_Right);
23 p_panRight->setText(
"&Pan Right");
24 p_panRight->setIcon(QPixmap(toolIconDir() +
"/forward.png"));
25 connect(p_panRight, SIGNAL(triggered()),
this, SLOT(panRight()));
27 p_panLeft =
new QAction(parent);
28 p_panLeft->setShortcut(Qt::CTRL + Qt::Key_Left);
29 p_panLeft->setText(
"&Pan Left");
30 p_panLeft->setIcon(QPixmap(toolIconDir() +
"/back.png"));
31 connect(p_panLeft, SIGNAL(triggered()),
this, SLOT(panLeft()));
34 p_panUp->setShortcut(Qt::CTRL + Qt::Key_Up);
35 p_panUp->setText(
"&Pan Up");
36 p_panUp->setIcon(QPixmap(toolIconDir() +
"/up.png"));
37 connect(p_panUp, SIGNAL(triggered()),
this, SLOT(panUp()));
39 p_panDown =
new QAction(parent);
40 p_panDown->setShortcut(Qt::CTRL + Qt::Key_Down);
41 p_panDown->setText(
"&Pan Down");
42 p_panDown->setIcon(QPixmap(toolIconDir() +
"/down.png"));
43 connect(p_panDown, SIGNAL(triggered()),
this, SLOT(panDown()));
50 action->setIcon(QPixmap(
toolIconDir() +
"/move.png"));
51 action->setToolTip(
"Pan (P)");
52 action->setShortcut(Qt::Key_P);
54 "<b>Function:</b> View different areas of the cube. \ 55 <p><b>Shortcut:</b> P</p> ";
56 action->setWhatsThis(text);
61 menu->addAction(p_panLeft);
62 menu->addAction(p_panRight);
63 menu->addAction(p_panUp);
64 menu->addAction(p_panDown);
70 QToolButton *leftButton =
new QToolButton(hbox);
71 leftButton->setIcon(QPixmap(
toolIconDir() +
"/back.png"));
72 leftButton->setToolTip(
"Pan Left");
74 "<b>Function: </b>Pan cube in the active viewport to the left \ 75 <p><b>Shortcut:</b> Ctrl+LeftArrow</p> \ 76 <p><b>Mouse:</b> Hold LeftButton and drag pointer to the right</p> \ 77 <p><b>Hint:</b> Arrow keys without Ctrl modifier moves \ 78 the mouse pointer</p>";
80 leftButton->setWhatsThis(text);
81 leftButton->setAutoRaise(
true);
82 leftButton->setIconSize(QSize(22, 22));
83 connect(leftButton, SIGNAL(clicked()),
this, SLOT(panLeft()));
85 QToolButton *rightButton =
new QToolButton(hbox);
86 rightButton->setIcon(QPixmap(
toolIconDir() +
"/forward.png"));
87 rightButton->setToolTip(
"Pan Right");
89 "<b>Function: </b>Pan cube in the active viewport to the right \ 90 <p><b>Shortcut:</b> Ctrl+RightArrow</p> \ 91 <p><b>Mouse:</b> Hold LeftButton and drag pointer to the left</p>\ 92 <p><b>Hint:</b> Arrow keys without Ctrl modifier moves \ 93 the mouse pointer</p>";
94 rightButton->setWhatsThis(text);
95 rightButton->setAutoRaise(
true);
96 rightButton->setIconSize(QSize(22, 22));
97 connect(rightButton, SIGNAL(clicked()),
this, SLOT(panRight()));
99 QToolButton *upButton =
new QToolButton(hbox);
100 upButton->setIcon(QPixmap(
toolIconDir() +
"/up.png"));
101 upButton->setToolTip(
"Pan Up");
103 "<b>Function: </b>Pan cube in the active viewport up \ 104 <p><b>Shortcut:</b> Ctrl+UpArrow</p> \ 105 <p><b>Mouse:</b> Hold LeftButton and drag pointer down</p> \ 106 <p><b>Hint:</b> Arrow keys without Ctrl modifier moves \ 107 the mouse pointer</p>";
108 upButton->setWhatsThis(text);
109 upButton->setAutoRaise(
true);
110 upButton->setIconSize(QSize(22, 22));
111 connect(upButton, SIGNAL(clicked()),
this, SLOT(panUp()));
113 QToolButton *downButton =
new QToolButton(hbox);
114 downButton->setIcon(QPixmap(
toolIconDir() +
"/down.png"));
115 downButton->setToolTip(
"Pan Down");
117 "<b>Function: </b>Pan cube in the active viewport down \ 118 <p><b>Shortcut:</b> Ctrl+DownArrow</p> \ 119 <p><b>Mouse:</b> Hold LeftButton and drag pointer up</p> \ 120 <p><b>Hint:</b> Arrow keys without Ctrl modifier moves \ 121 the mouse pointer</p>";
122 downButton->setWhatsThis(text);
123 downButton->setAutoRaise(
true);
124 downButton->setIconSize(QSize(22, 22));
125 connect(downButton, SIGNAL(clicked()),
this, SLOT(panDown()));
128 p_panRateBox->addItem(
"1/4 Screen");
129 p_panRateBox->addItem(
"1/2 Screen");
130 p_panRateBox->addItem(
"3/4 Screen");
131 p_panRateBox->addItem(
"Full Screen");
132 p_panRateBox->addItem(
"Custom");
133 p_panRateBox->setToolTip(
"Pan Rate");
135 "<b>Function: </b>Change the rate of panning when using the pan buttons \ 137 p_panRateBox->setWhatsThis(text);
139 connect(p_panRateBox, SIGNAL(activated(
int)),
140 this, SLOT(updateLineEdit()));
142 p_lineEdit =
new QLineEdit();
143 p_lineEdit->setFixedWidth(50);
144 p_lineEdit->setToolTip(
"Custom Pan Rate");
145 text =
"<b>Function: </b>Enter a custom percentage pan rate";
146 p_lineEdit->setWhatsThis(text);
148 connect(p_lineEdit, SIGNAL(returnPressed()),
149 this, SLOT(writeSettings()));
151 QIntValidator *ival =
new QIntValidator(hbox);
152 ival->setRange(1, 100);
153 p_lineEdit->setValidator(ival);
154 QLabel *percent =
new QLabel(
"%");
156 QHBoxLayout *layout =
new QHBoxLayout(hbox);
157 layout->setMargin(0);
158 layout->addWidget(leftButton);
159 layout->addWidget(rightButton);
160 layout->addWidget(upButton);
161 layout->addWidget(downButton);
162 layout->addWidget(p_panRateBox);
163 layout->addWidget(p_lineEdit);
164 layout->addWidget(percent);
165 layout->addStretch(1);
166 hbox->setLayout(layout);
173 int PanTool::panRate(
bool horz) {
175 if(d == NULL)
return 0;
176 if(p_lineEdit->text() ==
"") {
177 QString text =
"You must enter a value in the text box \n " 178 "to use the Custom pan percentage option";
179 QMessageBox::information(p_panRateBox,
"Invalid Value",
180 text, QMessageBox::Ok);
184 int percent = p_lineEdit->text().toInt();
186 return(
int)(d->viewport()->width() * (percent * 0.01));
189 return(
int)(d->viewport()->height() * (percent * 0.01));
194 void PanTool::pan(
int x,
int y) {
196 if(d == NULL)
return;
197 if(x == -1 || y == -1)
return;
204 if(d->isLinked()) d->scrollBy(x, y);
209 void PanTool::mouseButtonPress(QPoint p, Qt::MouseButton s) {
210 if(s == Qt::LeftButton) {
216 void PanTool::mouseMove(QPoint p) {
218 QPoint diff = p_lastPoint - p;
219 pan(diff.x(), diff.y());
224 void PanTool::mouseButtonRelease(QPoint p, Qt::MouseButton s) {
226 if(s != Qt::RightButton)
return;
229 if(d == NULL)
return;
231 d->viewportToCube(p.x(), p.y(), cx, cy);
239 d->viewportToCube(p.x(), p.y(), cx, cy);
247 void PanTool::setCustom() {
248 p_panRateBox->setCurrentIndex(4);
252 void PanTool::updateLineEdit() {
253 if(p_panRateBox->currentIndex() == 0) p_lineEdit->setText(
"25");
254 else if(p_panRateBox->currentIndex() == 1) p_lineEdit->setText(
"50");
255 else if(p_panRateBox->currentIndex() == 2) p_lineEdit->setText(
"75");
256 else if(p_panRateBox->currentIndex() == 3) p_lineEdit->setText(
"100");
257 else if(p_panRateBox->currentIndex() == 4) p_lineEdit->setText(
"");
260 void PanTool::writeSettings() {
261 FileName config(
"$HOME/.Isis/qview/Pan Tool.config");
262 QSettings settings(config.expanded(),
263 QSettings::NativeFormat);
264 settings.setValue(
"rate", p_lineEdit->text());
267 void PanTool::readSettings() {
268 FileName config(
"$HOME/.Isis/qview/Pan Tool.config");
269 QSettings settings(config.expanded(),
270 QSettings::NativeFormat);
271 QString rate = settings.value(
"rate",
"75").toString();
273 p_lineEdit->setText(rate);
274 if(rate ==
"100") p_panRateBox->setCurrentIndex(3);
275 else if(rate ==
"75") p_panRateBox->setCurrentIndex(2);
276 else if(rate ==
"50") p_panRateBox->setCurrentIndex(1);
277 else if(rate ==
"25") p_panRateBox->setCurrentIndex(0);
278 else p_panRateBox->setCurrentIndex(4);
Cube display widget for certain Isis MDI applications.
Namespace for ISIS/Bullet specific routines.