]> Shamusworld >> Repos - architektonas/commitdiff
Changed Actions to emit signal when needing a graphical update.
authorShamus Hammons <jlhamm@acm.org>
Thu, 5 Sep 2013 19:39:35 +0000 (14:39 -0500)
committerShamus Hammons <jlhamm@acm.org>
Thu, 5 Sep 2013 19:39:35 +0000 (14:39 -0500)
20 files changed:
TODO
src/action.h
src/container.cpp
src/container.h
src/drawarcaction.cpp
src/drawarcaction.h
src/drawcircleaction.cpp
src/drawcircleaction.h
src/drawdimensionaction.cpp
src/drawdimensionaction.h
src/drawingview.cpp
src/drawingview.h
src/drawlineaction.cpp
src/drawlineaction.h
src/drawtextaction.cpp
src/drawtextaction.h
src/mirroraction.cpp
src/mirroraction.h
src/rotateaction.cpp
src/rotateaction.h

diff --git a/TODO b/TODO
index 13ab43c7997f13ad3b8c7c540437545f9632a88e..9251e2bb82e357fb60b8b79eefca93c2513bab32 100644 (file)
--- a/TODO
+++ b/TODO
@@ -18,16 +18,16 @@ Stuff To Be Implemented/Fixed
  - Add fill/hatch to Objects
  - Fix zooming to be more intuitive
  - Add other Dimension types, like radial, diametric, leader
- - Mirror tool (started, needs actual mirroring implementation)
  - Restrict movement horizontal/vertical tool
- - Trim tool
  - Fix Arc manipulator. Idea: split edge handles so that the inner half controls
    arc sizing, outer half controls rotation. That way you can grab either handle
    and know what it's supposed to do.
  - Fix loading and saving code
  - Add Drawing Properties dialog (separate from Application Settings)
+ - Trim tool
  - Trim/Slice tool (to be able to click on a line segment crossing another, and
    remove it and it only, or to cut the entity at other entities crossing)
+ - Make Architektonas an MDI application
 
 
 Stuff That's Done
@@ -40,5 +40,7 @@ Stuff That's Done
    point. [Shamus 2013-08-18]
  - Add OSD routines so they don't have to be implemented in Objects [Shamus
    2013-08-24]
+ - Mirror tool (started, needs actual mirroring implementation) (Rotate tool is
+   also done :-D) [Shamus 2013-09-01]
 
 
index 96e8e87c9ccb5bad1390aaea4ee77ae6178a736d..fbd744829ae536e9df6a0a50555747749bdd5575 100644 (file)
@@ -21,11 +21,12 @@ class Action: public QObject
                virtual void MouseDown(Vector) = 0;
                virtual void MouseMoved(Vector) = 0;
                virtual void MouseReleased(void) = 0;
-               virtual bool KeyDown(int) = 0;
-               virtual bool KeyReleased(int) = 0;
+               virtual void KeyDown(int) = 0;
+               virtual void KeyReleased(int) = 0;
 
        signals:
                void ObjectReady(Object *);
+               void NeedRefresh(void);
 };
 
 #endif // __ACTION_H__
index e8a66e4d3ba040a178c7eadefc6a5c855adc6aa2..976172fb38220f094838a7cc806ab1fa482a9712 100644 (file)
@@ -442,7 +442,6 @@ void Container::MoveContentsTo(Container * newContainer)
                return;
 
        // Shuffle the contents of this container to the new one
-//     for(unsigned int i=0; i<objects.size(); i++)
        for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
        {
                newContainer->Add(*i);
@@ -454,6 +453,18 @@ void Container::MoveContentsTo(Container * newContainer)
 }
 
 
+void Container::CopyContentsTo(Container * newContainer)
+{
+       // Sanity check
+       if (newContainer == NULL)
+               return;
+
+       // Shuffle the contents of this container to the new one
+       for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+               newContainer->Add((*i)->Copy());
+}
+
+
 void Container::MoveSelectedContentsTo(Container * newContainer)
 {
        // Sanity check
@@ -537,6 +548,23 @@ same reference number.
 }
 
 
+/*virtual*/ void Container::Rotate(Point point, double angle)
+{
+       for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+               (*i)->Rotate(point, angle);
+}
+
+
+/*virtual*/ void Container::RotateSelected(Point point, double angle)
+{
+       for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+       {
+               if ((*i)->state == OSSelected)
+                       (*i)->Rotate(point, angle);
+       }
+}
+
+
 /*virtual*/ void Container::Mirror(Point p1, Point p2)
 {
        for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
@@ -544,6 +572,16 @@ same reference number.
 }
 
 
+/*virtual*/ void Container::MirrorSelected(Point p1, Point p2)
+{
+       for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+       {
+               if ((*i)->state == OSSelected)
+                       (*i)->Mirror(p1, p2);
+       }
+}
+
+
 /*virtual*/ void Container::Save(void)
 {
        Object::Save();
index f4e48e6be39ed8c9fd3d1cdf4e9d4e5ae4037bf9..d04f6bfd49d44c2b44ba5eb4d8e1c2dc630b69d2 100644 (file)
@@ -23,7 +23,10 @@ class Container: public Object
                virtual QRectF Extents(void);
                virtual void Enumerate(FILE *);
                virtual Object * Copy(void);
+               virtual void Rotate(Point, double);
+               virtual void RotateSelected(Point, double);
                virtual void Mirror(Point, Point);
+               virtual void MirrorSelected(Point, Point);
                virtual void Save(void);
                virtual void Restore(void);
                void Delete(Object *);
@@ -34,6 +37,7 @@ class Container: public Object
                int ItemsSelected(void);
                Object * SelectedItem(unsigned int);
                void MoveContentsTo(Container *);
+               void CopyContentsTo(Container *);
                void MoveSelectedContentsTo(Container *);
                void CopySelectedContentsTo(Container *);
                void ResizeAllDimensions(double);
index e416d3d07c42adab8f8ae0239b4be7f1a1e0934e..49ff15269965a340e01ba209f325b1e91ab332ce 100644 (file)
@@ -15,7 +15,6 @@
 #include "arc.h"
 #include "mathconstants.h"
 #include "painter.h"
-//#include "vector.h"
 
 
 enum { FIRST_POINT, SECOND_POINT, THIRD_POINT };
@@ -124,14 +123,12 @@ DrawArcAction::~DrawArcAction()
 }
 
 
-/*virtual*/ bool DrawArcAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawArcAction::KeyDown(int /*key*/)
 {
-       return false;
 }
 
 
-/*virtual*/ bool DrawArcAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawArcAction::KeyReleased(int /*key*/)
 {
-       return false;
 }
 
index 4c5c32b62ccd4611215633a121f4cc675cd81d2e..f11b2fae6a9bf9e36adcc1824103fd4b91f43a98 100644 (file)
@@ -15,8 +15,8 @@ class DrawArcAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
index a1ffe192b3653c3e63901c049b9e751ab8739d26..0a2ac79126f4a5322b041703143d86edc9c4e1b7 100644 (file)
@@ -17,8 +17,7 @@
 #include "vector.h"
 
 
-#define FIRST_POINT 0
-#define NEXT_POINT 1
+enum { FIRST_POINT, NEXT_POINT };
 
 
 DrawCircleAction::DrawCircleAction(): state(0), circle(NULL)
@@ -84,14 +83,12 @@ DrawCircleAction::~DrawCircleAction()
 }
 
 
-/*virtual*/ bool DrawCircleAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawCircleAction::KeyDown(int /*key*/)
 {
-       return false;
 }
 
 
-/*virtual*/ bool DrawCircleAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawCircleAction::KeyReleased(int /*key*/)
 {
-       return false;
 }
 
index 65dc6eccd84720e891a150fbff00aefcb6d6ae89..ab43259d4f49e4c03eb534cdf46727a0c44236b0 100644 (file)
@@ -15,8 +15,8 @@ class DrawCircleAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
index e51f88d394e39f72c23fc4da2af4b58704ef7677..66b2bfb1a176c149107eb5782e56859155590eac 100644 (file)
 #include "drawdimensionaction.h"
 #include "dimension.h"
 #include "painter.h"
-//#include "vector.h"
 
 
-#define FIRST_POINT 0
-#define NEXT_POINT 1
+enum { FIRST_POINT, NEXT_POINT };
 
 
 DrawDimensionAction::DrawDimensionAction(): state(0), dimension(NULL)
@@ -77,25 +75,21 @@ DrawDimensionAction::~DrawDimensionAction()
        {
                // We create the new object here, and then pass it off to the
                // DrawingView which stuffs it into the document.
-//             line = new Line(p1, p2);
                dimension = new Dimension(p1, p2);
                // We don't need no stinkin' sentinels, when we have signals & slots!
                emit ObjectReady(dimension);
 
                state = FIRST_POINT;
-//             p1 = p2;
        }
 }
 
 
-/*virtual*/ bool DrawDimensionAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawDimensionAction::KeyDown(int /*key*/)
 {
-       return false;
 }
 
 
-/*virtual*/ bool DrawDimensionAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawDimensionAction::KeyReleased(int /*key*/)
 {
-       return false;
 }
 
index edd5c7bbc4e4243e94a53731ed9642edd9a32839..58bf36e415cd6efd6a79559382b7f98a54ed1ea6 100644 (file)
@@ -15,8 +15,8 @@ class DrawDimensionAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
index 89c63ed429d9a95f71aa245160d09d95c6ca7e4b..656545b945c3738442e47513b96878f2843fe2f1 100644 (file)
@@ -41,6 +41,9 @@
 
 #define BACKGROUND_MAX_SIZE    512
 
+// Class variable
+//Container DrawingView::document(Vector(0, 0));
+
 
 DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
        // The value in the settings file will override this.
@@ -138,6 +141,7 @@ void DrawingView::SetToolActive(Action * action)
                toolAction = action;
                connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
                        SLOT(AddNewObjectToDocument(Object *)));
+               connect(toolAction, SIGNAL(NeedRefresh()), this, SLOT(HandleActionUpdate()));
        }
 }
 
@@ -260,6 +264,12 @@ void DrawingView::AddNewObjectToDocument(Object * object)
 }
 
 
+void DrawingView::HandleActionUpdate(void)
+{
+       update();
+}
+
+
 void DrawingView::SetCurrentLayer(int layer)
 {
        Object::currentLayer = layer;
@@ -461,10 +471,10 @@ void DrawingView::keyPressEvent(QKeyEvent * event)
 {
        if (toolAction)
        {
-               bool needUpdate = toolAction->KeyDown(event->key());
+               /*bool needUpdate =*/ toolAction->KeyDown(event->key());
 
-               if (needUpdate)
-                       update();
+//             if (needUpdate)
+//                     update();
        }
 }
 
@@ -473,10 +483,10 @@ void DrawingView::keyReleaseEvent(QKeyEvent * event)
 {
        if (toolAction)
        {
-               bool needUpdate = toolAction->KeyReleased(event->key());
+               /*bool needUpdate =*/ toolAction->KeyReleased(event->key());
 
-               if (needUpdate)
-                       update();
+//             if (needUpdate)
+//                     update();
        }
 }
 
index bd3e07e43307fe4d1256fa4898d70a683a243390..21220e88a99c4479e28a525ef481638204b480fe 100644 (file)
@@ -21,6 +21,7 @@ class DrawingView: public QWidget
 
        public slots:
                void AddNewObjectToDocument(Object *);
+               void HandleActionUpdate(void);
                void SetCurrentLayer(int);
 
        protected:
@@ -60,6 +61,10 @@ class DrawingView: public QWidget
 
        public:
                Action * toolAction;
+
+//     public:
+//             static Container document;
 };
 
 #endif // __DRAWINGVIEW_H__
+
index e14ba81ca1f440876c5e60dabba0cfe9b95c7962..27b9513c04574e395ca22a7273c3b3ed126b003d 100644 (file)
 #include "drawlineaction.h"
 #include "line.h"
 #include "painter.h"
-//#include "vector.h"
 
 
-//#define FIRST_POINT 0
-//#define NEXT_POINT 1
 enum { FIRST_POINT, NEXT_POINT };
 
 
@@ -98,7 +95,7 @@ DrawLineAction::~DrawLineAction()
 }
 
 
-/*virtual*/ bool DrawLineAction::KeyDown(int key)
+/*virtual*/ void DrawLineAction::KeyDown(int key)
 {
        if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
        {
@@ -106,14 +103,12 @@ DrawLineAction::~DrawLineAction()
                p1Save = p1;
                p1 = p2;
                state = FIRST_POINT;
-               return true;
+               emit(NeedRefresh());
        }
-
-       return false;
 }
 
 
-/*virtual*/ bool DrawLineAction::KeyReleased(int key)
+/*virtual*/ void DrawLineAction::KeyReleased(int key)
 {
        if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
        {
@@ -121,9 +116,7 @@ DrawLineAction::~DrawLineAction()
                p2 = p1;
                p1 = p1Save;
                state = NEXT_POINT;
-               return true;
+               emit(NeedRefresh());
        }
-
-       return false;
 }
 
index bb9aa7708a02cf363fefb1a32df9fd604a8eca16..7caa814799738f5f1171166cf20fe8e065cd1fc1 100644 (file)
@@ -15,8 +15,8 @@ class DrawLineAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
index b6a0715339e9b1c6157196e058330ffde402b7d3..5e44d8090abea8fad0626ceb43402401155b7f03 100644 (file)
@@ -86,14 +86,12 @@ DrawTextAction::~DrawTextAction()
 }
 
 
-/*virtual*/ bool DrawTextAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawTextAction::KeyDown(int /*key*/)
 {
-       return false;
 }
 
 
-/*virtual*/ bool DrawTextAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawTextAction::KeyReleased(int /*key*/)
 {
-       return false;
 }
 
index 68c4428b517c3a240c951f1beefa546f526bc3e0..bcc19ba11a22753f38cb39c92af844474abd1a26 100644 (file)
@@ -15,8 +15,8 @@ class DrawTextAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
index af786d7f1dc72393c3698cd09b3af38b69bf1098..6bc5b59f207c844f9ea5709a1e8af5670aee9bd9 100644 (file)
@@ -27,13 +27,10 @@ enum { FIRST_POINT, NEXT_POINT };
 
 
 MirrorAction::MirrorAction(): state(FIRST_POINT), line(NULL),
-       shiftWasPressedOnNextPoint(false), mirror(new Container(Vector()))
+       shiftWasPressedOnNextPoint(false), ctrlWasPressed(false),
+       mirror(new Container(Vector()))
 {
-//     ApplicationWindow::drawing->document.CopySelectedContentsTo(selected);
        ApplicationWindow::drawing->document.CopySelectedContentsTo(mirror);
-
-//     for(std::vector<Object *>::iterator i=mirror->objects.begin(); i!=mirror->objects.end(); i++)
-//             (*i)->Save();
        mirror->Save();
 }
 
@@ -68,8 +65,10 @@ MirrorAction::~MirrorAction()
 
                QString text = QChar(0x2221) + QObject::tr(": %1");
                text = text.arg(absAngle);
-//             QString text = tr("Length: %1 in.");
-//             text = text.arg(Vector::Magnitude(p1, p2));
+
+               if (ctrlWasPressed)
+                       text += " (Copy)";
+
                painter->DrawInformativeText(text);
 
                // Draw the mirror only if there's been a line to mirror around
@@ -98,12 +97,8 @@ MirrorAction::~MirrorAction()
        else
        {
                p2 = point;
-
-               for(std::vector<Object *>::iterator i=mirror->objects.begin(); i!=mirror->objects.end(); i++)
-               {
-                       (*i)->Restore();
-                       (*i)->Mirror(p1, p2);
-               }
+               mirror->Restore();
+               mirror->Mirror(p1, p2);
        }
 }
 
@@ -117,24 +112,25 @@ MirrorAction::~MirrorAction()
        }
        else if (state == NEXT_POINT)
        {
-               state = FIRST_POINT;
-
-               std::vector<Object *> & objs = ApplicationWindow::drawing->document.objects;
+               if (!ctrlWasPressed)
+               {
+                       state = FIRST_POINT;
+                       ApplicationWindow::drawing->document.MirrorSelected(p1, p2);
 
-               for(std::vector<Object *>::iterator i=objs.begin(); i!=objs.end(); i++)
+                       mirror->Clear();
+                       ApplicationWindow::drawing->document.CopySelectedContentsTo(mirror);
+                       mirror->Save();
+               }
+               else
                {
-                       if ((*i)->state == OSSelected)
-                               (*i)->Mirror(p1, p2);
+                       mirror->CopyContentsTo(&(ApplicationWindow::drawing->document));
+//                     mirror->CopyContentsTo(&(DrawingView.document));
                }
-
-               mirror->Clear();
-               ApplicationWindow::drawing->document.CopySelectedContentsTo(mirror);
-               mirror->Save();
        }
 }
 
 
-/*virtual*/ bool MirrorAction::KeyDown(int key)
+/*virtual*/ void MirrorAction::KeyDown(int key)
 {
        if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
        {
@@ -142,14 +138,17 @@ MirrorAction::~MirrorAction()
                p1Save = p1;
                p1 = p2;
                state = FIRST_POINT;
-               return true;
+               emit(NeedRefresh());
+       }
+       else if (key == Qt::Key_Control)
+       {
+               ctrlWasPressed = true;
+               emit(NeedRefresh());
        }
-
-       return false;
 }
 
 
-/*virtual*/ bool MirrorAction::KeyReleased(int key)
+/*virtual*/ void MirrorAction::KeyReleased(int key)
 {
        if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
        {
@@ -157,9 +156,12 @@ MirrorAction::~MirrorAction()
                p2 = p1;
                p1 = p1Save;
                state = NEXT_POINT;
-               return true;
+               emit(NeedRefresh());
+       }
+       else if (key == Qt::Key_Control)
+       {
+               ctrlWasPressed = false;
+               emit(NeedRefresh());
        }
-
-       return false;
 }
 
index caeda0d4d3ae5c6bf6a51ae354c26d463fdc9f54..aad35866b931b610bdf432ed1a1c7e84467199df 100644 (file)
@@ -16,15 +16,15 @@ class MirrorAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
                Line * line;
                Vector p1, p2, p1Save;
                bool shiftWasPressedOnNextPoint;
-//             Container * selected;
+               bool ctrlWasPressed;
                Container * mirror;
 };
 
index 661e617314d359a92c202da9fb5fa1751228744d..071b31d93ba321a712ea97b7961090c029b92650 100644 (file)
 #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 };
 
 
 RotateAction::RotateAction(): state(FIRST_POINT), line(NULL),
-       shiftWasPressedOnNextPoint(false), spin(new Container(Vector()))
+       shiftWasPressedOnNextPoint(false), ctrlWasPressed(false),
+       spin(new Container(Vector()))
 {
-//     ApplicationWindow::drawing->document.CopySelectedContentsTo(selected);
        ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
-
-//     for(std::vector<Object *>::iterator i=spin->objects.begin(); i!=spin->objects.end(); i++)
-//             (*i)->Save();
        spin->Save();
 }
 
@@ -55,26 +49,31 @@ RotateAction::~RotateAction()
        }
        else
        {
-//             Vector reflectedP2 = -(p2 - p1);
-//             Point newP2 = p1 + reflectedP2;
-               painter->DrawLine(p1, p2);
                painter->DrawHandle(p1);
 
-               double absAngle = (Vector(p2 - p1).Angle()) * RADIANS_TO_DEGREES;
+               // Draw the rotated objects only if there's been a line to spin around
+               if (p1 == p2)
+                       return;
 
-               // Keep the angle between 0 and 180 degrees
-//             if (absAngle > 180.0)
-//                     absAngle -= 180.0;
+               painter->DrawLine(p1, p2);
+
+               double absAngle = (Vector(p2 - p1).Angle()) * RADIANS_TO_DEGREES;
 
                QString text = QChar(0x2221) + QObject::tr(": %1");
                text = text.arg(absAngle);
-//             QString text = tr("Length: %1 in.");
-//             text = text.arg(Vector::Magnitude(p1, p2));
+
+               if (ctrlWasPressed)
+                       text += " (Copy)";
+
                painter->DrawInformativeText(text);
 
-               // Draw the rotated objects only if there's been a line to spin around
-               if (p1 != p2)
-                       spin->Draw(painter);
+// this does nothing, because the objects override any color set here with
+// their own pens... :-/
+// Which means we have to have a flag in the object to tell it not to color itself.
+//             if (ctrlWasPressed)
+//                     painter->SetPen(QPen(Qt::green, 3.0, Qt::SolidLine));
+
+               spin->Draw(painter);
        }
 }
 
@@ -99,12 +98,8 @@ RotateAction::~RotateAction()
        {
                p2 = point;
                double angle = Vector(p2, p1).Angle();
-
-               for(std::vector<Object *>::iterator i=spin->objects.begin(); i!=spin->objects.end(); i++)
-               {
-                       (*i)->Restore();
-                       (*i)->Rotate(p1, angle);
-               }
+               spin->Restore();
+               spin->Rotate(p1, angle);
        }
 }
 
@@ -118,25 +113,25 @@ RotateAction::~RotateAction()
        }
        else if (state == NEXT_POINT)
        {
-               state = FIRST_POINT;
-
-               std::vector<Object *> & objs = ApplicationWindow::drawing->document.objects;
-               double angle = Vector(p2, p1).Angle();
+               if (!ctrlWasPressed)
+               {
+                       state = FIRST_POINT;
+                       double angle = Vector(p2, p1).Angle();
+                       ApplicationWindow::drawing->document.RotateSelected(p1, angle);
 
-               for(std::vector<Object *>::iterator i=objs.begin(); i!=objs.end(); i++)
+                       spin->Clear();
+                       ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
+                       spin->Save();
+               }
+               else
                {
-                       if ((*i)->state == OSSelected)
-                               (*i)->Rotate(p1, angle);
+                       spin->CopyContentsTo(&(ApplicationWindow::drawing->document));
                }
-
-               spin->Clear();
-               ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
-               spin->Save();
        }
 }
 
 
-/*virtual*/ bool RotateAction::KeyDown(int key)
+/*virtual*/ void RotateAction::KeyDown(int key)
 {
        if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
        {
@@ -144,14 +139,17 @@ RotateAction::~RotateAction()
                p1Save = p1;
                p1 = p2;
                state = FIRST_POINT;
-               return true;
+               emit(NeedRefresh());
+       }
+       else if (key == Qt::Key_Control)
+       {
+               ctrlWasPressed = true;
+               emit(NeedRefresh());
        }
-
-       return false;
 }
 
 
-/*virtual*/ bool RotateAction::KeyReleased(int key)
+/*virtual*/ void RotateAction::KeyReleased(int key)
 {
        if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
        {
@@ -159,9 +157,12 @@ RotateAction::~RotateAction()
                p2 = p1;
                p1 = p1Save;
                state = NEXT_POINT;
-               return true;
+               emit(NeedRefresh());
+       }
+       else if (key == Qt::Key_Control)
+       {
+               ctrlWasPressed = false;
+               emit(NeedRefresh());
        }
-
-       return false;
 }
 
index 91a9bdda1b35afb151cbc39e5d4debe1e75082d3..3d8cdc32251841fe2732d287b058d3476ca23a24 100644 (file)
@@ -16,14 +16,15 @@ class RotateAction: public Action
                virtual void MouseDown(Vector);
                virtual void MouseMoved(Vector);
                virtual void MouseReleased(void);
-               virtual bool KeyDown(int);
-               virtual bool KeyReleased(int);
+               virtual void KeyDown(int);
+               virtual void KeyReleased(int);
 
        private:
                int state;
                Line * line;
                Point p1, p2, p1Save;
                bool shiftWasPressedOnNextPoint;
+               bool ctrlWasPressed;
 //             Container * selected;
                Container * spin;
 };