#include "about.h"
#include "drawingview.h"
-#include "settingsdialog.h"
#include "generaltab.h"
+#include "painter.h"
+#include "settingsdialog.h"
ApplicationWindow::ApplicationWindow(): settings("Underground Software", "Architektonas")
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();
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")));
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);
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);
void DeleteTool(void);
void DimensionTool(void);
void RotateTool(void);
+ void ZoomInTool(void);
+ void ZoomOutTool(void);
void HelpAbout(void);
void Settings(void);
void ReadSettings(void);
void WriteSettings(void);
-// EditWindow * editWnd;
-// CharWindow * charWnd;
DrawingView * drawing;
AboutWindow * aboutWin;
QAction * addArcAct;
QAction * aboutAct;
QAction * rotateAct;
+ QAction * zoomInAct;
+ QAction * zoomOutAct;
};
#endif // __APPLICATIONWINDOW_H__
useAntialiasing(true),
scale(1.0), offsetX(-10), offsetY(-10),
document(Vector(0, 0)),
- gridSpacing(32.0), collided(false), rotateTool(false), rx(150.0), ry(150.0)
+ gridSpacing(32.0), collided(false), rotateTool(false), rx(150.0), ry(150.0),
+ scrollDrag(false)
{
setBackgroundRole(QPalette::Base);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
update();
}
+//These are not needed... :-P
+#if 0
+void DrawingView::ZoomIn(void)
+{
+}
+
+void DrawingView::ZoomOut(void);
+{
+}
+#endif
+
QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event)
{
// This is undoing the transform, e.g. going from client coords to local coords.
qtPainter.setRenderHint(QPainter::Antialiasing);
Painter::screenSize = Vector(size().width(), size().height());
- Painter::zoom = 2.0; // 200% zoom
+// Painter::zoom = 2.0; // 200% zoom
#if 0
#if 0
painter.translate(QPoint(-offsetX, size.height() - (-offsetY)));
{
if (event->button() == Qt::LeftButton)
{
-// QPoint pt = GetAdjustedMousePosition(event);
-// Vector point(pt.x(), pt.y());
Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y()));
-
collided = document.Collided(point);
if (collided)
update(); // Do an update if collided with at least *one* object in the document
}
+ else if (event->button() == Qt::MiddleButton)
+ {
+ scrollDrag = true;
+ oldPoint = Vector(event->x(), event->y());
+ // Should also change the mouse pointer as well...
+ setCursor(Qt::SizeAllCursor);
+ }
}
void DrawingView::mouseMoveEvent(QMouseEvent * event)
{
-// QPoint pt = GetAdjustedMousePosition(event);
-// Vector point(pt.x(), pt.y());
Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y()));
+ if (event->buttons() & Qt::MiddleButton)
+ {
+ point = Vector(event->x(), event->y());
+ // Since we're using Qt coords for scrolling, we have to adjust them here to
+ // conform to Cartesian coords, since the origin is using them. :-)
+ Vector delta(point, oldPoint);
+ delta /= Painter::zoom;
+ delta.y = -delta.y;
+ Painter::origin -= delta;
+ update();
+ oldPoint = point;
+ return;
+ }
+
// Grid processing...
#if 1
// This looks strange, but it's really quite simple: We want a point that's
// if (collided)
update(); // Do an update if collided with at least *one* object in the document
}
+ else if (event->button() == Qt::MiddleButton)
+ {
+ scrollDrag = false;
+ setCursor(Qt::ArrowCursor);
+ }
}
public:
void SetRotateToolActive(bool state = true);
+// void ZoomIn(void);
+// void ZoomOut(void);
protected:
void paintEvent(QPaintEvent * event);
//Should this go into Object's class variables???
bool rotateTool;
double rx, ry;
+ bool scrollDrag;
+ Vector oldPoint;
/* QSize minimumSizeHint() const;
QSize sizeHint() const;
return *this;\r
}\r
\r
+// Vector - vector, self assigned\r
+\r
+Vector& Vector::operator-=(Vector const v)\r
+{\r
+ x -= v.x, y -= v.y, z -= v.z;\r
+\r
+ return *this;\r
+}\r
+\r
+// Vector - constant, self assigned\r
+\r
+Vector& Vector::operator-=(double const v)\r
+{\r
+ x -= v, y -= v, z -= v;\r
+\r
+ return *this;\r
+}\r
+\r
\r
Vector Vector::Unit(void)\r
{\r
Vector& operator/=(double const v); // Vector divided by constant self-assignment\r
Vector& operator+=(Vector const v); // Vector plus Vector self-assignment\r
Vector& operator+=(double const v); // Vector plus constant self-assignment\r
+ Vector& operator-=(Vector const v); // Vector minus Vector self-assignment\r
+ Vector& operator-=(double const v); // Vector minus constant self-assignment\r
\r
Vector Unit(void);\r
double Magnitude(void);\r