]> Shamusworld >> Repos - architektonas/commitdiff
Added new About logo, beginnings of generic rotation tool.
authorShamus Hammons <jlhamm@acm.org>
Sat, 4 Jun 2011 01:31:34 +0000 (01:31 +0000)
committerShamus Hammons <jlhamm@acm.org>
Sat, 4 Jun 2011 01:31:34 +0000 (01:31 +0000)
res/about-logo.png [new file with mode: 0644]
res/about-logo.xcf [new file with mode: 0644]
res/architektonas.qrc
src/about.cpp
src/applicationwindow.cpp
src/applicationwindow.h
src/container.cpp
src/drawingview.cpp
src/drawingview.h
src/line.cpp
src/object.h

diff --git a/res/about-logo.png b/res/about-logo.png
new file mode 100644 (file)
index 0000000..c3919d2
Binary files /dev/null and b/res/about-logo.png differ
diff --git a/res/about-logo.xcf b/res/about-logo.xcf
new file mode 100644 (file)
index 0000000..22c1640
Binary files /dev/null and b/res/about-logo.xcf differ
index 4481d1b37f73727dd04a37123dceb3ee05c94a50..0b5079e82dbe2a46a0283a82634016235594377f 100644 (file)
@@ -1,5 +1,6 @@
 <!DOCTYPE RCC><RCC version="1.0">
        <qresource prefix="/res">
+               <file>about-logo.png</file>
                <file>atns-icon.png</file>
                <file>dimension-tool.png</file>
                <file>fix-angle.png</file>
index bce636531dea867b595e3371830b5e92c56192d7..25cd93eaec454ae9bc2018fd1384b6beab115e40 100644 (file)
@@ -58,12 +58,13 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
                "</ul>"
        ));
 #else
-//     QString s = QString(tr("(Last full build was on %1 %2)<br>")).arg(__DATE__).arg(__TIME__);
-       QString s = QString(tr("<body style='background-image::/res/atns-icon.png'>"//<img src=':/res/atns-icon.png' style='float:right'>"//));
-//     s.append(tr(
-//"This is some random text. I wonder if it will be rendered correctly or not???</p>"
-//             "<table><tr><td valign='middle'>"
-               "<table style='float:left'>"
+       QString s = QString(tr(
+               "<table>"
+               "<tr>"
+               "<td><img src=':/res/about-logo.png' style='float:left; margin-right:20px'></td>"
+               "<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'><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>"
@@ -72,22 +73,22 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
 //             "<tr><td align='right'><b>Testers: </b></td><td>shamus</td></tr>"
                "<tr><td align='right'><b>Homepage: </b></td><td>http://shamusworld.gotdns.org/architektonas/</td></tr>"
                "</table>"
-"<img src=':/res/atns-icon.png' style='float:right'>"
-//             "</td>"
-//             "<td><img src=':/res/atns-icon.png'></td></tr></table>"
                "<br><br>"
                "<i>The authors of Architektonas would like to express their heartfelt gratitude to:</i>"
-//             "<br>"
                "<ul>"
                "<li>The authors of <b>Inkscape</b>, whose incredible GUI was a huge inspiration for us</li>"
                "<li><b>QCad</b> for sucking so bad that we just <i>had</i> to write something better</li>"
                "<li>Every other 2D CAD package out there that's mired in a legacy of the bad old days of pencil and paper, and all the attendant horrors that came along with that. We couldn't have done it without you!</li>"
-               "</ul></body>"
+               "</ul>"
+               "</td>"
+               "</tr>"
+               "</table>"
        ));
 #endif
 
        text = new QLabel(s);
        text->setWordWrap(true);
+//     text->setMinimumWidth(480);
 //     text->setMaximumWidth(800);
        layout->addWidget(text);
 }
index 38f0d7038a13b7d759c08aff28276ed3200ac329..2c7f22fb31ae4f7d54017684b58bc249f7558967 100644 (file)
@@ -93,6 +93,11 @@ void ApplicationWindow::DimensionTool(void)
        Object::SetDimensionActive(addDimensionAct->isChecked());
 }
 
+void ApplicationWindow::RotateTool(void)
+{
+       drawing->SetRotateToolActive(rotateAct->isChecked());
+}
+
 void ApplicationWindow::HelpAbout(void)
 {
        aboutWin->show();
@@ -115,7 +120,7 @@ void ApplicationWindow::CreateActions(void)
        deleteAct = CreateAction(tr("&Delete"), tr("Delete Object"), tr("Deletes selected objects."), QIcon(":/res/generic-tool.png"), QKeySequence(), true);
        connect(deleteAct, SIGNAL(triggered()), this, SLOT(DeleteTool()));
 
-       addDimensionAct = CreateAction(tr("Add &Dimension"), tr("Add Dimension"), tr("Adds a dimension to the drawing."), QIcon(":/res/dimension-tool.png"), QKeySequence("D, I"), true);
+       addDimensionAct = CreateAction(tr("Add &Dimension"), tr("Add Dimension"), tr("Adds a dimension to the drawing."), QIcon(":/res/dimension-tool.png"), QKeySequence("D,I"), true);
        connect(addDimensionAct, SIGNAL(triggered()), this, SLOT(DimensionTool()));
 
        addLineAct = CreateAction(tr("Add &Line"), tr("Add Line"), tr("Adds a line to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(), true);
@@ -127,7 +132,22 @@ void ApplicationWindow::CreateActions(void)
        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()));
 
-       //Hm.
+       rotateAct = CreateAction(tr("&Rotate Objects"), tr("Rotate"), tr("Rotate object(s) around an arbitrary center."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("R,O")), true);
+       connect(rotateAct, SIGNAL(triggered()), this, SLOT(RotateTool()));
+
+       fileNewAct = CreateAction(tr("&New Drawing"), tr("New Drawing"), tr("Creates a new drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+n")));
+
+       fileOpenAct = CreateAction(tr("&Open Drawing"), tr("Open Drawing"), tr("Opens an existing drawing from a file."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+o")));
+
+       fileSaveAct = CreateAction(tr("&Save Drawing"), tr("Save Drawing"), tr("Saves the current drawing to a file."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+s")));
+
+       fileSaveAsAct = CreateAction(tr("Save Drawing &As"), tr("Save As"), tr("Saves the current drawing to a file with a different name."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+Shift+s")));
+
+       fileCloseAct = CreateAction(tr("&Close Drawing"), tr("Close Drawing"), tr("Closes the current drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+w")));
+
+       settingsAct = CreateAction(tr("&Settings"), tr("Settings"), tr("Change certain defaults for Architektonas."), QIcon(":/res/generic-tool.png"), QKeySequence());
+
+//Hm. I think we'll have to have separate logic to do the "Radio Group Toolbar" thing...
 /*     QActionGroup * group = new QActionGroup(this);
        group->addAction(deleteAct);
        group->addAction(addDimensionAct);
@@ -173,16 +193,18 @@ QAction * ApplicationWindow::CreateAction2(QString name, QString tooltip, QStrin
 void ApplicationWindow::CreateMenus(void)
 {
        QMenu * menu = menuBar()->addMenu(tr("&File"));
-//     fileMenu->addAction(newAct);
-//     fileMenu->addAction(openAct);
-//     fileMenu->addAction(saveAct);
-//     fileMenu->addAction(saveAsAct);
-//     fileMenu->addSeparator();
+       menu->addAction(fileNewAct);
+       menu->addAction(fileOpenAct);
+       menu->addAction(fileSaveAct);
+       menu->addAction(fileSaveAsAct);
+       menu->addAction(fileCloseAct);
+       menu->addSeparator();
        menu->addAction(exitAct);
 
        menu = menuBar()->addMenu(tr("&Edit"));
        menu->addAction(fixAngleAct);
        menu->addAction(fixLengthAct);
+       menu->addAction(rotateAct);
        menu->addSeparator();
        menu->addAction(deleteAct);
        menu->addSeparator();
@@ -190,6 +212,8 @@ void ApplicationWindow::CreateMenus(void)
        menu->addAction(addCircleAct);
        menu->addAction(addArcAct);
        menu->addAction(addDimensionAct);
+       menu->addSeparator();
+       menu->addAction(settingsAct);
 
 //     editMenu = menuBar()->addMenu(tr("&Edit"));
 //     editMenu->addAction(cutAct);
@@ -211,6 +235,7 @@ void ApplicationWindow::CreateToolbars(void)
        toolbar = addToolBar(tr("Edit"));
        toolbar->addAction(fixAngleAct);
        toolbar->addAction(fixLengthAct);
+       toolbar->addAction(rotateAct);
        toolbar->addAction(deleteAct);
        toolbar->addAction(addLineAct);
        toolbar->addAction(addCircleAct);
@@ -222,6 +247,7 @@ void ApplicationWindow::ReadSettings(void)
 {
        QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
        QSize size = settings.value("size", QSize(400, 400)).toSize();
+       drawing->useAntialiasing = settings.value("useAntialiasing", true).toBool();
        resize(size);
        move(pos);
 //     pos = settings.value("charWndPos", QPoint(0, 0)).toPoint();
@@ -234,6 +260,7 @@ void ApplicationWindow::WriteSettings(void)
 {
        settings.setValue("pos", pos());
        settings.setValue("size", size());
+       settings.setValue("useAntialiasing", drawing->useAntialiasing);
 //     settings.setValue("charWndPos", ((TTEdit *)qApp)->charWnd->pos());
 //     settings.setValue("charWndSize", ((TTEdit *)qApp)->charWnd->size());
 }
index 5f220a8a11a2d96fa5ee3b6ba7989b81c25d2f8e..c3e06a5d91b52ac4c7a35c818088c87eef303b69 100644 (file)
@@ -27,6 +27,7 @@ class ApplicationWindow: public QMainWindow
                void FixLength(void);
                void DeleteTool(void);
                void DimensionTool(void);
+               void RotateTool(void);
                void HelpAbout(void);
 
        private:
@@ -47,7 +48,13 @@ class ApplicationWindow: public QMainWindow
 
                QSettings settings;
 
+               QAction * fileNewAct;
+               QAction * fileOpenAct;
+               QAction * fileSaveAct;
+               QAction * fileSaveAsAct;
+               QAction * fileCloseAct;
                QAction * exitAct;
+               QAction * settingsAct;
                QAction * fixAngleAct;
                QAction * fixLengthAct;
                QAction * deleteAct;
@@ -56,6 +63,7 @@ class ApplicationWindow: public QMainWindow
                QAction * addCircleAct;
                QAction * addArcAct;
                QAction * aboutAct;
+               QAction * rotateAct;
 };
 
 #endif // __APPLICATIONWINDOW_H__
index 8a9c07bcc297a64193d7b8c98ee0b27e2de874c3..a5653347ab325f97aa254897c4b25383af89e116 100644 (file)
@@ -9,6 +9,8 @@
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
 // JLH  03/30/2011  Created this file
+// JLH  06/02/2011  Added code to delete objects in this container when they go
+//                  out of scope
 //
 
 #include "container.h"
@@ -23,6 +25,12 @@ Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p),
 
 Container::~Container()
 {
+       // No memory leaks!
+       while (objects.size() > 0)
+       {
+               delete objects[0];
+               objects.erase(objects.begin());
+       }
 }
 
 /*virtual*/ void Container::Draw(QPainter * painter)
index bd4bb4638612a895ecb99185e28abbca7a05ecb5..e904bdb7ef2a5240fa152392d33f121891a9ce91 100644 (file)
 
 
 DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
+       // The value in the settings file will override this.
+       useAntialiasing(true),
 //     scale(1.0), offsetX(-10), offsetY(-10), tool(TOOLSelect),
 //     ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), oldPtNextHighlight(-1),
 //     polyFirstPoint(true)
        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)
 {
        setBackgroundRole(QPalette::Base);
        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -69,6 +71,12 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
 #endif
 }
 
+void DrawingView::SetRotateToolActive(bool state/*= true*/)
+{
+       rotateTool = state;
+       update();
+}
+
 QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event)
 {
        // This is undoing the transform, e.g. going from client coords to local coords.
@@ -88,7 +96,9 @@ QPoint DrawingView::GetAdjustedClientPosition(int x, int y)
 void DrawingView::paintEvent(QPaintEvent * /*event*/)
 {
        QPainter painter(this);
-       painter.setRenderHint(QPainter::Antialiasing);
+
+       if (useAntialiasing)
+               painter.setRenderHint(QPainter::Antialiasing);
 
 #if 0
        painter.translate(QPoint(-offsetX, size.height() - (-offsetY)));
@@ -111,6 +121,15 @@ void DrawingView::paintEvent(QPaintEvent * /*event*/)
        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);
+       }
+
 // Maybe we can make the grid into a background brush instead, and let Qt deal
 // with it???
        // Draw grid
index c7f7c3a3832d0e7aed65c568d0967cccb830996a..02baa301121a2d0ad0fd9989232532aba25ee101 100644 (file)
@@ -12,6 +12,9 @@ class DrawingView: public QWidget
        public:
                DrawingView(QWidget * parent = NULL);
 
+       public:
+               void SetRotateToolActive(bool state = true);
+
        protected:
                void paintEvent(QPaintEvent * event);
                void mousePressEvent(QMouseEvent * event);
@@ -22,12 +25,18 @@ class DrawingView: public QWidget
                QPoint GetAdjustedMousePosition(QMouseEvent * event);
                QPoint GetAdjustedClientPosition(int x, int y);
 
+       public:
+               bool useAntialiasing;
+
        private:
                double scale;                                                   // Window scaling factor
                int32_t offsetX, offsetY;                               // Window offsets
                Container document;
                double gridSpacing;
                bool collided;
+//Should this go into Object's class variables???
+               bool rotateTool;
+               double rx, ry;
 /*             QSize minimumSizeHint() const;
                QSize sizeHint() const;
 
index 385e086e9cdfc8036928e2116b481aac723e72ae..60e5ab0c1095ff67856aa5b333bf72a0d46afbcf 100644 (file)
@@ -13,7 +13,7 @@
 //                  "Fixed Length" button is down
 // JLH  04/27/2011  Fixed attached dimension to stay a correct length when
 //                  "Fixed Length" button is *not* down ;-)
-// JLH  05/29/2011  Added mouseover hints
+// JLH  05/29/2011  Added (some) mouseover hints
 //
 
 #include "line.h"
@@ -29,6 +29,16 @@ Line::Line(Vector p1, Vector p2, Object * p/*= NULL*/): Object(p1, p), endpoint(
 
 Line::~Line()
 {
+       // If there are any attached Dimensions, we must set the attachment points
+       // to NULL since they will no longer be valid.
+       if (attachedDimension)
+       {
+               attachedDimension->SetPoint1(NULL);
+               attachedDimension->SetPoint2(NULL);
+       }
+       // IT WOULD BE NICE to have any object points attached to this line automagically
+       // connect to this dimension object at this point, instead of just becoming
+       // detached.
 }
 
 /*virtual*/ void Line::Draw(QPainter * painter)
@@ -83,6 +93,17 @@ There's a small problem here with the implementation: You can have a dimension t
 to only one point while at the same time you can have a dimension sitting on this line.
 Since there's only *one* dimPoint for each point, this can be problematic...
 
+We solve this by allowing only *one* Dimension object to be attached to the Line,
+Arc, etc. and by giving the Dimension object a pointer to our endpoints.
+
+Problem still arises when we delete this object; The attached Dimension object will
+then have bad pointers! What is *should* do is delete the object if and only if this
+line is not attached to any other object. If it is, then one of those attachment
+points should be sent to the dimension object (done for position & endpoint).
+
+NOTE: The STL vector<T> *does not* take ownership of pointers, therefore is suitable
+      for our purposes
+
 Also: It would be nice to have a preview of the dimension being drawn, with a modifier
 key to make it draw/show on the other side...
 
index 1e6342290d629b6ff3bc29a42096632e1e457c09..8b047be15ab92c0839012fa3f53f22a42098cafd 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef __OBJECT_H__
 #define __OBJECT_H__
 
-#include "vector.h"
+#include <vector>                                                      // This is a container
+#include "vector.h"                                                    // This is the mathematical construct
 
 class QPainter;
 class QFont;
@@ -26,6 +27,7 @@ class Object
                virtual Object * GetParent(void);
                virtual void Add(Object *);
                ObjectState GetState(void);
+//Hm.          Object * Connect(Object *);
 
                // Class methods
                static void SetFixedAngle(bool state = true);
@@ -44,6 +46,7 @@ class Object
                ObjectState oldState;
                bool needUpdate;
                Dimension * attachedDimension;
+               std::vector<Object *> connected;
 
                // Class variables
                static QFont * font;