From 5446001bd9adfd9f4787f5de5a2a7afd8d7cdb5a Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Fri, 14 Sep 2012 17:00:05 +0000 Subject: [PATCH] Fix for missing ampersand in QApplication. --- src/about.cpp | 2 +- src/applicationwindow.cpp | 10 ++++++---- src/container.cpp | 27 +++++++++++++++++++++++++++ src/dimension.cpp | 11 +++++++++++ src/dimension.h | 2 ++ src/drawingview.cpp | 20 +++++++++++++------- src/drawingview.h | 2 ++ src/line.cpp | 12 ++++++++++++ src/line.h | 1 + src/main.cpp | 2 +- src/main.h | 2 +- src/object.cpp | 11 +++++++++++ src/object.h | 2 ++ src/vector.cpp | 11 +++++++++++ src/vector.h | 3 +++ 15 files changed, 104 insertions(+), 14 deletions(-) diff --git a/src/about.cpp b/src/about.cpp index 47bde97..a09924f 100644 --- a/src/about.cpp +++ b/src/about.cpp @@ -65,7 +65,7 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) "" "" // "" - "" + "" "" "" "" diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index 92c0547..448b380 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -53,7 +53,7 @@ ApplicationWindow::ApplicationWindow(): settings("Underground Software", "Archit CreateToolbars(); // Create status bar - zoomIndicator = new QLabel("Zoom: 12.5%"); + zoomIndicator = new QLabel("Grid: 12.0\" Zoom: 12.5%"); statusBar()->addPermanentWidget(zoomIndicator); statusBar()->showMessage(tr("Ready")); @@ -167,7 +167,8 @@ when zooming in, new origin will be (xCenter - origin.x) / 2, (yCenter - origin. //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->gridSpacing = 12.0 / Painter::zoom; + zoomIndicator->setText(QString("Grid: %2\" Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM).arg(drawing->gridSpacing)); drawing->UpdateGridBackground(); drawing->update(); } @@ -201,7 +202,8 @@ x 2 = (-426, -301) //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->gridSpacing = 12.0 / Painter::zoom; + zoomIndicator->setText(QString("Grid: %2\" Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM).arg(drawing->gridSpacing)); drawing->UpdateGridBackground(); drawing->update(); } @@ -263,7 +265,7 @@ void ApplicationWindow::CreateActions(void) QIcon(":/res/quit.png"), QKeySequence(tr("Ctrl+q"))); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); - snapToGridAct = CreateAction(tr("&Snap To Grid"), tr("Snap To Grid"), tr("Snaps mouse cursor to the visible grid when moving/creating objects."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("S,G")), true); + snapToGridAct = CreateAction(tr("Snap To &Grid"), tr("Snap To Grid"), tr("Snaps mouse cursor to the visible grid when moving/creating objects."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("S")), true); connect(snapToGridAct, SIGNAL(triggered()), this, SLOT(SnapToGridTool())); fixAngleAct = CreateAction(tr("Fix &Angle"), tr("Fix Angle"), tr("Fixes the angle of an object."), diff --git a/src/container.cpp b/src/container.cpp index e125672..c867eaf 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -16,6 +16,7 @@ #include "container.h" #include +#include "dimension.h" Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p), @@ -117,8 +118,34 @@ Like so: { if (objects[i]->Collided(point)) { +Dimension * dimension = objects[i]->GetAttachedDimension(); + objects.erase(objects.begin() + i); // Calls the destructor, (deletes the object, I presume... O_o) + +// If this object had an attached dimension, reattach it to another object, if any... +// The only problem with that approach is if the object it gets attached to is deleted, +// it will call the dimension to use a NULL pointer and BLAMMO +if (dimension) +{ + Vector p1 = dimension->GetPoint1(); + Vector p2 = dimension->GetPoint2(); + for(int j=0; j<(int)objects.size(); j++) + { + Vector * objectP1 = objects[i]->GetPointAt(p1); + Vector * objectP2 = objects[i]->GetPointAt(p2); + + if (objectP1) + dimension->SetPoint1(objectP1); + + if (objectP2) + dimension->SetPoint2(objectP2); + } +} + + // This only allows deleting objects one at a time... break; + // however, this way of doing things could be problematic if we don't + // delete one at a time... Need to come up with a better approach. } } } diff --git a/src/dimension.cpp b/src/dimension.cpp index 5aa6a88..26a39f5 100644 --- a/src/dimension.cpp +++ b/src/dimension.cpp @@ -329,6 +329,16 @@ void Dimension::SetPoint2(Vector * v) needUpdate = true; } +Vector Dimension::GetPoint1(void) +{ + return position; +} + +Vector Dimension::GetPoint2(void) +{ + return endpoint; +} + void Dimension::FlipSides(void) { #if 0 @@ -342,3 +352,4 @@ void Dimension::FlipSides(void) #endif needUpdate = true; } + diff --git a/src/dimension.h b/src/dimension.h index 222675a..44e2afe 100644 --- a/src/dimension.h +++ b/src/dimension.h @@ -17,6 +17,8 @@ class Dimension: public Object virtual void PointerReleased(void); void SetPoint1(Vector *); void SetPoint2(Vector *); + Vector GetPoint1(void); + Vector GetPoint2(void); void FlipSides(void); protected: diff --git a/src/drawingview.cpp b/src/drawingview.cpp index 0d62be1..8c706a9 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -46,7 +46,8 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent), gridBackground(256, 256), 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), + gridSpacing(12.0), collided(false), rotateTool(false), rx(150.0), ry(150.0), scrollDrag(false), addLineTool(false), toolAction(NULL) { setBackgroundRole(QPalette::Base); @@ -91,7 +92,7 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent), pmp.fillRect(192, 128, 64, 64, Qt::darkGray); #else pmp.fillRect(0, 0, 256, 256, QColor(240, 240, 240)); - pmp.setPen(QPen(QColor(190, 190, 255), 2.0, Qt::SolidLine)); + pmp.setPen(QPen(QColor(210, 210, 255), 2.0, Qt::SolidLine)); for(int i=0; i<255; i+=12) pmp.drawLine(i, 0, i, 255); for(int i=0; i<255; i+=12) @@ -178,6 +179,7 @@ setPalette(pal); Vector pixmapOrigin = Painter::CartesianToQtCoords(Vector()); int x = (int)pixmapOrigin.x; int y = (int)pixmapOrigin.y; + // Use mod arithmetic to grab the correct swatch of background // Problem with mod 128: Negative numbers screw it up... [FIXED] x = (x < 0 ? 0 : BG_BRUSH_SPAN - 1) - (x % BG_BRUSH_SPAN); y = (y < 0 ? 0 : BG_BRUSH_SPAN - 1) - (y % BG_BRUSH_SPAN); @@ -264,11 +266,11 @@ void DrawingView::paintEvent(QPaintEvent * /*event*/) painter.drawLine(-16384, (int)y, 16384, (int)y); #endif - painter.SetPen(QPen(Qt::black, 1.0, Qt::SolidLine)); - - for(double x=0; xshow(); diff --git a/src/main.h b/src/main.h index 95ec930..2b70ce4 100644 --- a/src/main.h +++ b/src/main.h @@ -10,7 +10,7 @@ class ApplicationWindow; class Architektonas: public QApplication { public: - Architektonas(int argc, char * argv[]); + Architektonas(int & argc, char * argv[]); public: // CharWindow * charWnd; diff --git a/src/object.cpp b/src/object.cpp index b5bab70..ab95c0e 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -82,6 +82,12 @@ Object::~Object() { } +// This returns a pointer to the point passed in, if it coincides. Otherwise returns NULL. +/*virtual*/ Vector * Object::GetPointAt(Vector) +{ + return 0; +} + ObjectState Object::GetState(void) { return state; @@ -92,6 +98,11 @@ void Object::Reparent(Object * newParent) parent = newParent; } +Dimension * Object::GetAttachedDimension(void) +{ + return attachedDimension; +} + // Class methods... void Object::SetFixedAngle(bool state/*= true*/) diff --git a/src/object.h b/src/object.h index 875e92c..efcffe1 100644 --- a/src/object.h +++ b/src/object.h @@ -26,8 +26,10 @@ class Object virtual void Transmute(Object *, Object *); virtual Object * GetParent(void); virtual void Add(Object *); + virtual Vector * GetPointAt(Vector); ObjectState GetState(void); void Reparent(Object *); + Dimension * GetAttachedDimension(void); //Hm. Object * Connect(Object *); // Class methods diff --git a/src/vector.cpp b/src/vector.cpp index 53cdbee..e992bbf 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -151,6 +151,17 @@ Vector& Vector::operator-=(double const v) return *this; } +// Check for equality +bool Vector::operator==(Vector const v) +{ + return (x == v.x && y == v.y && z == v.z ? true : false); +} + +// Check for inequality +bool Vector::operator!=(Vector const v) +{ + return (x != v.x || y != v.y || z != v.z ? true : false); +} Vector Vector::Unit(void) { diff --git a/src/vector.h b/src/vector.h index 0551ea8..6f11a32 100644 --- a/src/vector.h +++ b/src/vector.h @@ -35,6 +35,9 @@ class Vector Vector& operator-=(Vector const v); // Vector minus Vector self-assignment Vector& operator-=(double const v); // Vector minus constant self-assignment + bool operator==(Vector const v); // Check for equality + bool operator!=(Vector const v); // Check for inequality + Vector Unit(void); double Magnitude(void); double Angle(void); -- 2.37.2
Architektonas: Free, Industrial Strength 2D Computer Aided Design
Architektonas: Free, Industrial Strength 2D Computer Aided Design
Architektonas: Free, Industrial Strength 2D Computer Aided Design
Version: 1.0.0
License: GPL v3 or later
Chief Architect: James Hammons (shamus)