]> Shamusworld >> Repos - architektonas/blobdiff - src/applicationwindow.cpp
Added preliminary zooming and panning.
[architektonas] / src / applicationwindow.cpp
index fe0c29db9fd1e2696e91266b40411f0071c3cbad..f658a9b1d69aaa5da0c30faf0a25027b41dcce6a 100644 (file)
@@ -28,8 +28,9 @@
 
 #include "about.h"
 #include "drawingview.h"
-#include "settingsdialog.h"
 #include "generaltab.h"
+#include "painter.h"
+#include "settingsdialog.h"
 
 
 ApplicationWindow::ApplicationWindow(): settings("Underground Software", "Architektonas")
@@ -100,6 +101,24 @@ void ApplicationWindow::RotateTool(void)
        drawing->SetRotateToolActive(rotateAct->isChecked());
 }
 
+void ApplicationWindow::ZoomInTool(void)
+{
+//printf("Zoom in... level going from %02f to ", Painter::zoom);
+       // This just zooms leaving origin intact... should zoom in at the current center!
+//     drawing->ZoomIn();
+       Painter::zoom *= 2.0;
+       drawing->update();
+}
+
+void ApplicationWindow::ZoomOutTool(void)
+{
+//printf("Zoom out...\n");
+       // This just zooms leaving origin intact... should zoom out at the current center!
+//     drawing->ZoomOut();
+       Painter::zoom /= 2.0;
+       drawing->update();
+}
+
 void ApplicationWindow::HelpAbout(void)
 {
        aboutWin->show();
@@ -150,6 +169,12 @@ void ApplicationWindow::CreateActions(void)
        rotateAct = CreateAction(tr("&Rotate Objects"), tr("Rotate"), tr("Rotate object(s) around an arbitrary center."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("R,O")), true);
        connect(rotateAct, SIGNAL(triggered()), this, SLOT(RotateTool()));
 
+       zoomInAct = CreateAction(tr("Zoom &In"), tr("Zoom In"), tr("Zoom in on the document."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("=")));
+       connect(zoomInAct, SIGNAL(triggered()), this, SLOT(ZoomInTool()));
+
+       zoomOutAct = CreateAction(tr("Zoom &Out"), tr("Zoom Out"), tr("Zoom out of the document."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("-")));
+       connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(ZoomOutTool()));
+
        fileNewAct = CreateAction(tr("&New Drawing"), tr("New Drawing"), tr("Creates a new drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+n")));
 
        fileOpenAct = CreateAction(tr("&Open Drawing"), tr("Open Drawing"), tr("Opens an existing drawing from a file."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+o")));
@@ -217,6 +242,10 @@ void ApplicationWindow::CreateMenus(void)
        menu->addSeparator();
        menu->addAction(exitAct);
 
+       menu = menuBar()->addMenu(tr("&View"));
+       menu->addAction(zoomInAct);
+       menu->addAction(zoomOutAct);
+
        menu = menuBar()->addMenu(tr("&Edit"));
        menu->addAction(fixAngleAct);
        menu->addAction(fixLengthAct);
@@ -248,6 +277,10 @@ void ApplicationWindow::CreateToolbars(void)
        QToolBar * toolbar = addToolBar(tr("File"));
        toolbar->addAction(exitAct);
 
+       toolbar = addToolBar(tr("View"));
+       toolbar->addAction(zoomInAct);
+       toolbar->addAction(zoomOutAct);
+
        toolbar = addToolBar(tr("Edit"));
        toolbar->addAction(fixAngleAct);
        toolbar->addAction(fixLengthAct);