CreateToolbars();
// Create status bar
+ zoomIndicator = new QLabel("Zoom: 12.5%");
+ statusBar()->addPermanentWidget(zoomIndicator);
statusBar()->showMessage(tr("Ready"));
ReadSettings();
SetInternalToolStates();
}
+void ApplicationWindow::AddArcTool(void)
+{
+ ClearUIToolStatesExcept(addArcAct);
+ SetInternalToolStates();
+}
+
+void ApplicationWindow::AddPolygonTool(void)
+{
+ ClearUIToolStatesExcept(addPolygonAct);
+ SetInternalToolStates();
+}
+
void ApplicationWindow::ZoomInTool(void)
{
double zoomFactor = 2.0;
//printf("Zoom in... level going from %02f to ", Painter::zoom);
// This just zooms leaving origin intact... should zoom in at the current center! [DONE]
Painter::zoom *= zoomFactor;
+ zoomIndicator->setText(QString("Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM));
drawing->update();
}
//printf("Zoom out...\n");
// This just zooms leaving origin intact... should zoom out at the current center! [DONE]
Painter::zoom /= zoomFactor;
+ zoomIndicator->setText(QString("Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM));
drawing->update();
}
connect(addCircleAct, SIGNAL(triggered()), this, SLOT(AddCircleTool()));
addArcAct = CreateAction(tr("Add &Arc"), tr("Add Arc"), tr("Adds arcs to the drawing."), QIcon(":/res/add-arc-tool.png"), QKeySequence("A,A"), true);
+ connect(addArcAct, SIGNAL(triggered()), this, SLOT(AddArcTool()));
addPolygonAct = CreateAction(tr("Add &Polygon"), tr("Add Polygon"), tr("Add polygons to the drawing."), QIcon(":/res/add-polygon-tool.png"), QKeySequence("A,P"), true);
+ connect(addPolygonAct, SIGNAL(triggered()), this, SLOT(AddPolygonTool()));
aboutAct = CreateAction(tr("About &Architektonas"), tr("About Architektonas"), tr("Gives information about this program."), QIcon(":/res/generic-tool.png"), QKeySequence());
connect(aboutAct, SIGNAL(triggered()), this, SLOT(HelpAbout()));
connect(settingsAct, SIGNAL(triggered()), this, SLOT(Settings()));
//Hm. I think we'll have to have separate logic to do the "Radio Group Toolbar" thing...
+// Yup, in order to turn them off, we'd have to have an "OFF" toolbar button. Ick.
/* QActionGroup * group = new QActionGroup(this);
group->addAction(deleteAct);
group->addAction(addDimensionAct);
//class CharWindow;
class AboutWindow;
class DrawingView;
+class QLabel;
class ApplicationWindow: public QMainWindow
{
void RotateTool(void);
void AddLineTool(void);
void AddCircleTool(void);
+ void AddArcTool(void);
+ void AddPolygonTool(void);
void ZoomInTool(void);
void ZoomOutTool(void);
void HelpAbout(void);
DrawingView * drawing;
AboutWindow * aboutWin;
+ QLabel * zoomIndicator;
QSettings settings;
else
painter->SetPen(QPen(Qt::black, 1.0, Qt::SolidLine));
- // Draw handles (if needed)
+ // Draw the object...
+ painter->DrawEllipse(position, radius, radius);
+
+ // & draw handles (if needed)
if (state == OSSelected || hitCenter)
painter->DrawHandle(position);
if (state == OSSelected && draggingEdge && objectWasDragged)
painter->DrawHandle(dragPoint);
-
- // & finally, draw the object!
- painter->DrawEllipse(position, radius, radius);
}
/*virtual*/ Vector Circle::Center(void)
Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle));
Vector unit = Vector(endpoint - position).Unit();
+//NOTE: SCREEN_ZOOM is our kludge factor... We need to figure out a better
+// way of doing this...
// Get our line parallel to our points
- Point p1 = position + (orthogonal * 10.0);
- Point p2 = endpoint + (orthogonal * 10.0);
+ Point p1 = position + (orthogonal * 10.0 * SCREEN_ZOOM);
+ Point p2 = endpoint + (orthogonal * 10.0 * SCREEN_ZOOM);
// Draw main dimension line
painter->DrawLine(p1, p2);
- Point p3 = position + (orthogonal * 16.0);
- Point p4 = endpoint + (orthogonal * 16.0);
- Point p5 = position + (orthogonal * 4.0);
- Point p6 = endpoint + (orthogonal * 4.0);
+ Point p3 = position + (orthogonal * 16.0 * SCREEN_ZOOM);
+ Point p4 = endpoint + (orthogonal * 16.0 * SCREEN_ZOOM);
+ Point p5 = position + (orthogonal * 4.0 * SCREEN_ZOOM);
+ Point p6 = endpoint + (orthogonal * 4.0 * SCREEN_ZOOM);
// Draw extension lines
painter->DrawLine(p3, p5);
painter->SetBrush(QBrush(QColor(Qt::blue)));
painter->DrawArrowhead(p1, p2);
painter->DrawArrowhead(p2, p1);
-#if 0
- // Draw arrowheads, dots, etc :-P
- // NOTE: These need some kind of enum in the header so that they can
- // be created with some kind of user control...
-
- Point p7 = position + (unit * 9.0);
- Point p8 = endpoint - (unit * 9.0);
- Point p9 = p7 + (orthogonal * 7.0);
- Point p10 = p7 + (orthogonal * 13.0);
- Point p11 = p8 + (orthogonal * 7.0);
- Point p12 = p8 + (orthogonal * 13.0);
-
- painter->DrawLine(p1, p9);
- painter->DrawLine(p9, p10);
- painter->DrawLine(p10, p1);
- painter->DrawLine(p2, p11);
- painter->DrawLine(p11, p12);
- painter->DrawLine(p12, p2);
-#endif
// Draw length of dimension line...
- painter->SetFont(QFont("Arial", 10 * Painter::zoom));
+ painter->SetFont(QFont("Arial", 10.0 * Painter::zoom * SCREEN_ZOOM));
Vector v1((p1.x - p2.x) / 2.0, (p1.y - p2.y) / 2.0);
Point ctr = p2 + v1;
// This is in pixels, which isn't even remotely correct... !!! FIX !!!
Vector current(point2 - point1);
Vector v = current.Unit() * length;
Vector v2 = point1 + v;
- painter->DrawLine((int)point1.x, (int)point1.y, (int)v2.x, (int)v2.y);
+// painter->DrawLine((int)point1.x, (int)point1.y, (int)v2.x, (int)v2.y);
+ painter->DrawLine(point1, v2);
if (current.Magnitude() > length)
{
painter->SetPen(QPen(QColor(128, 0, 0), 1.0, Qt::DashLine));
- painter->DrawLine((int)v2.x, (int)v2.y, (int)point2.x, (int)point2.y);
+// painter->DrawLine((int)v2.x, (int)v2.y, (int)point2.x, (int)point2.y);
+ painter->DrawLine(v2, point2);
}
}
+// Problem: when drawing at large zoom levels, this throws away precision thus
+// causing the line to rendered too short. !!! FIX !!! [DONE]
else
- painter->DrawLine((int)position.x, (int)position.y, (int)endpoint.x, (int)endpoint.y);
+// painter->DrawLine((int)position.x, (int)position.y, (int)endpoint.x, (int)endpoint.y);
+ painter->DrawLine(position, endpoint);
}
/*virtual*/ Vector Line::Center(void)
// simplifies the calculation of the determinant.
//How do we determine distance here? Especially if zoomed in or out???
-#warning "!!! Distances tested for may not be valid if zoomed in or out !!!"
- if (v1.Magnitude() < 8.0)
+//#warning "!!! Distances tested for may not be valid if zoomed in or out !!!"
+// [FIXED]
+ if ((v1.Magnitude() * Painter::zoom) < 8.0)
hitPoint1 = true;
- else if (v2.Magnitude() < 8.0)
+ else if ((v2.Magnitude() * Painter::zoom) < 8.0)
hitPoint2 = true;
- else if (distance < 5.0)
+ else if ((distance * Painter::zoom) < 5.0)
hitLine = true;
return StateChanged();
t(d1x) - s(d2x) = p2x - p0x
t(d1y) - s(d2y) = p2y - p0y
-Determinant D is ad - bc where the matrix look like:
+Determinant D is ad - bc where the matrix looks like:
a b
c d
// then rotate the frame to the desired angle.
center = CartesianToQtCoords(center);
+// NOTE: 1/32 is a kludge to make things look right at screen resolution...
// We may need this stuff... If dimension text is large enough.
// int textWidth = QFontMetrics(painter->font()).width(text);
// int textHeight = QFontMetrics(painter->font()).height();
- QRectF textBox(-100 * zoom, -100 * zoom, 200 * zoom, 200 * zoom); // x, y, w, h; x/y = upper left corner
+ QRectF textBox(-100 * zoom * SCREEN_ZOOM, -100 * zoom * SCREEN_ZOOM, 200 * zoom * SCREEN_ZOOM, 200 * zoom * SCREEN_ZOOM); // x, y, w, h; x/y = upper left corner
// This is in pixels. Might not render correctly at all zoom levels.
// Need to figure out if dimensions are always rendered at one size regardless of zoom,
// or if they have a definite size, and are thus zoomable.
// If zoomable, this is incorrect:
// (Added zoom, so this is correct now :-)
- int yOffset = -12 * zoom;
+ int yOffset = -12 * zoom * SCREEN_ZOOM;
// Fix text so it isn't upside down...
if ((angle > PI * 0.5) && (angle < PI * 1.5))
{
angle += PI;
- yOffset = 12 * zoom;
+ yOffset = 12 * zoom * SCREEN_ZOOM;
}
#if 0
Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle));
Vector unit = Vector(head - tail).Unit();
- Point p1 = head - (unit * 9.0);
- Point p2 = p1 + (orthogonal * 3.0);
- Point p3 = p1 - (orthogonal * 3.0);
+// NOTE: 1/32 is a kludge to make things look right at scale...
+ Point p1 = head - (unit * 9.0 * SCREEN_ZOOM);
+ Point p2 = p1 + (orthogonal * 3.0 * SCREEN_ZOOM);
+ Point p3 = p1 - (orthogonal * 3.0 * SCREEN_ZOOM);
Point p4 = CartesianToQtCoords(head);
Point p5 = CartesianToQtCoords(p2);
#include <QtGui>
#include "vector.h"
+#define SCREEN_ZOOM (1.0 / 8.0)
+
// Forward declarations
class Painter