23 #include <QApplication> 24 #include <QHBoxLayout> 29 #include <QMessageBox> 30 #include <QPushButton> 31 #include <QStackedWidget> 32 #include <QToolButton> 37 #include "MainWindow.h" 39 #include "RubberBandTool.h" 60 p_zoomIn4X->setShortcut(Qt::CTRL + Qt::Key_Plus);
64 p_zoomIn8X->setShortcut(Qt::ALT + Qt::Key_Plus);
109 action->setIcon(QPixmap(
toolIconDir() +
"/viewmag.png"));
110 action->setToolTip(
"Zoom (Z)");
111 action->setShortcut(Qt::Key_Z);
113 "<b>Function:</b> Zoom in or out of the current cube. \ 114 <p><b>Shortcut:</b> Z</p> ";
115 action->setWhatsThis(text);
157 QToolButton *zoomInButton =
new QToolButton(hbox);
158 zoomInButton->setIcon(QPixmap(
toolIconDir() +
"/viewmag+.png"));
159 zoomInButton->setToolTip(
"Zoom In");
161 "<b>Function:</b> Zoom in 2X at the center of the active viewport \ 162 <p><b>Shortcut:</b> +</p> \ 163 <p><b>Mouse:</b> LeftButton zooms in 2X under pointer</p> \ 164 <p><b>Modifiers:</b> Shortcuts and mouse clicks can be augmented \ 165 using the Ctrl or Alt key for 4X and 8X zooms, respectively</p> \ 166 <p><b>Hint:</b> Left click and drag for a local zoom which scales data \ 167 in the red marquee to the viewport</p>";
168 zoomInButton->setWhatsThis(text);
169 connect(zoomInButton, SIGNAL(clicked()),
this, SLOT(
zoomIn2X()));
170 zoomInButton->setAutoRaise(
true);
171 zoomInButton->setIconSize(QSize(22, 22));
173 QToolButton *zoomOutButton =
new QToolButton(hbox);
174 zoomOutButton->setIcon(QPixmap(
toolIconDir() +
"/viewmag-.png"));
175 zoomOutButton->setToolTip(
"Zoom Out");
177 "<b>Function:</b> Zoom out 2X at the center of the active viewport \ 178 <p><b>Shortcut:</b> +</p> \ 179 <p><b>Mouse:</b> RightButton zooms out 2X under pointer</p> \ 180 <p><b>Modifiers:</b> Shortcuts and mouse clicks can be augmented \ 181 using the Ctrl or Alt key for 4X and 8X zooms, respectively</p> \ 182 <p><b>Hint:</b> Left click and drag for a local zoom which scales data \ 183 in the red marquee to the viewport</p>";
184 zoomOutButton->setWhatsThis(text);
185 connect(zoomOutButton, SIGNAL(clicked()),
this, SLOT(
zoomOut2X()));
186 zoomOutButton->setAutoRaise(
true);
187 zoomOutButton->setIconSize(QSize(22, 22));
189 QToolButton *zoomActButton =
new QToolButton(hbox);
190 zoomActButton->setIcon(QPixmap(
toolIconDir() +
"/viewmag1.png"));
191 zoomActButton->setToolTip(
"Zoom 1:1");
193 "<b>Function:</b> Zoom the active viewport to 1:1 such that one \ 194 viewport pixel represents one cube pixel. That is, 100% scale. \ 195 <p><b>Shortcut:</b> /</p> \ 196 <p><b>Mouse:</b> Ctrl+MiddleButton zooms 1:1 under pointer</p> \ 197 <p><b>Hint:</b> MiddleButton (without Ctrl) retains current \ 198 scale but moves the pixel under the pointer to the center of the \ 200 zoomActButton->setWhatsThis(text);
201 connect(zoomActButton, SIGNAL(clicked()),
this, SLOT(
zoomActual()));
202 zoomActButton->setAutoRaise(
true);
203 zoomActButton->setIconSize(QSize(22, 22));
209 fitWidth->setText(
"Fit Width");
210 connect(fitWidth, SIGNAL(triggered(
bool)),
this, SLOT(
zoomFitWidth()));
211 zoomFitMenu->addAction(fitWidth);
214 fitHeight->setText(
"Fit Height");
215 connect(fitHeight, SIGNAL(triggered(
bool)),
this, SLOT(
zoomFitHeight()));
216 zoomFitMenu->addAction(fitHeight);
218 QToolButton *zoomFitButton =
new QToolButton(hbox);
219 zoomFitButton->setIcon(QPixmap(
toolIconDir() +
"/viewmagfit.png"));
220 zoomFitButton->setMenu(zoomFitMenu);
221 zoomFitButton->setPopupMode(QToolButton::MenuButtonPopup);
222 zoomFitButton->setToolTip(
"Fit in viewport");
224 "<b>Function:</b> Fit the entire cube inside the active viewport. For \ 225 extremely large cubes, this may not be possible. \ 226 <p><b>Shortcut:</b> *</p> \ 227 <p><b>Hint:</b> Many shortcuts for the zoom tool and other tools \ 228 are easily available on the numeric keypad </p>";
229 zoomFitButton->setWhatsThis(text);
230 connect(zoomFitButton, SIGNAL(clicked()),
this, SLOT(
zoomFit()));
231 zoomFitButton->setAutoRaise(
true);
232 zoomFitButton->setIconSize(QSize(22, 22));
239 QDoubleValidator *dval =
new QDoubleValidator(hbox);
243 policy.setHorizontalPolicy(QSizePolicy::Fixed);
248 "<b>Function:</b> Shows the scale of the active viewport. Additionally, \ 249 you can manually enter the scale.";
253 QHBoxLayout *layout =
new QHBoxLayout(hbox);
254 layout->setMargin(0);
255 layout->addWidget(zoomInButton);
256 layout->addWidget(zoomOutButton);
257 layout->addWidget(zoomActButton);
258 layout->addWidget(zoomFitButton);
260 layout->addStretch(1);
261 hbox->setLayout(layout);
343 if(d == NULL)
return;
344 double newScale = d->
scale() * factor;
345 if(newScale == 0.0) {
358 newScale = d->
scale() * factor;
359 if(newScale == 0.0) {
381 if (d == NULL)
return;
407 if (d == NULL)
return;
433 if (d == NULL)
return;
460 if(d == NULL)
return;
462 double newScale = strScale.toDouble() / 100.;
489 strScale.setNum(scale);
508 QApplication::processEvents();
510 if(!rubberBandTool()->isValid())
return;
513 if(!rubberBandTool()->figureIsPoint()) {
515 if((r.width() >= 5) && (r.height() >= 5)) {
516 int x = r.x() + r.width() / 2;
517 int y = r.y() + r.height() / 2;
518 double xscale = (double) d->viewport()->width() / r.width();
519 double yscale = (double) d->viewport()->height() / r.height();
520 double newScale = xscale < yscale ? xscale : yscale;
521 if(rubberBandTool()->mouseButton() & Qt::RightButton) {
522 newScale = 1.0 / newScale;
524 newScale *= d->
scale();
532 int x = r.x() + r.width() / 2;
533 int y = r.y() + r.height() / 2;
534 double xscale = (double) d->viewport()->width() / r.width();
535 double yscale = (double) d->viewport()->height() / r.height();
536 double newScale = xscale < yscale ? xscale : yscale;
537 if(rubberBandTool()->mouseButton() & Qt::RightButton) {
538 newScale = 1.0 / newScale;
540 newScale *= d->
scale();
550 if(rubberBandTool()->mouseButton() & Qt::ControlModifier) {
553 if(rubberBandTool()->mouseButton() & Qt::ShiftModifier) {
556 if(rubberBandTool()->mouseButton() & Qt::RightButton) {
557 factor = 1.0 / factor;
559 if(rubberBandTool()->mouseButton() & Qt::MidButton) {
562 if(rubberBandTool()->mouseButton() == Qt::MidButton + Qt::ControlModifier) {
566 double newScale = d->
scale() * factor;
567 if(newScale == 0.0) {
572 QPoint p = rubberBandTool()->
vertices()[0];
573 setScale(d, newScale, p.x(), p.y());
581 newScale = d->
scale() * factor;
582 if(newScale == 0.0) {
587 newScale =
setScale(d, newScale, p.x(), p.y());
602 rubberBandTool()->
enable(RubberBandTool::RectangleMode);
603 rubberBandTool()->enablePoints();
604 rubberBandTool()->enableAllClicks();
627 double oldScale = d->
scale();
629 if (newScale <= 0.0) {
631 "Scale value must be greater than 0.",
639 "Unable to rescale image to [" 642 QString message = fullError.
toString();
643 QMessageBox::warning((
QWidget *)parent(),
"Warning", message);
672 double oldScale = d->
scale();
674 if (newScale <= 0.0) {
676 "Scale value must be greater than 0.",
_FILEINFO_);
682 "Unable to rescale image to [" 683 +
IString(newScale * 100) +
"]",
685 QString message = fullError.
toString();
686 QMessageBox::warning((
QWidget *)parent(),
"Warning", message);
714 double oldScale = d->
scale();
716 if (newScale <= 0.0) {
718 "Scale value must be greater than 0.",
_FILEINFO_);
725 "Unable to rescale image to [" 728 QString message = fullError.
toString();
729 QMessageBox::warning((
QWidget *)parent(),
"Warning", message);
Cube display widget for certain Isis MDI applications.
int cubeLines() const
Return the number of lines in the cube.
void setScale(double scale)
Change the scale of the cube to the given parameter value.
double fitScale() const
Determine the scale that causes the full cube to fit in the viewport.
double fitScaleWidth() const
Determine the scale of cube in the width to fit in the viewport.
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
bool isLinked() const
Is the viewport linked with other viewports.
int cubeSamples() const
Return the number of samples in the cube.
QString toString() const
Returns a string representation of this exception.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
double fitScaleHeight() const
Determine the scale of cube in heighth to fit in the viewport.