From: Shamus Hammons Date: Sun, 9 Feb 2014 23:33:02 +0000 (-0600) Subject: Readded click to add dimension to object (for Line). X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=architektonas;a=commitdiff_plain;h=4d6ba8a6eb781dbee818b6a55d21df7b52468936 Readded click to add dimension to object (for Line). --- diff --git a/cross-compile b/cross-compile index 7844851..4115825 100755 --- a/cross-compile +++ b/cross-compile @@ -5,13 +5,14 @@ # by James Hammons # (C) 2012 Underground Software # -TARGET = architectonas -echo "Cross compiling $(TARGET) for Win32..." +TARGET=architektonas +echo "Cross compiling ${TARGET} for Win32..." export PATH=/opt/mxe/usr/bin:$PATH rm Makefile /opt/mxe/usr/i686-pc-mingw32/qt/bin/qmake make #make CROSS=i686-pc-mingw32- #rel=`svn info | grep Revision | cut -f 2 -d ' '` -#rel=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1 | tr -d -` -#cd release && upx -9v $(TARGET).exe && zip -9v $(TARGET)-$rel.zip $(TARGET).exe +rel=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1 | tr -d -` +#echo ${TARGET}.exe +cd release && upx -9v ${TARGET}.exe && zip -9v ${TARGET}-${rel}.zip ${TARGET}.exe diff --git a/res/architektonas.qrc b/res/architektonas.qrc index 697cad7..cf1593b 100644 --- a/res/architektonas.qrc +++ b/res/architektonas.qrc @@ -31,5 +31,11 @@ file-save-as.png settings.png mirror-tool.png + layer-add.png + layer-delete.png + layer-edit.png + layer-up.png + layer-down.png + block-import.png diff --git a/src/action.h b/src/action.h index fbd7448..b0ddc14 100644 --- a/src/action.h +++ b/src/action.h @@ -27,6 +27,10 @@ class Action: public QObject signals: void ObjectReady(Object *); void NeedRefresh(void); + + // Class variables +// public: +// static unsigned int currentLayer; }; #endif // __ACTION_H__ diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index effcc1e..5261dd1 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -86,7 +86,7 @@ ApplicationWindow::ApplicationWindow(): dock2->setObjectName("Blocks"); // Create status bar - zoomIndicator = new QLabel("Grid: 12.0\" Zoom: 12.5%"); + zoomIndicator = new QLabel("Grid: 12.0\" BU: Inch"); statusBar()->addPermanentWidget(zoomIndicator); statusBar()->showMessage(tr("Ready")); @@ -121,6 +121,11 @@ void ApplicationWindow::FileOpen(void) { QString filename = QFileDialog::getOpenFileName(this, tr("Open Drawing"), "", tr("Architektonas files (*.drawing)")); + + // User cancelled open + if (filename.isEmpty()) + return; + FILE * file = fopen(filename.toAscii().data(), "r"); if (file == 0) diff --git a/src/arc.cpp b/src/arc.cpp index e4a6b6f..36245b4 100644 --- a/src/arc.cpp +++ b/src/arc.cpp @@ -302,7 +302,8 @@ This vector is already unitized, so all we need to do to get our point is to multiply it by radius (to get the length correct) and add it to the center point (to get the correct position). */ - Vector v1(point, position); // Head minus tail (vector points at "point") +// Vector v1(point, position); // Head minus tail (vector points at "point") + Vector v1(position, point); // Head minus tail (vector points at "point") Point p1(cos(startAngle), sin(startAngle)); Point p2(cos(startAngle + angleSpan), sin(startAngle + angleSpan)); Vector handle2 = (p1 * radius) + position; diff --git a/src/blockwidget.cpp b/src/blockwidget.cpp index d493eba..d6965c9 100644 --- a/src/blockwidget.cpp +++ b/src/blockwidget.cpp @@ -40,10 +40,27 @@ BlockWidget::BlockWidget(void): QWidget() qlw->setItemWidget(qli4, biw4); qlw->setItemWidget(qli5, biw5); +#if 0 QPushButton * pb1 = new QPushButton("+"); QPushButton * pb2 = new QPushButton("-"); QPushButton * pb3 = new QPushButton("Edit"); QPushButton * pb4 = new QPushButton("Import"); +#else + QToolButton * pb1 = new QToolButton; + QToolButton * pb2 = new QToolButton; + QToolButton * pb3 = new QToolButton; + QToolButton * pb4 = new QToolButton; + + pb1->setIcon(QIcon(":/res/layer-add.png")); + pb2->setIcon(QIcon(":/res/layer-delete.png")); + pb3->setIcon(QIcon(":/res/layer-edit.png")); + pb4->setIcon(QIcon(":/res/block-import.png")); + + pb1->setToolTip(tr("Add block")); + pb2->setToolTip(tr("Remove block")); + pb3->setToolTip(tr("Edit block")); + pb4->setToolTip(tr("Import block")); +#endif QHBoxLayout * hbox1 = new QHBoxLayout; hbox1->addWidget(pb1); diff --git a/src/container.cpp b/src/container.cpp index 6050f32..9cda1fa 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -123,12 +123,13 @@ having to ungroup them first (like Inkscape). /*virtual*/ bool Container::Collided(Vector point) { objectWasDragged = false; -// Vector v1 = position - point; - bool collision = false; + lastObjectClicked = NULL; - // NOTE that this deletes the object on mouse down instead of mouse up. Have to - // check to see how it feels to do it that way... + // NOTE that this deletes the object on mouse down instead of mouse up. + // Have to check to see how it feels to do it that way... + // N.B.: This only works because the toolAction is not set, & + // Object::ignoreClicks isn't set either... if (deleteActive) { for(std::vector::iterator i=objects.begin(); i!=objects.end();) @@ -149,7 +150,11 @@ printf("Container::Collided: Deleting object ($%X)\n", *i); for(std::vector::iterator i=objects.begin(); i!=objects.end(); i++) { if ((*i)->Collided(point)) + { collision = true; + lastObjectClicked = *i; +//printf("Container::Collided: lastObjectClicked = %X\n", lastObjectClicked); + } } } diff --git a/src/container.h b/src/container.h index d04f6bf..a9066d6 100644 --- a/src/container.h +++ b/src/container.h @@ -48,6 +48,7 @@ class Container: public Object public: std::vector objects; bool isTopLevelContainer; + Object * lastObjectClicked; private: bool dragging; bool draggingHandle1; diff --git a/src/dimension.cpp b/src/dimension.cpp index 27823b3..b3c8da6 100644 --- a/src/dimension.cpp +++ b/src/dimension.cpp @@ -23,21 +23,21 @@ Dimension::Dimension(Vector p1, Vector p2, DimensionType dt/*= DTLinear*/, Object * p/*= NULL*/): Object(p1, p), endpoint(p2), dragging(false), draggingHandle1(false), draggingHandle2(false), - length(p2.Magnitude()), dimensionType(dt), size(0.25), point1(NULL), point2(NULL) + length(p2.Magnitude()), dimensionType(dt), size(0.25)//, point1(NULL), point2(NULL) { // We set the size to 1/4 base unit. Could be anything. type = OTDimension; } - +#if 0 // This is bad, p1 & p2 could be NULL, causing much consternation... Dimension::Dimension(Connection p1, Connection p2, DimensionType dt/*= DTLinear*/, Object * p/*= NULL*/): dragging(false), draggingHandle1(false), draggingHandle2(false), - length(0), dimensionType(dt), size(0.25), point1(p1), point2(p2) + length(0), dimensionType(dt), size(0.25)//, point1(p1), point2(p2) { type = OTDimension; } - +#endif Dimension::~Dimension() { @@ -89,15 +89,12 @@ all objects move as a unified whole. painter->SetBrush(QBrush(QColor(Qt::blue))); // Draw an aligned dimension line - double angle = Vector(endpoint - position).Angle(); - double orthoAngle = angle + (PI / 2.0); - Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle)); - Vector unit = Vector(endpoint - position).Unit(); - -// Arrowhead: -// Point p1 = head - (unit * 9.0 * size); -// Point p2 = p1 + (orthogonal * 3.0 * size); -// Point p3 = p1 - (orthogonal * 3.0 * size); + Vector v(position, endpoint); + double angle = v.Angle(); +// double orthoAngle = angle + (PI / 2.0); +// Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle)); + Vector orthogonal = Vector::Normal(position, endpoint); + Vector unit = v.Unit(); /* The numbers hardcoded into here, what are they? @@ -152,7 +149,8 @@ I believe they are pixels. QString dimText = QString("%1\"").arg(Vector(endpoint - position).Magnitude()); #else QString dimText; - double length = Vector(endpoint - position).Magnitude(); +// double length = Vector(endpoint - position).Magnitude(); + double length = v.Magnitude(); if (length < 12.0) dimText = QString("%1\"").arg(length); @@ -169,6 +167,21 @@ I believe they are pixels. #endif painter->DrawAngledText(ctr, angle, dimText, size); + + if (hitLine) + { + Point p9 = ((position + endpoint) / 2.0) + (orthogonal * 14.0) + + (unit * 7.0); + + Point p10 = p9 + (orthogonal * -7.0); + Point p11 = p10 + (unit * 7.0); + Point p12 = p11 + (orthogonal * 7.0); + Point p13 = p12 + (unit * -7.0); + painter->DrawLine(p10, p11); + painter->DrawLine(p11, p12); + painter->DrawLine(p12, p13); + painter->DrawLine(p13, p10); + } } @@ -299,28 +312,39 @@ about keeping track of old states... /*virtual*/ bool Dimension::HitTest(Point point) { - hitPoint1 = hitPoint2 = false; -// Vector lineSegment(position, endpoint); + Vector orthogonal = Vector::Normal(position, endpoint); + // Get our line parallel to our points + Point p1 = position + (orthogonal * 10.0 * size); + Point p2 = endpoint + (orthogonal * 10.0 * size); + Point p3(p1, point); + + hitPoint1 = hitPoint2 = hitLine = hitFlipSwitch = false; Vector v1(position, point); Vector v2(endpoint, point); +// Vector lineSegment(position, endpoint); + Vector lineSegment(p1, p2); // double t = Geometry::ParameterOfLineAndPoint(position, endpoint, point); -// double distance; + double t = Geometry::ParameterOfLineAndPoint(p1, p2, point); + double distance; -// if (t < 0.0) -// distance = v1.Magnitude(); -// else if (t > 1.0) -// distance = v2.Magnitude(); -// else + if (t < 0.0) + distance = v1.Magnitude(); + else if (t > 1.0) + distance = v2.Magnitude(); + else // distance = ?Det?(ls, v1) / |ls| // distance = fabs((lineSegment.x * v1.y - v1.x * lineSegment.y) -// / lineSegment.Magnitude()); + distance = fabs((lineSegment.x * p3.y - p3.x * lineSegment.y) + / lineSegment.Magnitude()); if ((v1.Magnitude() * Painter::zoom) < 8.0) hitPoint1 = true; else if ((v2.Magnitude() * Painter::zoom) < 8.0) hitPoint2 = true; + else if ((distance * Painter::zoom) < 5.0) + hitLine = true; - return (hitPoint1 || hitPoint2 ? true : false); + return (hitPoint1 || hitPoint2 || hitLine ? true : false); } @@ -328,13 +352,13 @@ void Dimension::SaveHitState(void) { oldHitPoint1 = hitPoint1; oldHitPoint2 = hitPoint2; -// oldHitLine = hitLine; + oldHitLine = hitLine; } bool Dimension::HitStateChanged(void) { - if ((hitPoint1 != oldHitPoint1) || (hitPoint2 != oldHitPoint2)) + if ((hitPoint1 != oldHitPoint1) || (hitPoint2 != oldHitPoint2) || (hitLine != oldHitLine)) return true; return false; @@ -387,7 +411,7 @@ same reference number. {} // Not sure how to handle this case :-P } - +#if 0 /*virtual*/ void Dimension::Connect(Object * obj, double param) { // There are four possibilities here... @@ -444,18 +468,18 @@ same reference number. if (point2.object == obj) point2.object = NULL; } - +#endif /*virtual*/ QRectF Dimension::Extents(void) { Point p1 = position; Point p2 = endpoint; - if (point1.object) - p1 = point1.object->GetPointAtParameter(point1.t); - - if (point2.object) - p2 = point2.object->GetPointAtParameter(point2.t); +// if (point1.object) +// p1 = point1.object->GetPointAtParameter(point1.t); +// +// if (point2.object) +// p2 = point2.object->GetPointAtParameter(point2.t); return QRectF(QPointF(p1.x, p1.y), QPointF(p2.x, p2.y)); } @@ -471,10 +495,12 @@ same reference number. void Dimension::FlipSides(void) { -#if 0 +#if 1 Vector tmp = position; position = endpoint; endpoint = tmp; +//Not sure this matters... +//#warning "!!! May need to swap parameter values on connected objects !!!" #else Connection tmp = point1; point1 = point2; diff --git a/src/dimension.h b/src/dimension.h index a5767a3..ba30b8f 100644 --- a/src/dimension.h +++ b/src/dimension.h @@ -15,7 +15,7 @@ class Dimension: public Object public: Dimension(Vector, Vector, DimensionType dt = DTLinear, Object * p = 0); - Dimension(Connection, Connection, DimensionType dt = DTLinear, Object * p = 0); +// Dimension(Connection, Connection, DimensionType dt = DTLinear, Object * p = 0); ~Dimension(); virtual void Draw(Painter *); @@ -28,9 +28,9 @@ class Dimension: public Object virtual Object * Copy(void); virtual Vector GetPointAtParameter(double parameter); virtual void MovePointAtParameter(double parameter, Vector); - virtual void Connect(Object *, double); - virtual void Disconnect(Object *, double); - virtual void DisconnectAll(Object *); +// virtual void Connect(Object *, double); +// virtual void Disconnect(Object *, double); +// virtual void DisconnectAll(Object *); virtual QRectF Extents(void); void FlipSides(void); @@ -52,15 +52,17 @@ class Dimension: public Object DimensionType dimensionType; bool hitPoint1; bool hitPoint2; - bool oldHitPoint1, oldHitPoint2; + bool hitLine; + bool hitFlipSwitch; + bool oldHitPoint1, oldHitPoint2, oldHitLine, oldHitFlipSwitch; public: double size; // Size of arrows/text in base units private: // We use these in lieu of the built-in connected[] array; no reason to // do it this way especially - Connection point1; - Connection point2; +// Connection point1; +// Connection point2; }; #endif // __DIMENSION_H__ diff --git a/src/drawarcaction.cpp b/src/drawarcaction.cpp index 49ff152..290f8dd 100644 --- a/src/drawarcaction.cpp +++ b/src/drawarcaction.cpp @@ -57,6 +57,7 @@ DrawArcAction::~DrawArcAction() /*virtual*/ void DrawArcAction::MouseDown(Vector point) { if (state == FIRST_POINT) + // How to check for hitting an object here? p1 = point; else if (state == SECOND_POINT) { diff --git a/src/drawdimensionaction.cpp b/src/drawdimensionaction.cpp index 66b2bfb..d366c22 100644 --- a/src/drawdimensionaction.cpp +++ b/src/drawdimensionaction.cpp @@ -12,11 +12,14 @@ // #include "drawdimensionaction.h" +#include "applicationwindow.h" #include "dimension.h" +#include "drawingview.h" +#include "line.h" #include "painter.h" -enum { FIRST_POINT, NEXT_POINT }; +enum { FIRST_POINT, NEXT_POINT, NO_POINT }; DrawDimensionAction::DrawDimensionAction(): state(0), dimension(NULL) @@ -33,12 +36,11 @@ DrawDimensionAction::~DrawDimensionAction() { painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine)); - // I think stuff like crosshairs should be done in the DrawingView, tho if (state == FIRST_POINT) { painter->DrawHandle(p1); } - else + else if (state == NEXT_POINT) { painter->DrawLine(p1, p2); painter->DrawHandle(p2); @@ -48,6 +50,21 @@ DrawDimensionAction::~DrawDimensionAction() /*virtual*/ void DrawDimensionAction::MouseDown(Vector point) { + obj = ApplicationWindow::drawing->document.lastObjectClicked; + + if (obj) + { + if (obj->type == OTLine) + { + // Make sure we didn't hit an endpoint... + if (!(((Line *) obj)->hitPoint1 || ((Line *)obj)->hitPoint2)) + { + state = NO_POINT; + return; + } + } + } + if (state == FIRST_POINT) p1 = point; else @@ -66,7 +83,12 @@ DrawDimensionAction::~DrawDimensionAction() /*virtual*/ void DrawDimensionAction::MouseReleased(void) { - if (state == FIRST_POINT) + if (state == NO_POINT) + { + HandleAddDimensionToObject();//ApplicationWindow::drawing->document.lastObjectClicked); + state = FIRST_POINT; + } + else if (state == FIRST_POINT) { p2 = p1; state = NEXT_POINT; @@ -93,3 +115,27 @@ DrawDimensionAction::~DrawDimensionAction() { } + +void DrawDimensionAction::HandleAddDimensionToObject(void)//Object * obj) +{ +//printf("Adding dimension to object...\n"); + if (obj->type == OTLine) + { + Object * existing = ((Line *)obj)->FindAttachedDimension(); + + if (existing) + { + ((Dimension *)existing)->FlipSides(); + } +//printf("--> type == LINE\n"); + // Should also check here to see if it hit the line proper or just hit + // an endpoint... + else + { + dimension = new Dimension(p1, p2); + ((Line *)obj)->SetDimensionOnLine(dimension); + emit ObjectReady(dimension); + } + } +} + diff --git a/src/drawdimensionaction.h b/src/drawdimensionaction.h index 58bf36e..0e691ed 100644 --- a/src/drawdimensionaction.h +++ b/src/drawdimensionaction.h @@ -4,6 +4,7 @@ #include "action.h" class Dimension; +class Object; class DrawDimensionAction: public Action { @@ -18,10 +19,15 @@ class DrawDimensionAction: public Action virtual void KeyDown(int); virtual void KeyReleased(int); + private: +// void HandleAddDimensionToObject(Object *); + void HandleAddDimensionToObject(void); + private: int state; Dimension * dimension; Vector p1, p2; + Object * obj; }; #endif // __DRAWDIMENSIONACTION_H__ diff --git a/src/drawingview.cpp b/src/drawingview.cpp index 07d7d9f..acfad40 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -49,23 +49,14 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent), // The value in the settings file will override this. useAntialiasing(true), gridBackground(BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE), - scale(1.0), offsetX(-10), offsetY(-10), - document(Vector(0, 0)), - /*gridSpacing(12.0),*/ gridPixels(0), collided(false), //rotateTool(false), -// rx(150.0), ry(150.0), -// scrollDrag(false), addLineTool(false), addCircleTool(false), -// addDimensionTool(false), - toolAction(NULL) + scale(1.0), offsetX(-10), offsetY(-10), document(Vector(0, 0)), + gridPixels(0), collided(false), toolAction(NULL) { document.isTopLevelContainer = true; setBackgroundRole(QPalette::Base); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - Object::gridSpacing = 12.0; -// toolPalette = new ToolWindow(); -// CreateCursors(); -// setCursor(cur[TOOLSelect]); -// setMouseTracking(true); + Object::gridSpacing = 12.0; // In base units (inch is default) Line * line = new Line(Vector(5, 5), Vector(50, 40), &document); document.Add(line); @@ -130,7 +121,7 @@ need a thickness parameter similar to the "size" param for dimensions. (And now we do! :-) */ - SetGridSize(12); + SetGridSize(12); // This is in pixels } @@ -341,26 +332,11 @@ void DrawingView::mousePressEvent(QMouseEvent * event) if (event->button() == Qt::LeftButton) { Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y())); - -// Problem with this: Can't select stuff very well with the snap grid on. -// Completely screws things up, as sometimes things don't fall on the grid. -/* -So, how to fix this? Have the Object check itself? -Maybe we can fix this by having the initial point not be snapped, but when there's -a drag, we substitute the snapped point 'oldPoint' which the Object keeps track of -internally to know how far it was dragged... - -Now we do... :-/ -*/ -#if 0 - if (Object::snapToGrid) - point = Object::SnapPointToGrid(point); -#endif - collided = document.Collided(point); + // Do an update if collided with at least *one* object in the document if (collided) - update(); // Do an update if collided with at least *one* object in the document + update(); if (toolAction) { diff --git a/src/layerwidget.cpp b/src/layerwidget.cpp index 286518b..3322120 100644 --- a/src/layerwidget.cpp +++ b/src/layerwidget.cpp @@ -35,11 +35,17 @@ LayerWidget::LayerWidget(void): QWidget(), QToolButton * pb4 = new QToolButton; QToolButton * pb5 = new QToolButton; - pb1->setIcon(QIcon(":/res/generic-tool.png")); - pb2->setIcon(QIcon(":/res/generic-tool.png")); - pb3->setIcon(QIcon(":/res/generic-tool.png")); - pb4->setIcon(QIcon(":/res/generic-tool.png")); - pb5->setIcon(QIcon(":/res/generic-tool.png")); + pb1->setIcon(QIcon(":/res/layer-add.png")); + pb2->setIcon(QIcon(":/res/layer-delete.png")); + pb3->setIcon(QIcon(":/res/layer-edit.png")); + pb4->setIcon(QIcon(":/res/layer-up.png")); + pb5->setIcon(QIcon(":/res/layer-down.png")); + + pb1->setToolTip(tr("Add layer")); + pb2->setToolTip(tr("Remove layer")); + pb3->setToolTip(tr("Edit layer")); + pb4->setToolTip(tr("Move layer up")); + pb5->setToolTip(tr("Move layer down")); #endif QHBoxLayout * hbox1 = new QHBoxLayout; diff --git a/src/line.cpp b/src/line.cpp index 8fc9b9c..efd92e5 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -106,21 +106,7 @@ Line::~Line() QString text = QObject::tr("Length: %1 in.\n") + QChar(0x2221) + QObject::tr(": %2"); text = text.arg(absLength).arg(absAngle); -#if 0 - QPen pen = QPen(QColor(0x00, 0xFF, 0x00), 1.0, Qt::SolidLine); - painter->SetPen(pen); - painter->SetBrush(QBrush(QColor(0x40, 0xFF, 0x40, 0x9F))); - QRectF textRect(10.0, 10.0, 270.0, 70.0); // x, y, w, h (in Qt coords) - painter->DrawRoundedRect(textRect, 7.0, 7.0); - - textRect.setLeft(textRect.left() + 14); - painter->SetFont(*Object::font); - pen = QPen(QColor(0x00, 0x5F, 0xDF)); - painter->SetPen(pen); - painter->DrawText(textRect, Qt::AlignVCenter, text); -#else painter->DrawInformativeText(text); -#endif } } @@ -137,14 +123,16 @@ Line::~Line() what we can do here is set ignoreClicks to true to keep other objects that are selected from deselecting themselves. Will that fuck up something else? Not sure yet... :-/ +Actually, this is done here to keep tools from selecting stuff inadvertantly... */ - // Someone told us to fuck off, so we'll fuck off. :-) - if (ignoreClicks) - return false; - // We can assume this, since this is a mouse down event here. objectWasDragged = false; - HitTest(point); + bool hit = HitTest(point); + + // Someone told us to fuck off, so we'll fuck off. :-) + if (ignoreClicks) +// return false; + return hit; // Now that we've done our hit testing on the non-snapped point, snap it if // necessary... @@ -637,23 +625,25 @@ same reference number. void Line::SetDimensionOnLine(Dimension * dimension/*= NULL*/) { // If they don't pass one in, create it for the caller. - if (dimension == NULL) + // But ONLY if this line has a parent container! + // This is really bad to do here, it should be done in the parent container, always! +#warning "!!! Parent container should be creating Dimension object !!!" + if ((dimension == NULL) && (parent != NULL)) { //printf("Line::SetDimensionOnLine(): Creating new dimension...\n"); -// dimension = new Dimension(position, endpoint, DTLinear, this); - dimension = new Dimension(Connection(this, 0), Connection(this, 1.0), DTLinear, this); + dimension = new Dimension(position, endpoint, DTLinear, parent); +// dimension = new Dimension(Connection(this, 0), Connection(this, 1.0), DTLinear, this); - if (parent) + // THIS IS SERIOUS!!! WITHOUT A PARENT, THIS OBJECT IS IN LIMBO!!! +// if (parent) //{ //printf("Line::SetDimensionOnLine(): Adding to parent...\n"); - parent->Add(dimension); + parent->Add(dimension); //} } - else - { - dimension->Connect(this, 0); - dimension->Connect(this, 1.0); - } + + dimension->Connect(this, 0); + dimension->Connect(this, 1.0); // Make sure the Dimension is connected to us... Connect(dimension, 0); diff --git a/src/line.h b/src/line.h index 0ad264c..70bf398 100644 --- a/src/line.h +++ b/src/line.h @@ -50,7 +50,9 @@ class Line: public Object bool objectWasDragged; double length; Vector angle; + public: bool hitPoint1, hitPoint2, hitLine; + private: bool oldHitPoint1, oldHitPoint2, oldHitLine; }; diff --git a/src/mirroraction.cpp b/src/mirroraction.cpp index 6bc5b59..8770173 100644 --- a/src/mirroraction.cpp +++ b/src/mirroraction.cpp @@ -18,11 +18,8 @@ #include "line.h" #include "mathconstants.h" #include "painter.h" -//#include "vector.h" -//#define FIRST_POINT 0 -//#define NEXT_POINT 1 enum { FIRST_POINT, NEXT_POINT }; @@ -44,8 +41,6 @@ MirrorAction::~MirrorAction() { painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine)); - // I think stuff like crosshairs should be done in the DrawingView, tho - // (and it's done there now...) if (state == FIRST_POINT) { painter->DrawHandle(p1); @@ -124,7 +119,6 @@ MirrorAction::~MirrorAction() else { mirror->CopyContentsTo(&(ApplicationWindow::drawing->document)); -// mirror->CopyContentsTo(&(DrawingView.document)); } } } diff --git a/src/object.h b/src/object.h index 4f50821..08b7e9d 100644 --- a/src/object.h +++ b/src/object.h @@ -43,7 +43,6 @@ class Object virtual void Disconnect(Object *, double); virtual void DisconnectAll(Object *); virtual QRectF Extents(void); -// virtual ObjectType Type(void);// = 0; // Pure virtual, must be implemented virtual void Translate(Vector); virtual void Rotate(Point, double); virtual void Scale(Point, double); @@ -52,8 +51,6 @@ class Object virtual void Restore(void); ObjectState GetState(void); void Reparent(Object *); -// Dimension * GetAttachedDimension(void); -//Hm. Object * Connect(Object *); // Class methods static void SetFixedAngle(bool state = true); @@ -68,6 +65,7 @@ class Object protected: Vector position; // All objects have a position (doubles as reference point) Object * parent; +//this needs to be added eventually // Pen pen; // Fill fill; Point oldPosition; @@ -78,7 +76,6 @@ class Object protected: ObjectState oldState; bool needUpdate; -// Dimension * attachedDimension; std::vector connected; // Class variables