]> Shamusworld >> Repos - architektonas/commitdiff
Fix for missing ampersand in QApplication.
authorShamus Hammons <jlhamm@acm.org>
Fri, 14 Sep 2012 17:00:05 +0000 (17:00 +0000)
committerShamus Hammons <jlhamm@acm.org>
Fri, 14 Sep 2012 17:00:05 +0000 (17:00 +0000)
15 files changed:
src/about.cpp
src/applicationwindow.cpp
src/container.cpp
src/dimension.cpp
src/dimension.h
src/drawingview.cpp
src/drawingview.h
src/line.cpp
src/line.h
src/main.cpp
src/main.h
src/object.cpp
src/object.h
src/vector.cpp
src/vector.h

index 47bde97eadcc436bc154e0da10ab828442b86294..a09924f8b68657b20bd19aeb858fee32eaeede6a 100644 (file)
@@ -65,7 +65,7 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
                "<td>"
                "<table>"
 //             "<tr><td align='right'><b>Architektonas: </b></td><td width='100'>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
-               "<tr><td align='right' width='100'><b>Architektonas: </b></td><td>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
+               "<tr><td align='right' width='110'><b>Architektonas: </b></td><td>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
                "<tr><td align='right'><b>Version: </b></td><td>1.0.0</td></tr>"
                "<tr><td align='right'><b>License: </b></td><td>GPL v3 or later</td></tr>"
                "<tr><td align='right'><b>Chief Architect: </b></td><td>James Hammons (shamus)</td></tr>"
index 92c0547f773281dcc7e516db5f4eba1a88f8f408..448b380e276d5cbe7c723b45c942b10a3574439b 100644 (file)
@@ -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."),
index e125672eac63c6690d4d1cbc4da044e08a9e6ee7..c867eaf80224c59609925d49eed1ec35683d3103 100644 (file)
@@ -16,6 +16,7 @@
 #include "container.h"
 
 #include <QtGui>
+#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.
                        }
                }
        }
index 5aa6a8829a815634a96135411c5c4bda46370580..26a39f5d29d9b4c001a47e5d79c4b793336ed203 100644 (file)
@@ -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;
 }
+
index 222675a275b595e10f1752a63bed2132800a2975..44e2afe3e4b1101de32c176f4cf236359f110c48 100644 (file)
@@ -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:
index 0d62be16552d6eafc26e70268b8b085faa6b2ace..8c706a9372b8f27330bcff2c4b1f7f299b68b284 100644 (file)
@@ -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; x<size().width(); x+=gridSpacing)
-               for(double y=0; y<size().height(); y+=gridSpacing)
-                       painter.DrawPoint((int)x, (int)y);
+//     painter.SetPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+//
+//     for(double x=0; x<size().width(); x+=gridSpacing)
+//             for(double y=0; y<size().height(); y+=gridSpacing)
+//                     painter.DrawPoint((int)x, (int)y);
 
        // The top level document takes care of rendering for us...
        document.Draw(&painter);
@@ -331,6 +333,10 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event)
        {
                point += gridSpacing / 2.0;                                     // *This* adds to Z!!!
                point /= gridSpacing;
+//200% is ok, gridSpacing = 6 in this case...
+//won't run into problems until gridSpacing = 1.5 (zoom = 800%)
+//run into problems with this approach: when zoom level is 200% this truncates to
+//integers, which is *not* what's wanted here...
                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!!!
index 98b34b5681fab05569975ca3754ffd86777cb421..989693c870f76477774de10890d0bee1ac2ba0e4 100644 (file)
@@ -41,7 +41,9 @@ class DrawingView: public QWidget
                double scale;                                                   // Window scaling factor
                int32_t offsetX, offsetY;                               // Window offsets
                Container document;
+       public:
                double gridSpacing;
+       private:
                bool collided;
 //Should this go into Object's class variables???
                bool rotateTool;
index 2459636024e8be411f17f6d8994c037b27ae7d68..0884d9028b3c9f4a9140abdf87582bf492eb7ee0 100644 (file)
@@ -360,6 +360,18 @@ about keeping track of old states...
                state = oldState;
 }
 
+// Check to see if the point passed in coincides with any we have. If so, return a
+// pointer to it; otherwise, return NULL.
+/*virtual*/ Vector * Line::GetPointAt(Vector v)
+{
+       if (v == position)
+               return &position;
+       else if (v == endpoint)
+               return &endpoint;
+
+       return 0;
+}
+
 #if 0
 void Line::SetDimensionOnPoint1(Dimension * dimension)
 {
index 5e1430c2f1132a58c31dfe4c09103cf85a61129a..816bfc284d7dda12bfe0c5d3ad909dd02933b557 100644 (file)
@@ -16,6 +16,7 @@ class Line: public Object
                virtual bool Collided(Vector);
                virtual void PointerMoved(Vector);
                virtual void PointerReleased(void);
+               virtual Vector * GetPointAt(Vector);
 //             void SetDimensionOnPoint1(Dimension *);
 //             void SetDimensionOnPoint2(Dimension *);
                void SetDimensionOnLine(Dimension * d = 0);
index e17fccf139e4fffbd46781b90c87cd1499ec077c..42425e9764a2942415f95772b992a93710f6b881 100644 (file)
@@ -19,7 +19,7 @@
 
 // Main app constructor--we stick globally accessible stuff here...
 
-Architektonas::Architektonas(int argc, char * argv[]): QApplication(argc, argv)//, charWnd(NULL)
+Architektonas::Architektonas(int argc, char * argv[]): QApplication(argc, argv)//, charWnd(NULL)
 {
        mainWindow = new ApplicationWindow;
        mainWindow->show();
index 95ec9305e136878639606675059052e577406365..2b70ce424a4bac9994cb5f7370fc42aed631fa8b 100644 (file)
@@ -10,7 +10,7 @@ class ApplicationWindow;
 class Architektonas: public QApplication
 {
        public:
-               Architektonas(int argc, char * argv[]);
+               Architektonas(int argc, char * argv[]);
 
        public:
 //             CharWindow * charWnd;
index b5bab70d954f7c2f80e93cc29de2d3f790484c72..ab95c0ea16fb5a35cf56af5074671b17cf8377b2 100644 (file)
@@ -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*/)
index 875e92ca6c358f7eec29ef60c3a1d24cf7d8895c..efcffe1f00bd34990cb15102f19a8759990cace6 100644 (file)
@@ -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
index 53cdbee39ceaba9938ab3b0c82375d640f712833..e992bbffd53aa5496bffde85c0ff6b543f4891fd 100644 (file)
@@ -151,6 +151,17 @@ Vector& Vector::operator-=(double const v)
        return *this;\r
 }\r
 \r
+// Check for equality\r
+bool Vector::operator==(Vector const v)\r
+{\r
+       return (x == v.x && y == v.y && z == v.z ? true : false);\r
+}\r
+\r
+// Check for inequality\r
+bool Vector::operator!=(Vector const v)\r
+{\r
+       return (x != v.x || y != v.y || z != v.z ? true : false);\r
+}\r
 \r
 Vector Vector::Unit(void)\r
 {\r
index 0551ea87cc8555a0309aa0ad1946d5f8d340c39b..6f11a32e94b850efa31515c122c28aa2c75faaca 100644 (file)
@@ -35,6 +35,9 @@ class Vector
                Vector& operator-=(Vector const v);             // Vector minus Vector self-assignment\r
                Vector& operator-=(double const v);             // Vector minus constant self-assignment\r
 \r
+               bool operator==(Vector const v);                // Check for equality\r
+               bool operator!=(Vector const v);                // Check for inequality\r
+\r
                Vector Unit(void);\r
                double Magnitude(void);\r
                double Angle(void);\r