12 #include <QApplication> 
   13 #include <QHBoxLayout> 
   18 #include <QMessageBox> 
   19 #include <QPushButton> 
   20 #include <QStackedWidget> 
   21 #include <QToolButton> 
   24 #include "IException.h" 
   26 #include "MainWindow.h" 
   27 #include "MdiCubeViewport.h" 
   28 #include "RubberBandTool.h" 
   30 #include "Workspace.h" 
   49     p_zoomIn4X->setShortcut(Qt::CTRL + Qt::Key_Plus);
 
   53     p_zoomIn8X->setShortcut(Qt::ALT + Qt::Key_Plus);
 
   98     action->setIcon(QPixmap(
toolIconDir() + 
"/viewmag.png"));
 
   99     action->setToolTip(
"Zoom (Z)");
 
  100     action->setShortcut(Qt::Key_Z);
 
  102       "<b>Function:</b>  Zoom in or out of the current cube. \ 
  103       <p><b>Shortcut:</b>  Z</p> ";
 
  104     action->setWhatsThis(text);
 
  146     QToolButton *zoomInButton = 
new QToolButton(hbox);
 
  147     zoomInButton->setIcon(QPixmap(
toolIconDir() + 
"/viewmag+.png"));
 
  148     zoomInButton->setToolTip(
"Zoom In");
 
  150       "<b>Function:</b> Zoom in 2X at the center of the active viewport \ 
  151       <p><b>Shortcut:</b>  +</p> \ 
  152       <p><b>Mouse:</b>  LeftButton zooms in 2X under pointer</p> \ 
  153       <p><b>Modifiers:</b>  Shortcuts and mouse clicks can be augmented \ 
  154       using the Ctrl or Alt key for 4X and 8X zooms, respectively</p> \ 
  155       <p><b>Hint:</b>  Left click and drag for a local zoom which scales data \ 
  156       in the red marquee to the viewport</p>";
 
  157     zoomInButton->setWhatsThis(text);
 
  158     connect(zoomInButton, SIGNAL(clicked()), 
this, SLOT(
zoomIn2X()));
 
  159     zoomInButton->setAutoRaise(
true);
 
  160     zoomInButton->setIconSize(QSize(22, 22));
 
  162     QToolButton *zoomOutButton = 
new QToolButton(hbox);
 
  163     zoomOutButton->setIcon(QPixmap(
toolIconDir() + 
"/viewmag-.png"));
 
  164     zoomOutButton->setToolTip(
"Zoom Out");
 
  166       "<b>Function:</b> Zoom out 2X at the center of the active viewport \ 
  167       <p><b>Shortcut:</b>  +</p> \ 
  168       <p><b>Mouse:</b>  RightButton zooms out 2X under pointer</p> \ 
  169       <p><b>Modifiers:</b>  Shortcuts and mouse clicks can be augmented \ 
  170       using the Ctrl or Alt key for 4X and 8X zooms, respectively</p> \ 
  171       <p><b>Hint:</b>  Left click and drag for a local zoom which scales data \ 
  172       in the red marquee to the viewport</p>";
 
  173     zoomOutButton->setWhatsThis(text);
 
  174     connect(zoomOutButton, SIGNAL(clicked()), 
this, SLOT(
zoomOut2X()));
 
  175     zoomOutButton->setAutoRaise(
true);
 
  176     zoomOutButton->setIconSize(QSize(22, 22));
 
  178     QToolButton *zoomActButton = 
new QToolButton(hbox);
 
  179     zoomActButton->setIcon(QPixmap(
toolIconDir() + 
"/viewmag1.png"));
 
  180     zoomActButton->setToolTip(
"Zoom 1:1");
 
  182       "<b>Function:</b> Zoom the active viewport to 1:1 such that one \ 
  183       viewport pixel represents one cube pixel. That is, 100% scale. \ 
  184       <p><b>Shortcut:</b> /</p> \ 
  185       <p><b>Mouse:</b>  Ctrl+MiddleButton zooms 1:1 under pointer</p> \ 
  186       <p><b>Hint:</b>  MiddleButton (without Ctrl) retains current \ 
  187       scale but moves the pixel under the pointer to the center of the \ 
  189     zoomActButton->setWhatsThis(text);
 
  190     connect(zoomActButton, SIGNAL(clicked()), 
this, SLOT(
zoomActual()));
 
  191     zoomActButton->setAutoRaise(
true);
 
  192     zoomActButton->setIconSize(QSize(22, 22));
 
  198     fitWidth->setText(
"Fit Width");
 
  199     connect(fitWidth, SIGNAL(triggered(
bool)), 
this, SLOT(
zoomFitWidth()));
 
  200     zoomFitMenu->addAction(fitWidth);
 
  203     fitHeight->setText(
"Fit Height");
 
  204     connect(fitHeight, SIGNAL(triggered(
bool)), 
this, SLOT(
zoomFitHeight()));
 
  205     zoomFitMenu->addAction(fitHeight);
 
  207     QToolButton *zoomFitButton = 
new QToolButton(hbox);
 
  208     zoomFitButton->setIcon(QPixmap(
toolIconDir() + 
"/viewmagfit.png"));
 
  209     zoomFitButton->setMenu(zoomFitMenu);
 
  210     zoomFitButton->setPopupMode(QToolButton::MenuButtonPopup);
 
  211     zoomFitButton->setToolTip(
"Fit in viewport");
 
  213       "<b>Function:</b> Fit the entire cube inside the active viewport. For \ 
  214       extremely large cubes, this may not be possible. \ 
  215       <p><b>Shortcut:</b> *</p> \ 
  216       <p><b>Hint:</b>  Many shortcuts for the zoom tool and other tools \ 
  217       are easily available on the numeric keypad </p>";
 
  218     zoomFitButton->setWhatsThis(text);
 
  219     connect(zoomFitButton, SIGNAL(clicked()), 
this, SLOT(
zoomFit()));
 
  220     zoomFitButton->setAutoRaise(
true);
 
  221     zoomFitButton->setIconSize(QSize(22, 22));
 
  228     QDoubleValidator *dval = 
new QDoubleValidator(hbox);
 
  232     policy.setHorizontalPolicy(QSizePolicy::Fixed);
 
  237       "<b>Function:</b> Shows the scale of the active viewport.  Additionally, \ 
  238       you can manually enter the scale.";
 
  242     QHBoxLayout *layout = 
new QHBoxLayout(hbox);
 
  243     layout->setMargin(0);
 
  244     layout->addWidget(zoomInButton);
 
  245     layout->addWidget(zoomOutButton);
 
  246     layout->addWidget(zoomActButton);
 
  247     layout->addWidget(zoomFitButton);
 
  249     layout->addStretch(1);
 
  250     hbox->setLayout(layout);
 
  332     if(d == NULL) 
return;
 
  333     double newScale = d->
scale() * factor;
 
  334     if(newScale == 0.0) {
 
  347           newScale = d->
scale() * factor;
 
  348           if(newScale == 0.0) {
 
  370     if (d == NULL) 
return;
 
  396     if (d == NULL) 
return;
 
  422     if (d == NULL) 
return;
 
  449     if(d == NULL) 
return;
 
  451     double newScale = strScale.toDouble() / 100.;
 
  478       strScale.setNum(scale);
 
  497     QApplication::processEvents();
 
  499     if(!rubberBandTool()->isValid()) 
return;
 
  502     if(!rubberBandTool()->figureIsPoint()) {
 
  504       if((r.width() >= 5) && (r.height() >= 5)) {
 
  505         int x = r.x() + r.width() / 2;
 
  506         int y = r.y() + r.height() / 2;
 
  507         double xscale = (double) d->viewport()->width() / r.width();
 
  508         double yscale = (double) d->viewport()->height() / r.height();
 
  509         double newScale = xscale < yscale ? xscale : yscale;
 
  510         if(rubberBandTool()->
mouseButton() & Qt::RightButton) {
 
  511           newScale = 1.0 / newScale;
 
  513         newScale *= d->
scale();
 
  521               int x = r.x() + r.width() / 2;
 
  522               int y = r.y() + r.height() / 2;
 
  523               double xscale = (double) d->viewport()->width() / r.width();
 
  524               double yscale = (double) d->viewport()->height() / r.height();
 
  525               double newScale = xscale < yscale ? xscale : yscale;
 
  526               if(rubberBandTool()->
mouseButton() & Qt::RightButton) {
 
  527                 newScale = 1.0 / newScale;
 
  529               newScale *= d->
scale();
 
  539       if(rubberBandTool()->mouseButton() & Qt::ControlModifier) {
 
  542       if(rubberBandTool()->mouseButton() & Qt::ShiftModifier) {
 
  545       if(rubberBandTool()->mouseButton() & Qt::RightButton) {
 
  546         factor = 1.0 / factor;
 
  548       if(rubberBandTool()->mouseButton() & Qt::MidButton) {
 
  551       if(rubberBandTool()->mouseButton() == Qt::MidButton + Qt::ControlModifier) {
 
  555       double newScale = d->
scale() * factor;
 
  556       if(newScale == 0.0) {
 
  561       QPoint p = rubberBandTool()->
vertices()[0];
 
  562       setScale(d, newScale, p.x(), p.y());
 
  570             newScale = d->
scale() * factor;
 
  571             if(newScale == 0.0) {
 
  576             newScale = 
setScale(d, newScale, p.x(), p.y());
 
  591     rubberBandTool()->
enable(RubberBandTool::RectangleMode);
 
  592     rubberBandTool()->enablePoints();
 
  593     rubberBandTool()->enableAllClicks();
 
  616     double oldScale = d->
scale();
 
  618       if (newScale <= 0.0) {
 
  620                          "Scale value must be greater than 0.",
 
  628                            "Unable to rescale image to [" 
  631       QString message = fullError.
toString();
 
  632       QMessageBox::warning((
QWidget *)parent(), 
"Warning", message);
 
  661     double oldScale = d->
scale();
 
  663       if (newScale <= 0.0) {
 
  665             "Scale value must be greater than 0.", _FILEINFO_);
 
  671                            "Unable to rescale image to [" 
  672                            + 
IString(newScale * 100) + 
"]",
 
  674       QString message = fullError.
toString();
 
  675       QMessageBox::warning((
QWidget *)parent(), 
"Warning", message);
 
  703     double oldScale = d->
scale();
 
  705       if (newScale <= 0.0) {
 
  707             "Scale value must be greater than 0.", _FILEINFO_);
 
  714                            "Unable to rescale image to [" 
  717       QString message = fullError.
toString();
 
  718       QMessageBox::warning((
QWidget *)parent(), 
"Warning", message);