-// scale(1.0), offsetX(-10), offsetY(-10), tool(TOOLSelect),
-// ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), oldPtNextHighlight(-1),
-// polyFirstPoint(true)
+ // The value in the settings file will override this.
+ useAntialiasing(true),
scale(1.0), offsetX(-10), offsetY(-10),
document(Vector(0, 0)),
scale(1.0), offsetX(-10), offsetY(-10),
document(Vector(0, 0)),
- gridSpacing(32.0), collided(false)
+ gridSpacing(32.0), collided(false), rotateTool(false), rx(150.0), ry(150.0),
+ scrollDrag(false)
{
setBackgroundRole(QPalette::Base);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
{
setBackgroundRole(QPalette::Base);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- document.Add(new Line(Vector(5, 5), Vector(50, 40), &document));
+ Line * line = new Line(Vector(5, 5), Vector(50, 40), &document);
+ document.Add(line);
document.Add(new Line(Vector(50, 40), Vector(10, 83), &document));
document.Add(new Line(Vector(10, 83), Vector(17, 2), &document));
document.Add(new Circle(Vector(100, 100), 36, &document));
document.Add(new Circle(Vector(50, 150), 49, &document));
document.Add(new Arc(Vector(300, 300), 32, PI / 4.0, PI * 1.3, &document)),
document.Add(new Arc(Vector(200, 200), 60, PI / 2.0, PI * 1.5, &document));
document.Add(new Line(Vector(50, 40), Vector(10, 83), &document));
document.Add(new Line(Vector(10, 83), Vector(17, 2), &document));
document.Add(new Circle(Vector(100, 100), 36, &document));
document.Add(new Circle(Vector(50, 150), 49, &document));
document.Add(new Arc(Vector(300, 300), 32, PI / 4.0, PI * 1.3, &document)),
document.Add(new Arc(Vector(200, 200), 60, PI / 2.0, PI * 1.5, &document));
- document.Add(new Dimension(Vector(5, 5), Vector(50, 40), &document));
+#if 1
+ Dimension * dimension = new Dimension(Vector(0, 0), Vector(0, 0), &document);
+ line->SetDimensionOnLine(dimension);
+ document.Add(dimension);
+#else
+ // Alternate way to do the above...
+ line->SetDimensionOnLine();
+#endif
+}
+
+void DrawingView::SetRotateToolActive(bool state/*= true*/)
+{
+ rotateTool = state;
+ update();
+}
+
+//These are not needed... :-P
+#if 0
+void DrawingView::ZoomIn(void)
+{
+}
+
+void DrawingView::ZoomOut(void);
+{
#if 0
painter.translate(QPoint(-offsetX, size.height() - (-offsetY)));
painter.scale(1.0, -1.0);
#if 0
painter.translate(QPoint(-offsetX, size.height() - (-offsetY)));
painter.scale(1.0, -1.0);
transform.translate(-offsetX, -size().height() - offsetY);
// transform.scale(0.25, 0.25);
painter.setTransform(transform);
transform.translate(-offsetX, -size().height() - offsetY);
// transform.scale(0.25, 0.25);
painter.setTransform(transform);
- painter.setPen(QPen(Qt::blue, 1.0, Qt::DotLine));
- painter.drawLine(0, -16384, 0, 16384);
- painter.drawLine(-16384, 0, 16384, 0);
+ painter.SetPen(QPen(Qt::blue, 1.0, Qt::DotLine));
+ painter.DrawLine(0, -16384, 0, 16384);
+ painter.DrawLine(-16384, 0, 16384, 0);
+
+ // Draw supplemental (tool related) points
+
+ if (rotateTool)
+ {
+ painter.SetPen(QPen(QColor(0, 200, 0), 2.0, Qt::SolidLine));
+ painter.DrawLine(rx - 10, ry, rx + 10, ry);
+ painter.DrawLine(rx, ry - 10, rx, ry + 10);
+ }
painter.setPen(QPen(QColor(90, 90, 90), 1.0, Qt::DotLine));
//these two loops kill performance!
painter.setPen(QPen(QColor(90, 90, 90), 1.0, Qt::DotLine));
//these two loops kill performance!
- p.drawLine((int)x, -16384, (int)x, 16384);
+ painter.drawLine((int)x, -16384, (int)x, 16384);
- p.drawLine(-16384, (int)y, 16384, (int)y);
+ painter.drawLine(-16384, (int)y, 16384, (int)y);
collided = document.Collided(point);
if (collided)
update(); // Do an update if collided with at least *one* object in the document
}
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);
+ }
- 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;
+ }
// snap to the one before it. So we add half of the grid spacing to the
// point, then divide by it so that we can remove the fractional part, then
// multiply it back to get back to the correct answer.
// snap to the one before it. So we add half of the grid spacing to the
// point, then divide by it so that we can remove the fractional part, then
// multiply it back to get back to the correct answer.
- point += gridSpacing / 2.0; // *This* adds to Z!!!
- point /= gridSpacing;
- point.x = floor(point.x);//need to fix this for negative numbers...
- point.y = floor(point.y);
- point.z = 0; // Make *sure* Z doesn't go anywhere!!!
- point *= gridSpacing;
+ if (event->buttons() & Qt::LeftButton)
+ {
+ point += gridSpacing / 2.0; // *This* adds to Z!!!
+ point /= gridSpacing;
+ point.x = floor(point.x);//need to fix this for negative numbers...
+ point.y = floor(point.y);
+ point.z = 0; // Make *sure* Z doesn't go anywhere!!!
+ point *= gridSpacing;
+ }