]> Shamusworld >> Repos - architektonas/commitdiff
Major refactoring of actions: Moved implementation from header files
authorShamus Hammons <jlhamm@acm.org>
Sat, 5 Jun 2010 12:55:00 +0000 (12:55 +0000)
committerShamus Hammons <jlhamm@acm.org>
Sat, 5 Jun 2010 12:55:00 +0000 (12:55 +0000)
to ,cpp files, removed all createGUIAction() functions, removed
unnecessary includes from header files.

229 files changed:
architektonas.pro
src/actions/rs_actionblocksadd.cpp
src/actions/rs_actionblocksadd.h
src/actions/rs_actionblocksattributes.cpp
src/actions/rs_actionblocksattributes.h
src/actions/rs_actionblockscreate.cpp
src/actions/rs_actionblockscreate.h
src/actions/rs_actionblocksedit.cpp
src/actions/rs_actionblocksedit.h
src/actions/rs_actionblocksexplode.cpp
src/actions/rs_actionblocksexplode.h
src/actions/rs_actionblocksfreezeall.cpp
src/actions/rs_actionblocksfreezeall.h
src/actions/rs_actionblocksinsert.cpp
src/actions/rs_actionblocksinsert.h
src/actions/rs_actionblocksremove.cpp
src/actions/rs_actionblocksremove.h
src/actions/rs_actionblockstoggleview.cpp
src/actions/rs_actionblockstoggleview.h
src/actions/rs_actiondefault.cpp
src/actions/rs_actiondefault.h
src/actions/rs_actiondimaligned.cpp
src/actions/rs_actiondimaligned.h
src/actions/rs_actiondimangular.cpp
src/actions/rs_actiondimangular.h
src/actions/rs_actiondimdiametric.cpp
src/actions/rs_actiondimdiametric.h
src/actions/rs_actiondimension.cpp
src/actions/rs_actiondimension.h
src/actions/rs_actiondimleader.cpp
src/actions/rs_actiondimleader.h
src/actions/rs_actiondimlinear.cpp
src/actions/rs_actiondimlinear.h
src/actions/rs_actiondimradial.cpp
src/actions/rs_actiondimradial.h
src/actions/rs_actiondrawarc.cpp
src/actions/rs_actiondrawarc.h
src/actions/rs_actiondrawarc3p.cpp
src/actions/rs_actiondrawarc3p.h
src/actions/rs_actiondrawarctangential.cpp
src/actions/rs_actiondrawarctangential.h
src/actions/rs_actiondrawcircle.cpp
src/actions/rs_actiondrawcircle.h
src/actions/rs_actiondrawcircle2p.cpp
src/actions/rs_actiondrawcircle2p.h
src/actions/rs_actiondrawcircle3p.cpp
src/actions/rs_actiondrawcircle3p.h
src/actions/rs_actiondrawcirclecr.cpp
src/actions/rs_actiondrawcirclecr.h
src/actions/rs_actiondrawellipseaxis.cpp
src/actions/rs_actiondrawellipseaxis.h
src/actions/rs_actiondrawhatch.cpp
src/actions/rs_actiondrawhatch.h
src/actions/rs_actiondrawimage.cpp
src/actions/rs_actiondrawimage.h
src/actions/rs_actiondrawline.cpp
src/actions/rs_actiondrawline.h
src/actions/rs_actiondrawlineangle.cpp
src/actions/rs_actiondrawlineangle.h
src/actions/rs_actiondrawlinebisector.cpp
src/actions/rs_actiondrawlinebisector.h
src/actions/rs_actiondrawlinefree.cpp
src/actions/rs_actiondrawlinefree.h
src/actions/rs_actiondrawlinehorvert.cpp
src/actions/rs_actiondrawlinehorvert.h
src/actions/rs_actiondrawlineparallel.cpp
src/actions/rs_actiondrawlineparallel.h
src/actions/rs_actiondrawlineparallelthrough.cpp
src/actions/rs_actiondrawlineparallelthrough.h
src/actions/rs_actiondrawlinepolygon.cpp
src/actions/rs_actiondrawlinepolygon.h
src/actions/rs_actiondrawlinepolygon2.cpp
src/actions/rs_actiondrawlinepolygon2.h
src/actions/rs_actiondrawlinerectangle.cpp
src/actions/rs_actiondrawlinerectangle.h
src/actions/rs_actiondrawlinerelangle.cpp
src/actions/rs_actiondrawlinerelangle.h
src/actions/rs_actiondrawlinetangent1.cpp
src/actions/rs_actiondrawlinetangent1.h
src/actions/rs_actiondrawlinetangent2.cpp
src/actions/rs_actiondrawlinetangent2.h
src/actions/rs_actiondrawpoint.cpp
src/actions/rs_actiondrawpoint.h
src/actions/rs_actiondrawspline.cpp
src/actions/rs_actiondrawspline.h
src/actions/rs_actiondrawtext.cpp
src/actions/rs_actiondrawtext.h
src/actions/rs_actioneditcopy.cpp
src/actions/rs_actioneditcopy.h
src/actions/rs_actioneditpaste.cpp
src/actions/rs_actioneditpaste.h
src/actions/rs_actioneditundo.cpp
src/actions/rs_actioneditundo.h
src/actions/rs_actionfilenew.cpp
src/actions/rs_actionfilenew.h
src/actions/rs_actionfileopen.cpp
src/actions/rs_actionfileopen.h
src/actions/rs_actionfilesave.cpp
src/actions/rs_actionfilesave.h
src/actions/rs_actionfilesaveas.cpp
src/actions/rs_actionfilesaveas.h
src/actions/rs_actioninfoangle.cpp
src/actions/rs_actioninfoangle.h
src/actions/rs_actioninfoarea.cpp
src/actions/rs_actioninfoarea.h
src/actions/rs_actioninfodist.cpp
src/actions/rs_actioninfodist.h
src/actions/rs_actioninfodist2.cpp
src/actions/rs_actioninfodist2.h
src/actions/rs_actioninfoinside.cpp
src/actions/rs_actioninfoinside.h
src/actions/rs_actioninfototallength.cpp
src/actions/rs_actioninfototallength.h
src/actions/rs_actionlayersadd.cpp
src/actions/rs_actionlayersadd.h
src/actions/rs_actionlayersedit.cpp
src/actions/rs_actionlayersedit.h
src/actions/rs_actionlayersfreezeall.cpp
src/actions/rs_actionlayersfreezeall.h
src/actions/rs_actionlayersremove.cpp
src/actions/rs_actionlayersremove.h
src/actions/rs_actionlayerstogglelock.cpp
src/actions/rs_actionlayerstogglelock.h
src/actions/rs_actionlayerstoggleview.cpp
src/actions/rs_actionlayerstoggleview.h
src/actions/rs_actionlibraryinsert.cpp
src/actions/rs_actionlibraryinsert.h
src/actions/rs_actionlockrelativezero.cpp
src/actions/rs_actionlockrelativezero.h
src/actions/rs_actionmodifyattributes.cpp
src/actions/rs_actionmodifyattributes.h
src/actions/rs_actionmodifybevel.cpp
src/actions/rs_actionmodifybevel.h
src/actions/rs_actionmodifycut.cpp
src/actions/rs_actionmodifycut.h
src/actions/rs_actionmodifydelete.cpp
src/actions/rs_actionmodifydelete.h
src/actions/rs_actionmodifydeletefree.cpp
src/actions/rs_actionmodifydeletefree.h
src/actions/rs_actionmodifydeletequick.cpp
src/actions/rs_actionmodifydeletequick.h
src/actions/rs_actionmodifyentity.cpp
src/actions/rs_actionmodifyentity.h
src/actions/rs_actionmodifyexplodetext.cpp
src/actions/rs_actionmodifyexplodetext.h
src/actions/rs_actionmodifymirror.cpp
src/actions/rs_actionmodifymirror.h
src/actions/rs_actionmodifymove.cpp
src/actions/rs_actionmodifymove.h
src/actions/rs_actionmodifymoverotate.cpp
src/actions/rs_actionmodifymoverotate.h
src/actions/rs_actionmodifyrotate.cpp
src/actions/rs_actionmodifyrotate.h
src/actions/rs_actionmodifyrotate2.cpp
src/actions/rs_actionmodifyrotate2.h
src/actions/rs_actionmodifyround.cpp
src/actions/rs_actionmodifyround.h
src/actions/rs_actionmodifyscale.cpp
src/actions/rs_actionmodifyscale.h
src/actions/rs_actionmodifystretch.cpp
src/actions/rs_actionmodifystretch.h
src/actions/rs_actionmodifytrim.cpp
src/actions/rs_actionmodifytrim.h
src/actions/rs_actionmodifytrimamount.cpp
src/actions/rs_actionmodifytrimamount.h
src/actions/rs_actionoptionsdrawing.cpp
src/actions/rs_actionoptionsdrawing.h
src/actions/rs_actionprintpreview.cpp
src/actions/rs_actionprintpreview.h
src/actions/rs_actionselect.cpp
src/actions/rs_actionselect.h
src/actions/rs_actionselectall.cpp
src/actions/rs_actionselectall.h
src/actions/rs_actionselectbase.cpp
src/actions/rs_actionselectbase.h
src/actions/rs_actionselectcontour.cpp
src/actions/rs_actionselectcontour.h
src/actions/rs_actionselectintersected.cpp
src/actions/rs_actionselectintersected.h
src/actions/rs_actionselectinvert.cpp
src/actions/rs_actionselectinvert.h
src/actions/rs_actionselectlayer.cpp
src/actions/rs_actionselectlayer.h
src/actions/rs_actionselectsingle.cpp
src/actions/rs_actionselectsingle.h
src/actions/rs_actionselectwindow.cpp
src/actions/rs_actionselectwindow.h
src/actions/rs_actionsetrelativezero.cpp
src/actions/rs_actionsetrelativezero.h
src/actions/rs_actionsetsnapmode.cpp
src/actions/rs_actionsetsnapmode.h
src/actions/rs_actionsetsnaprestriction.cpp
src/actions/rs_actionsetsnaprestriction.h
src/actions/rs_actionsnapintersectionmanual.cpp
src/actions/rs_actionsnapintersectionmanual.h
src/actions/rs_actiontoolregeneratedimensions.cpp
src/actions/rs_actiontoolregeneratedimensions.h
src/actions/rs_actionzoomauto.cpp
src/actions/rs_actionzoomauto.h
src/actions/rs_actionzoomautoy.cpp
src/actions/rs_actionzoomautoy.h
src/actions/rs_actionzoomin.cpp
src/actions/rs_actionzoomin.h
src/actions/rs_actionzoompan.cpp
src/actions/rs_actionzoompan.h
src/actions/rs_actionzoomprevious.cpp
src/actions/rs_actionzoomprevious.h
src/actions/rs_actionzoomredraw.cpp
src/actions/rs_actionzoomredraw.h
src/actions/rs_actionzoomscroll.cpp
src/actions/rs_actionzoomscroll.h
src/actions/rs_actionzoomwindow.cpp
src/actions/rs_actionzoomwindow.h
src/base/rs.h
src/base/rs_actioninterface.cpp
src/base/rs_actioninterface.h
src/base/rs_application.h.old [moved from src/base/rs_application.h with 100% similarity]
src/base/rs_commandevent.cpp [new file with mode: 0644]
src/base/rs_commandevent.h
src/base/rs_coordinateevent.h.old [moved from src/base/rs_coordinateevent.h with 100% similarity]
src/base/rs_creation.cpp
src/base/rs_creation.h
src/base/rs_eventhandler.cpp
src/base/rs_graphicview.cpp
src/base/rs_graphicview.h
src/base/rs_previewactioninterface.cpp
src/base/rs_previewactioninterface.h
src/base/rs_snapper.cpp
src/base/rs_snapper.h

index b14716495622f9cd9a08788f7eaaa703590a7e3e..7c4f4bae73412eaa170c38fb68d1a615b6a76673 100644 (file)
@@ -34,7 +34,6 @@ HEADERS = \
        src/base/rs_creation.h \
        src/base/rs_debug.h \
        src/base/rs.h \
-       src/base/rs_application.h \
        src/base/rs_arc.h \
        src/base/rs_atomicentity.h \
        src/base/rs_block.h \
@@ -91,7 +90,6 @@ HEADERS = \
        src/base/rs_filterdxf1.h \
        src/base/rs_filterinterface.h \
        src/base/rs_commandevent.h \
-       src/base/rs_coordinateevent.h \
        src/base/rs_dialogfactory.h \
        src/base/rs_dialogfactoryinterface.h \
        src/base/rs_dialogfactoryadapter.h \
index d6705fedf092328a139a2460ed8e0718a735d295..a0ca3d69d040790986b7bfc116e76c2ace2dda89 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
@@ -29,9 +29,8 @@
 #include "drawing.h"
 #include "rs_dialogfactory.h"
 
-RS_ActionBlocksAdd::RS_ActionBlocksAdd(RS_EntityContainer& container,
-                                       RS_GraphicView& graphicView)
-        :RS_ActionInterface("Add Block", container, graphicView)
+RS_ActionBlocksAdd::RS_ActionBlocksAdd(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Add Block", container, graphicView)
 {
 }
 
@@ -41,17 +40,17 @@ QAction * RS_ActionBlocksAdd::createGUIAction(RS2::ActionType /*type*/, QObject
 //    QAction * action = new QAction(tr("Add Block"), tr("&Add Block"),
 //                             QKeySequence(), NULL);
        QAction * action = new QAction(tr("&Add Block"), 0);
-    action->setStatusTip(tr("Add Block"));
-    return action;
+       action->setStatusTip(tr("Add Block"));
+       return action;
 }
 
 void RS_ActionBlocksAdd::trigger()
 {
-    RS_DEBUG->print("adding block");
-    //RS_Block* block = new RS_Block(container, "", Vector(0.0,0.0));
+       RS_DEBUG->print("adding block");
+       //RS_Block* block = new RS_Block(container, "", Vector(0.0,0.0));
 
-    if (graphic != NULL)
-    {
+       if (graphic != NULL)
+       {
                RS_BlockList * blockList = graphic->getBlockList();
 
                if (blockList != NULL)
@@ -59,21 +58,17 @@ void RS_ActionBlocksAdd::trigger()
                        RS_BlockData d = RS_DIALOGFACTORY->requestNewBlockDialog(blockList);
 
                        if (d.isValid())
-                       {
-                       graphic->addBlock(new RS_Block(container, d));
-                       }
+                               graphic->addBlock(new RS_Block(container, d));
                }
-    }
+       }
 
-    finish();
+       finish();
 }
 
-
-
 void RS_ActionBlocksAdd::init(int status)
 {
-    RS_ActionInterface::init(status);
-    trigger();
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
 // EOF
index 70f4cafa330ffb2d45a3f8c7d9d27d05c2c6e598..c2b2e0c49351b0baaf46aec434ef88485a11d8bf 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksAdd : public RS_ActionInterface {
-  //Q_OBJECT
-public:
-    RS_ActionBlocksAdd(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionBlocksAdd() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionBlocksAdd: public RS_ActionInterface
+{
+       //Q_OBJECT
+       public:
+               RS_ActionBlocksAdd(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksAdd()
+               {
+               }
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
 
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 9c363e31ebe05ecbd36d0fca53fae260b8a71796..67ef48b36a2b97800c6db3f2c7dc1c3fad39571c 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
 #include "drawing.h"
 #include "rs_dialogfactory.h"
 
-
-
 RS_ActionBlocksAttributes::RS_ActionBlocksAttributes(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Edit Block Attributes", container, graphicView)
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Edit Block Attributes", container, graphicView)
 {
 }
 
-
-
-QAction* RS_ActionBlocksAttributes::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+QAction * RS_ActionBlocksAttributes::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
 {
-
-    QAction * action = new QAction(tr("&Rename Block"), 0);
+       QAction * action = new QAction(tr("&Rename Block"), 0);
 //    QAction* action = new QAction(tr("Rename Block"),
 //                                  tr("&Rename Block"),
 //                                  QKeySequence(), NULL);
-    action->setStatusTip(tr("Rename Block and all Inserts"));
-    return action;
+       action->setStatusTip(tr("Rename Block and all Inserts"));
+       return action;
 }
 
-
-
 void RS_ActionBlocksAttributes::trigger()
 {
-    RS_DEBUG->print("editing block attributes");
-
-    if (graphic!=NULL && RS_DIALOGFACTORY!=NULL) {
-        RS_Block* block = graphic->getActiveBlock();
-        RS_BlockList* blockList = graphic->getBlockList();
-        if (blockList!=NULL && block!=NULL) {
-            QString oldName = block->getName();
-
-            RS_BlockData d;
-            d = RS_DIALOGFACTORY->requestBlockAttributesDialog(
-                    blockList);
-
-            if (d.isValid()) {
-
-                QString newName = d.name;
-                blockList->rename(block, newName);
-
-                // update the name of all inserts:
-                graphic->renameInserts(oldName, newName);
-
-                graphic->addBlockNotification();
-            }
-        }
-
-    }
-    finish();
+       RS_DEBUG->print("editing block attributes");
+
+       if (graphic != NULL && RS_DIALOGFACTORY != NULL)
+       {
+               RS_Block * block = graphic->getActiveBlock();
+               RS_BlockList * blockList = graphic->getBlockList();
+
+               if (blockList != NULL && block != NULL)
+               {
+                       QString oldName = block->getName();
+
+                       RS_BlockData d;
+                       d = RS_DIALOGFACTORY->requestBlockAttributesDialog(
+                                       blockList);
+
+                       if (d.isValid())
+                       {
+                               QString newName = d.name;
+                               blockList->rename(block, newName);
+
+                               // update the name of all inserts:
+                               graphic->renameInserts(oldName, newName);
+
+                               graphic->addBlockNotification();
+                       }
+               }
+       }
+       finish();
 }
 
-
-
 void RS_ActionBlocksAttributes::init(int status)
 {
-    RS_ActionInterface::init(status);
-    trigger();
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
 // EOF
index 9c36281abd4f7d09dc351d06d762c7c32d5b67d4..80dc698a8177e8a809a8dcf72a73ba5f7a1775df 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksAttributes : public RS_ActionInterface {
-  //Q_OBJECT
-public:
-    RS_ActionBlocksAttributes(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionBlocksAttributes() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionBlocksAttributes: public RS_ActionInterface
+{
+       //Q_OBJECT
+       public:
+               RS_ActionBlocksAttributes(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksAttributes()
+               {
+               }
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
 
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 77f0126e582366525f8b0c51c4b47566a87a0928..083f2fe4e4588f25b3beea28b6ab8077e880120f 100644 (file)
-/****************************************************************************
-** $Id: rs_actionblockscreate.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionblockscreate.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+// JLH  06/03/2010  Scrubbed out all occurances of RS_CoordinateEvent
+//
 
 #include "rs_actionblockscreate.h"
 
 #include "rs_creation.h"
+#include "rs_dialogfactory.h"
 #include "rs_insert.h"
 #include "rs_modification.h"
 
 /**
  * Constructor.
  */
-RS_ActionBlocksCreate::RS_ActionBlocksCreate(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Blocks Create",
-                           container, graphicView)
+RS_ActionBlocksCreate::RS_ActionBlocksCreate(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Blocks Create", container, graphicView)
 {
-    referencePoint = Vector(false);
+       referencePoint = Vector(false);
 }
 
+RS_ActionBlocksCreate::~RS_ActionBlocksCreate()
+{
+}
 
-
-RS_ActionBlocksCreate::~RS_ActionBlocksCreate() {}
-
-
-
-QAction* RS_ActionBlocksCreate::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+#if 0
+QAction * RS_ActionBlocksCreate::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
 {
-    QAction * action = new QAction(tr("&Create Block"), 0);
+       QAction * action = new QAction(tr("&Create Block"), 0);
 //    QAction* action = new QAction(tr("Create Block"),
 //                                  tr("&Create Block"),
 //                                  QKeySequence(), NULL);
-    action->setStatusTip(tr("Create Block"));
+       action->setStatusTip(tr("Create Block"));
 
-    return action;
+       return action;
 }
 
+#endif
 
-
-void RS_ActionBlocksCreate::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
+/*virtual*/ RS2::ActionType RS_ActionBlocksCreate::rtti()
+{
+       return RS2::ActionBlocksCreate;
 }
 
-
-
-void RS_ActionBlocksCreate::trigger() {
-    deleteSnapper();
-    //deletePreview();
-    //clearPreview();
-
-    //RS_Modification m(*container, graphicView);
-    //m.paste(data.insertionPoint);
-    //std::cout << *RS_Clipboard::instance();
-
-    if (graphic!=NULL) {
-        RS_BlockList* blockList = graphic->getBlockList();
-        if (blockList!=NULL) {
-            RS_BlockData d =
-                RS_DIALOGFACTORY->requestNewBlockDialog(blockList);
-
-            if (!d.name.isEmpty()) {
-                RS_Creation creation(container, graphicView);
-                creation.createBlock(d, referencePoint, true);
-
-                RS_InsertData id(
-                    d.name,
-                    referencePoint,
-                    Vector(1.0,1.0),
-                    0.0,
-                    1, 1, Vector(0.0,0.0)
-                );
-                creation.createInsert(id);
-            }
-        }
-    }
-
-    graphicView->redraw();
-    finish();
-    graphicView->killSelectActions();
+void RS_ActionBlocksCreate::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 }
 
-
-void RS_ActionBlocksCreate::mouseMoveEvent(QMouseEvent* e) {
-    snapPoint(e);
-
-    switch (getStatus()) {
-    case SetReferencePoint:
-        //data.insertionPoint = snapPoint(e);
-
-        /*if (block!=NULL) {
-            deletePreview();
-            clearPreview();
-            //preview->addAllFrom(*block);
-            //preview->move(data.insertionPoint);
-               RS_Creation creation(preview, NULL, false);
-               creation.createInsert(data);
-            drawPreview();
-    }*/
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionBlocksCreate::trigger()
+{
+       deleteSnapper();
+       //deletePreview();
+       //clearPreview();
+
+       //RS_Modification m(*container, graphicView);
+       //m.paste(data.insertionPoint);
+       //std::cout << *RS_Clipboard::instance();
+
+       if (graphic != NULL)
+       {
+               RS_BlockList * blockList = graphic->getBlockList();
+
+               if (blockList != NULL)
+               {
+                       RS_BlockData d = RS_DIALOGFACTORY->requestNewBlockDialog(blockList);
+
+                       if (!d.name.isEmpty())
+                       {
+                               RS_Creation creation(container, graphicView);
+                               creation.createBlock(d, referencePoint, true);
+
+                               RS_InsertData id(d.name, referencePoint, Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0));
+                               creation.createInsert(id);
+                       }
+               }
+       }
+
+       graphicView->redraw();
+       finish();
+       graphicView->killSelectActions();
 }
 
-
-
-void RS_ActionBlocksCreate::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionBlocksCreate::mouseMoveEvent(QMouseEvent * e)
+{
+       snapPoint(e);
+
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               //data.insertionPoint = snapPoint(e);
+
+               /*if (block!=NULL) {
+                       deletePreview();
+                       clearPreview();
+                       //preview->addAllFrom(*block);
+                       //preview->move(data.insertionPoint);
+                       RS_Creation creation(preview, NULL, false);
+                       creation.createInsert(data);
+                       drawPreview();
+                  }*/
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionBlocksCreate::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetReferencePoint:
-        referencePoint = e->getCoordinate();
-        trigger();
-        break;
-
-    default:
-        break;
-
-    }
+void RS_ActionBlocksCreate::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+//             Vector ce(snapPoint(e));
+//             coordinateEvent(&ce);
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+//     else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionBlocksCreate::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+//void RS_ActionBlocksCreate::coordinateEvent(Vector * e)
+void RS_ActionBlocksCreate::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+//             referencePoint = e->getCoordinate();
+               referencePoint = *e;
+               trigger();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionBlocksCreate::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionBlocksCreate::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionBlocksCreate::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-    }
+void RS_ActionBlocksCreate::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionBlocksCreate::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+}
 
-// EOF
index 6e09a3c7e61b93144ba2902b3ed570f6ea2ad27b..021c47c61b1fe4c63594300c5dc161ee3e23a730 100644 (file)
@@ -1,83 +1,48 @@
-/****************************************************************************
-** $Id: rs_actionblockscreate.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONBLOCKSCREATE_H
 #define RS_ACTIONBLOCKSCREATE_H
 
 #include "rs_previewactioninterface.h"
-#include "rs_insert.h"
+//#include "rs_insert.h"
 
 /**
- * This action class can handle user events for creating blocks from 
+ * This action class can handle user events for creating blocks from
  * existing entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksCreate : public RS_PreviewActionInterface {
+class RS_ActionBlocksCreate: public RS_PreviewActionInterface
+{
        //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetReferencePoint,    /**< Setting the reference point. */
-               ShowDialog            /**< Showing dialog for name. */
-    };
-
-public:
-    RS_ActionBlocksCreate(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionBlocksCreate();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionBlocksCreate;
-       }
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void coordinateEvent(RS_CoordinateEvent* e);
-    //virtual void commandEvent(RS_CommandEvent* e);
-       //virtual QStringList getAvailableCommands();
-
-       //virtual void showOptions();
-       //virtual void hideOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-       Vector referencePoint;
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetReferencePoint,    /**< Setting the reference point. */
+                       ShowDialog            /**< Showing dialog for name. */
+               };
+
+       public:
+               RS_ActionBlocksCreate(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksCreate();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+//             virtual void coordinateEvent(Vector * e);
+               virtual void coordinateEvent(Vector * e);
+               //virtual void commandEvent(RS_CommandEvent * e);
+               //virtual QStringList getAvailableCommands();
+               //virtual void showOptions();
+               //virtual void hideOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               Vector referencePoint;
 };
 
 #endif
index e63c7a258410d11e2270215852057854c04f6043..c8b163cf4cbe774ee1e74d411fa23f20a5dff2a6 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
 #include "drawing.h"
 #include "rs_dialogfactory.h"
 
+RS_ActionBlocksEdit::RS_ActionBlocksEdit(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Edit Block", container, graphicView)
+{
+}
 
-
-RS_ActionBlocksEdit::RS_ActionBlocksEdit(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Edit Block", container, graphicView) {}
-
-
-QAction* RS_ActionBlocksEdit::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+QAction * RS_ActionBlocksEdit::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
 {
-        QAction* action = new QAction(tr("&Edit Block"), 0);
+       QAction * action = new QAction(tr("&Edit Block"), 0);
 //        QAction* action = new QAction(tr("Edit Block"), tr("&Edit Block"),
 //                             QKeySequence(), NULL);
-        action->setStatusTip(tr("Edit Block"));
-               return action;
+       action->setStatusTip(tr("Edit Block"));
+       return action;
 }
 
+void RS_ActionBlocksEdit::trigger()
+{
+       RS_DEBUG->print("edit block");
 
-void RS_ActionBlocksEdit::trigger() {
-    RS_DEBUG->print("edit block");
-    if (graphic!=NULL) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->requestEditBlockWindow(graphic->getBlockList());
-        }
-    } else {
-        RS_DEBUG->print(RS_Debug::D_WARNING,
-               "RS_ActionBlocksEdit::trigger(): graphic is NULL");
-    }
-    finish();
+       if (graphic != NULL)
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestEditBlockWindow(graphic->getBlockList());
+       }
+       else
+               RS_DEBUG->print(RS_Debug::D_WARNING,
+                       "RS_ActionBlocksEdit::trigger(): graphic is NULL");
+       finish();
 }
 
-
-
-void RS_ActionBlocksEdit::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionBlocksEdit::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
index 845cdfa9c802070dba55dc8eaaffedcd808b18d4..764e036f8b369434752d0c9c1b351371cb6ad663 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksEdit : public RS_ActionInterface {
+class RS_ActionBlocksEdit: public RS_ActionInterface
+{
        //Q_OBJECT
-public:
-    RS_ActionBlocksEdit(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionBlocksEdit() {}
+       public:
+               RS_ActionBlocksEdit(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksEdit()
+               {
+               }
 
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
+               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
 
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 969e0973a43fae2522a83d814bf5efcaab95b784..f0de0d69570a9c4b03db5c81dea44f29b22f2037 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
 /**
  * Constructor.
  */
-RS_ActionBlocksExplode::RS_ActionBlocksExplode(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Blocks Explode",
-                           container, graphicView) {
+RS_ActionBlocksExplode::RS_ActionBlocksExplode(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Blocks Explode",
+               container, graphicView)
+{
 }
 
+RS_ActionBlocksExplode::~RS_ActionBlocksExplode()
+{
+}
 
-
-RS_ActionBlocksExplode::~RS_ActionBlocksExplode() {}
-
-
-QAction* RS_ActionBlocksExplode::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+QAction * RS_ActionBlocksExplode::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
 {
-    QAction * action = new QAction(tr("&Explode"), 0);
+       QAction * action = new QAction(tr("&Explode"), 0);
 //    QAction* action = new QAction(tr("Explode"),
 //                                  tr("&Explode"),
 //                                  QKeySequence(), NULL);
-    action->setStatusTip(tr("Explode Blocks and other Entity Groups"));
+       action->setStatusTip(tr("Explode Blocks and other Entity Groups"));
 
-    return action;
+       return action;
 }
 
+void RS_ActionBlocksExplode::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-void RS_ActionBlocksExplode::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    trigger();
-    finish();
+       trigger();
+       finish();
 }
 
-
-
-void RS_ActionBlocksExplode::trigger() {
-    RS_Modification m(*container, graphicView);
-    m.explode();
+void RS_ActionBlocksExplode::trigger()
+{
+       RS_Modification m(*container, graphicView);
+       m.explode();
 }
 
-
 // EOF
index e6cf42286f6ebf5c889a1aafab97cb386bbadc90..ed2de134ac8df130839a16d9fafa812d8645b47a 100644 (file)
@@ -10,7 +10,7 @@
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
-** Licensees holding valid qcadlib Professional Edition licenses may use 
+** Licensees holding valid qcadlib Professional Edition licenses may use
 ** this file in accordance with the qcadlib Commercial License
 ** Agreement provided with the Software.
 **
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksExplode : public RS_PreviewActionInterface {
+class RS_ActionBlocksExplode: public RS_PreviewActionInterface
+{
        //Q_OBJECT
-public:
-    RS_ActionBlocksExplode(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionBlocksExplode();
+       public:
+               RS_ActionBlocksExplode(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksExplode();
 
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionBlocksExplode;
-       }
+               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
 
-    virtual void init(int status=0);
+               virtual RS2::ActionType rtti()
+               {
+                       return RS2::ActionBlocksExplode;
+               }
 
-    virtual void trigger();
+               virtual void init(int status = 0);
+
+               virtual void trigger();
 };
 
 #endif
index 13305d3bcbadedbb9cbb69b79d2fb8698028b4f4..90313f75046b1fe6cf4d3c6c98a1238a38df3d0e 100644 (file)
 #include "rs_actionblocksfreezeall.h"
 
 #include "drawing.h"
+#include "rs_graphicview.h"
 
-RS_ActionBlocksFreezeAll::RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container,
-       RS_GraphicView& graphicView): RS_ActionInterface("Freeze all Blocks",
-       container, graphicView)
+RS_ActionBlocksFreezeAll::RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Freeze all Blocks",
+               container, graphicView)
 {
        this->freeze = freeze;
 }
 
-QAction * RS_ActionBlocksFreezeAll::createGUIAction(RS2::ActionType type, QObject* /*parent*/)
+RS_ActionBlocksFreezeAll::~RS_ActionBlocksFreezeAll()
 {
-    QAction * action = NULL;
-
-       if (type == RS2::ActionBlocksFreezeAll)
-       {
-               action = new QAction(tr("&Freeze all"), 0);
-//             action= new QAction(tr("Freeze all"), tr("&Freeze all"),
-//                                  QKeySequence(), NULL);
-       action->setStatusTip(tr("Freeze all blocks"));
-       }
-       else if (type == RS2::ActionBlocksDefreezeAll)
-       {
-        action = new QAction(tr("&Defreeze all"), 0);
-//        action = new QAction(tr("Defreeze all"), tr("&Defreeze all"),
-//                             QKeySequence(), NULL);
-        action->setStatusTip(tr("Defreeze all blocks"));
-       }
-
-    return action;
 }
 
 void RS_ActionBlocksFreezeAll::trigger()
 {
        RS_DEBUG->print("RS_ActionBlocksFreezeAll::trigger");
 
-       if (graphic!=NULL)
+       if (graphic != NULL)
                graphic->freezeAllBlocks(freeze);
 
        graphicView->redraw();
@@ -61,3 +43,4 @@ void RS_ActionBlocksFreezeAll::init(int status)
        RS_ActionInterface::init(status);
        trigger();
 }
+
index 4192b624e48cb395832199ed516ec0cb7c7966b6..32a04b708d723a6edc8fa6b071030cd7c189d846 100644 (file)
@@ -1,55 +1,25 @@
-/****************************************************************************
-** $Id: rs_actionblocksfreezeall.h 1092 2004-03-16 18:01:08Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONBLOCKSFREEZEALL_H
 #define RS_ACTIONBLOCKSFREEZEALL_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to edit layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksFreezeAll : public RS_ActionInterface {
+class RS_ActionBlocksFreezeAll: public RS_ActionInterface
+{
        //Q_OBJECT
-public:
-    RS_ActionBlocksFreezeAll(bool freeze,
-                             RS_EntityContainer& container,
-                             RS_GraphicView& graphicView);
-    ~RS_ActionBlocksFreezeAll() {}
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
+       public:
+               RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksFreezeAll();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-private:
-    bool freeze;
+       private:
+               bool freeze;
 };
 
 #endif
index 5312c31da64c03ca1d3a8dadaeec15fb55fbd0b9..390485c369794cae00726d92d5033be98700dc03 100644 (file)
-/****************************************************************************
-** $Id: rs_actionblocksinsert.cpp 1148 2004-09-11 21:38:11Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionblocksinsert.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+// JLH  06/03/2010  Scrubbed out all occurances of RS_CoordinateEvent
+//
 
 #include "rs_actionblocksinsert.h"
 
-#include "rs_creation.h"
 #include "commands.h"
+#include "rs_creation.h"
+#include "rs_dialogfactory.h"
 #include "rs_modification.h"
-
+#include "rs_preview.h"
 
 /**
  * Constructor.
  */
-RS_ActionBlocksInsert::RS_ActionBlocksInsert(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Blocks Insert",
-                           container, graphicView) {}
-
-
+RS_ActionBlocksInsert::RS_ActionBlocksInsert(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Blocks Insert",
+               container, graphicView)
+{
+}
 
-RS_ActionBlocksInsert::~RS_ActionBlocksInsert() {}
+RS_ActionBlocksInsert::~RS_ActionBlocksInsert()
+{
+}
 
-QAction* RS_ActionBlocksInsert::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+#if 0
+QAction * RS_ActionBlocksInsert::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
 {
-    QAction * action = new QAction(tr("&Insert Block"), 0);
+       QAction * action = new QAction(tr("&Insert Block"), 0);
 //    QAction* action = new QAction(tr("Insert Block"), tr("&Insert Block"),
 //                                  QKeySequence(), NULL);
-    action->setStatusTip(tr("Insert Block"));
+       action->setStatusTip(tr("Insert Block"));
 
-    return action;
+       return action;
 }
 
-void RS_ActionBlocksInsert::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+#endif
 
-    if (graphic!=NULL) {
-        block = graphic->getActiveBlock();
-        if (block!=NULL) {
-            data.name = block->getName();
-        } else {
-            finish();
-        }
-    }
+/*virtual*/ RS2::ActionType RS_ActionBlocksInsert::rtti()
+{
+       return RS2::ActionBlocksInsert;
 }
 
+void RS_ActionBlocksInsert::init(int status /*= 0*/)
+{
+       RS_PreviewActionInterface::init(status);
+
+       reset();
 
+       if (graphic != NULL)
+       {
+               block = graphic->getActiveBlock();
 
-void RS_ActionBlocksInsert::reset() {
-    data = RS_InsertData("",
-                         Vector(0.0,0.0),
-                         Vector(1.0,1.0),
-                         0.0,
-                         1, 1,
-                         Vector(1.0,1.0),
-                         NULL,
-                         RS2::Update);
+               if (block != NULL)
+                       data.name = block->getName();
+               else
+                       finish();
+       }
 }
 
+void RS_ActionBlocksInsert::reset()
+{
+       data = RS_InsertData("", Vector(0.0, 0.0), Vector(1.0, 1.0), 0.0,
+                       1, 1, Vector(1.0, 1.0), NULL, RS2::Update);
+}
 
+void RS_ActionBlocksInsert::trigger()
+{
+       deleteSnapper();
+       deletePreview();
+       clearPreview();
 
-void RS_ActionBlocksInsert::trigger() {
-    deleteSnapper();
-    deletePreview();
-    clearPreview();
-
-    //RS_Modification m(*container, graphicView);
-    //m.paste(data.insertionPoint);
-    //std::cout << *RS_Clipboard::instance();
+       //RS_Modification m(*container, graphicView);
+       //m.paste(data.insertionPoint);
+       //std::cout << *RS_Clipboard::instance();
 
-    if (block!=NULL) {
-        RS_Creation creation(container, graphicView);
+       if (block != NULL)
+       {
+               RS_Creation creation(container, graphicView);
                data.updateMode = RS2::Update;
-        creation.createInsert(data);
-    }
+               creation.createInsert(data);
+       }
 
-    graphicView->redraw();
-    //finish();
+       graphicView->redraw();
+       //finish();
 }
 
-
-void RS_ActionBlocksInsert::mouseMoveEvent(QMouseEvent* e) {
-    switch (getStatus()) {
-    case SetTargetPoint:
-        data.insertionPoint = snapPoint(e);
-
-        if (block!=NULL) {
-            deletePreview();
-            clearPreview();
-            //preview->addAllFrom(*block);
-            //preview->move(data.insertionPoint);
-            RS_Creation creation(preview, NULL, false);
+void RS_ActionBlocksInsert::mouseMoveEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
+       case SetTargetPoint:
+               data.insertionPoint = snapPoint(e);
+
+               if (block != NULL)
+               {
+                       deletePreview();
+                       clearPreview();
+                       //preview->addAllFrom(*block);
+                       //preview->move(data.insertionPoint);
+                       RS_Creation creation(preview, NULL, false);
                        // Create insert as preview only
                        data.updateMode = RS2::PreviewUpdate;
-            creation.createInsert(data);
-            drawPreview();
-        }
-        break;
-
-    default:
-        break;
-    }
+                       creation.createInsert(data);
+                       drawPreview();
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionBlocksInsert::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionBlocksInsert::mouseReleaseEvent(QMouseEvent * e)
+{
+//    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionBlocksInsert::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-
-void RS_ActionBlocksInsert::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    data.insertionPoint = e->getCoordinate();
-    trigger();
+//     data.insertionPoint = e->getCoordinate();
+       data.insertionPoint = *e;
+       trigger();
 }
 
-
-
-void RS_ActionBlocksInsert::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetTargetPoint:
-        if (checkCommand("angle", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetAngle);
-        } else if (checkCommand("factor", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetFactor);
-        } else if (checkCommand("columns", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetColumns);
-        } else if (checkCommand("rows", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetRows);
-        } else if (checkCommand("columnspacing", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetColumnSpacing);
-        } else if (checkCommand("rowspacing", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetRowSpacing);
-        }
-        break;
-
-    case SetAngle: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.angle = RS_Math::deg2rad(a);
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetFactor: {
-            bool ok;
-            double f = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                setFactor(f);
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetColumns: {
-            bool ok;
-            int cols = (int)RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.cols = cols;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetRows: {
-            bool ok;
-            int rows = (int)RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.rows = rows;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetColumnSpacing: {
-            bool ok;
-            double cs = (int)RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.spacing.x = cs;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetRowSpacing: {
-            bool ok;
-            int rs = (int)RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.spacing.y = rs;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionBlocksInsert::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetTargetPoint:
+
+               if (checkCommand("angle", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetAngle);
+               }
+               else if (checkCommand("factor", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetFactor);
+               }
+               else if (checkCommand("columns", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetColumns);
+               }
+               else if (checkCommand("rows", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetRows);
+               }
+               else if (checkCommand("columnspacing", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetColumnSpacing);
+               }
+               else if (checkCommand("rowspacing", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetRowSpacing);
+               }
+               break;
+
+       case SetAngle:
+       {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.angle = RS_Math::deg2rad(a);
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetFactor:
+       {
+               bool ok;
+               double f = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       setFactor(f);
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetColumns:
+       {
+               bool ok;
+               int cols = (int)RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.cols = cols;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetRows:
+       {
+               bool ok;
+               int rows = (int)RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.rows = rows;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetColumnSpacing:
+       {
+               bool ok;
+               double cs = (int)RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.spacing.x = cs;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetRowSpacing:
+       {
+               bool ok;
+               int rs = (int)RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.spacing.y = rs;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionBlocksInsert::getAvailableCommands()
+{
+       QStringList cmd;
+
+       switch (getStatus())
+       {
+       case SetTargetPoint:
+               cmd += command("angle");
+               cmd += command("factor");
+               cmd += command("columns");
+               cmd += command("rows");
+               cmd += command("columnspacing");
+               cmd += command("rowspacing");
+               break;
+
+       default:
+               break;
+       }
+
+       return cmd;
+}
 
-
-QStringList RS_ActionBlocksInsert::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetTargetPoint:
-        cmd += command("angle");
-        cmd += command("factor");
-        ;
-        cmd += command("columns");
-        cmd += command("rows");
-        cmd += command("columnspacing");
-        cmd += command("rowspacing");
-        break;
-    default:
-        break;
-    }
-
-    return cmd;
+void RS_ActionBlocksInsert::showOptions()
+{
+       RS_ActionInterface::showOptions();
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionBlocksInsert::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
+       RS_DIALOGFACTORY->requestOptions(this, false);
+}
 
-void RS_ActionBlocksInsert::showOptions() {
-    RS_ActionInterface::showOptions();
+void RS_ActionBlocksInsert::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
+               break;
+
+       case SetAngle:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter angle:"), "");
+               break;
+
+       case SetFactor:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter factor:"), "");
+               break;
+
+       case SetColumns:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter columns:"), "");
+               break;
+
+       case SetRows:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter rows:"), "");
+               break;
+
+       case SetColumnSpacing:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter column spacing:"), "");
+               break;
+
+       case SetRowSpacing:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter row spacing:"), "");
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
+}
 
-    RS_DIALOGFACTORY->requestOptions(this, true);
+void RS_ActionBlocksInsert::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionBlocksInsert::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+}
 
+double RS_ActionBlocksInsert::getAngle()
+{
+       return data.angle;
+}
 
-void RS_ActionBlocksInsert::hideOptions() {
-    RS_ActionInterface::hideOptions();
+void RS_ActionBlocksInsert::setAngle(double a)
+{
+       data.angle = a;
+}
 
-    RS_DIALOGFACTORY->requestOptions(this, false);
+double RS_ActionBlocksInsert::getFactor()
+{
+       return data.scaleFactor.x;
 }
 
+void RS_ActionBlocksInsert::setFactor(double f)
+{
+       data.scaleFactor = Vector(f, f);
+}
 
-void RS_ActionBlocksInsert::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Cancel"));
-        break;
-    case SetAngle:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter angle:"),
-                                            "");
-        break;
-    case SetFactor:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter factor:"),
-                                            "");
-        break;
-    case SetColumns:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter columns:"),
-                                            "");
-        break;
-    case SetRows:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter rows:"),
-                                            "");
-        break;
-    case SetColumnSpacing:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter column spacing:"),
-                                            "");
-        break;
-    case SetRowSpacing:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter row spacing:"),
-                                            "");
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+int RS_ActionBlocksInsert::getColumns()
+{
+       return data.cols;
 }
 
+void RS_ActionBlocksInsert::setColumns(int c)
+{
+       data.cols = c;
+}
 
+int RS_ActionBlocksInsert::getRows()
+{
+       return data.rows;
+}
 
-void RS_ActionBlocksInsert::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionBlocksInsert::setRows(int r)
+{
+       data.rows = r;
 }
 
+double RS_ActionBlocksInsert::getColumnSpacing()
+{
+       return data.spacing.x;
+}
 
+void RS_ActionBlocksInsert::setColumnSpacing(double cs)
+{
+       data.spacing.x = cs;
+}
 
-void RS_ActionBlocksInsert::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-    }
+double RS_ActionBlocksInsert::getRowSpacing()
+{
+       return data.spacing.y;
 }
 
+void RS_ActionBlocksInsert::setRowSpacing(double rs)
+{
+       data.spacing.y = rs;
+}
 
-// EOF
index 433dc9f2ce7db9eaa44236b4d906ceaf4f73cb87..5ef409566843f150dabcdaf586c53b3de701cada 100644 (file)
@@ -1,29 +1,3 @@
-/****************************************************************************
-** $Id: rs_actionblocksinsert.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONBLOCKSINSERT_H
 #define RS_ACTIONBLOCKSINSERT_H
 
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksInsert : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetTargetPoint,    /**< Setting the reference point. */
-               SetAngle,          /**< Setting angle in the command line. */
-               SetFactor,         /**< Setting factor in the command line. */
-               SetColumns,        /**< Setting columns in the command line. */
-               SetRows,           /**< Setting rows in the command line. */
-               SetColumnSpacing,  /**< Setting column spacing in the command line. */
-               SetRowSpacing      /**< Setting row spacing in the command line. */
-    };
-
-public:
-    RS_ActionBlocksInsert(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionBlocksInsert();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionBlocksInsert;
-       }
-
-    virtual void init(int status=0);
-
-       void reset();
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-       virtual void showOptions();
-       virtual void hideOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       double getAngle() {
-               return data.angle;
-       }
-
-       void setAngle(double a) {
-               data.angle = a;
-       }
-
-       double getFactor() {
-               return data.scaleFactor.x;
-       }
-
-       void setFactor(double f) {
-               data.scaleFactor = Vector(f, f);
-       }
-
-       int getColumns() {
-               return data.cols;
-       }
-
-       void setColumns(int c) {
-               data.cols = c;
-       }
-       
-       int getRows() {
-               return data.rows;
-       }
-
-       void setRows(int r) {
-               data.rows = r;
-       }
-
-       double getColumnSpacing() {
-               return data.spacing.x;
-       }
-
-       void setColumnSpacing(double cs) {
-               data.spacing.x = cs;
-       }
-       
-       double getRowSpacing() {
-               return data.spacing.y;
-       }
-
-       void setRowSpacing(double rs) {
-               data.spacing.y = rs;
-       }
-
-protected:
-       RS_Block* block;
-       RS_InsertData data;
-       
-       /** Last status before entering option. */
-       Status lastStatus;
+class RS_ActionBlocksInsert: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetTargetPoint,    /**< Setting the reference point. */
+                       SetAngle,          /**< Setting angle in the command line. */
+                       SetFactor,         /**< Setting factor in the command line. */
+                       SetColumns,        /**< Setting columns in the command line. */
+                       SetRows,           /**< Setting rows in the command line. */
+                       SetColumnSpacing,  /**< Setting column spacing in the command line. */
+                       SetRowSpacing      /**< Setting row spacing in the command line. */
+               };
+
+       public:
+               RS_ActionBlocksInsert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksInsert();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               void reset();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void showOptions();
+               virtual void hideOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+               double getAngle();
+               void setAngle(double a);
+               double getFactor();
+               void setFactor(double f);
+               int getColumns();
+               void setColumns(int c);
+               int getRows();
+               void setRows(int r);
+               double getColumnSpacing();
+               void setColumnSpacing(double cs);
+               double getRowSpacing();
+               void setRowSpacing(double rs);
+
+       protected:
+               RS_Block * block;
+               RS_InsertData data;
+
+               /** Last status before entering option. */
+               Status lastStatus;
 };
 
 #endif
index d51e5b0eb7ce21bc302548e0e22c7ee8d046eaf5..0fae7c73e801b43138fed581c92e8e2bf996fd4d 100644 (file)
@@ -1,57 +1,39 @@
-/****************************************************************************
-** $Id: rs_actionblocksremove.cpp 2372 2005-04-29 11:44:54Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionblocksremove.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actionblocksremove.h"
 
 #include "rs_block.h"
+#include "rs_dialogfactory.h"
 #include "drawing.h"
+#include "rs_graphicview.h"
 #include "rs_insert.h"
-#include "rs_dialogfactory.h"
 
-RS_ActionBlocksRemove::RS_ActionBlocksRemove(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionBlocksRemove::RS_ActionBlocksRemove(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Remove Block", container, graphicView)
 {
 }
 
-QAction * RS_ActionBlocksRemove::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionBlocksRemove::~RS_ActionBlocksRemove()
 {
-       QAction * action = new QAction(tr("&Remove Block"), 0);
-//        QAction* action = new QAction(tr("Remove Block"), tr("&Remove Block"),
-//                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Remove Block"));
-
-               return action;
 }
 
 void RS_ActionBlocksRemove::trigger()
 {
        RS_DEBUG->print("RS_ActionBlocksRemove::trigger");
 
-       if (graphic!=NULL)
+       if (graphic != NULL)
        {
                RS_Block * block = RS_DIALOGFACTORY->requestBlockRemovalDialog(graphic->getBlockList());
 
@@ -61,14 +43,14 @@ void RS_ActionBlocksRemove::trigger()
                containerList.append(graphic);
                RS_BlockList * blkLst = graphic->getBlockList();
 
-               for(uint bi=0; bi<blkLst->count(); bi++)
+               for (uint bi = 0; bi < blkLst->count(); bi++)
                        containerList.append(blkLst->at(bi));
 
                if (block != NULL)
                {
 //                     for (RS_EntityContainer * cont=containerList.first(); cont!=NULL;
 //                             cont=containerList.next())
-                       for(int i=0; i<containerList.size(); i++)
+                       for (int i = 0; i < containerList.size(); i++)
                        {
                                RS_EntityContainer * cont = containerList[i];
                                // remove all inserts from the graphic:
@@ -78,9 +60,8 @@ void RS_ActionBlocksRemove::trigger()
                                {
                                        done = true;
 
-                                       for (RS_Entity* e=cont->firstEntity(RS2::ResolveNone); e!=NULL;
-                                               e=cont->nextEntity(RS2::ResolveNone))
-                                       {
+                                       for (RS_Entity * e = cont->firstEntity(RS2::ResolveNone); e != NULL;
+                                            e = cont->nextEntity(RS2::ResolveNone))
                                                if (e->rtti() == RS2::EntityInsert)
                                                {
                                                        RS_Insert * ins = (RS_Insert *)e;
@@ -92,7 +73,6 @@ void RS_ActionBlocksRemove::trigger()
                                                                break;
                                                        }
                                                }
-                                       }
                                }
                                while (!done);
                        }
@@ -117,3 +97,4 @@ void RS_ActionBlocksRemove::init(int status)
        RS_ActionInterface::init(status);
        trigger();
 }
+
index 1400d887c7f8ca2d2f8696ed5382ec0ab42725e2..4ad441ebc44de40da9cdeb41d13ebfe9406bc047 100644 (file)
@@ -1,29 +1,3 @@
-/****************************************************************************
-** $Id: rs_actionblocksremove.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONBLOCKSREMOVE_H
 #define RS_ACTIONBLOCKSREMOVE_H
 
  */
 class RS_ActionBlocksRemove: public RS_ActionInterface
 {
-//     //Q_OBJECT
        public:
                RS_ActionBlocksRemove(RS_EntityContainer & container, RS_GraphicView & graphicView);
-               ~RS_ActionBlocksRemove() {}
-
-               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
+               ~RS_ActionBlocksRemove();
 
                virtual void init(int status = 0);
                virtual void trigger();
index 66fd128c7201880eb458b85c1ab115d710358855..f596ceb31f30b2e09285def4e6d2c66332087b17 100644 (file)
@@ -1,69 +1,48 @@
-/****************************************************************************
-** $Id: rs_actionblockstoggleview.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionblockstoggleview.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actionblockstoggleview.h"
 
 #include "drawing.h"
+#include "rs_graphicview.h"
 
-
-
-RS_ActionBlocksToggleView::RS_ActionBlocksToggleView(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Toggle Block Visibility",
-                    container, graphicView) {}
-
-
-QAction * RS_ActionBlocksToggleView::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionBlocksToggleView::RS_ActionBlocksToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Toggle Block Visibility",
+               container, graphicView)
 {
-    QAction * action = new QAction(tr("&Toggle Block"), 0);
-//        QAction* action = new QAction(tr("Toggle Block Visibility"),
-//                             tr("&Toggle Block"),
-//                             QKeySequence(), NULL);
-    action->setStatusTip(tr("Toggle Block"));
+}
 
-       return action;
+RS_ActionBlocksToggleView::~RS_ActionBlocksToggleView()
+{
 }
 
+void RS_ActionBlocksToggleView::trigger()
+{
+       RS_DEBUG->print("toggle block");
+
+       if (graphic != NULL)
+       {
+               RS_Block * block = graphic->getActiveBlock();
+               graphic->toggleBlock(block);
+       }
 
-void RS_ActionBlocksToggleView::trigger() {
-    RS_DEBUG->print("toggle block");
-    if (graphic!=NULL) {
-        RS_Block* block = graphic->getActiveBlock();
-        graphic->toggleBlock(block);
-    }
        graphicView->redraw();
-    finish();
+       finish();
 }
 
-
-
-void RS_ActionBlocksToggleView::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionBlocksToggleView::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index 1a69d67ecf3466a247daf85b43984c5110ac1694..9009d346d3b971460061d509ce230a9cbfabe327 100644 (file)
@@ -1,52 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionblockstoggleview.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONBLOCKSTOGGLEVIEW_H
 #define RS_ACTIONBLOCKSTOGGLEVIEW_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to edit layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionBlocksToggleView : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionBlocksToggleView(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionBlocksToggleView() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
+class RS_ActionBlocksToggleView: public RS_ActionInterface
+{
+       public:
+               RS_ActionBlocksToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionBlocksToggleView();
 
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 62aa5a3095eed4c06509c28e10ed866171b5fbb0..9159eee0eb2b27da4ae0ff6f4e385124c8818d55 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondefault.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondefault.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondefault.h"
 
 #include "rs.h"
+#include "rs_dialogfactory.h"
+#include "rs_line.h"
 #include "rs_modification.h"
+#include "rs_preview.h"
 #include "rs_snapper.h"
 #include "rs_selection.h"
 
-
-
 /**
  * Constructor.
  */
-RS_ActionDefault::RS_ActionDefault(RS_EntityContainer& container,
-                                   RS_GraphicView& graphicView)
-        : RS_PreviewActionInterface("Default",
-                            container, graphicView) {
-
+RS_ActionDefault::RS_ActionDefault(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Default",
+               container, graphicView)
+{
        RS_DEBUG->print("RS_ActionDefault::RS_ActionDefault");
        RS_DEBUG->print("RS_ActionDefault::RS_ActionDefault: OK");
 }
 
-
-
-RS_ActionDefault::~RS_ActionDefault() {
+RS_ActionDefault::~RS_ActionDefault()
+{
 }
 
-
-
-QAction* RS_ActionDefault::createGUIAction(RS2::ActionType /*type*/, 
-       QObject* /*parent*/) {
-
-       return NULL;
-}
-
-
-void RS_ActionDefault::init(int status) {
+void RS_ActionDefault::init(int status)
+{
        RS_DEBUG->print("RS_ActionDefault::init");
-    
+
        RS_PreviewActionInterface::init(status);
-    v1 = v2 = Vector(false);
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
-    restrBak = RS2::RestrictNothing;
+       v1 = v2 = Vector(false);
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
+       restrBak = RS2::RestrictNothing;
        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-       
+
        RS_DEBUG->print("RS_ActionDefault::init: OK");
 }
 
-
-
-void RS_ActionDefault::trigger() {
-    RS_PreviewActionInterface::trigger();
-
+void RS_ActionDefault::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 }
 
-void RS_ActionDefault::keyPressEvent(QKeyEvent* e) {
-       if (e->key()==Qt::Key_Shift) {
+void RS_ActionDefault::keyPressEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Shift)
+       {
                restrBak = snapRes;
                setSnapRestriction(RS2::RestrictOrthogonal);
        }
 }
 
-void RS_ActionDefault::keyReleaseEvent(QKeyEvent* e) {
-       if (e->key()==Qt::Key_Shift) {
+void RS_ActionDefault::keyReleaseEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Shift)
                setSnapRestriction(restrBak);
-       }
 }
 
+void RS_ActionDefault::mouseMoveEvent(QMouseEvent * e)
+{
+       Vector mouse = graphicView->toGraph(Vector(e->x(), e->y()));
+       Vector relMouse = mouse - graphicView->getRelativeZero();
 
-void RS_ActionDefault::mouseMoveEvent(QMouseEvent* e) {
-
-    Vector mouse = graphicView->toGraph(Vector(e->x(), e->y()));
-    Vector relMouse = mouse - graphicView->getRelativeZero();
+       RS_DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
 
-    RS_DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
+       switch (getStatus())
+       {
+       case Dragging:
+               //v2 = graphicView->toGraph(e->x(), e->y());
+               v2 = mouse;
 
-    switch (getStatus()) {
-    case Dragging:
-        //v2 = graphicView->toGraph(e->x(), e->y());
-        v2 = mouse;
+               if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
+               {
+                       // look for reference points to drag:
+                       double dist;
+                       Vector ref = container->getNearestSelectedRef(v1, &dist);
 
-        if (graphicView->toGuiDX(v1.distanceTo(v2))>10) {
-            // look for reference points to drag:
-            double dist;
-            Vector ref = container->getNearestSelectedRef(v1, &dist);
-            if (ref.valid==true && graphicView->toGuiDX(dist)<8) {
+                       if (ref.valid == true && graphicView->toGuiDX(dist) < 8)
+                       {
                                RS_DEBUG->print("RS_ActionDefault::mouseMoveEvent: "
                                        "moving reference point");
-                setStatus(MovingRef);
-                v1 = ref;
-                       graphicView->moveRelativeZero(v1);
-            } 
-                       else {
-                // test for an entity to drag:
-                RS_Entity* en = catchEntity(v1);
-                if (en!=NULL && en->isSelected()) {
+                               setStatus(MovingRef);
+                               v1 = ref;
+                               graphicView->moveRelativeZero(v1);
+                       }
+                       else
+                       {
+                               // test for an entity to drag:
+                               RS_Entity * en = catchEntity(v1);
+
+                               if (en != NULL && en->isSelected())
+                               {
                                        RS_DEBUG->print("RS_ActionDefault::mouseMoveEvent: "
                                                "moving entity");
-                    setStatus(Moving);
-                    v1 = en->getNearestRef(v1);
-                               graphicView->moveRelativeZero(v1);
-                }
-
-                // no entity found. start area selection:
-                else {
-                    setStatus(SetCorner2);
-                }
-            }
-        }
-        break;
-               
-    case MovingRef:
-        v2 = snapPoint(e);
-
-        deletePreview();
-        clearPreview();
-        preview->addSelectionFrom(*container);
-               preview->moveRef(v1, v2-v1);
-        drawPreview();
-        break;
-
-    case Moving:
-        v2 = snapPoint(e);
-
-        deletePreview();
-        clearPreview();
-        preview->addSelectionFrom(*container);
-        preview->move(v2-v1);
-        drawPreview();
-        break;
-
-    case SetCorner2:
-        if (v1.valid) {
-            //v2 = snapPoint(e);
-            v2 = mouse;
-
-            //deleteSnapper();
-            deletePreview();
-            clearPreview();
-
-            preview->addEntity(new RS_Line(preview,
-                                           RS_LineData(Vector(v1.x, v1.y),
-                                                       Vector(v2.x, v1.y))));
-            preview->addEntity(new RS_Line(preview,
-                                           RS_LineData(Vector(v2.x, v1.y),
-                                                       Vector(v2.x, v2.y))));
-            preview->addEntity(new RS_Line(preview,
-                                           RS_LineData(Vector(v2.x, v2.y),
-                                                       Vector(v1.x, v2.y))));
-            preview->addEntity(new RS_Line(preview,
-                                           RS_LineData(Vector(v1.x, v2.y),
-                                                       Vector(v1.x, v1.y))));
-            drawPreview();
-        }
-
-    default:
-        break;
-    }
-}
-
-
-
-void RS_ActionDefault::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case Neutral:
-            v1 = graphicView->toGraph(e->x(), e->y());
-            setStatus(Dragging);
-            break;
-
-        case Moving: {
-                       v2 = snapPoint(e);
-                deleteSnapper();
-                deletePreview();
-                clearPreview();
-                RS_Modification m(*container, graphicView);
-                RS_MoveData data;
-                data.number = 0;
-                data.useCurrentLayer = false;
-                data.useCurrentAttributes = false;
-                data.offset = v2-v1;
-                m.move(data);
-                setStatus(Neutral);
-                RS_DIALOGFACTORY->updateSelectionWidget(
-                        container->countSelected());
-                               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-            }
-            break;
-                       
-        case MovingRef: {
-                       v2 = snapPoint(e);
-                deleteSnapper();
-                deletePreview();
-                clearPreview();
-                RS_Modification m(*container, graphicView);
-                RS_MoveRefData data;
-                               data.ref = v1;
-                               data.offset = v2-v1;
-                m.moveRef(data);
-                               //container->moveSelectedRef(v1, v2-v2);
-                setStatus(Neutral);
-                RS_DIALOGFACTORY->updateSelectionWidget(
-                        container->countSelected());
-                               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-            }
-            break;
-
-        default:
-            break;
-        }
-    }
-}
-
+                                       setStatus(Moving);
+                                       v1 = en->getNearestRef(v1);
+                                       graphicView->moveRelativeZero(v1);
+                               }
+                               // no entity found. start area selection:
+                               else
+                                       setStatus(SetCorner2);
+                       }
+               }
+               break;
 
+       case MovingRef:
+               v2 = snapPoint(e);
 
-void RS_ActionDefault::mouseReleaseEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDefault::mouseReleaseEvent()");
+               deletePreview();
+               clearPreview();
+               preview->addSelectionFrom(*container);
+               preview->moveRef(v1, v2 - v1);
+               drawPreview();
+               break;
 
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        v2 = graphicView->toGraph(e->x(), e->y());
-        switch (getStatus()) {
-        case Dragging: {
-                // select single entity:
-                RS_Entity* en = catchEntity(e);
+       case Moving:
+               v2 = snapPoint(e);
 
-                if (en!=NULL) {
-                    deleteSnapper();
-                    deletePreview();
-                    clearPreview();
+               deletePreview();
+               clearPreview();
+               preview->addSelectionFrom(*container);
+               preview->move(v2 - v1);
+               drawPreview();
+               break;
 
-                    RS_Selection s(*container, graphicView);
-                    s.selectSingle(en);
+       case SetCorner2:
+
+               if (v1.valid)
+               {
+                       //v2 = snapPoint(e);
+                       v2 = mouse;
+
+                       //deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+
+                       preview->addEntity(new RS_Line(preview,
+                                       RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
+                       preview->addEntity(new RS_Line(preview,
+                                       RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
+                       preview->addEntity(new RS_Line(preview,
+                                       RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
+                       preview->addEntity(new RS_Line(preview,
+                                       RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
+                       drawPreview();
+               }
 
-                    RS_DIALOGFACTORY->updateSelectionWidget(
-                        container->countSelected());
+       default:
+               break;
+       }
+}
 
-                    //deleteSnapper();
-#if QT_VERSION>=0x030000
-                    e->accept();
-#endif
+void RS_ActionDefault::mousePressEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case Neutral:
+                       v1 = graphicView->toGraph(e->x(), e->y());
+                       setStatus(Dragging);
+                       break;
 
-                    setStatus(Neutral);
-                } else {
-                    setStatus(SetCorner2);
-                }
-            }
-            break;
+               case Moving:
+               {
+                       v2 = snapPoint(e);
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       RS_Modification m(*container, graphicView);
+                       RS_MoveData data;
+                       data.number = 0;
+                       data.useCurrentLayer = false;
+                       data.useCurrentAttributes = false;
+                       data.offset = v2 - v1;
+                       m.move(data);
+                       setStatus(Neutral);
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+               }
+               break;
 
-        case SetCorner2: {
-                //v2 = snapPoint(e);
-                v2 = graphicView->toGraph(e->x(), e->y());
+               case MovingRef:
+               {
+                       v2 = snapPoint(e);
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       RS_Modification m(*container, graphicView);
+                       RS_MoveRefData data;
+                       data.ref = v1;
+                       data.offset = v2 - v1;
+                       m.moveRef(data);
+                       //container->moveSelectedRef(v1, v2-v2);
+                       setStatus(Neutral);
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+               }
+               break;
 
-                // select window:
-                //if (graphicView->toGuiDX(v1.distanceTo(v2))>20) {
-                deleteSnapper();
-                deletePreview();
-                clearPreview();
+               default:
+                       break;
+               }
+       }
+}
 
-                bool cross = (v2.y>v1.y);
-                RS_Selection s(*container, graphicView);
-                s.selectWindow(v1, v2, true, cross);
+void RS_ActionDefault::mouseReleaseEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDefault::mouseReleaseEvent()");
+
+       if (e->button() == Qt::LeftButton)
+       {
+               v2 = graphicView->toGraph(e->x(), e->y());
+
+               switch (getStatus())
+               {
+               case Dragging:
+               {
+                       // select single entity:
+                       RS_Entity * en = catchEntity(e);
+
+                       if (en != NULL)
+                       {
+                               deleteSnapper();
+                               deletePreview();
+                               clearPreview();
+
+                               RS_Selection s(*container, graphicView);
+                               s.selectSingle(en);
+
+                               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+
+                               //deleteSnapper();
+                               e->accept();
+                               setStatus(Neutral);
+                       }
+                       else
+                               setStatus(SetCorner2);
+               }
+               break;
 
-                RS_DIALOGFACTORY->updateSelectionWidget(
-                    container->countSelected());
+               case SetCorner2:
+               {
+                       //v2 = snapPoint(e);
+                       v2 = graphicView->toGraph(e->x(), e->y());
 
-                setStatus(Neutral);
-#if QT_VERSION>=0x030000
+                       // select window:
+                       //if (graphicView->toGuiDX(v1.distanceTo(v2))>20) {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
 
-                e->accept();
-#endif
-                //}
-            }
-            break;
+                       bool cross = (v2.y > v1.y);
+                       RS_Selection s(*container, graphicView);
+                       s.selectWindow(v1, v2, true, cross);
 
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 
-        default:
-            break;
+                       setStatus(Neutral);
+                       e->accept();
+                       //}
+               }
+               break;
 
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        switch (getStatus()) {
+               default:
+                       break;
+               }
+       }
+       else if (e->button() == Qt::RightButton)
+       {
+               switch (getStatus())
+               {
                case SetCorner2:
                case Moving:
                case MovingRef:
-            deletePreview();
-            clearPreview();
-            deleteSnapper();
-            setStatus(Neutral);
+                       deletePreview();
+                       clearPreview();
+                       deleteSnapper();
+                       setStatus(Neutral);
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-#if QT_VERSION>=0x030000
-
-            e->accept();
-#endif
+                       e->accept();
                        break;
 
                default:
-            deleteSnapper();
-            RS_DIALOGFACTORY->requestPreviousMenu();
-#if QT_VERSION>=0x030000
-
-            e->accept();
-#endif
+                       deleteSnapper();
+                       RS_DIALOGFACTORY->requestPreviousMenu();
+                       e->accept();
                        break;
                }
-    }
+       }
 }
 
-
-
-void RS_ActionDefault::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    // if the current action can't deal with the command,
-    //   it might be intended to launch a new command
-    //if (!e.isAccepted()) {
-    // command for new action:
-    //RS2::ActionType type = RS_COMMANDS->cmdToAction(c);
-    //if (type!=RS2::ActionNone) {
-    //graphicView->setCurrentAction(type);
-    //return true;
-    //}
-    //}
+void RS_ActionDefault::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       // if the current action can't deal with the command,
+       //   it might be intended to launch a new command
+       //if (!e.isAccepted()) {
+       // command for new action:
+       //RS2::ActionType type = RS_COMMANDS->cmdToAction(c);
+       //if (type!=RS2::ActionNone) {
+       //graphicView->setCurrentAction(type);
+       //return true;
+       //}
+       //}
 }
 
+QStringList RS_ActionDefault::getAvailableCommands()
+{
+       QStringList cmd;
 
+       //cmd += "line";
+       //cmd += "rectangle";
 
-QStringList RS_ActionDefault::getAvailableCommands() {
-    QStringList cmd;
-
-    //cmd += "line";
-    //cmd += "rectangle";
-
-    return cmd;
+       return cmd;
 }
 
+void RS_ActionDefault::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case Neutral:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
 
-void RS_ActionDefault::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case Neutral:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    case SetCorner2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
-}
-
+       case SetCorner2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"), tr("Back"));
+               break;
 
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
+}
 
-void RS_ActionDefault::updateMouseCursor() {
-       switch (getStatus()) {
+void RS_ActionDefault::updateMouseCursor()
+{
+       switch (getStatus())
+       {
        case Neutral:
-       graphicView->setMouseCursor(RS2::ArrowCursor);
+               graphicView->setMouseCursor(RS2::ArrowCursor);
                break;
+
        case Moving:
        case MovingRef:
-       graphicView->setMouseCursor(RS2::SelectCursor);
+               graphicView->setMouseCursor(RS2::SelectCursor);
                break;
+
        default:
                break;
        }
 }
 
-
-
-void RS_ActionDefault::updateToolBar() {
-    //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-       switch (getStatus()) {
+void RS_ActionDefault::updateToolBar()
+{
+       //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+       switch (getStatus())
+       {
        case Neutral:
                // would switch back to main in edit / measure / .. modes
                //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
                break;
+
        case Moving:
        case MovingRef:
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
                break;
+
        default:
                break;
        }
 }
 
-// EOF
index 6c505ab9ea962e32a0fdae9d7adbe93b58be4e88..53e56ab8a407fd055227463eeb67a4c15d21409d 100644 (file)
@@ -1,91 +1,64 @@
-/****************************************************************************
-** $Id: rs_actiondefault.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECTWINDOW_H
 #define RS_ACTIONSELECTWINDOW_H
 
 #include "rs_previewactioninterface.h"
 #include "vector.h"
 
-
 /**
  * This action class can handle user events to select all entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDefault : public RS_PreviewActionInterface {
-    //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        Neutral,        /**< we don't know what we do yet.  */
-        Dragging,       /**< dragging (either an entity or the
-                                            first part of a selection window) */
-        SetCorner2,     /**< Setting the 2nd corner of a selection window. */
-        Moving,         /**< Moving entities (drag'n'drop) */
-        MovingRef       /**< Moving a reference point of one or more selected
-                                            entities */
-    };
+class RS_ActionDefault: public RS_PreviewActionInterface
+{
+       //Q_OBJECT
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       Neutral, /**< we don't know what we do yet.  */
+                       Dragging, /**< dragging (either an entity or the
+                                            first part of a selection window) */
+                       SetCorner2, /**< Setting the 2nd corner of a selection window. */
+                       Moving, /**< Moving entities (drag'n'drop) */
+                       MovingRef /**< Moving a reference point of one or more selected
+                                            entities */
+               };
 
-public:
-    RS_ActionDefault(RS_EntityContainer& container,
-                     RS_GraphicView& graphicView);
-    virtual ~RS_ActionDefault();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+       public:
+               RS_ActionDefault(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               virtual ~RS_ActionDefault();
 
-    virtual RS2::ActionType rtti() {
-        return RS2::ActionDefault;
-    }
+               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
 
-    virtual void init(int status=0);
+               virtual RS2::ActionType rtti()
+               {
+                       return RS2::ActionDefault;
+               }
 
-    virtual void trigger();
+               virtual void init(int status = 0);
 
-    virtual void keyPressEvent(QKeyEvent* e);
-    virtual void keyReleaseEvent(QKeyEvent* e);
+               virtual void trigger();
 
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
+               virtual void keyPressEvent(QKeyEvent * e);
+               virtual void keyReleaseEvent(QKeyEvent * e);
 
-    virtual void commandEvent(RS_CommandEvent* e);
-    virtual QStringList getAvailableCommands();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
 
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
 
-protected:
-    Vector v1;
-    Vector v2;
-       RS2::SnapRestriction restrBak;
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
 
+       protected:
+               Vector v1;
+               Vector v2;
+               RS2::SnapRestriction restrBak;
 };
 
 #endif
index 63ee67b0c700e15b6ea53ad9f38c2877e4e3e605..90401f4541d3949b78f53f84e93d2477d4096863 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondimaligned.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondimaligned.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondimaligned.h"
 
-#include "rs_snapper.h"
 #include "rs_constructionline.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
+#include "rs_snapper.h"
 
-
-
-RS_ActionDimAligned::RS_ActionDimAligned(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionDimension("Draw aligned dimensions",
-                    container, graphicView)
+RS_ActionDimAligned::RS_ActionDimAligned(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw aligned dimensions",
+               container, graphicView)
 {
-    reset();
+       reset();
 }
 
 RS_ActionDimAligned::~RS_ActionDimAligned()
 {
 }
 
-QAction * RS_ActionDimAligned::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionDimAligned::rtti()
 {
-       QAction * action = new QAction(tr("&Aligned"), 0);
-//        QAction* action = new QAction(tr("Aligned"), tr("&Aligned"),
-//                             QKeySequence(), NULL);
-       action->setStatusTip(tr("Aligned Dimension"));
-
-       return action;
+       return RS2::ActionDimAligned;
 }
 
-
 void RS_ActionDimAligned::reset()
 {
-    RS_ActionDimension::reset();
-    edata = RS_DimAlignedData(Vector(false), Vector(false));
-    lastStatus = SetExtPoint1;
+       RS_ActionDimension::reset();
+       edata = RS_DimAlignedData(Vector(false), Vector(false));
+       lastStatus = SetExtPoint1;
 
        if (RS_DIALOGFACTORY != NULL)
-        RS_DIALOGFACTORY->requestOptions(this, true, true);
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
-
-
 void RS_ActionDimAligned::trigger()
 {
-    RS_ActionDimension::trigger();
-
-    preparePreview();
-    graphicView->moveRelativeZero(data.definitionPoint);
+       RS_ActionDimension::trigger();
+       preparePreview();
+       graphicView->moveRelativeZero(data.definitionPoint);
 
        //data.text = getText();
-    RS_DimAligned* dim =
-        new RS_DimAligned(container, data, edata);
-    dim->setLayerToActive();
-    dim->setPenToActive();
-    dim->update();
-    container->addEntity(dim);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(dim);
-        document->endUndoCycle();
-    }
-
-    deleteSnapper();
-    Vector rz = graphicView->getRelativeZero();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(dim);
-    graphicView->moveRelativeZero(rz);
-    drawSnapper();
-
-    RS_DEBUG->print("RS_ActionDimAligned::trigger():"
-                    " dim added: %d", dim->getId());
+       RS_DimAligned * dim = new RS_DimAligned(container, data, edata);
+       dim->setLayerToActive();
+       dim->setPenToActive();
+       dim->update();
+       container->addEntity(dim);
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(dim);
+               document->endUndoCycle();
+       }
+
+       deleteSnapper();
+       Vector rz = graphicView->getRelativeZero();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(dim);
+       graphicView->moveRelativeZero(rz);
+       drawSnapper();
+
+       RS_DEBUG->print("RS_ActionDimAligned::trigger(): dim added: %d", dim->getId());
 }
 
-
-
-void RS_ActionDimAligned::preparePreview() {
-    Vector dirV;
-    dirV.setPolar(100.0,
-                  edata.extensionPoint1.angleTo(
-                      edata.extensionPoint2)
-                  +M_PI/2.0);
-    RS_ConstructionLine cl(NULL,
-                           RS_ConstructionLineData(
-                               edata.extensionPoint2,
-                               edata.extensionPoint2+dirV));
-
-    data.definitionPoint =
-        cl.getNearestPointOnEntity(data.definitionPoint);
+void RS_ActionDimAligned::preparePreview()
+{
+       Vector dirV;
+       dirV.setPolar(100.0, edata.extensionPoint1.angleTo(edata.extensionPoint2) + M_PI / 2.0);
+       RS_ConstructionLine cl(NULL, RS_ConstructionLineData(edata.extensionPoint2,
+                       edata.extensionPoint2 + dirV));
+       data.definitionPoint = cl.getNearestPointOnEntity(data.definitionPoint);
 }
 
+void RS_ActionDimAligned::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDimAligned::mouseMoveEvent begin");
+       Vector mouse = snapPoint(e);
 
+       switch (getStatus())
+       {
+       case SetExtPoint1:
+               break;
 
-void RS_ActionDimAligned::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDimAligned::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
+       case SetExtPoint2:
 
-    switch (getStatus()) {
-    case SetExtPoint1:
-        break;
+               if (edata.extensionPoint1.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(new RS_Line(preview,
+                                       RS_LineData(edata.extensionPoint1, mouse)));
+                       drawPreview();
+               }
+               break;
 
-    case SetExtPoint2:
-        if (edata.extensionPoint1.valid) {
-            deletePreview();
-            clearPreview();
-            preview->addEntity(
-                new RS_Line(preview,
-                            RS_LineData(edata.extensionPoint1, mouse))
-            );
-            drawPreview();
-        }
-        break;
+       case SetDefPoint:
 
-    case SetDefPoint:
-        if (edata.extensionPoint1.valid && edata.extensionPoint2.valid) {
-            deletePreview();
-            clearPreview();
-            data.definitionPoint = mouse;
+               if (edata.extensionPoint1.valid && edata.extensionPoint2.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       data.definitionPoint = mouse;
 
-            preparePreview();
+                       preparePreview();
 
                        //data.text = getText();
-            RS_DimAligned* dim = new RS_DimAligned(preview, data, edata);
-            dim->update();
-            preview->addEntity(dim);
-            drawPreview();
-        }
-        break;
+                       RS_DimAligned * dim = new RS_DimAligned(preview, data, edata);
+                       dim->update();
+                       preview->addEntity(dim);
+                       drawPreview();
+               }
+               break;
 
        default:
                break;
-    }
+       }
 
-    RS_DEBUG->print("RS_ActionDimAligned::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDimAligned::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDimAligned::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDimAligned::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionDimAligned::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
+       Vector pos = *e; //->getCoordinate();
 
-void RS_ActionDimAligned::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector pos = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetExtPoint1:
-        edata.extensionPoint1 = pos;
-        graphicView->moveRelativeZero(pos);
-        setStatus(SetExtPoint2);
-        break;
+       switch (getStatus())
+       {
+       case SetExtPoint1:
+               edata.extensionPoint1 = pos;
+               graphicView->moveRelativeZero(pos);
+               setStatus(SetExtPoint2);
+               break;
 
-    case SetExtPoint2:
-        edata.extensionPoint2 = pos;
-        graphicView->moveRelativeZero(pos);
-        setStatus(SetDefPoint);
-        break;
+       case SetExtPoint2:
+               edata.extensionPoint2 = pos;
+               graphicView->moveRelativeZero(pos);
+               setStatus(SetDefPoint);
+               break;
 
-    case SetDefPoint:
-        data.definitionPoint = pos;
-        trigger();
-        reset();
-        setStatus(SetExtPoint1);
-        break;
+       case SetDefPoint:
+               data.definitionPoint = pos;
+               trigger();
+               reset();
+               setStatus(SetExtPoint1);
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+void RS_ActionDimAligned::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
 
-void RS_ActionDimAligned::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetText: {
-            setText(c);
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(lastStatus);
-            graphicView->enableCoordinateInput();
-        }
-        break;
-
-    default:
-        if (checkCommand("text", c)) {
-            lastStatus = (Status)getStatus();
-            graphicView->disableCoordinateInput();
-            setStatus(SetText);
-        }
-        break;
-    }
-}
-
+               return;
+       }
 
+       switch (getStatus())
+       {
+       case SetText:
+               setText(c);
 
-QStringList RS_ActionDimAligned::getAvailableCommands() {
-    QStringList cmd;
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
 
-    switch (getStatus()) {
-    case SetExtPoint1:
-    case SetExtPoint2:
-    case SetDefPoint:
-        cmd += command("text");
-        break;
+               setStatus(lastStatus);
+               graphicView->enableCoordinateInput();
+               break;
 
-    default:
-        break;
-    }
+       default:
 
-    return cmd;
+               if (checkCommand("text", c))
+               {
+                       lastStatus = (Status)getStatus();
+                       graphicView->disableCoordinateInput();
+                       setStatus(SetText);
+               }
+               break;
+       }
 }
 
+QStringList RS_ActionDimAligned::getAvailableCommands()
+{
+       QStringList cmd;
+
+       switch (getStatus())
+       {
+       case SetExtPoint1:
+       case SetExtPoint2:
+       case SetDefPoint:
+               cmd += command("text");
+               break;
 
+       default:
+               break;
+       }
 
-void RS_ActionDimAligned::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetExtPoint1:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify first extension line origin"),
-                tr("Cancel"));
-            break;
-        case SetExtPoint2:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify second extension line origin"),
-                tr("Back"));
-            break;
-        case SetDefPoint:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify dimension line location"),
-                tr("Back"));
-            break;
-        case SetText:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+       return cmd;
 }
 
-
-
-void RS_ActionDimAligned::hideOptions() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
-
-    RS_ActionDimension::hideOptions();
+void RS_ActionDimAligned::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetExtPoint1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first extension line origin"), tr("Cancel"));
+                       break;
+
+               case SetExtPoint2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second extension line origin"), tr("Back"));
+                       break;
+
+               case SetDefPoint:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify dimension line location"), tr("Back"));
+                       break;
+
+               case SetText:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
+void RS_ActionDimAligned::hideOptions()
+{
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 
+       RS_ActionDimension::hideOptions();
+}
 
-void RS_ActionDimAligned::showOptions() {
-    RS_ActionDimension::showOptions();
+void RS_ActionDimAligned::showOptions()
+{
+       RS_ActionDimension::showOptions();
 
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
-
-// EOF
index 4936143184899e4d81742f57a5679708ae09d402..8e6b958ae9e01972511fb165821aea93200ba4bb 100644 (file)
@@ -1,29 +1,3 @@
-/****************************************************************************
-** $Id: rs_actiondimaligned.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMALIGNED_H
 #define RS_ACTIONDIMALIGNED_H
 
 #include "rs_dimaligned.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * aligned dimensions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDimAligned : public RS_ActionDimension {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetExtPoint1,    /**< Setting the 1st ext point.  */
-        SetExtPoint2,    /**< Setting the 2nd ext point. */
-        SetDefPoint,     /**< Setting the common def point */
-               SetText          /**< Setting the text label in command line */
-    };
-
-public:
-    RS_ActionDimAligned(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionDimAligned();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDimAligned;
-       }
-
-    virtual void reset();
-
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-
-protected:
-    /**
-     * Aligned dimension data.
-     */
-    RS_DimAlignedData edata;
-
-       /** Last status before entering text. */
-       Status lastStatus;
-}
-;
+class RS_ActionDimAligned: public RS_ActionDimension
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetExtPoint1,    /**< Setting the 1st ext point.  */
+                       SetExtPoint2,    /**< Setting the 2nd ext point. */
+                       SetDefPoint,     /**< Setting the common def point */
+                       SetText          /**< Setting the text label in command line */
+               };
+
+       public:
+               RS_ActionDimAligned(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDimAligned();
+
+               virtual RS2::ActionType rtti();
+               virtual void reset();
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+
+       protected:
+               /**
+                * Aligned dimension data.
+                */
+               RS_DimAlignedData edata;
+
+               /** Last status before entering text. */
+               Status lastStatus;
+};
 
 #endif
index 57c16b44d0e9c918882f1c6cae15df53bde47228..31bb89e34b42eae7d700eff4fcd0a4ef00cb82b1 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondimangular.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondimangular.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondimangular.h"
 
-#include "rs_creation.h"
-#include "rs_information.h"
-#include "rs_snapper.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_information.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDimAngular::RS_ActionDimAngular(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionDimension("Draw Angular Dimensions",
-                    container, graphicView) {
-    reset();
+RS_ActionDimAngular::RS_ActionDimAngular(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw Angular Dimensions",
+               container, graphicView)
+{
+       reset();
 }
 
-QAction * RS_ActionDimAngular::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDimAngular::~RS_ActionDimAngular()
 {
-       QAction * action = new QAction(tr("&Angular"), 0);
-//    QAction* action = new QAction(tr("Angular"), tr("&Angular"),
-//                                  QKeySequence(), NULL);
-       action->setStatusTip(tr("Angular Dimension"));
-
-       return action;
 }
 
-
-void RS_ActionDimAngular::reset() {
-    RS_ActionDimension::reset();
-
-    edata = RS_DimAngularData(Vector(false),
-                              Vector(false),
-                              Vector(false),
-                              Vector(false));
-    line1 = NULL;
-    line2 = NULL;
-    center = Vector(false);
-    RS_DIALOGFACTORY->requestOptions(this, true, true);
+/*virtual*/ RS2::ActionType RS_ActionDimAngular::rtti()
+{
+       return RS2::ActionDimAngular;
 }
 
-
-
-void RS_ActionDimAngular::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    if (line1!=NULL && line2!=NULL) {
-        RS_DimAngular* newEntity = NULL;
-
-        newEntity = new RS_DimAngular(container,
-                                      data,
-                                      edata);
-
-        newEntity->setLayerToActive();
-        newEntity->setPenToActive();
-        newEntity->update();
-        container->addEntity(newEntity);
-
-        // upd. undo list:
-        if (document!=NULL) {
-            document->startUndoCycle();
-            document->addUndoable(newEntity);
-            document->endUndoCycle();
-        }
-        deleteSnapper();
-        Vector rz = graphicView->getRelativeZero();
-        graphicView->moveRelativeZero(Vector(0.0,0.0));
-        graphicView->drawEntity(newEntity);
-        graphicView->moveRelativeZero(rz);
-
-    } else {
-        RS_DEBUG->print("RS_ActionDimAngular::trigger:"
-                        " Entity is NULL\n");
-    }
+void RS_ActionDimAngular::reset()
+{
+       RS_ActionDimension::reset();
+       edata = RS_DimAngularData(Vector(false), Vector(false), Vector(false), Vector(false));
+       line1 = NULL;
+       line2 = NULL;
+       center = Vector(false);
+       RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
+void RS_ActionDimAngular::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       if (line1 != NULL && line2 != NULL)
+       {
+               RS_DimAngular * newEntity = NULL;
+
+               newEntity = new RS_DimAngular(container,
+                               data,
+                               edata);
+
+               newEntity->setLayerToActive();
+               newEntity->setPenToActive();
+               newEntity->update();
+               container->addEntity(newEntity);
+
+               // upd. undo list:
+               if (document != NULL)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(newEntity);
+                       document->endUndoCycle();
+               }
+               deleteSnapper();
+               Vector rz = graphicView->getRelativeZero();
+               graphicView->moveRelativeZero(Vector(0.0, 0.0));
+               graphicView->drawEntity(newEntity);
+               graphicView->moveRelativeZero(rz);
+       }
+       else
+               RS_DEBUG->print("RS_ActionDimAngular::trigger:"
+                       " Entity is NULL\n");
+}
 
+void RS_ActionDimAngular::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDimAngular::mouseMoveEvent begin");
 
-void RS_ActionDimAngular::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDimAngular::mouseMoveEvent begin");
+       Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
 
-    Vector mouse(graphicView->toGraphX(e->x()),
-                    graphicView->toGraphY(e->y()));
+       switch (getStatus())
+       {
+       case SetLine1:
+               break;
 
-    switch (getStatus()) {
-    case SetLine1:
-        break;
+       case SetLine2:
+               break;
 
-    case SetLine2:
-        break;
+       case SetPos:
 
-    case SetPos:
-        if (line1!=NULL && line2!=NULL && center.valid) {
-            Vector mouse = snapPoint(e);
-            edata.definitionPoint4 = mouse;
+               if (line1 != NULL && line2 != NULL && center.valid)
+               {
+                       Vector mouse = snapPoint(e);
+                       edata.definitionPoint4 = mouse;
 
-            RS_DimAngular* d = new RS_DimAngular(preview, data, edata);
-            d->update();
+                       RS_DimAngular * d = new RS_DimAngular(preview, data, edata);
+                       d->update();
 
-            deletePreview();
-            clearPreview();
-            preview->addEntity(d);
-            drawPreview();
-        }
-        break;
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(d);
+                       drawPreview();
+               }
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionDimAngular::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDimAngular::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDimAngular::mouseReleaseEvent(QMouseEvent* e) {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetLine1: {
-                RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-                if (en!=NULL &&
-                        en->rtti()==RS2::EntityLine) {
-                    line1 = (RS_Line*)en;
-                    setStatus(SetLine2);
-                }
-            }
-            break;
-
-        case SetLine2: {
-                RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-                if (en!=NULL &&
-                        en->rtti()==RS2::EntityLine) {
-                    line2 = (RS_Line*)en;
-
-                    VectorSolutions sol =
-                        RS_Information::getIntersectionLineLine(line1, line2);
-
-                    if (sol.get(0).valid) {
-                        center = sol.get(0);
-
-                        if (center.distanceTo(line1->getStartpoint()) <
-                                center.distanceTo(line1->getEndpoint())) {
-                            edata.definitionPoint1 = line1->getStartpoint();
-                            edata.definitionPoint2 = line1->getEndpoint();
-                        } else {
-                            edata.definitionPoint1 = line1->getEndpoint();
-                            edata.definitionPoint2 = line1->getStartpoint();
-                        }
-
-                        if (center.distanceTo(line2->getStartpoint()) <
-                                center.distanceTo(line2->getEndpoint())) {
-                            edata.definitionPoint3 = line2->getStartpoint();
-                            data.definitionPoint = line2->getEndpoint();
-                        } else {
-                            edata.definitionPoint3 = line2->getEndpoint();
-                            data.definitionPoint = line2->getStartpoint();
-                        }
-                        graphicView->moveRelativeZero(center);
-                        setStatus(SetPos);
-                    }
-                }
-            }
-            break;
-
-        case SetPos: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        clearPreview();
-        init(getStatus()-1);
-    }
-
+void RS_ActionDimAngular::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetLine1: {
+                       RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+                       if (en != NULL
+                           && en->rtti() == RS2::EntityLine)
+                       {
+                               line1 = (RS_Line *)en;
+                               setStatus(SetLine2);
+                       }
+               }
+               break;
+
+               case SetLine2: {
+                       RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+                       if (en != NULL
+                           && en->rtti() == RS2::EntityLine)
+                       {
+                               line2 = (RS_Line *)en;
+
+                               VectorSolutions sol =
+                                       RS_Information::getIntersectionLineLine(line1, line2);
+
+                               if (sol.get(0).valid)
+                               {
+                                       center = sol.get(0);
+
+                                       if (center.distanceTo(line1->getStartpoint())
+                                           < center.distanceTo(line1->getEndpoint()))
+                                       {
+                                               edata.definitionPoint1 = line1->getStartpoint();
+                                               edata.definitionPoint2 = line1->getEndpoint();
+                                       }
+                                       else
+                                       {
+                                               edata.definitionPoint1 = line1->getEndpoint();
+                                               edata.definitionPoint2 = line1->getStartpoint();
+                                       }
+
+                                       if (center.distanceTo(line2->getStartpoint())
+                                           < center.distanceTo(line2->getEndpoint()))
+                                       {
+                                               edata.definitionPoint3 = line2->getStartpoint();
+                                               data.definitionPoint = line2->getEndpoint();
+                                       }
+                                       else
+                                       {
+                                               edata.definitionPoint3 = line2->getEndpoint();
+                                               data.definitionPoint = line2->getStartpoint();
+                                       }
+                                       graphicView->moveRelativeZero(center);
+                                       setStatus(SetPos);
+                               }
+                       }
+               }
+               break;
+
+               case SetPos: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               clearPreview();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDimAngular::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPos:
-        edata.definitionPoint4 = e->getCoordinate();
-        trigger();
-        reset();
-        setStatus(SetLine1);
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDimAngular::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       switch (getStatus())
+       {
+       case SetPos:
+               edata.definitionPoint4 = *e;
+               trigger();
+               reset();
+               setStatus(SetLine1);
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionDimAngular::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    // setting new text label:
-    if (getStatus()==SetText) {
-        setText(c);
-        RS_DIALOGFACTORY->requestOptions(this, true, true);
-        graphicView->enableCoordinateInput();
-        setStatus(lastStatus);
-        return;
-    }
-
-    // command: text
-    if (checkCommand("text", c)) {
-        lastStatus = (Status)getStatus();
-        graphicView->disableCoordinateInput();
-        setStatus(SetText);
-    }
+void RS_ActionDimAngular::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       // setting new text label:
+       if (getStatus() == SetText)
+       {
+               setText(c);
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               graphicView->enableCoordinateInput();
+               setStatus(lastStatus);
+               return;
+       }
+
+       // command: text
+       if (checkCommand("text", c))
+       {
+               lastStatus = (Status)getStatus();
+               graphicView->disableCoordinateInput();
+               setStatus(SetText);
+       }
 }
 
+QStringList RS_ActionDimAngular::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetLine1:
+       case SetLine2:
+       case SetPos:
+               cmd += command("text");
+               break;
 
-QStringList RS_ActionDimAngular::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetLine1:
-    case SetLine2:
-    case SetPos:
-        cmd += command("text");
-        break;
-
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
+void RS_ActionDimAngular::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDimAngular::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDimAngular::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDimAngular::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionDimAngular::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetLine1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"),
-                                            tr("Cancel"));
-        break;
-    case SetLine2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"),
-                                            tr("Cancel"));
-        break;
-    case SetPos:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify dimension arc line location"), tr("Cancel"));
-        break;
-    case SetText:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDimAngular::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetLine1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"),
+                       tr("Cancel"));
+               break;
+
+       case SetLine2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"),
+                       tr("Cancel"));
+               break;
+
+       case SetPos:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify dimension arc line location"), tr("Cancel"));
+               break;
+
+       case SetText:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
 // EOF
index b558254a0785e176a73120f58fd6941650dc0f40..a8e9a52afd41b2976130f97d3211a2ea7d310380 100644 (file)
@@ -1,89 +1,54 @@
-/****************************************************************************
-** $Id: rs_actiondimangular.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMANGULAR_H
 #define RS_ACTIONDIMANGULAR_H
 
 #include "rs_actiondimension.h"
 #include "rs_dimangular.h"
+#include "vector.h"
 
+class RS_Line;
 
 /**
  * This action class can handle user events to draw angular dimensions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDimAngular : public RS_ActionDimension {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetLine1,      /**< Choose 1st line. */
-        SetLine2,      /**< Choose 2nd line. */
-        SetPos,        /**< Choose position. */
-               SetText        /**< Setting text label in consle. */
-    };
-
-public:
-    RS_ActionDimAngular(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDimAngular() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDimAngular;
-       }
-
-       virtual void reset();
-       
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseButtonHints();
-
-private:
-    /** 1st chosen line */
-    RS_Line* line1;
-    /** 2nd chosen line */
-    RS_Line* line2;
-       /** Center of arc */
-       Vector center;
-    /** Data of new dimension */
-    RS_DimAngularData edata;
-       /** Last status before entering text. */
-       Status lastStatus;
+class RS_ActionDimAngular: public RS_ActionDimension
+{
+       private:
+               enum Status {
+                       SetLine1,      /**< Choose 1st line. */
+                       SetLine2,      /**< Choose 2nd line. */
+                       SetPos,        /**< Choose position. */
+                       SetText        /**< Setting text label in consle. */
+               };
+
+       public:
+               RS_ActionDimAngular(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDimAngular();
+
+               virtual RS2::ActionType rtti();
+               virtual void reset();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+
+       private:
+               /** 1st chosen line */
+               RS_Line * line1;
+               /** 2nd chosen line */
+               RS_Line * line2;
+               /** Center of arc */
+               Vector center;
+               /** Data of new dimension */
+               RS_DimAngularData edata;
+               /** Last status before entering text. */
+               Status lastStatus;
 };
 
 #endif
index 18b7aa5647c4fc2f9b42dafad165b93a6e5309d3..07bfa2b503a1e5fe1b9aac8e9b0bb637f04dec89 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondimdiametric.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondimdiametric.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondimdiametric.h"
 
-#include "rs_creation.h"
-#include "rs_snapper.h"
+#include "rs_graphicview.h"
 #include "rs_dialogfactory.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDimDiametric::RS_ActionDimDiametric(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionDimension("Draw Diametric Dimensions",
-                    container, graphicView)
+RS_ActionDimDiametric::RS_ActionDimDiametric(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw Diametric Dimensions",
+               container, graphicView)
 {
        reset();
 }
 
-
-QAction * RS_ActionDimDiametric::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionDimDiametric::~RS_ActionDimDiametric()
 {
-       QAction * action = new QAction(tr("&Diametric"), 0);
-//     QAction* action = new QAction(tr("Diametric"), tr("&Diametric"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Diametric Dimension"));
+}
 
-       return action;
+/*virtual*/ RS2::ActionType RS_ActionDimDiametric::rtti()
+{
+       return RS2::ActionDimDiametric;
 }
 
 void RS_ActionDimDiametric::reset()
 {
-    RS_ActionDimension::reset();
-
-    edata = RS_DimDiametricData(Vector(false),
-                                0.0);
-    entity = NULL;
-    pos = Vector(false);
-    RS_DIALOGFACTORY->requestOptions(this, true, true);
+       RS_ActionDimension::reset();
+       edata = RS_DimDiametricData(Vector(false), 0.0);
+       entity = NULL;
+       pos = Vector(false);
+       RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
-
-
 void RS_ActionDimDiametric::trigger()
 {
-    RS_PreviewActionInterface::trigger();
-
-    preparePreview();
-    if (entity!=NULL) {
-        RS_DimDiametric* newEntity = NULL;
-
-        newEntity = new RS_DimDiametric(container,
-                                        data,
-                                        edata);
-
-        newEntity->setLayerToActive();
-        newEntity->setPenToActive();
-        newEntity->update();
-        container->addEntity(newEntity);
-
-        // upd. undo list:
-        if (document!=NULL) {
-            document->startUndoCycle();
-            document->addUndoable(newEntity);
-            document->endUndoCycle();
-        }
-        deleteSnapper();
-        Vector rz = graphicView->getRelativeZero();
-        graphicView->moveRelativeZero(Vector(0.0,0.0));
-        graphicView->drawEntity(newEntity);
-        graphicView->moveRelativeZero(rz);
-
-    } else {
-        RS_DEBUG->print("RS_ActionDimDiametric::trigger:"
-                        " Entity is NULL\n");
-    }
+       RS_PreviewActionInterface::trigger();
+
+       preparePreview();
+
+       if (entity != NULL)
+       {
+               RS_DimDiametric * newEntity = NULL;
+
+               newEntity = new RS_DimDiametric(container,
+                               data,
+                               edata);
+
+               newEntity->setLayerToActive();
+               newEntity->setPenToActive();
+               newEntity->update();
+               container->addEntity(newEntity);
+
+               // upd. undo list:
+               if (document != NULL)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(newEntity);
+                       document->endUndoCycle();
+               }
+               deleteSnapper();
+               Vector rz = graphicView->getRelativeZero();
+               graphicView->moveRelativeZero(Vector(0.0, 0.0));
+               graphicView->drawEntity(newEntity);
+               graphicView->moveRelativeZero(rz);
+       }
+       else
+               RS_DEBUG->print("RS_ActionDimDiametric::trigger:"
+                       " Entity is NULL\n");
 }
 
-
-
 void RS_ActionDimDiametric::preparePreview()
 {
-    if (entity!=NULL) {
-        double radius=0.0;
-        Vector center = Vector(false);
-        if (entity->rtti()==RS2::EntityArc) {
-            radius = ((RS_Arc*)entity)->getRadius();
-            center = ((RS_Arc*)entity)->getCenter();
-        } else if (entity->rtti()==RS2::EntityCircle) {
-            radius = ((RS_Circle*)entity)->getRadius();
-            center = ((RS_Circle*)entity)->getCenter();
-        }
-        double angle = center.angleTo(pos);
-
-        data.definitionPoint.setPolar(radius, angle+M_PI);
-        data.definitionPoint += center;
-
-        edata.definitionPoint.setPolar(radius, angle);
-        edata.definitionPoint += center;
-    }
+       if (entity != NULL)
+       {
+               double radius = 0.0;
+               Vector center = Vector(false);
+
+               if (entity->rtti() == RS2::EntityArc)
+               {
+                       radius = ((RS_Arc *)entity)->getRadius();
+                       center = ((RS_Arc *)entity)->getCenter();
+               }
+               else if (entity->rtti() == RS2::EntityCircle)
+               {
+                       radius = ((RS_Circle *)entity)->getRadius();
+                       center = ((RS_Circle *)entity)->getCenter();
+               }
+               double angle = center.angleTo(pos);
+
+               data.definitionPoint.setPolar(radius, angle + M_PI);
+               data.definitionPoint += center;
+
+               edata.definitionPoint.setPolar(radius, angle);
+               edata.definitionPoint += center;
+       }
 }
 
-
-
-void RS_ActionDimDiametric::mouseMoveEvent(QMouseEvent* e)
+void RS_ActionDimDiametric::mouseMoveEvent(QMouseEvent * e)
 {
-    RS_DEBUG->print("RS_ActionDimDiametric::mouseMoveEvent begin");
+       RS_DEBUG->print("RS_ActionDimDiametric::mouseMoveEvent begin");
 
-    Vector mouse(graphicView->toGraphX(e->x()),
-                    graphicView->toGraphY(e->y()));
+       Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
 
-    switch (getStatus()) {
-    case SetEntity:
-        entity = catchEntity(e, RS2::ResolveAll);
-        break;
+       switch (getStatus())
+       {
+       case SetEntity:
+               entity = catchEntity(e, RS2::ResolveAll);
+               break;
 
-    case SetPos:
-        if (entity!=NULL) {
-            pos = snapPoint(e);
+       case SetPos:
 
-            preparePreview();
-            RS_DimDiametric* d = new RS_DimDiametric(preview, data, edata);
-            d->update();
+               if (entity != NULL)
+               {
+                       pos = snapPoint(e);
 
-            deletePreview();
-            clearPreview();
-            preview->addEntity(d);
-            drawPreview();
-        }
-        break;
+                       preparePreview();
+                       RS_DimDiametric * d = new RS_DimDiametric(preview, data, edata);
+                       d->update();
 
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDimDiametric::mouseMoveEvent end");
-}
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(d);
+                       drawPreview();
+               }
+               break;
 
+       default:
+               break;
+       }
 
+       RS_DEBUG->print("RS_ActionDimDiametric::mouseMoveEvent end");
+}
 
-void RS_ActionDimDiametric::mouseReleaseEvent(QMouseEvent* e)
+void RS_ActionDimDiametric::mouseReleaseEvent(QMouseEvent * e)
 {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetEntity: {
-                RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-                if (en!=NULL) {
-                    if (en->rtti()==RS2::EntityArc ||
-                            en->rtti()==RS2::EntityCircle) {
-
-                        entity = en;
-                        Vector center;
-                        if (entity->rtti()==RS2::EntityArc) {
-                            center =
-                                ((RS_Arc*)entity)->getCenter();
-                        } else if (entity->rtti()==RS2::EntityCircle) {
-                            center =
-                                ((RS_Circle*)entity)->getCenter();
-                        }
-                        graphicView->moveRelativeZero(center);
-                        setStatus(SetPos);
-                    } else {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a circle "
-                                                            "or arc entity"));
-                    }
-                }
-            }
-            break;
-
-        case SetPos: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        clearPreview();
-        init(getStatus()-1);
-    }
-
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity: {
+                       RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+                       if (en != NULL)
+                       {
+                               if (en->rtti() == RS2::EntityArc
+                                   || en->rtti() == RS2::EntityCircle)
+                               {
+                                       entity = en;
+                                       Vector center;
+
+                                       if (entity->rtti() == RS2::EntityArc)
+                                               center =
+                                                       ((RS_Arc *)entity)->getCenter();
+                                       else if (entity->rtti() == RS2::EntityCircle)
+                                               center =
+                                                       ((RS_Circle *)entity)->getCenter();
+                                       graphicView->moveRelativeZero(center);
+                                       setStatus(SetPos);
+                               }
+                               else
+                                       RS_DIALOGFACTORY->commandMessage(tr("Not a circle "
+                                                       "or arc entity"));
+                       }
+               }
+               break;
+
+               case SetPos: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               clearPreview();
+               init(getStatus() - 1);
+       }
 }
 
-
-void RS_ActionDimDiametric::coordinateEvent(RS_CoordinateEvent* e)
+void RS_ActionDimDiametric::coordinateEvent(Vector * e)
 {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPos:
-        pos = e->getCoordinate();
-        trigger();
-        reset();
-        setStatus(SetEntity);
-        break;
-
-    default:
-        break;
-    }
+       if (e == NULL)
+               return;
+
+       switch (getStatus())
+       {
+       case SetPos:
+               pos = *e;
+               trigger();
+               reset();
+               setStatus(SetEntity);
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionDimDiametric::commandEvent(RS_CommandEvent* e)
+void RS_ActionDimDiametric::commandEvent(RS_CommandEvent * e)
 {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    // setting new text label:
-    if (getStatus()==SetText) {
-        setText(c);
-        RS_DIALOGFACTORY->requestOptions(this, true, true);
-        graphicView->enableCoordinateInput();
-        setStatus(lastStatus);
-        return;
-    }
-
-    // command: text
-    if (checkCommand("text", c)) {
-        lastStatus = (Status)getStatus();
-        graphicView->disableCoordinateInput();
-        setStatus(SetText);
-    }
-
-    // setting angle
-    if (getStatus()==SetPos) {
-        bool ok;
-        double a = RS_Math::eval(c, &ok);
-        if (ok==true) {
-            pos.setPolar(1.0, RS_Math::deg2rad(a));
-            pos += data.definitionPoint;
-            trigger();
-            reset();
-            setStatus(SetEntity);
-        } else {
-            RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-        }
-        return;
-    }
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       // setting new text label:
+       if (getStatus() == SetText)
+       {
+               setText(c);
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               graphicView->enableCoordinateInput();
+               setStatus(lastStatus);
+               return;
+       }
+
+       // command: text
+       if (checkCommand("text", c))
+       {
+               lastStatus = (Status)getStatus();
+               graphicView->disableCoordinateInput();
+               setStatus(SetText);
+       }
+
+       // setting angle
+       if (getStatus() == SetPos)
+       {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       pos.setPolar(1.0, RS_Math::deg2rad(a));
+                       pos += data.definitionPoint;
+                       trigger();
+                       reset();
+                       setStatus(SetEntity);
+               }
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               return;
+       }
 }
 
+QStringList RS_ActionDimDiametric::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetEntity:
+       case SetPos:
+               cmd += command("text");
+               break;
 
-QStringList RS_ActionDimDiametric::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetEntity:
-    case SetPos:
-        cmd += command("text");
-        break;
-
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-void RS_ActionDimDiametric::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select arc or circle entity"),
-                                            tr("Cancel"));
-        break;
-    case SetPos:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify dimension line location"), tr("Cancel"));
-        break;
-    case SetText:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDimDiametric::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select arc or circle entity"),
+                       tr("Cancel"));
+               break;
+
+       case SetPos:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify dimension line location"), tr("Cancel"));
+               break;
+
+       case SetText:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDimDiametric::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDimDiametric::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDimDiametric::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDimDiametric::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    //RS_DIALOGFACTORY->requestDimDiametricOptions(edata, false);
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       //RS_DIALOGFACTORY->requestDimDiametricOptions(edata, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
 // EOF
index 00e9ded42effcd6934e69a530f9622402d2844f0..1515b02d68f1e54b4639d6b72fe3d36ee9fe060f 100644 (file)
@@ -1,87 +1,52 @@
-/****************************************************************************
-** $Id: rs_actiondimdiametric.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMDIAMETRIC_H
 #define RS_ACTIONDIMDIAMETRIC_H
 
 #include "rs_actiondimension.h"
 #include "rs_dimdiametric.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to draw diametric dimensions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDimDiametric : public RS_ActionDimension {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetEntity,     /**< Choose entity. */
-        SetPos,        /**< Choose point. */
-               SetText        /**< Setting text label in the command line. */
-    };
-
-public:
-    RS_ActionDimDiametric(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDimDiametric() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDimDiametric;
-       }
-
-       virtual void reset();
-       
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-
-private:
-    /** Chosen entity (arc / circle) */
-    RS_Entity* entity;
-       /** Chosen position */
-       Vector pos;
-    /** Data of new dimension */
-    RS_DimDiametricData edata;
-       /** Last status before entering text. */
-       Status lastStatus;
+class RS_ActionDimDiametric: public RS_ActionDimension
+{
+       private:
+               enum Status {
+                       SetEntity,     /**< Choose entity. */
+                       SetPos,        /**< Choose point. */
+                       SetText        /**< Setting text label in the command line. */
+               };
+
+       public:
+               RS_ActionDimDiametric(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDimDiametric();
+
+               virtual RS2::ActionType rtti();
+               virtual void reset();
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+
+       private:
+               /** Chosen entity (arc / circle) */
+               RS_Entity * entity;
+               /** Chosen position */
+               Vector pos;
+               /** Data of new dimension */
+               RS_DimDiametricData edata;
+               /** Last status before entering text. */
+               Status lastStatus;
 };
 
 #endif
index cbedac1d0b5f2d02dac4de11e2b3af8fa858f7d0..89af7a5b0586e76e91297115403683f66c8d556a 100644 (file)
@@ -1,40 +1,26 @@
-/****************************************************************************
-** $Id: rs_actiondimension.cpp 1141 2004-07-29 20:32:39Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#include "rs_actiondimaligned.h"
-
-#include "rs_snapper.h"
-#include "rs_constructionline.h"
+// rs_actiondimension.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
+
+#include "rs_actiondimension.h"
+
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 
-RS_ActionDimension::RS_ActionDimension(const char * name,
-       RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDimension::RS_ActionDimension(const char * name, RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface(name, container, graphicView)
 {
-    reset();
+       reset();
 }
 
 RS_ActionDimension::~RS_ActionDimension()
@@ -43,22 +29,14 @@ RS_ActionDimension::~RS_ActionDimension()
 
 void RS_ActionDimension::reset()
 {
-    data = RS_DimensionData(Vector(false),
-                            Vector(false),
-                            RS2::VAlignMiddle,
-                            RS2::HAlignCenter,
-                            RS2::Exact,
-                            1.0,
-                            "",
-                            "Standard",
-                            0.0);
+       data = RS_DimensionData(Vector(false), Vector(false), RS2::VAlignMiddle,
+                       RS2::HAlignCenter, RS2::Exact, 1.0, "", "Standard", 0.0);
        diameter = false;
 }
 
 void RS_ActionDimension::init(int status)
 {
        RS_PreviewActionInterface::init(status);
-       //reset();
 }
 
 void RS_ActionDimension::hideOptions()
@@ -66,9 +44,7 @@ void RS_ActionDimension::hideOptions()
        RS_ActionInterface::hideOptions();
 
        if (RS_DIALOGFACTORY != NULL)
-       {
                RS_DIALOGFACTORY->requestOptions(this, false);
-       }
 }
 
 void RS_ActionDimension::showOptions()
@@ -76,9 +52,7 @@ void RS_ActionDimension::showOptions()
        RS_ActionInterface::showOptions();
 
        if (RS_DIALOGFACTORY != NULL)
-       {
                RS_DIALOGFACTORY->requestOptions(this, true, true);
-       }
 }
 
 void RS_ActionDimension::updateMouseCursor()
@@ -88,17 +62,85 @@ void RS_ActionDimension::updateMouseCursor()
 
 void RS_ActionDimension::updateToolBar()
 {
-       if (RS_DIALOGFACTORY!=NULL)
+       if (RS_DIALOGFACTORY != NULL)
        {
                if (!isFinished())
-               {
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-               }
                else
-               {
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
-               }
        }
 }
 
-// EOF
+QString RS_ActionDimension::getText()
+{
+       if (!data.text.isEmpty())
+               return data.text;
+
+       QString l = label;
+
+       if (l.isEmpty() && (diameter || !tol1.isEmpty() || !tol2.isEmpty()))
+               l = "<>";
+
+       if (diameter)
+               l = QChar(0x2205) + l;
+
+       if (!tol1.isEmpty() || !tol2.isEmpty())
+               l += QString("\\S%1\\%2;").arg(tol1).arg(tol2);
+
+       return l;
+}
+
+void RS_ActionDimension::setText(const QString & t)
+{
+       data.text = t;
+}
+
+QString RS_ActionDimension::getLabel()
+{
+       return label;
+}
+
+void RS_ActionDimension::setLabel(const QString & t)
+{
+       label = t;
+}
+
+QString RS_ActionDimension::getTol1()
+{
+       return tol1;
+}
+
+void RS_ActionDimension::setTol1(const QString & t)
+{
+       tol1 = t;
+}
+
+QString RS_ActionDimension::getTol2()
+{
+       return tol2;
+}
+
+void RS_ActionDimension::setTol2(const QString & t)
+{
+       tol2 = t;
+}
+
+bool RS_ActionDimension::getDiameter()
+{
+       return diameter;
+}
+
+void RS_ActionDimension::setDiameter(bool d)
+{
+       diameter = d;
+}
+
+/*static*/ bool RS_ActionDimension::isDimensionAction(RS2::ActionType type)
+{
+       return (type == RS2::ActionDimAligned
+               || type == RS2::ActionDimLinear
+               || type == RS2::ActionDimAngular
+               || type == RS2::ActionDimDiametric
+               || type == RS2::ActionDimRadial);
+}
+
index f207d86c824de01ff912a6178d84f84c35b82ce5..1c4735b354c2152abb24dd735c22382f7b1d0e97 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondimension.h 1119 2004-04-12 22:44:04Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMENSION_H
 #define RS_ACTIONDIMENSION_H
 
-#include "rs_previewactioninterface.h"
+#include <QtCore>
 #include "rs_dimension.h"
+#include "rs_previewactioninterface.h"
 
 /**
  * Base class for dimension actions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDimension : public RS_PreviewActionInterface {
-    //Q_OBJECT
-public:
-    RS_ActionDimension(const char* name,
-                       RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionDimension();
-
-    virtual void reset();
-
-    virtual void init(int status=0);
-
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-    QString getText() {
-               if (!data.text.isEmpty()) {
-                       return data.text;
-               }
-       
-        QString l = label;
-
-        if (l.isEmpty() &&
-            (diameter==true || !tol1.isEmpty() || !tol2.isEmpty())) {
-            l = "<>";
-        }
-
-        if (diameter==true) {
-            l = QChar(0x2205) + l;
-        }
-
-        if (!tol1.isEmpty() || !tol2.isEmpty()) {
-            l += QString("\\S%1\\%2;").arg(tol1).arg(tol2);
-        }
-
-        return l;
-    }
-       
-    void setText(const QString& t) {
-        data.text = t;
-       }
-
-       QString getLabel() {
-               return label;
-       }
-    void setLabel(const QString& t) {
-        //data.text = t;
-        label = t;
-    }
-       QString getTol1() {
-               return tol1;
-       }
-    void setTol1(const QString& t) {
-        tol1 = t;
-    }
-       QString getTol2() {
-               return tol2;
-       }
-    void setTol2(const QString& t) {
-        tol2 = t;
-    }
-       bool getDiameter() {
-               return diameter;
-       }
-    void setDiameter(bool d) {
-        diameter = d;
-    }
-
-    static bool isDimensionAction(RS2::ActionType type) {
-        return (type==RS2::ActionDimAligned ||
-                type==RS2::ActionDimLinear ||
-                type==RS2::ActionDimAngular ||
-                type==RS2::ActionDimDiametric ||
-                type==RS2::ActionDimRadial);
-    }
-
-protected:
-    /**
-     * Generic dimension data.
-     */
-    RS_DimensionData data;
-
-    QString label;
-    QString tol1;
-    QString tol2;
-    bool diameter;
-
-
-    /**
-     * Commands.
-     */
-    /*
-      QString cmdText;
-      QString cmdText2;
-    */
+class RS_ActionDimension: public RS_PreviewActionInterface
+{
+       public:
+               RS_ActionDimension(const char * name, RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDimension();
+
+               virtual void reset();
+               virtual void init(int status = 0);
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               QString getText();
+               void setText(const QString & t);
+               QString getLabel();
+               void setLabel(const QString & t);
+               QString getTol1();
+               void setTol1(const QString & t);
+               QString getTol2();
+               void setTol2(const QString & t);
+               bool getDiameter();
+               void setDiameter(bool d);
+               static bool isDimensionAction(RS2::ActionType type);
+
+       protected:
+               /**
+                * Generic dimension data.
+                */
+               RS_DimensionData data;
+
+               QString label;
+               QString tol1;
+               QString tol2;
+               bool diameter;
 };
 
 #endif
index d1793d1800d7c3d89d3d1ed34c9d910a2afd6f8a..c1d2aa9ba084c4ba3b5dbb6303e4492dccf66562 100644 (file)
@@ -1,35 +1,24 @@
-/****************************************************************************
-** $Id: rs_actiondimleader.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondimleader.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondimleader.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDimLeader::RS_ActionDimLeader(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDimLeader::RS_ActionDimLeader(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw leaders", container, graphicView)
 {
        reset();
@@ -44,16 +33,6 @@ RS_ActionDimLeader::~RS_ActionDimLeader()
        return RS2::ActionDimLeader;
 }
 
-QAction * RS_ActionDimLeader::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
-       QAction * action = new QAction(tr("&Leader"), 0);
-//     QAction* action = new QAction(tr("Leader"), tr("&Leader"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Leader Dimension"));
-
-       return action;
-}
-
 void RS_ActionDimLeader::reset()
 {
        //data = RS_LineData(Vector(false), Vector(false));
@@ -81,7 +60,7 @@ void RS_ActionDimLeader::trigger()
 
 //             for(Vector * v=points.first(); v!=NULL; v=points.next())
 //                     leader->addVertex(*v);
-               for(int i=0; i<points.size(); i++)
+               for (int i = 0; i < points.size(); i++)
                        leader->addVertex(*(points[i]));
 
                container->addEntity(leader);
@@ -113,7 +92,7 @@ void RS_ActionDimLeader::mouseMoveEvent(QMouseEvent * e)
 
        Vector mouse = snapPoint(e);
 
-       if (getStatus()==SetEndpoint && points.last()!=NULL)
+       if (getStatus() == SetEndpoint && points.last() != NULL)
        {
                deletePreview();
                clearPreview();
@@ -122,7 +101,7 @@ void RS_ActionDimLeader::mouseMoveEvent(QMouseEvent * e)
                Vector last(false);
 
 //             for(Vector * v=points.first(); v!=NULL; v=points.next())
-               for(int i=0; i<points.size(); i++)
+               for (int i = 0; i < points.size(); i++)
                {
                        Vector * v = points[i];
 
@@ -144,7 +123,7 @@ void RS_ActionDimLeader::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -174,12 +153,12 @@ void RS_ActionDimLeader::keyPressEvent(QKeyEvent * e)
        }
 }
 
-void RS_ActionDimLeader::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDimLeader::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
        switch (getStatus())
        {
@@ -212,10 +191,8 @@ void RS_ActionDimLeader::commandEvent(RS_CommandEvent * e)
        if (checkCommand("help", c))
        {
                if (RS_DIALOGFACTORY != NULL)
-               {
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                + getAvailableCommands().join(", "));
-               }
 
                return;
        }
@@ -246,9 +223,11 @@ void RS_ActionDimLeader::updateMouseButtonHints()
                case SetStartpoint:
                        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"), tr("Cancel"));
                        break;
+
                case SetEndpoint:
                        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point"), tr("Finish"));
                        break;
+
                default:
                        RS_DIALOGFACTORY->updateMouseWidget("", "");
                        break;
@@ -285,3 +264,4 @@ void RS_ActionDimLeader::updateToolBar()
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
        }
 }
+
index 3bf575042d8044f843b2a9e1d4ff44be156785be..545bff6e8194fff6deed118dcd9a195fdf6ba410 100644 (file)
@@ -1,34 +1,11 @@
-/****************************************************************************
-** $Id: rs_actiondimleader.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMLEADER_H
 #define RS_ACTIONDIMLEADER_H
 
-#include "rs_previewactioninterface.h"
+#include <QtCore>
 #include "rs_leader.h"
+#include "rs_previewactioninterface.h"
+
+class Vector;
 
 /**
  * This action class can handle user events to draw
  */
 class RS_ActionDimLeader: public RS_PreviewActionInterface
 {
-//hm   //Q_OBJECT
        public:
                /**
-               * Action States.
-               */
+                * Action States.
+                */
                enum Status {
                        SetStartpoint,   /**< Setting the startpoint.  */
                        SetEndpoint      /**< Setting the endpoint. */
@@ -52,7 +28,7 @@ class RS_ActionDimLeader: public RS_PreviewActionInterface
                RS_ActionDimLeader(RS_EntityContainer & container, RS_GraphicView & graphicView);
                ~RS_ActionDimLeader();
 
-               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
+               //static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
 
                virtual RS2::ActionType rtti();
                void reset();
@@ -61,7 +37,7 @@ class RS_ActionDimLeader: public RS_PreviewActionInterface
                virtual void mouseMoveEvent(QMouseEvent * e);
                virtual void mouseReleaseEvent(QMouseEvent * e);
                virtual void keyPressEvent(QKeyEvent *);
-               virtual void coordinateEvent(RS_CoordinateEvent * e);
+               virtual void coordinateEvent(Vector * e);
                virtual void commandEvent(RS_CommandEvent * e);
                virtual QStringList getAvailableCommands();
                virtual void showOptions();
@@ -78,7 +54,7 @@ class RS_ActionDimLeader: public RS_PreviewActionInterface
                /**
                 * Points set so far.
                 */
-       //      Q3PtrList<Vector> points;
+               //      Q3PtrList<Vector> points;
                QList<Vector *> points;
 };
 
index cac9a5b808ccba0eee262a55204aeed57245bf9c..db10186569f96ac01a28bef35988ac8967c8772e 100644 (file)
 
 #include "rs_actiondimlinear.h"
 
-#include "rs_snapper.h"
 #include "rs_constructionline.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 /**
  * Constructor.
  * @param fixedAngle true: The user can't change the angle.
  *                   false: The user can change the angle in a option widget.
  */
-RS_ActionDimLinear::RS_ActionDimLinear(RS_EntityContainer& container,
-       RS_GraphicView& graphicView, double angle, bool fixedAngle):
+RS_ActionDimLinear::RS_ActionDimLinear(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle, bool fixedAngle):
        RS_ActionDimension("Draw linear dimensions", container, graphicView)
 {
        edata.angle = angle;
        this->fixedAngle = fixedAngle;
-
        lastStatus = SetExtPoint1;
-
        reset();
 }
 
@@ -41,316 +39,297 @@ RS_ActionDimLinear::~RS_ActionDimLinear()
 {
 }
 
-QAction * RS_ActionDimLinear::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionDimLinear::rtti()
 {
-       QAction * action;
-
-       switch (type)
-       {
-       default:
-       case RS2::ActionDimLinear:
-               action = new QAction(tr("&Linear"), 0);
-//        action = new QAction(tr("Linear"), tr("&Linear"),
-//                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Linear Dimension"));
-               break;
-
-       case RS2::ActionDimLinearHor:
-               action = new QAction(tr("&Horizontal"), 0);
-//        action = new QAction(tr("Horizontal"), tr("&Horizontal"),
-//                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Horizontal Dimension"));
-               break;
-
-       case RS2::ActionDimLinearVer:
-               action = new QAction(tr("&Vertical"), 0);
-//        action = new QAction(tr("Vertical"), tr("&Vertical"),
-//                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Vertical Dimension"));
-               break;
-       }
-
-       return action;
+       return RS2::ActionDimLinear;
 }
 
+void RS_ActionDimLinear::reset()
+{
+       RS_ActionDimension::reset();
+       edata = RS_DimLinearData(Vector(false), Vector(false), (fixedAngle ? edata.angle : 0.0), 0.0);
 
-void RS_ActionDimLinear::reset() {
-    RS_ActionDimension::reset();
-
-    edata = RS_DimLinearData(Vector(false),
-                             Vector(false),
-                             (fixedAngle ? edata.angle : 0.0), 0.0);
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
+void RS_ActionDimLinear::trigger()
+{
+       RS_ActionDimension::trigger();
+       preparePreview();
+       RS_DimLinear * dim = new RS_DimLinear(container, data, edata);
+       dim->setLayerToActive();
+       dim->setPenToActive();
+       dim->update();
+       container->addEntity(dim);
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(dim);
+               document->endUndoCycle();
+       }
 
+       deleteSnapper();
+       Vector rz = graphicView->getRelativeZero();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(dim);
+       graphicView->moveRelativeZero(rz);
+       drawSnapper();
 
-void RS_ActionDimLinear::trigger() {
-    RS_ActionDimension::trigger();
-
-    preparePreview();
-    RS_DimLinear* dim = new RS_DimLinear(container, data, edata);
-    dim->setLayerToActive();
-    dim->setPenToActive();
-    dim->update();
-    container->addEntity(dim);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(dim);
-        document->endUndoCycle();
-    }
-
-    deleteSnapper();
-    Vector rz = graphicView->getRelativeZero();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(dim);
-    graphicView->moveRelativeZero(rz);
-    drawSnapper();
-
-    RS_DEBUG->print("RS_ActionDimLinear::trigger():"
-                    " dim added: %d", dim->getId());
+       RS_DEBUG->print("RS_ActionDimLinear::trigger(): dim added: %d", dim->getId());
 }
 
+void RS_ActionDimLinear::preparePreview()
+{
+       Vector dirV;
+       dirV.setPolar(100.0, edata.angle + M_PI / 2.0);
 
-void RS_ActionDimLinear::preparePreview() {
-    Vector dirV;
-    dirV.setPolar(100.0, edata.angle+M_PI/2.0);
-
-    RS_ConstructionLine cl(
-        NULL,
-        RS_ConstructionLineData(
-            edata.extensionPoint2,
-            edata.extensionPoint2+dirV));
-
-    data.definitionPoint =
-        cl.getNearestPointOnEntity(data.definitionPoint);
+       RS_ConstructionLine cl(
+               NULL, RS_ConstructionLineData(
+                       edata.extensionPoint2,
+                       edata.extensionPoint2 + dirV));
 
+       data.definitionPoint =
+               cl.getNearestPointOnEntity(data.definitionPoint);
 }
 
+void RS_ActionDimLinear::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDimLinear::mouseMoveEvent begin");
 
+       Vector mouse = snapPoint(e);
 
-void RS_ActionDimLinear::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDimLinear::mouseMoveEvent begin");
+       switch (getStatus())
+       {
+       case SetExtPoint1:
+               break;
 
-    Vector mouse = snapPoint(e);
+       case SetExtPoint2:
+
+               if (edata.extensionPoint1.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(new RS_Line(preview,
+                                       RS_LineData(edata.extensionPoint1,
+                                               mouse)));
+                       drawPreview();
+               }
+               break;
 
-    switch (getStatus()) {
-    case SetExtPoint1:
-        break;
+       case SetDefPoint:
 
-    case SetExtPoint2:
-        if (edata.extensionPoint1.valid) {
-            deletePreview();
-            clearPreview();
-            preview->addEntity(new RS_Line(preview,
-                                           RS_LineData(edata.extensionPoint1,
-                                                       mouse)));
-            drawPreview();
-        }
-        break;
+               if (edata.extensionPoint1.valid && edata.extensionPoint2.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       data.definitionPoint = mouse;
 
-    case SetDefPoint:
-        if (edata.extensionPoint1.valid && edata.extensionPoint2.valid) {
-            deletePreview();
-            clearPreview();
-            data.definitionPoint = mouse;
+                       preparePreview();
 
-            preparePreview();
+                       RS_DimLinear * dim = new RS_DimLinear(preview, data, edata);
+                       dim->update();
+                       preview->addEntity(dim);
+                       drawPreview();
+               }
+               break;
+       }
 
-            RS_DimLinear* dim = new RS_DimLinear(preview, data, edata);
-            dim->update();
-            preview->addEntity(dim);
-            drawPreview();
-        }
-        break;
-    }
+       RS_DEBUG->print("RS_ActionDimLinear::mouseMoveEvent end");
+}
 
-    RS_DEBUG->print("RS_ActionDimLinear::mouseMoveEvent end");
+void RS_ActionDimLinear::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionDimLinear::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
+       Vector pos = *e;
 
-void RS_ActionDimLinear::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
-}
+       switch (getStatus())
+       {
+       case SetExtPoint1:
+               edata.extensionPoint1 = pos;
+               graphicView->moveRelativeZero(pos);
+               setStatus(SetExtPoint2);
+               break;
 
+       case SetExtPoint2:
+               edata.extensionPoint2 = pos;
+               graphicView->moveRelativeZero(pos);
+               setStatus(SetDefPoint);
+               break;
 
+       case SetDefPoint:
+               data.definitionPoint = pos;
+               trigger();
+               reset();
+               setStatus(SetExtPoint1);
+               break;
 
-void RS_ActionDimLinear::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
+       default:
+               break;
+       }
+}
 
-    Vector pos = e->getCoordinate();
+void RS_ActionDimLinear::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
-    switch (getStatus()) {
-    case SetExtPoint1:
-        edata.extensionPoint1 = pos;
-        graphicView->moveRelativeZero(pos);
-        setStatus(SetExtPoint2);
-        break;
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
 
-    case SetExtPoint2:
-        edata.extensionPoint2 = pos;
-        graphicView->moveRelativeZero(pos);
-        setStatus(SetDefPoint);
-        break;
+       switch (getStatus())
+       {
+       case SetText:
+               setText(c);
 
-    case SetDefPoint:
-        data.definitionPoint = pos;
-        trigger();
-        reset();
-        setStatus(SetExtPoint1);
-        break;
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               graphicView->enableCoordinateInput();
+               setStatus(lastStatus);
+               break;
 
-    default:
-        break;
-    }
-}
+       case SetAngle: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
 
+               if (ok == true)
+                       setAngle(RS_Math::deg2rad(a));
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
 
-void RS_ActionDimLinear::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetText:
-        setText(c);
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-        }
-        graphicView->enableCoordinateInput();
-        setStatus(lastStatus);
-        break;
-
-    case SetAngle: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                setAngle(RS_Math::deg2rad(a));
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(lastStatus);
-        }
-        break;
-
-    default:
-        lastStatus = (Status)getStatus();
-        deleteSnapper();
-        deletePreview();
-        clearPreview();
-        if (checkCommand("text", c)) {
-            graphicView->disableCoordinateInput();
-            setStatus(SetText);
-            return;
-        } else if (!fixedAngle && (checkCommand("angle", c))) {
-            setStatus(SetAngle);
-        }
-        break;
-    }
+       default:
+               lastStatus = (Status)getStatus();
+               deleteSnapper();
+               deletePreview();
+               clearPreview();
+
+               if (checkCommand("text", c))
+               {
+                       graphicView->disableCoordinateInput();
+                       setStatus(SetText);
+                       return;
+               }
+               else if (!fixedAngle && (checkCommand("angle", c)))
+                       setStatus(SetAngle);
+               break;
+       }
 }
 
+QStringList RS_ActionDimLinear::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetExtPoint1:
+       case SetExtPoint2:
+       case SetDefPoint:
+               cmd += command("text");
 
-QStringList RS_ActionDimLinear::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetExtPoint1:
-    case SetExtPoint2:
-    case SetDefPoint:
-        cmd += command("text");
-        if (!fixedAngle) {
-            cmd += command("angle");
-        }
-        break;
+               if (!fixedAngle)
+                       cmd += command("angle");
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-void RS_ActionDimLinear::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetExtPoint1:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify first extension line origin"),
-                tr("Cancel"));
-            break;
-        case SetExtPoint2:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify second extension line origin"),
-                tr("Back"));
-            break;
-        case SetDefPoint:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify dimension line location"),
-                tr("Back"));
-            break;
-        case SetText:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
-            break;
-        case SetAngle:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Enter dimension line angle:"), "");
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDimLinear::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetExtPoint1:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify first extension line origin"), tr("Cancel"));
+                       break;
+
+               case SetExtPoint2:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify second extension line origin"), tr("Back"));
+                       break;
+
+               case SetDefPoint:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify dimension line location"), tr("Back"));
+                       break;
+
+               case SetText:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
+                       break;
+
+               case SetAngle:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension line angle:"), "");
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
+void RS_ActionDimLinear::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDimLinear::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
+void RS_ActionDimLinear::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
+}
 
-void RS_ActionDimLinear::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
+double RS_ActionDimLinear::getAngle()
+{
+       return edata.angle;
 }
 
+void RS_ActionDimLinear::setAngle(double a)
+{
+       edata.angle = a;
+}
 
+bool RS_ActionDimLinear::hasFixedAngle()
+{
+       return fixedAngle;
+}
 
-// EOF
index 3827fe4d378358a0e2de60ee24d2f2830c8fa001..471c03be2ceffc0d3fd4f4721bc65ac87a2eacec 100644 (file)
@@ -1,29 +1,3 @@
-/****************************************************************************
-** $Id: rs_actiondimlinear.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMLINEAR_H
 #define RS_ACTIONDIMLINEAR_H
 
 #include "rs_dimlinear.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * aligned dimensions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDimLinear : public RS_ActionDimension {
-       //Q_OBJECT
-public:
-       /**
-        * Varitions of this action.
-        */
-       enum Variation {
-               AnyAngle,
-               Horizontal,
-               Vertical
-       };
-        
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetExtPoint1,    /**< Setting the 1st ext point.  */
-        SetExtPoint2,    /**< Setting the 2nd ext point. */
-        SetDefPoint,     /**< Setting the common def point. */
-               SetText,         /**< Setting the text label in the command line. */
-               SetAngle         /**< Setting the angle in the command line. */
-    };
-
-public:
-    RS_ActionDimLinear(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView,
-                       double angle=0.0, bool fixedAngle=false);
-    ~RS_ActionDimLinear();
-       
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDimLinear;
-       }
-
-    void reset();
-
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
+class RS_ActionDimLinear: public RS_ActionDimension
+{
+       public:
+               /**
+                * Varitions of this action.
+                */
+               enum Variation {
+                       AnyAngle,
+                       Horizontal,
+                       Vertical
+               };
 
-       double getAngle() {
-               return edata.angle;
-       }
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetExtPoint1,    /**< Setting the 1st ext point.  */
+                       SetExtPoint2,    /**< Setting the 2nd ext point. */
+                       SetDefPoint,     /**< Setting the common def point. */
+                       SetText,         /**< Setting the text label in the command line. */
+                       SetAngle         /**< Setting the angle in the command line. */
+               };
 
-       void setAngle(double a) {
-               edata.angle = a;
-       }
+       public:
+               RS_ActionDimLinear(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+               ~RS_ActionDimLinear();
 
-       bool hasFixedAngle() {
-               return fixedAngle;
-       }
+               virtual RS2::ActionType rtti();
+               void reset();
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               double getAngle();
+               void setAngle(double a);
+               bool hasFixedAngle();
 
-protected:
-    /**
-     * Aligned dimension data.
-     */
-    RS_DimLinearData edata;
-    /**
-     * Is the angle fixed?
-     */
-    bool fixedAngle;
+       protected:
+               /**
+                * Aligned dimension data.
+                */
+               RS_DimLinearData edata;
+               /**
+                * Is the angle fixed?
+                */
+               bool fixedAngle;
 
-       /** Last status before entering text or angle. */
-       Status lastStatus;
+               /** Last status before entering text or angle. */
+               Status lastStatus;
 };
 
 #endif
index ce138328a496aabe0451cec546a74134dc6e7584..9d3bebf4981e1f369ebdff35541af774eaf051aa 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondimradial.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondimradial.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondimradial.h"
 
-#include "rs_creation.h"
-#include "rs_snapper.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDimRadial::RS_ActionDimRadial(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionDimension("Draw Radial Dimensions",
-                    container, graphicView) {
-    reset();
+RS_ActionDimRadial::RS_ActionDimRadial(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw Radial Dimensions",
+               container, graphicView)
+{
+       reset();
 }
 
-
-QAction * RS_ActionDimRadial::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionDimRadial::~RS_ActionDimRadial()
 {
-       QAction * action = new QAction(tr("&Radial"), 0);
-//     QAction * action = new QAction(tr("Radial"), tr("&Radial"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Radial Dimension"));
+}
 
-       return action;
+/*virtual*/ RS2::ActionType RS_ActionDimRadial::rtti()
+{
+       return RS2::ActionDimRadial;
 }
 
 void RS_ActionDimRadial::reset()
 {
-    RS_ActionDimension::reset();
+       RS_ActionDimension::reset();
 
-    edata = RS_DimRadialData(Vector(false),
-                             0.0);
-    entity = NULL;
-    pos = Vector(false);
-    RS_DIALOGFACTORY->requestOptions(this, true, true);
+       edata = RS_DimRadialData(Vector(false),
+                       0.0);
+       entity = NULL;
+       pos = Vector(false);
+       RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
-
-
-void RS_ActionDimRadial::trigger() {
-    RS_ActionDimension::trigger();
-
-    preparePreview();
-    if (entity!=NULL) {
-        RS_DimRadial* newEntity = NULL;
-
-        newEntity = new RS_DimRadial(container,
-                                     data,
-                                     edata);
-
-        newEntity->setLayerToActive();
-        newEntity->setPenToActive();
-        newEntity->update();
-        container->addEntity(newEntity);
-
-        // upd. undo list:
-        if (document!=NULL) {
-            document->startUndoCycle();
-            document->addUndoable(newEntity);
-            document->endUndoCycle();
-        }
-        deleteSnapper();
-        Vector rz = graphicView->getRelativeZero();
-        graphicView->moveRelativeZero(Vector(0.0,0.0));
-        graphicView->drawEntity(newEntity);
-        graphicView->moveRelativeZero(rz);
-        //drawSnapper();
-
-    }
-    else {
-        RS_DEBUG->print("RS_ActionDimRadial::trigger:"
-                        " Entity is NULL\n");
-    }
+void RS_ActionDimRadial::trigger()
+{
+       RS_ActionDimension::trigger();
+
+       preparePreview();
+
+       if (entity != NULL)
+       {
+               RS_DimRadial * newEntity = NULL;
+
+               newEntity = new RS_DimRadial(container,
+                               data,
+                               edata);
+
+               newEntity->setLayerToActive();
+               newEntity->setPenToActive();
+               newEntity->update();
+               container->addEntity(newEntity);
+
+               // upd. undo list:
+               if (document != NULL)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(newEntity);
+                       document->endUndoCycle();
+               }
+               deleteSnapper();
+               Vector rz = graphicView->getRelativeZero();
+               graphicView->moveRelativeZero(Vector(0.0, 0.0));
+               graphicView->drawEntity(newEntity);
+               graphicView->moveRelativeZero(rz);
+               //drawSnapper();
+       }
+       else
+               RS_DEBUG->print("RS_ActionDimRadial::trigger:"
+                       " Entity is NULL\n");
 }
 
-
-void RS_ActionDimRadial::preparePreview() {
-    if (entity!=NULL) {
-        double angle = data.definitionPoint.angleTo(pos);
-        double radius=0.0;
-        if (entity->rtti()==RS2::EntityArc) {
-            radius = ((RS_Arc*)entity)->getRadius();
-        } else if (entity->rtti()==RS2::EntityCircle) {
-            radius = ((RS_Circle*)entity)->getRadius();
-        }
-
-        edata.definitionPoint.setPolar(radius, angle);
-        edata.definitionPoint += data.definitionPoint;
-    }
+void RS_ActionDimRadial::preparePreview()
+{
+       if (entity != NULL)
+       {
+               double angle = data.definitionPoint.angleTo(pos);
+               double radius = 0.0;
+
+               if (entity->rtti() == RS2::EntityArc)
+                       radius = ((RS_Arc *)entity)->getRadius();
+               else if (entity->rtti() == RS2::EntityCircle)
+                       radius = ((RS_Circle *)entity)->getRadius();
+
+               edata.definitionPoint.setPolar(radius, angle);
+               edata.definitionPoint += data.definitionPoint;
+       }
 }
 
+void RS_ActionDimRadial::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDimRadial::mouseMoveEvent begin");
 
+       //Vector mouse(graphicView->toGraphX(e->x()),
+       //                graphicView->toGraphY(e->y()));
 
-void RS_ActionDimRadial::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDimRadial::mouseMoveEvent begin");
-
-    //Vector mouse(graphicView->toGraphX(e->x()),
-    //                graphicView->toGraphY(e->y()));
+       switch (getStatus())
+       {
+       case SetEntity:
+               entity = catchEntity(e, RS2::ResolveAll);
+               break;
 
-    switch (getStatus()) {
-    case SetEntity:
-        entity = catchEntity(e, RS2::ResolveAll);
-        break;
+       case SetPos:
 
-    case SetPos:
-        if (entity!=NULL) {
-            pos = snapPoint(e);
+               if (entity != NULL)
+               {
+                       pos = snapPoint(e);
 
-            preparePreview();
+                       preparePreview();
 
-            RS_DimRadial* d = new RS_DimRadial(preview, data, edata);
-            d->update();
+                       RS_DimRadial * d = new RS_DimRadial(preview, data, edata);
+                       d->update();
 
-            deletePreview();
-            clearPreview();
-            preview->addEntity(d);
-            drawPreview();
-        }
-        break;
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(d);
+                       drawPreview();
+               }
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionDimRadial::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDimRadial::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDimRadial::mouseReleaseEvent(QMouseEvent* e) {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetEntity: {
-                RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-                if (en!=NULL) {
-                    if (en->rtti()==RS2::EntityArc ||
-                            en->rtti()==RS2::EntityCircle) {
-                        entity = en;
-                        if (entity->rtti()==RS2::EntityArc) {
-                            data.definitionPoint =
-                                ((RS_Arc*)entity)->getCenter();
-                        } else if (entity->rtti()==RS2::EntityCircle) {
-                            data.definitionPoint =
-                                ((RS_Circle*)entity)->getCenter();
-                        }
-                        graphicView->moveRelativeZero(data.definitionPoint);
-                        setStatus(SetPos);
-                    } else {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a circle "
-                                                            "or arc entity"));
-                    }
-                }
-            }
-            break;
-
-        case SetPos: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        clearPreview();
-        init(getStatus()-1);
-    }
+void RS_ActionDimRadial::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity: {
+                       RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+                       if (en != NULL)
+                       {
+                               if (en->rtti() == RS2::EntityArc
+                                   || en->rtti() == RS2::EntityCircle)
+                               {
+                                       entity = en;
+
+                                       if (entity->rtti() == RS2::EntityArc)
+                                               data.definitionPoint =
+                                                       ((RS_Arc *)entity)->getCenter();
+                                       else if (entity->rtti() == RS2::EntityCircle)
+                                               data.definitionPoint =
+                                                       ((RS_Circle *)entity)->getCenter();
+                                       graphicView->moveRelativeZero(data.definitionPoint);
+                                       setStatus(SetPos);
+                               }
+                               else
+                                       RS_DIALOGFACTORY->commandMessage(tr("Not a circle "
+                                                       "or arc entity"));
+                       }
+               }
+               break;
+
+               case SetPos: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               clearPreview();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDimRadial::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPos:
-        pos = e->getCoordinate();
-        trigger();
-        reset();
-        setStatus(SetEntity);
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDimRadial::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       switch (getStatus())
+       {
+       case SetPos:
+               pos = *e;
+               trigger();
+               reset();
+               setStatus(SetEntity);
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDimRadial::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    // setting new text label:
-    if (getStatus()==SetText) {
-        setText(c);
-        RS_DIALOGFACTORY->requestOptions(this, true, true);
-        graphicView->enableCoordinateInput();
-        setStatus(lastStatus);
-        return;
-    }
-
-    // command: text
-    if (checkCommand("text", c)) {
-        lastStatus = (Status)getStatus();
-        graphicView->disableCoordinateInput();
-        setStatus(SetText);
-    }
-
-    // setting angle
-    if (getStatus()==SetPos) {
-        bool ok;
-        double a = RS_Math::eval(c, &ok);
-        if (ok==true) {
-            pos.setPolar(1.0, RS_Math::deg2rad(a));
-            pos += data.definitionPoint;
-            trigger();
-            reset();
-            setStatus(SetEntity);
-        } else {
-            RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-        }
-        return;
-    }
+void RS_ActionDimRadial::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       // setting new text label:
+       if (getStatus() == SetText)
+       {
+               setText(c);
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               graphicView->enableCoordinateInput();
+               setStatus(lastStatus);
+               return;
+       }
+
+       // command: text
+       if (checkCommand("text", c))
+       {
+               lastStatus = (Status)getStatus();
+               graphicView->disableCoordinateInput();
+               setStatus(SetText);
+       }
+
+       // setting angle
+       if (getStatus() == SetPos)
+       {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       pos.setPolar(1.0, RS_Math::deg2rad(a));
+                       pos += data.definitionPoint;
+                       trigger();
+                       reset();
+                       setStatus(SetEntity);
+               }
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+               return;
+       }
 }
 
+QStringList RS_ActionDimRadial::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetEntity:
+       case SetPos:
+               cmd += command("text");
+               break;
 
-QStringList RS_ActionDimRadial::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetEntity:
-    case SetPos:
-        cmd += command("text");
-        break;
-
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-void RS_ActionDimRadial::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select arc or circle entity"),
-                                            tr("Cancel"));
-        break;
-    case SetPos:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify dimension line position or enter angle:"),
-            tr("Cancel"));
-        break;
-    case SetText:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDimRadial::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select arc or circle entity"),
+                       tr("Cancel"));
+               break;
+
+       case SetPos:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify dimension line position or enter angle:"),
+                       tr("Cancel"));
+               break;
+
+       case SetText:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), "");
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDimRadial::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDimRadial::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
-    //RS_DIALOGFACTORY->requestDimRadialOptions(edata, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
+       //RS_DIALOGFACTORY->requestDimRadialOptions(edata, true);
 }
 
+void RS_ActionDimRadial::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDimRadial::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    //RS_DIALOGFACTORY->requestDimRadialOptions(edata, false);
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       //RS_DIALOGFACTORY->requestDimRadialOptions(edata, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
 // EOF
index ed8053fede8499416b39e5ca99d0602238df1e8c..475aa949121fd22c497caf5a0706e917c582c0f8 100644 (file)
@@ -1,88 +1,52 @@
-/****************************************************************************
-** $Id: rs_actiondimradial.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDIMRADIAL_H
 #define RS_ACTIONDIMRADIAL_H
 
 #include "rs_actiondimension.h"
 #include "rs_dimradial.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to draw radial dimensions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDimRadial : public RS_ActionDimension {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetEntity,     /**< Choose entity. */
-        SetPos,      /**< Choose point. */
-               SetText        /**< Setting text label in the command line. */
-    };
-
-public:
-    RS_ActionDimRadial(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDimRadial() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDimRadial;
-       }
-
-       virtual void reset();
-       
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseButtonHints();
-
-
-private:
-    /** Chosen entity (arc / circle) */
-    RS_Entity* entity;
-       /** Chosen position */
-       Vector pos;
-    /** Data of new dimension */
-    RS_DimRadialData edata;
-       /** Last status before entering text. */
-       Status lastStatus;
+class RS_ActionDimRadial: public RS_ActionDimension
+{
+       private:
+               enum Status {
+                       SetEntity,     /**< Choose entity. */
+                       SetPos,        /**< Choose point. */
+                       SetText        /**< Setting text label in the command line. */
+               };
+
+       public:
+               RS_ActionDimRadial(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDimRadial();
+
+               virtual RS2::ActionType rtti();
+               virtual void reset();
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+
+       private:
+               /** Chosen entity (arc / circle) */
+               RS_Entity * entity;
+               /** Chosen position */
+               Vector pos;
+               /** Data of new dimension */
+               RS_DimRadialData edata;
+               /** Last status before entering text. */
+               Status lastStatus;
 };
 
 #endif
index 2064d718c1f5c9f3fa8c6d18c9ba796cab184302..c4fded99e432b67f4927e08e04fdc1c121c61aec 100644 (file)
@@ -1,55 +1,34 @@
-/****************************************************************************
-** $Id: rs_actiondrawarc.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawarc.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawarc.h"
 
 #include "commands.h"
-#include "rs_snapper.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 RS_ActionDrawArc::RS_ActionDrawArc(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw arcs", container, graphicView)
 {
-    reset();
+       reset();
 }
 
 RS_ActionDrawArc::~RS_ActionDrawArc()
 {
 }
 
-QAction * RS_ActionDrawArc::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
-       QAction * action = new QAction(tr("&Center, Point, Angles"), 0);
-//     QAction* action = new QAction(tr("Arc: Center, Point, Angles"),
-//                                                                     tr("&Center, Point, Angles"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw arcs"));
-       return action;
-}
-
 RS2::ActionType RS_ActionDrawArc::rtti()
 {
        return RS2::ActionDrawArc;
@@ -112,6 +91,7 @@ void RS_ActionDrawArc::mouseMoveEvent(QMouseEvent * e)
                break;
 
        case SetRadius:
+
                if (data.center.valid)
                {
                        data.radius = data.center.distanceTo(mouse);
@@ -155,6 +135,7 @@ void RS_ActionDrawArc::mouseMoveEvent(QMouseEvent * e)
        case SetChordLength:
        {
                double x = data.center.distanceTo(mouse);
+
                if (fabs(x / (2 * data.radius)) <= 1.0)
                {
                        data.angle2 = data.angle1 + asin(x / (2 * data.radius)) * 2;
@@ -164,11 +145,10 @@ void RS_ActionDrawArc::mouseMoveEvent(QMouseEvent * e)
                        drawPreview();
                }
        }
-               break;
+       break;
 
        default:
                break;
-
        }
 
        RS_DEBUG->print("RS_ActionDrawArc::mouseMoveEvent end");
@@ -178,7 +158,7 @@ void RS_ActionDrawArc::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -189,45 +169,46 @@ void RS_ActionDrawArc::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawArc::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawArc::coordinateEvent(Vector * e)
 {
-    if (e == NULL)
-        return;
+       if (e == NULL)
+               return;
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
-    switch (getStatus())
+       switch (getStatus())
        {
-    case SetCenter:
-        data.center = mouse;
-        graphicView->moveRelativeZero(mouse);
-        //deleteSnapper();
-        setStatus(SetRadius);
-        break;
+       case SetCenter:
+               data.center = mouse;
+               graphicView->moveRelativeZero(mouse);
+               //deleteSnapper();
+               setStatus(SetRadius);
+               break;
 
-    case SetRadius:
-        if (data.center.valid)
-            data.radius = data.center.distanceTo(mouse);
+       case SetRadius:
+
+               if (data.center.valid)
+                       data.radius = data.center.distanceTo(mouse);
 
                setStatus(SetAngle1);
-        break;
+               break;
 
-    case SetAngle1:
-        data.angle1 = data.center.angleTo(mouse);
-        setStatus(SetAngle2);
-        break;
+       case SetAngle1:
+               data.angle1 = data.center.angleTo(mouse);
+               setStatus(SetAngle2);
+               break;
 
-    case SetAngle2:
-        data.angle2 = data.center.angleTo(mouse);
-        trigger();
-        break;
+       case SetAngle2:
+               data.angle2 = data.center.angleTo(mouse);
+               trigger();
+               break;
 
-    case SetIncAngle:
-        data.angle2 = data.angle1 + data.center.angleTo(mouse);
-        trigger();
-        break;
+       case SetIncAngle:
+               data.angle2 = data.angle1 + data.center.angleTo(mouse);
+               trigger();
+               break;
 
-    case SetChordLength:
+       case SetChordLength:
        {
                double x = data.center.distanceTo(mouse);
 
@@ -237,187 +218,199 @@ void RS_ActionDrawArc::coordinateEvent(RS_CoordinateEvent * e)
                        trigger();
                }
        }
-        break;
+       break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
 void RS_ActionDrawArc::commandEvent(RS_CommandEvent * e)
 {
-    QString c = e->getCommand().toLower();
-
-    if (RS_COMMANDS->checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    if (RS_COMMANDS->checkCommand("reversed", c)) {
-        e->accept();
-        setReversed(!isReversed());
-
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-
-    case SetRadius: {
-            bool ok;
-            double r = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.radius = r;
-                setStatus(SetAngle1);
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    case SetAngle1: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.angle1 = RS_Math::deg2rad(a);
-                setStatus(SetAngle2);
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    case SetAngle2: {
-            if (RS_COMMANDS->checkCommand("angle", c)) {
-                setStatus(SetIncAngle);
-            } else if (RS_COMMANDS->checkCommand("chord length", c)) {
-                setStatus(SetChordLength);
-            } else {
-                bool ok;
-                double a = RS_Math::eval(c, &ok);
-                if (ok==true) {
-                    data.angle2 = RS_Math::deg2rad(a);
-                    trigger();
-                } else {
-                    if (RS_DIALOGFACTORY!=NULL) {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                    }
-                }
-            }
-        }
-        break;
-
-    case SetIncAngle: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.angle2 = data.angle1 + RS_Math::deg2rad(a);
-                trigger();
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    case SetChordLength: {
-            bool ok;
-            double l = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                if (fabs(l/(2*data.radius))<=1.0) {
-                    data.angle2 = data.angle1 + asin(l/(2*data.radius)) * 2;
-                    trigger();
-                } else {
-                    if (RS_DIALOGFACTORY!=NULL) {
-                        RS_DIALOGFACTORY->commandMessage(
-                            tr("Not a valid chord length"));
-                    }
-                }
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
+       QString c = e->getCommand().toLower();
+
+       if (RS_COMMANDS->checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
+
+       if (RS_COMMANDS->checkCommand("reversed", c))
+       {
+               e->accept();
+               setReversed(!isReversed());
+
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetRadius: {
+               bool ok;
+               double r = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       data.radius = r;
+                       setStatus(SetAngle1);
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+       }
+       break;
+
+       case SetAngle1: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       data.angle1 = RS_Math::deg2rad(a);
+                       setStatus(SetAngle2);
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+       }
+       break;
+
+       case SetAngle2:
+
+               if (RS_COMMANDS->checkCommand("angle", c))
+                       setStatus(SetIncAngle);
+               else if (RS_COMMANDS->checkCommand("chord length", c))
+                       setStatus(SetChordLength);
+               else
+               {
+                       bool ok;
+                       double a = RS_Math::eval(c, &ok);
+
+                       if (ok == true)
+                       {
+                               data.angle2 = RS_Math::deg2rad(a);
+                               trigger();
+                       }
+                       else if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+               }
+               break;
+
+       case SetIncAngle: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       data.angle2 = data.angle1 + RS_Math::deg2rad(a);
+                       trigger();
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+       }
+       break;
+
+       case SetChordLength: {
+               bool ok;
+               double l = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       if (fabs(l / (2 * data.radius)) <= 1.0)
+                       {
+                               data.angle2 = data.angle1 + asin(l / (2 * data.radius)) * 2;
+                               trigger();
+                       }
+                       else if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->commandMessage(
+                                       tr("Not a valid chord length"));
+
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
 QStringList RS_ActionDrawArc::getAvailableCommands()
 {
-    QStringList cmd;
-    cmd += RS_COMMANDS->command("reversed");
-    return cmd;
+       QStringList cmd;
+       cmd += RS_COMMANDS->command("reversed");
+       return cmd;
 }
 
 void RS_ActionDrawArc::updateMouseButtonHints()
 {
-    if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY != NULL)
        {
-        switch (getStatus())
+               switch (getStatus())
                {
-        case SetCenter:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify center"), tr("Cancel"));
-            break;
-        case SetRadius:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify radius"), tr("Back"));
-            break;
-        case SetAngle1:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify start angle:"), tr("Back"));
-            break;
-        case SetAngle2:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify end angle or [Angle/chord Length]"),
-                tr("Back"));
-            break;
-        case SetIncAngle:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify included angle:"),
-                                                tr("Back"));
-            break;
-        case SetChordLength:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify chord length:"),
-                                                tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+               case SetCenter:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify center"), tr("Cancel"));
+                       break;
+
+               case SetRadius:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify radius"), tr("Back"));
+                       break;
+
+               case SetAngle1:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify start angle:"), tr("Back"));
+                       break;
+
+               case SetAngle2:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify end angle or [Angle/chord Length]"),
+                               tr("Back"));
+                       break;
+
+               case SetIncAngle:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify included angle:"),
+                               tr("Back"));
+                       break;
+
+               case SetChordLength:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify chord length:"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
 void RS_ActionDrawArc::showOptions()
 {
-    RS_ActionInterface::showOptions();
+       RS_ActionInterface::showOptions();
 
-    if (RS_DIALOGFACTORY != NULL)
-        RS_DIALOGFACTORY->requestOptions(this, true);
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
 void RS_ActionDrawArc::hideOptions()
 {
-    RS_ActionInterface::hideOptions();
+       RS_ActionInterface::hideOptions();
 
-    if (RS_DIALOGFACTORY != NULL)
-        RS_DIALOGFACTORY->requestOptions(this, false);
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
 void RS_ActionDrawArc::updateMouseCursor()
 {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
 void RS_ActionDrawArc::updateToolBar()
@@ -440,3 +433,4 @@ void RS_ActionDrawArc::setReversed(bool r)
 {
        data.reversed = r;
 }
+
index e12c59e71b9b81d44402238da43e2cbbf25b70f9..6edc795168ca8ac1ca5bdda42ba14480405efe16 100644 (file)
@@ -1,29 +1,3 @@
-/****************************************************************************
-** $Id: rs_actiondrawarc.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWARC_H
 #define RS_ACTIONDRAWARC_H
 
  */
 class RS_ActionDrawArc: public RS_PreviewActionInterface
 {
-//     //Q_OBJECT
        public:
                /**
-               * Action States.
-               */
+                * Action States.
+                */
                enum Status {
                        SetCenter,       /**< Setting the center point. */
                        SetRadius,       /**< Setting the radius. */
@@ -56,42 +29,28 @@ class RS_ActionDrawArc: public RS_PreviewActionInterface
                RS_ActionDrawArc(RS_EntityContainer & container, RS_GraphicView & graphicView);
                ~RS_ActionDrawArc();
 
-               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
                virtual RS2::ActionType rtti();
                void reset();
-
                virtual void init(int status = 0);
                virtual void trigger();
-
                virtual void mouseMoveEvent(QMouseEvent * e);
                virtual void mouseReleaseEvent(QMouseEvent * e);
-
-               virtual void coordinateEvent(RS_CoordinateEvent * e);
+               virtual void coordinateEvent(Vector * e);
                virtual void commandEvent(RS_CommandEvent * e);
                virtual QStringList getAvailableCommands();
-
                virtual void hideOptions();
                virtual void showOptions();
-
                virtual void updateMouseButtonHints();
                virtual void updateMouseCursor();
                virtual void updateToolBar();
-
                bool isReversed();
-               void setReversed(bool r);
+               void setReversed(bool r);
 
        protected:
                /**
                 * Arc data defined so far.
                 */
                RS_ArcData data;
-               /**
-                * Commands
-                */
-               /*QString cmdReversed;
-               QString cmdReversed2;
-               QString cmdReversed3;
-               */
 };
 
 #endif
index 9c80b67015a016971867ca5202c7039e3e184cb8..6f5d641851b53fbabb65499d4ecb9ec817a36836 100644 (file)
@@ -1,55 +1,35 @@
-/****************************************************************************
-** $Id: rs_actiondrawarc3p.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawarc3p.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawarc3p.h"
 
 #include "rs_actiondrawarc.h"
 #include "commands.h"
-#include "rs_snapper.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDrawArc3P::RS_ActionDrawArc3P(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDrawArc3P::RS_ActionDrawArc3P(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw arcs 3P", container, graphicView)
 {
-    reset();
+       reset();
 }
 
 RS_ActionDrawArc3P::~RS_ActionDrawArc3P()
 {
 }
 
-QAction * RS_ActionDrawArc3P::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
-       QAction * action = new QAction(tr("&3 Points"), 0);
-//     QAction* action = new QAction(tr("Arc: 3 Points"), tr("&3 Points"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw arcs with 3 points"));
-       return action;
-}
-
 void RS_ActionDrawArc3P::reset()
 {
        data.reset();
@@ -95,9 +75,7 @@ void RS_ActionDrawArc3P::trigger()
                reset();
        }
        else
-       {
                RS_DIALOGFACTORY->commandMessage(tr("Invalid arc data."));
-       }
 }
 
 void RS_ActionDrawArc3P::preparePreview()
@@ -162,7 +140,7 @@ void RS_ActionDrawArc3P::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -173,12 +151,12 @@ void RS_ActionDrawArc3P::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawArc3P::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawArc3P::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
        switch (getStatus())
        {
@@ -235,12 +213,15 @@ void RS_ActionDrawArc3P::updateMouseButtonHints()
        case SetPoint1:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify startpoint or [Center]"), tr("Cancel"));
                break;
+
        case SetPoint2:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second point"), tr("Back"));
                break;
+
        case SetPoint3:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify endpoint"), tr("Back"));
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
@@ -259,3 +240,4 @@ void RS_ActionDrawArc3P::updateToolBar()
        else
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs);
 }
+
index 8851220b2b1cafa0a026405638981395b932d125..052c09556fbc25fb03fefec6cff557266c325c65 100644 (file)
@@ -1,95 +1,62 @@
-/****************************************************************************
-** $Id: rs_actiondrawarc3p.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWARC3P_H
 #define RS_ACTIONDRAWARC3P_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_arc.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * arcs with three points given.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawArc3P : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetPoint1,       /**< Setting the 1st point. */
-        SetPoint2,       /**< Setting the 2nd point. */
-        SetPoint3        /**< Setting the 3rd point. */
-    };
-
-public:
-    RS_ActionDrawArc3P(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionDrawArc3P();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    void reset();
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /**
-     * Arc data defined so far.
-     */
-    RS_ArcData data;
-    /**
-     * 1st point.
-     */
-    Vector point1;
-    /**
-     * 2nd point.
-     */
-    Vector point2;
-    /**
-     * 3nd point.
-     */
-    Vector point3;
+class RS_ActionDrawArc3P: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetPoint1,       /**< Setting the 1st point. */
+                       SetPoint2,       /**< Setting the 2nd point. */
+                       SetPoint3        /**< Setting the 3rd point. */
+               };
+
+       public:
+               RS_ActionDrawArc3P(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawArc3P();
+
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /**
+                * Arc data defined so far.
+                */
+               RS_ArcData data;
+               /**
+                * 1st point.
+                */
+               Vector point1;
+               /**
+                * 2nd point.
+                */
+               Vector point2;
+               /**
+                * 3nd point.
+                */
+               Vector point3;
 };
 
 #endif
index 809510468375f980068b3cc86d569fce1017d3ac..25d52bc3774914a2d9648fd28ac40b1d9129e192 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawarctangential.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawarctangential.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawarctangential.h"
 
-#include "commands.h"
-#include "rs_snapper.h"
 #include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDrawArcTangential::RS_ActionDrawArcTangential(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw arcs tangential",
-                           container, graphicView) {
-    reset();
+RS_ActionDrawArcTangential::RS_ActionDrawArcTangential(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw arcs tangential",
+               container, graphicView)
+{
+       reset();
 }
 
-
-
-RS_ActionDrawArcTangential::~RS_ActionDrawArcTangential() {}
-
-
-QAction* RS_ActionDrawArcTangential::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawArcTangential::~RS_ActionDrawArcTangential()
 {
-       QAction * action = new QAction(tr("&Tangential"), 0);
-//     QAction* action = new QAction(tr("Arc: Tangential"),
-//                                                                     tr("&Tangential"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw arcs tangential to base entity"));
-       return action;
 }
 
-
-void RS_ActionDrawArcTangential::reset() {
-    baseEntity = NULL;
-    isStartPoint = false;
-    point = Vector(false);
+/*virtual*/ RS2::ActionType RS_ActionDrawArcTangential::rtti()
+{
+       return RS2::ActionDrawArcTangential;
 }
 
-
-
-void RS_ActionDrawArcTangential::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    //reset();
+void RS_ActionDrawArcTangential::reset()
+{
+       baseEntity = NULL;
+       isStartPoint = false;
+       point = Vector(false);
 }
 
-
-
-void RS_ActionDrawArcTangential::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    if (point.valid==false || baseEntity==NULL) {
-        RS_DEBUG->print("RS_ActionDrawArcTangential::trigger: "
-                        "conditions not met");
-        return;
-    }
-
-    preparePreview();
-    RS_Arc* arc = new RS_Arc(container, data);
-    arc->setLayerToActive();
-    arc->setPenToActive();
-    container->addEntity(arc);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(arc);
-        document->endUndoCycle();
-    }
-
-    deleteSnapper();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(arc);
-    graphicView->moveRelativeZero(arc->getCenter());
-    drawSnapper();
-
-    setStatus(SetBaseEntity);
-    reset();
+void RS_ActionDrawArcTangential::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
+       //reset();
 }
 
-
-
-void RS_ActionDrawArcTangential::preparePreview() {
-    if (baseEntity!=NULL && point.valid) {
-        Vector startPoint;
-        double direction;
-        if (isStartPoint) {
-            startPoint = baseEntity->getStartpoint();
-            direction = RS_Math::correctAngle(baseEntity->getDirection1()+M_PI);
-        } else {
-            startPoint = baseEntity->getEndpoint();
-            direction = RS_Math::correctAngle(baseEntity->getDirection2()+M_PI);
-        }
-
-        RS_Arc arc(NULL, RS_ArcData());
-        bool suc = arc.createFrom2PDirectionRadius(startPoint, point, direction, data.radius);
-        if (suc) {
-            data = arc.getData();
-        }
-    }
+void RS_ActionDrawArcTangential::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       if (point.valid == false || baseEntity == NULL)
+       {
+               RS_DEBUG->print("RS_ActionDrawArcTangential::trigger: "
+                       "conditions not met");
+               return;
+       }
+
+       preparePreview();
+       RS_Arc * arc = new RS_Arc(container, data);
+       arc->setLayerToActive();
+       arc->setPenToActive();
+       container->addEntity(arc);
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(arc);
+               document->endUndoCycle();
+       }
+
+       deleteSnapper();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(arc);
+       graphicView->moveRelativeZero(arc->getCenter());
+       drawSnapper();
+
+       setStatus(SetBaseEntity);
+       reset();
 }
 
-
-void RS_ActionDrawArcTangential::mouseMoveEvent(QMouseEvent* e) {
-    switch (getStatus()) {
-    case SetBaseEntity:
-        break;
-
-    case SetEndAngle: {
-            point = snapPoint(e);
-            preparePreview();
-            if (data.isValid()) {
-                RS_Arc* arc = new RS_Arc(preview, data);
-                deletePreview();
-                clearPreview();
-                preview->addEntity(arc);
-                drawPreview();
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawArcTangential::preparePreview()
+{
+       if (baseEntity != NULL && point.valid)
+       {
+               Vector startPoint;
+               double direction;
+
+               if (isStartPoint)
+               {
+                       startPoint = baseEntity->getStartpoint();
+                       direction = RS_Math::correctAngle(baseEntity->getDirection1() + M_PI);
+               }
+               else
+               {
+                       startPoint = baseEntity->getEndpoint();
+                       direction = RS_Math::correctAngle(baseEntity->getDirection2() + M_PI);
+               }
+
+               RS_Arc arc(NULL, RS_ArcData());
+               bool suc = arc.createFrom2PDirectionRadius(startPoint, point, direction, data.radius);
+
+               if (suc)
+                       data = arc.getData();
+       }
 }
 
-
-
-void RS_ActionDrawArcTangential::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-
-            // set base entity:
-        case SetBaseEntity: {
-                Vector coord = graphicView->toGraph(e->x(), e->y());
-                RS_Entity* entity = catchEntity(coord, RS2::ResolveAll);
-                if (entity!=NULL) {
-                    if (entity->isAtomic()) {
-                        baseEntity = (RS_AtomicEntity*)entity;
-                        if (baseEntity->getStartpoint().distanceTo(coord) <
-                                baseEntity->getEndpoint().distanceTo(coord)) {
-                            isStartPoint = true;
-                        } else {
-                            isStartPoint = false;
-                        }
-                        setStatus(SetEndAngle);
-                        updateMouseButtonHints();
-                    } else {
-                        // TODO: warning
-                    }
-                }
-                else {
-                    deleteSnapper();
-                }
-            }
-            break;
-
-            // set angle (point that defines the angle)
-        case SetEndAngle: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawArcTangential::mouseMoveEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
+       case SetBaseEntity:
+               break;
+
+       case SetEndAngle:
+               point = snapPoint(e);
+               preparePreview();
+
+               if (data.isValid())
+               {
+                       RS_Arc * arc = new RS_Arc(preview, data);
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(arc);
+                       drawPreview();
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
+void RS_ActionDrawArcTangential::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               // set base entity:
+               case SetBaseEntity: {
+                       Vector coord = graphicView->toGraph(e->x(), e->y());
+                       RS_Entity * entity = catchEntity(coord, RS2::ResolveAll);
+
+                       if (entity != NULL)
+                       {
+                               if (entity->isAtomic())
+                               {
+                                       baseEntity = (RS_AtomicEntity *)entity;
+
+                                       if (baseEntity->getStartpoint().distanceTo(coord)
+                                           < baseEntity->getEndpoint().distanceTo(coord))
+                                               isStartPoint = true;
+                                       else
+                                               isStartPoint = false;
+                                       setStatus(SetEndAngle);
+                                       updateMouseButtonHints();
+                               }
+                               else
+                               {
+                                       // TODO: warning
+                               }
+                       }
+                       else
+                               deleteSnapper();
+               }
+               break;
+
+               // set angle (point that defines the angle)
+               case SetEndAngle: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
+}
 
+void RS_ActionDrawArcTangential::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-void RS_ActionDrawArcTangential::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-    Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
-    switch (getStatus()) {
-    case SetBaseEntity:
-        break;
+       switch (getStatus())
+       {
+       case SetBaseEntity:
+               break;
 
-    case SetEndAngle:
-        point = mouse;
-        trigger();
-        break;
+       case SetEndAngle:
+               point = mouse;
+               trigger();
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawArcTangential::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
+void RS_ActionDrawArcTangential::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
 }
 
-
-
-QStringList RS_ActionDrawArcTangential::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+QStringList RS_ActionDrawArcTangential::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
+void RS_ActionDrawArcTangential::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-void RS_ActionDrawArcTangential::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
-    updateMouseButtonHints();
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
+       updateMouseButtonHints();
 }
 
+void RS_ActionDrawArcTangential::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawArcTangential::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionDrawArcTangential::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetBaseEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify base entity"),
-            tr("Cancel"));
-        break;
-    case SetEndAngle:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify end angle"), tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDrawArcTangential::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetBaseEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify base entity"),
+                       tr("Cancel"));
+               break;
+
+       case SetEndAngle:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify end angle"), tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawArcTangential::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawArcTangential::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawArcTangential::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs);
-    }
+void RS_ActionDrawArcTangential::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs);
 }
 
+void RS_ActionDrawArcTangential::setRadius(double r)
+{
+       data.radius = r;
+}
 
-// EOF
+double RS_ActionDrawArcTangential::getRadius()
+{
+       return data.radius;
+}
 
index 5a90dcb333952d21ddc0ae803beba2ff4a8e57a0..bca26bdf222ed4b6d8cab120ee742beec2e36ef9 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawarctangential.h 1155 2004-11-18 16:01:06Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWARCTANGENTIAL_H
 #define RS_ACTIONDRAWARCTANGENTIAL_H
 
 #include "rs_previewactioninterface.h"
 #include "rs_arc.h"
+#include "vector.h"
+
+class RS_AtomicEntity;
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * arcs with three points given.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawArcTangential : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-               SetBaseEntity,   /**< Setting base entity. */
-               SetEndAngle      /**< Setting end angle. */
-    };
-
-public:
-    RS_ActionDrawArcTangential(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionDrawArcTangential();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawArcTangential;
-       }
-
-    void reset();
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-    
-       virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
+class RS_ActionDrawArcTangential: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetBaseEntity,   /**< Setting base entity. */
+                       SetEndAngle      /**< Setting end angle. */
+               };
 
-       void setRadius(double r) {
-               data.radius = r;
-       }
+       public:
+               RS_ActionDrawArcTangential(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawArcTangential();
 
-       double getRadius() {
-               return data.radius;
-       }
+               virtual RS2::ActionType rtti();
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setRadius(double r);
+               double getRadius();
 
-protected:
-    /**
-     * Base entity.
-     */
-    RS_AtomicEntity* baseEntity;
-       /**
-        * Start point of base entity clicked?
-        */
-       bool isStartPoint;
-    /**
-     * Point that determines end angle.
-     */
-    Vector point;
-    /**
-        * Arc data calculated.
-        */
-       RS_ArcData data;
+       protected:
+               /**
+                * Base entity.
+                */
+               RS_AtomicEntity * baseEntity;
+               /**
+                * Start point of base entity clicked?
+                */
+               bool isStartPoint;
+               /**
+                * Point that determines end angle.
+                */
+               Vector point;
+               /**
+                * Arc data calculated.
+                */
+               RS_ArcData data;
 };
 
 #endif
index 1c4da96bbf5e42306c166e05ae9619d2d00f0afd..54baf3107ec6bf1ed316e502dd30934adbb0a174 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawcircle.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawcircle.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawcircle.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDrawCircle::RS_ActionDrawCircle(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDrawCircle::RS_ActionDrawCircle(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw circles", container, graphicView)
 {
-    reset();
+       reset();
 }
 
-RS_ActionDrawCircle::~RS_ActionDrawCircle() {}
-
-QAction * RS_ActionDrawCircle::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionDrawCircle::~RS_ActionDrawCircle()
 {
-       QAction * action = new QAction(tr("Center, &Point"), 0);
-//     QAction* action = new QAction(tr("Circle: Center, Point"),
-//                                                                     tr("Center, &Point"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw circles with center and point"));
-       return action;
 }
 
-void RS_ActionDrawCircle::reset()
+/*virtual*/ RS2::ActionType RS_ActionDrawCircle::rtti()
 {
-    data = RS_CircleData(Vector(false), 0.0);
+       return RS2::ActionDrawCircle;
 }
 
-
-
-void RS_ActionDrawCircle::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+void RS_ActionDrawCircle::reset()
+{
+       data = RS_CircleData(Vector(false), 0.0);
 }
 
+void RS_ActionDrawCircle::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-
-void RS_ActionDrawCircle::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    RS_Circle* circle = new RS_Circle(container,
-                                      data);
-    circle->setLayerToActive();
-    circle->setPenToActive();
-    container->addEntity(circle);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(circle);
-        document->endUndoCycle();
-    }
-    deleteSnapper();
-    Vector rz = graphicView->getRelativeZero();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(circle);
-    graphicView->moveRelativeZero(circle->getCenter());
-    drawSnapper();
-
-    setStatus(SetCenter);
-    reset();
-
-    RS_DEBUG->print("RS_ActionDrawCircle::trigger(): circle added: %d",
-                    circle->getId());
+       reset();
 }
 
-
-
-void RS_ActionDrawCircle::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawCircle::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
-    switch (getStatus()) {
-    case SetCenter:
-        data.center = mouse;
-        break;
-
-    case SetRadius:
-        if (data.center.valid) {
-            data.radius = data.center.distanceTo(mouse);
-            deletePreview();
-            clearPreview();
-            preview->addEntity(new RS_Circle(preview,
-                                             data));
-            drawPreview();
-        }
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDrawCircle::mouseMoveEvent end");
+void RS_ActionDrawCircle::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       RS_Circle * circle = new RS_Circle(container, data);
+       circle->setLayerToActive();
+       circle->setPenToActive();
+       container->addEntity(circle);
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(circle);
+               document->endUndoCycle();
+       }
+
+       deleteSnapper();
+       Vector rz = graphicView->getRelativeZero();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(circle);
+       graphicView->moveRelativeZero(circle->getCenter());
+       drawSnapper();
+
+       setStatus(SetCenter);
+       reset();
+
+       RS_DEBUG->print("RS_ActionDrawCircle::trigger(): circle added: %d", circle->getId());
 }
 
-
-
-void RS_ActionDrawCircle::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawCircle::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawCircle::mouseMoveEvent begin");
+
+       Vector mouse = snapPoint(e);
+
+       switch (getStatus())
+       {
+       case SetCenter:
+               data.center = mouse;
+               break;
+
+       case SetRadius:
+
+               if (data.center.valid)
+               {
+                       data.radius = data.center.distanceTo(mouse);
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(new RS_Circle(preview,
+                                       data));
+                       drawPreview();
+               }
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionDrawCircle::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawCircle::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetCenter:
-        data.center = mouse;
-        graphicView->moveRelativeZero(mouse);
-        setStatus(SetRadius);
-        break;
-
-    case SetRadius:
-        if (data.center.valid) {
-            graphicView->moveRelativeZero(mouse);
-            data.radius = data.center.distanceTo(mouse);
-            trigger();
-        }
-        //setStatus(SetCenter);
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawCircle::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawCircle::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-
-    case SetRadius: {
-            bool ok;
-            double r = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.radius = r;
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(
-                        tr("Not a valid expression"));
-                }
-            }
-            trigger();
-            //setStatus(SetCenter);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawCircle::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetCenter:
+               data.center = mouse;
+               graphicView->moveRelativeZero(mouse);
+               setStatus(SetRadius);
+               break;
+
+       case SetRadius:
+
+               if (data.center.valid)
+               {
+                       graphicView->moveRelativeZero(mouse);
+                       data.radius = data.center.distanceTo(mouse);
+                       trigger();
+               }
+               //setStatus(SetCenter);
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-QStringList RS_ActionDrawCircle::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+void RS_ActionDrawCircle::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetRadius: {
+               bool ok;
+               double r = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.radius = r;
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(
+                               tr("Not a valid expression"));
+
+               trigger();
+               //setStatus(SetCenter);
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionDrawCircle::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetCenter:
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify center"), tr("Cancel"));
-        }
-        break;
-    case SetRadius:
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify radius"), tr("Back"));
-        }
-        break;
-    default:
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-        }
-        break;
-    }
+QStringList RS_ActionDrawCircle::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
+void RS_ActionDrawCircle::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetCenter:
 
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify center"), tr("Cancel"));
+               break;
 
-void RS_ActionDrawCircle::showOptions() {
-    RS_ActionInterface::showOptions();
-}
+       case SetRadius:
 
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify radius"), tr("Back"));
+               break;
 
+       default:
 
-void RS_ActionDrawCircle::hideOptions() {
-    RS_ActionInterface::hideOptions();
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDrawCircle::showOptions()
+{
+       RS_ActionInterface::showOptions();
+}
 
-
-void RS_ActionDrawCircle::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawCircle::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 }
 
+void RS_ActionDrawCircle::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
+void RS_ActionDrawCircle::updateToolBar()
+{
+       if (!isFinished())
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       }
+       else if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
 
-void RS_ActionDrawCircle::updateToolBar() {
-    if (!isFinished()) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        }
-    } else {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
-        }
-    }
 }
 
-
 // EOF
 
index 63452c79119362582da6636d07d2ffc461f31adb..87572750ed3aa1ee5f8b8d75e61927c43671c426 100644 (file)
@@ -1,88 +1,50 @@
-/****************************************************************************
-** $Id: rs_actiondrawcircle.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWCIRCLE_H
 #define RS_ACTIONDRAWCIRCLE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_circle.h"
+#include "rs_previewactioninterface.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * circles with a given center and a point on the circle line.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawCircle : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetCenter,       /**< Setting the center point. */
-        SetRadius        /**< Setting the radius. */
-    };
-
-public:
-    RS_ActionDrawCircle(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionDrawCircle();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawCircle;
-       }
-
-    void reset();
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /**
-     * Circle data defined so far.
-     */
-    RS_CircleData data;
+class RS_ActionDrawCircle: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetCenter,       /**< Setting the center point. */
+                       SetRadius        /**< Setting the radius. */
+               };
+
+       public:
+               RS_ActionDrawCircle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawCircle();
+
+               virtual RS2::ActionType rtti();
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /**
+                * Circle data defined so far.
+                */
+               RS_CircleData data;
 };
 
 #endif
index 7721e057a259a9a3baa002ae3ec7273c8372ecc7..71c410abe56d2dc52620a5f1c999c97e0036fc0a 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawcircle2p.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawcircle2p.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawcircle2p.h"
-#include "rs_snapper.h"
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-RS_ActionDrawCircle2P::RS_ActionDrawCircle2P(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw circles",
-                           container, graphicView) {
-    reset();
+RS_ActionDrawCircle2P::RS_ActionDrawCircle2P(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw circles",
+               container, graphicView)
+{
+       reset();
 }
 
-
-
-RS_ActionDrawCircle2P::~RS_ActionDrawCircle2P() {}
-
-
-QAction* RS_ActionDrawCircle2P::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawCircle2P::~RS_ActionDrawCircle2P()
 {
-       QAction * action = new QAction(tr("2 Points"), 0);
-//     QAction* action = new QAction(tr("Circle: 2 Points"), tr("2 Points"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw circles with 2 points"));
-
-       return action;
 }
 
-
-void RS_ActionDrawCircle2P::reset() {
-    data.reset();
-    point1 = Vector(false);
-    point2 = Vector(false);
+void RS_ActionDrawCircle2P::reset()
+{
+       data.reset();
+       point1 = Vector(false);
+       point2 = Vector(false);
 }
 
+void RS_ActionDrawCircle2P::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-
-void RS_ActionDrawCircle2P::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+       reset();
 }
 
-
-
-void RS_ActionDrawCircle2P::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    preparePreview();
-    if (data.isValid()) {
-        RS_Circle* circle = new RS_Circle(container,
-                                          data);
-        circle->setLayerToActive();
-        circle->setPenToActive();
-        container->addEntity(circle);
-
-        // upd. undo list:
-        if (document!=NULL) {
-            document->startUndoCycle();
-            document->addUndoable(circle);
-            document->endUndoCycle();
-        }
-
-        deleteSnapper();
-        Vector rz = graphicView->getRelativeZero();
-        graphicView->moveRelativeZero(Vector(0.0,0.0));
-        graphicView->drawEntity(circle);
-        graphicView->moveRelativeZero(rz);
-        drawSnapper();
-
-        setStatus(SetPoint1);
-        reset();
-    } else {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->requestWarningDialog(tr("Invalid Circle data."));
-        }
-    }
+void RS_ActionDrawCircle2P::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       preparePreview();
+
+       if (data.isValid())
+       {
+               RS_Circle * circle = new RS_Circle(container, data);
+               circle->setLayerToActive();
+               circle->setPenToActive();
+               container->addEntity(circle);
+
+               // upd. undo list:
+               if (document != NULL)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(circle);
+                       document->endUndoCycle();
+               }
+
+               deleteSnapper();
+               Vector rz = graphicView->getRelativeZero();
+               graphicView->moveRelativeZero(Vector(0.0, 0.0));
+               graphicView->drawEntity(circle);
+               graphicView->moveRelativeZero(rz);
+               drawSnapper();
+
+               setStatus(SetPoint1);
+               reset();
+       }
+       else    if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestWarningDialog(tr("Invalid Circle data."));
 }
 
+void RS_ActionDrawCircle2P::preparePreview()
+{
+       data.reset();
 
+       if (point1.valid && point2.valid)
+       {
+               RS_Circle circle(NULL, data);
+               bool suc = circle.createFrom2P(point1, point2);
 
-void RS_ActionDrawCircle2P::preparePreview() {
-    data.reset();
-    if (point1.valid && point2.valid) {
-        RS_Circle circle(NULL, data);
-        bool suc = circle.createFrom2P(point1, point2);
-        if (suc) {
-            data = circle.getData();
-        }
-    }
+               if (suc)
+                       data = circle.getData();
+       }
 }
 
-
-void RS_ActionDrawCircle2P::mouseMoveEvent(QMouseEvent* e) {
-    Vector mouse = snapPoint(e);
-    switch (getStatus()) {
-    case SetPoint1:
-        point1 = mouse;
-        break;
-
-    case SetPoint2:
-        point2 = mouse;
-        preparePreview();
-        if (data.isValid()) {
-            RS_Circle* circle = new RS_Circle(preview, data);
-            deletePreview();
-            clearPreview();
-            preview->addEntity(circle);
-            drawPreview();
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawCircle2P::mouseMoveEvent(QMouseEvent * e)
+{
+       Vector mouse = snapPoint(e);
+
+       switch (getStatus())
+       {
+       case SetPoint1:
+               point1 = mouse;
+               break;
+
+       case SetPoint2:
+               point2 = mouse;
+               preparePreview();
+
+               if (data.isValid())
+               {
+                       RS_Circle * circle = new RS_Circle(preview, data);
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(circle);
+                       drawPreview();
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawCircle2P::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawCircle2P::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawCircle2P::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetPoint1:
-        point1 = mouse;
-        graphicView->moveRelativeZero(mouse);
-        setStatus(SetPoint2);
-        break;
-
-    case SetPoint2:
-        point2 = mouse;
-        graphicView->moveRelativeZero(mouse);
-        trigger();
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawCircle2P::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetPoint1:
+               point1 = mouse;
+               graphicView->moveRelativeZero(mouse);
+               setStatus(SetPoint2);
+               break;
+
+       case SetPoint2:
+               point2 = mouse;
+               graphicView->moveRelativeZero(mouse);
+               trigger();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawCircle2P::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
+void RS_ActionDrawCircle2P::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
 }
 
-
-
-QStringList RS_ActionDrawCircle2P::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+QStringList RS_ActionDrawCircle2P::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
-
-
-void RS_ActionDrawCircle2P::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetPoint1:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify first point"), tr("Cancel"));
-            break;
-        case SetPoint2:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify second point"), tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawCircle2P::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetPoint1:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify first point"), tr("Cancel"));
+                       break;
+
+               case SetPoint2:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify second point"), tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionDrawCircle2P::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawCircle2P::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawCircle2P::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
-        }
-    }
+void RS_ActionDrawCircle2P::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
+       }
 }
 
-
 // EOF
 
index 6f95f5bcb6375c4e29b58f32977142800bbdfa2e..97c0ef5f64a452bab117a8e2b0cc3ef9f4d671d9 100644 (file)
@@ -1,90 +1,57 @@
-/****************************************************************************
-** $Id: rs_actiondrawcircle2p.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWCIRCLE2P_H
 #define RS_ACTIONDRAWCIRCLE2P_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_circle.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * simple arcs with the center, radius, start- and endangle given.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawCircle2P : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetPoint1,       /**< Setting the 1st point. */
-        SetPoint2        /**< Setting the 2nd point. */
-    };
-
-public:
-    RS_ActionDrawCircle2P(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionDrawCircle2P();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    void reset();
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /**
-     * Circle data defined so far.
-     */
-    RS_CircleData data;
-    /**
-     * 1st point.
-     */
-    Vector point1;
-    /**
-     * 2nd point.
-     */
-    Vector point2;
+class RS_ActionDrawCircle2P: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetPoint1,       /**< Setting the 1st point. */
+                       SetPoint2        /**< Setting the 2nd point. */
+               };
+
+       public:
+               RS_ActionDrawCircle2P(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawCircle2P();
+
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /**
+                * Circle data defined so far.
+                */
+               RS_CircleData data;
+               /**
+                * 1st point.
+                */
+               Vector point1;
+               /**
+                * 2nd point.
+                */
+               Vector point2;
 };
 
 #endif
index ce4f29ee6415f63d52a000cc4c80f23f79dcf9f1..a65954354af1b5616a5a73c1ac1a01b963e04e99 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawcircle3p.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawcircle3p.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawcircle3p.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDrawCircle3P::RS_ActionDrawCircle3P(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw circles",
-                           container, graphicView) {
-    reset();
-}
-
-
-
-RS_ActionDrawCircle3P::~RS_ActionDrawCircle3P() {}
-
-
-QAction* RS_ActionDrawCircle3P::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawCircle3P::RS_ActionDrawCircle3P(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw circles",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("3 Points"), 0);
-//     QAction* action = new QAction(tr("Circle: 3 Points"), tr("3 Points"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw circles with 3 points"));
-
-       return action;
+       reset();
 }
 
-
-
-void RS_ActionDrawCircle3P::reset() {
-    data.reset();
-    point1 = Vector(false);
-    point2 = Vector(false);
-    point3 = Vector(false);
+RS_ActionDrawCircle3P::~RS_ActionDrawCircle3P()
+{
 }
 
-
-
-void RS_ActionDrawCircle3P::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+void RS_ActionDrawCircle3P::reset()
+{
+       data.reset();
+       point1 = Vector(false);
+       point2 = Vector(false);
+       point3 = Vector(false);
 }
 
+void RS_ActionDrawCircle3P::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-
-void RS_ActionDrawCircle3P::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    preparePreview();
-    if (data.isValid()) {
-        RS_Circle* circle = new RS_Circle(container,
-                                          data);
-        circle->setLayerToActive();
-        circle->setPenToActive();
-        container->addEntity(circle);
-
-        // upd. undo list:
-        if (document!=NULL) {
-            document->startUndoCycle();
-            document->addUndoable(circle);
-            document->endUndoCycle();
-        }
-        deleteSnapper();
-        Vector rz = graphicView->getRelativeZero();
-        graphicView->moveRelativeZero(Vector(0.0,0.0));
-        graphicView->drawEntity(circle);
-        graphicView->moveRelativeZero(rz);
-        drawSnapper();
-
-        setStatus(SetPoint1);
-        reset();
-    } else {
-        RS_DIALOGFACTORY->requestWarningDialog(tr("Invalid circle data."));
-    }
+       reset();
 }
 
-
-void RS_ActionDrawCircle3P::preparePreview() {
-    data.reset();
-    if (point1.valid && point2.valid && point3.valid) {
-        RS_Circle circle(NULL, data);
-        bool suc = circle.createFrom3P(point1, point2, point3);
-        if (suc) {
-            data = circle.getData();
-        }
-    }
+void RS_ActionDrawCircle3P::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       preparePreview();
+
+       if (data.isValid())
+       {
+               RS_Circle * circle = new RS_Circle(container,
+                               data);
+               circle->setLayerToActive();
+               circle->setPenToActive();
+               container->addEntity(circle);
+
+               // upd. undo list:
+               if (document != NULL)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(circle);
+                       document->endUndoCycle();
+               }
+               deleteSnapper();
+               Vector rz = graphicView->getRelativeZero();
+               graphicView->moveRelativeZero(Vector(0.0, 0.0));
+               graphicView->drawEntity(circle);
+               graphicView->moveRelativeZero(rz);
+               drawSnapper();
+
+               setStatus(SetPoint1);
+               reset();
+       }
+       else
+               RS_DIALOGFACTORY->requestWarningDialog(tr("Invalid circle data."));
 }
 
+void RS_ActionDrawCircle3P::preparePreview()
+{
+       data.reset();
 
+       if (point1.valid && point2.valid && point3.valid)
+       {
+               RS_Circle circle(NULL, data);
+               bool suc = circle.createFrom3P(point1, point2, point3);
 
-void RS_ActionDrawCircle3P::mouseMoveEvent(QMouseEvent* e) {
-    Vector mouse = snapPoint(e);
-
-    switch (getStatus()) {
-    case SetPoint1:
-        point1 = mouse;
-        break;
-
-    case SetPoint2:
-        point2 = mouse;
-        break;
-
-    case SetPoint3:
-        point3 = mouse;
-        preparePreview();
-        if (data.isValid()) {
-            RS_Circle* circle = new RS_Circle(preview, data);
-
-            deletePreview();
-            clearPreview();
-            preview->addEntity(circle);
-            drawPreview();
-        }
-        break;
-    }
+               if (suc)
+                       data = circle.getData();
+       }
 }
 
-
-
-void RS_ActionDrawCircle3P::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawCircle3P::mouseMoveEvent(QMouseEvent * e)
+{
+       Vector mouse = snapPoint(e);
+
+       switch (getStatus())
+       {
+       case SetPoint1:
+               point1 = mouse;
+               break;
+
+       case SetPoint2:
+               point2 = mouse;
+               break;
+
+       case SetPoint3:
+               point3 = mouse;
+               preparePreview();
+
+               if (data.isValid())
+               {
+                       RS_Circle * circle = new RS_Circle(preview, data);
+
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(circle);
+                       drawPreview();
+               }
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawCircle3P::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetPoint1:
-        point1 = mouse;
-        graphicView->moveRelativeZero(mouse);
-        setStatus(SetPoint2);
-        break;
-
-    case SetPoint2:
-        point2 = mouse;
-        graphicView->moveRelativeZero(mouse);
-        setStatus(SetPoint3);
-        break;
-
-    case SetPoint3:
-        point3 = mouse;
-        trigger();
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawCircle3P::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawCircle3P::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
+void RS_ActionDrawCircle3P::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetPoint1:
+               point1 = mouse;
+               graphicView->moveRelativeZero(mouse);
+               setStatus(SetPoint2);
+               break;
+
+       case SetPoint2:
+               point2 = mouse;
+               graphicView->moveRelativeZero(mouse);
+               setStatus(SetPoint3);
+               break;
+
+       case SetPoint3:
+               point3 = mouse;
+               trigger();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-QStringList RS_ActionDrawCircle3P::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+void RS_ActionDrawCircle3P::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
 }
 
-
-void RS_ActionDrawCircle3P::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetPoint1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"),
-                                            tr("Cancel"));
-        break;
-    case SetPoint2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second point"),
-                                            tr("Back"));
-        break;
-    case SetPoint3:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify third point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+QStringList RS_ActionDrawCircle3P::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
-
-
-void RS_ActionDrawCircle3P::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawCircle3P::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetPoint1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"),
+                       tr("Cancel"));
+               break;
+
+       case SetPoint2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second point"),
+                       tr("Back"));
+               break;
+
+       case SetPoint3:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify third point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawCircle3P::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
-    }
+void RS_ActionDrawCircle3P::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionDrawCircle3P::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
+}
 
 // EOF
 
index 7ae4d97f295fa1cf56aa8abcf20b15a16acb1d8e..695cc2f4d0e2ce30f1155799a965421b1ed6103e 100644 (file)
@@ -1,95 +1,62 @@
-/****************************************************************************
-** $Id: rs_actiondrawcircle3p.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWCIRCLE3P_H
 #define RS_ACTIONDRAWCIRCLE3P_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_circle.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * circles with three points given.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawCircle3P : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetPoint1,       /**< Setting the 1st point. */
-        SetPoint2,       /**< Setting the 2nd point. */
-        SetPoint3        /**< Setting the 3rd point. */
-    };
-
-public:
-    RS_ActionDrawCircle3P(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionDrawCircle3P();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    void reset();
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       void preparePreview();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /**
-     * Circle data defined so far.
-     */
-    RS_CircleData data;
-    /**
-     * 1st point.
-     */
-    Vector point1;
-    /**
-     * 2nd point.
-     */
-    Vector point2;
-    /**
-     * 3nd point.
-     */
-    Vector point3;
+class RS_ActionDrawCircle3P: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetPoint1,       /**< Setting the 1st point. */
+                       SetPoint2,       /**< Setting the 2nd point. */
+                       SetPoint3        /**< Setting the 3rd point. */
+               };
+
+       public:
+               RS_ActionDrawCircle3P(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawCircle3P();
+
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               void preparePreview();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /**
+                * Circle data defined so far.
+                */
+               RS_CircleData data;
+               /**
+                * 1st point.
+                */
+               Vector point1;
+               /**
+                * 2nd point.
+                */
+               Vector point2;
+               /**
+                * 3nd point.
+                */
+               Vector point3;
 };
 
 #endif
index 085c6e63fcd5488bcbc76d34ddeea58926e94559..1825b4fb79b40387718876b3c3a36182ddc1df0c 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawcirclecr.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawcirclecr.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawcirclecr.h"
-#include "rs_snapper.h"
+
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 /**
  * Constructor.
  */
-RS_ActionDrawCircleCR::RS_ActionDrawCircleCR(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw circles CR",
-                           container, graphicView) {
-
-    reset();
+RS_ActionDrawCircleCR::RS_ActionDrawCircleCR(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw circles CR",
+               container, graphicView)
+{
+       reset();
 }
 
-
-
-RS_ActionDrawCircleCR::~RS_ActionDrawCircleCR() {}
-
-
-QAction* RS_ActionDrawCircleCR::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawCircleCR::~RS_ActionDrawCircleCR()
 {
-       QAction * action = new QAction(tr("Center, &Radius"), 0);
-//     QAction* action = new QAction(tr("Circle: Center, Radius"),
-//                                                                     tr("Center, &Radius"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw circles with center and radius"));
-       return action;
 }
 
-
-void RS_ActionDrawCircleCR::reset() {
-    data = RS_CircleData(Vector(false), 0.0);
+/*virtual*/ RS2::ActionType RS_ActionDrawCircleCR::rtti()
+{
+       return RS2::ActionDrawCircleCR;
 }
 
-
-
-void RS_ActionDrawCircleCR::init(int status) {
-    RS_PreviewActionInterface::init(status);
+void RS_ActionDrawCircleCR::reset()
+{
+       data = RS_CircleData(Vector(false), 0.0);
 }
 
-
-
-void RS_ActionDrawCircleCR::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    RS_Circle* circle = new RS_Circle(container,
-                                      data);
-    circle->setLayerToActive();
-    circle->setPenToActive();
-    container->addEntity(circle);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(circle);
-        document->endUndoCycle();
-    }
-    deleteSnapper();
-    Vector rz = graphicView->getRelativeZero();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(circle);
-    graphicView->moveRelativeZero(circle->getCenter());
-    drawSnapper();
-
-    setStatus(SetCenter);
-
-    RS_DEBUG->print("RS_ActionDrawCircleCR::trigger(): circle added: %d",
-                    circle->getId());
+void RS_ActionDrawCircleCR::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 }
 
-
-
-void RS_ActionDrawCircleCR::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawCircleCR::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
-    switch (getStatus()) {
-    case SetCenter:
-        data.center = mouse;
-        deletePreview();
-        clearPreview();
-        preview->addEntity(new RS_Circle(preview,
-                                         data));
-        drawPreview();
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDrawCircleCR::mouseMoveEvent end");
+void RS_ActionDrawCircleCR::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       RS_Circle * circle = new RS_Circle(container, data);
+       circle->setLayerToActive();
+       circle->setPenToActive();
+       container->addEntity(circle);
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(circle);
+               document->endUndoCycle();
+       }
+
+       deleteSnapper();
+       Vector rz = graphicView->getRelativeZero();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(circle);
+       graphicView->moveRelativeZero(circle->getCenter());
+       drawSnapper();
+
+       setStatus(SetCenter);
+
+       RS_DEBUG->print("RS_ActionDrawCircleCR::trigger(): circle added: %d", circle->getId());
 }
 
-
-
-void RS_ActionDrawCircleCR::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawCircleCR::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawCircleCR::mouseMoveEvent begin");
+       Vector mouse = snapPoint(e);
+
+       switch (getStatus())
+       {
+       case SetCenter:
+               data.center = mouse;
+               deletePreview();
+               clearPreview();
+               preview->addEntity(new RS_Circle(preview, data));
+               drawPreview();
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionDrawCircleCR::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawCircleCR::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetCenter:
-        data.center = mouse;
-        trigger();
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawCircleCR::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionDrawCircleCR::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
+       Vector mouse = *e;
 
-void RS_ActionDrawCircleCR::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetCenter:
-        if (checkCommand("radius", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetRadius);
-        }
-        break;
-
-    case SetRadius: {
-            bool ok;
-            double r = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.radius = r;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(SetCenter);
-        }
-        break;
+       switch (getStatus())
+       {
+       case SetCenter:
+               data.center = mouse;
+               trigger();
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+void RS_ActionDrawCircleCR::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetCenter:
+
+               if (checkCommand("radius", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetRadius);
+               }
+               break;
+
+       case SetRadius:
+       {
+               bool ok;
+               double r = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.radius = r;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(SetCenter);
+       }
+       break;
+
+       default:
+               break;
+       }
+}
 
+QStringList RS_ActionDrawCircleCR::getAvailableCommands()
+{
+       QStringList cmd;
 
-QStringList RS_ActionDrawCircleCR::getAvailableCommands() {
-    QStringList cmd;
+       switch (getStatus())
+       {
+       case SetCenter:
+               cmd += command("radius");
+               break;
 
-    switch (getStatus()) {
-    case SetCenter:
-        cmd += command("radius");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-void RS_ActionDrawCircleCR::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetCenter:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify circle center"),
-                                            tr("Cancel"));
-        break;
-    case SetRadius:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify circle radius"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDrawCircleCR::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetCenter:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify circle center"), tr("Cancel"));
+               break;
+
+       case SetRadius:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify circle radius"), tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDrawCircleCR::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDrawCircleCR::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDrawCircleCR::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawCircleCR::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionDrawCircleCR::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawCircleCR::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawCircleCR::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
-    }
+void RS_ActionDrawCircleCR::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
 }
 
+double RS_ActionDrawCircleCR::getRadius()
+{
+       return data.radius;
+}
 
-// EOF
+void RS_ActionDrawCircleCR::setRadius(double r)
+{
+       data.radius = r;
+}
 
index 940f2a59bffa0c90a8d6dfcccce11b21055c1f54..f60f461de4ace9141dff686f2c03f1d48b731938 100644 (file)
@@ -1,97 +1,52 @@
-/****************************************************************************
-** $Id: rs_actiondrawcirclecr.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWCIRCLECR_H
 #define RS_ACTIONDRAWCIRCLECR_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_circle.h"
+#include "rs_previewactioninterface.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * simple arcs with the center, radius, start- and endangle given.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawCircleCR : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetCenter,         /**< Setting the center point. */
-               SetRadius          /**< Setting radius in command line. */
-    };
-
-public:
-    RS_ActionDrawCircleCR(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionDrawCircleCR();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawCircleCR;
-       }
-
-    void reset();
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       double getRadius() {
-               return data.radius;
-       }
-
-       void setRadius(double r) {
-               data.radius = r;
-       }
-
-protected:
-    /**
-     * Circle data defined so far.
-     */
-    RS_CircleData data;
-       
+class RS_ActionDrawCircleCR: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetCenter,         /**< Setting the center point. */
+                       SetRadius          /**< Setting radius in command line. */
+               };
+
+       public:
+               RS_ActionDrawCircleCR(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawCircleCR();
+
+               virtual RS2::ActionType rtti();
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               double getRadius();
+               void setRadius(double r);
+
+       protected:
+               /**
+                * Circle data defined so far.
+                */
+               RS_CircleData data;
 };
 
 #endif
index 35c3bb4b6fcb37f3ae47f6b8b3542a6c735371cc..a262fa12482efedac4e2050ac51d4d21520865a0 100644 (file)
 //
 
 #include "rs_actiondrawellipseaxis.h"
-#include "rs_snapper.h"
+
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 /**
  * Constructor.
  * @param isArc true if this action will produce an ellipse arc.
  *              false if it will produce a full ellipse.
  */
-RS_ActionDrawEllipseAxis::RS_ActionDrawEllipseAxis(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView,
-    bool isArc)
-        :RS_PreviewActionInterface("Draw ellipse with axis",
-                           container, graphicView) {
-
-    this->isArc = isArc;
-    center = Vector(false);
-    major = Vector(false);
-    ratio = 0.5;
-    angle1 = 0.0;
-    angle2 = 2*M_PI;
+RS_ActionDrawEllipseAxis::RS_ActionDrawEllipseAxis(RS_EntityContainer & container, RS_GraphicView & graphicView, bool isArc): RS_PreviewActionInterface("Draw ellipse with axis",
+               container, graphicView)
+{
+       this->isArc = isArc;
+       center = Vector(false);
+       major = Vector(false);
+       ratio = 0.5;
+       angle1 = 0.0;
+       angle2 = 2 * M_PI;
 }
 
 RS_ActionDrawEllipseAxis::~RS_ActionDrawEllipseAxis()
 {
 }
 
-QAction * RS_ActionDrawEllipseAxis::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+void RS_ActionDrawEllipseAxis::init(int status)
 {
-       QAction * action;
+       RS_PreviewActionInterface::init(status);
 
-       if (type==RS2::ActionDrawEllipseArcAxis)
-       {
-               action = new QAction(tr("&Ellipse Arc (Axis)"), 0);
-//             action = new QAction(tr("Ellipse Arc with Axis"),
-//                                                             tr("&Ellipse Arc (Axis)"), QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw Ellipse Arcs"));
-       }
-       else
-       {
-               action = new QAction(tr("&Ellipse (Axis)"), 0);
-//             action = new QAction(tr("Ellipse with Axis"),
-//                                                             tr("&Ellipse (Axis)"), QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw Ellipses"));
-       }
-       return action;
-}
+       if (status == SetCenter)
+               center = Vector(false);
 
-void RS_ActionDrawEllipseAxis::init(int status)
-{
-    RS_PreviewActionInterface::init(status);
+       if (status <= SetMajor)
+               major = Vector(false);
 
-    if (status==SetCenter)
-       {
-        center = Vector(false);
-    }
-    if (status<=SetMajor)
-       {
-        major = Vector(false);
-    }
-    if (status<=SetMinor)
-       {
-        ratio = 0.5;
-    }
-    if (status<=SetAngle1)
-       {
-        angle1 = 0.0;
-    }
-    if (status<=SetAngle2)
-       {
-        angle2 = 2*M_PI;
-    }
-}
+       if (status <= SetMinor)
+               ratio = 0.5;
 
+       if (status <= SetAngle1)
+               angle1 = 0.0;
 
+       if (status <= SetAngle2)
+               angle2 = 2 * M_PI;
+}
 
-void RS_ActionDrawEllipseAxis::trigger() {
-    RS_PreviewActionInterface::trigger();
+void RS_ActionDrawEllipseAxis::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 
-    RS_EllipseData ellipseData(center, major,
-                               ratio,
-                               angle1, angle2,
-                               false);
-    RS_Ellipse* ellipse = new RS_Ellipse(container, ellipseData);
-    ellipse->setLayerToActive();
-    ellipse->setPenToActive();
+       RS_EllipseData ellipseData(center, major, ratio, angle1, angle2, false);
+       RS_Ellipse * ellipse = new RS_Ellipse(container, ellipseData);
+       ellipse->setLayerToActive();
+       ellipse->setPenToActive();
 
-    container->addEntity(ellipse);
+       container->addEntity(ellipse);
 
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(ellipse);
-        document->endUndoCycle();
-    }
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(ellipse);
+               document->endUndoCycle();
+       }
 
-    deleteSnapper();
-    Vector rz = graphicView->getRelativeZero();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(ellipse);
-    graphicView->moveRelativeZero(rz);
-    drawSnapper();
+       deleteSnapper();
+       Vector rz = graphicView->getRelativeZero();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(ellipse);
+       graphicView->moveRelativeZero(rz);
+       drawSnapper();
 
-    setStatus(SetCenter);
+       setStatus(SetCenter);
 
-    RS_DEBUG->print("RS_ActionDrawEllipseAxis::trigger():"
-                    " entity added: %d", ellipse->getId());
+       RS_DEBUG->print("RS_ActionDrawEllipseAxis::trigger():"
+               " entity added: %d", ellipse->getId());
 }
 
+void RS_ActionDrawEllipseAxis::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawEllipseAxis::mouseMoveEvent begin");
 
+       Vector mouse = snapPoint(e);
 
-void RS_ActionDrawEllipseAxis::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawEllipseAxis::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
-
-    switch (getStatus()) {
-    case SetCenter:
-        break;
-
-    case SetMajor:
-        if (center.valid) {
-            deletePreview();
-            clearPreview();
-            RS_EllipseData ed(center, mouse-center,
-                              0.5,
-                              0.0, 2*M_PI,
-                              false);
-            preview->addEntity(new RS_Ellipse(preview, ed));
-            drawPreview();
-        }
-        break;
-
-    case SetMinor:
-        if (center.valid && major.valid) {
-            deletePreview();
-            clearPreview();
-            RS_Line line(NULL, RS_LineData(center-major, center+major));
-            double d = line.getDistanceToPoint(mouse);
-            ratio = d/(line.getLength()/2);
-            RS_EllipseData ed(center, major,
-                              ratio,
-                              0.0, 2*M_PI,
-                              false);
-            preview->addEntity(new RS_Ellipse(preview, ed));
-            drawPreview();
-        }
-        break;
-
-    case SetAngle1:
-        if (center.valid && major.valid) {
-            deletePreview();
-            clearPreview();
-
-            //angle1 = center.angleTo(mouse);
+       switch (getStatus())
+       {
+       case SetCenter:
+               break;
+
+       case SetMajor:
+
+               if (center.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       RS_EllipseData ed(center, mouse - center, 0.5, 0.0, 2 * M_PI, false);
+                       preview->addEntity(new RS_Ellipse(preview, ed));
+                       drawPreview();
+               }
+               break;
+
+       case SetMinor:
+
+               if (center.valid && major.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       RS_Line line(NULL, RS_LineData(center - major, center + major));
+                       double d = line.getDistanceToPoint(mouse);
+                       ratio = d / (line.getLength() / 2);
+                       RS_EllipseData ed(center, major, ratio, 0.0, 2 * M_PI, false);
+                       preview->addEntity(new RS_Ellipse(preview, ed));
+                       drawPreview();
+               }
+               break;
+
+       case SetAngle1:
+
+               if (center.valid && major.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+
+                       //angle1 = center.angleTo(mouse);
 
                        Vector m = mouse;
                        m.rotate(center, -major.angle());
-                       Vector v = m-center;
-                       v.scale(Vector(1.0, 1.0/ratio));
+                       Vector v = m - center;
+                       v.scale(Vector(1.0, 1.0 / ratio));
                        angle1 = v.angle(); // + major.angle();
 
-            preview->addEntity(new RS_Line(preview, RS_LineData(center, mouse)));
+                       preview->addEntity(new RS_Line(preview, RS_LineData(center, mouse)));
 
-            RS_EllipseData ed(center, major,
-                              ratio,
-                              angle1, angle1+1.0,
-                              false);
-            preview->addEntity(new RS_Ellipse(preview, ed));
-            drawPreview();
-        }
-        break;
+                       RS_EllipseData ed(center, major, ratio, angle1, angle1 + 1.0, false);
+                       preview->addEntity(new RS_Ellipse(preview, ed));
+                       drawPreview();
+               }
+               break;
 
-    case SetAngle2:
-        if (center.valid && major.valid) {
-            deletePreview();
-            clearPreview();
-            //angle2 = center.angleTo(mouse);
+       case SetAngle2:
+
+               if (center.valid && major.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       //angle2 = center.angleTo(mouse);
 
                        Vector m = mouse;
                        m.rotate(center, -major.angle());
-                       Vector v = m-center;
-                       v.scale(Vector(1.0, 1.0/ratio));
+                       Vector v = m - center;
+                       v.scale(Vector(1.0, 1.0 / ratio));
                        angle2 = v.angle(); // + major.angle();
 
-            preview->addEntity(new RS_Line(preview, RS_LineData(center, mouse)));
+                       preview->addEntity(new RS_Line(preview, RS_LineData(center, mouse)));
 
-            RS_EllipseData ed(
-                center, major,
-                ratio,
-                angle1, angle2,
-                false);
-            preview->addEntity(new RS_Ellipse(preview, ed));
-            drawPreview();
-        }
+                       RS_EllipseData ed(
+                               center, major, ratio, angle1, angle2, false);
+                       preview->addEntity(new RS_Ellipse(preview, ed));
+                       drawPreview();
+               }
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionDrawEllipseAxis::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDrawEllipseAxis::mouseMoveEvent end");
 }
 
+void RS_ActionDrawEllipseAxis::mouseReleaseEvent(QMouseEvent * e)
+{
+       // Proceed to next status
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       // Return to last status:
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
+}
 
+void RS_ActionDrawEllipseAxis::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-void RS_ActionDrawEllipseAxis::mouseReleaseEvent(QMouseEvent* e) {
-    // Proceed to next status
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    }
-
-    // Return to last status:
-    else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
-}
+       Vector mouse = *e;
 
+       switch (getStatus())
+       {
+       case SetCenter:
+               center = mouse;
+               graphicView->moveRelativeZero(mouse);
+               setStatus(SetMajor);
+               break;
+
+       case SetMajor:
+               major = mouse - center;
+               setStatus(SetMinor);
+               break;
+
+       case SetMinor:
+       {
+               RS_Line line(NULL, RS_LineData(center - major, center + major));
+               double d = line.getDistanceToPoint(mouse);
+               ratio = d / (line.getLength() / 2);
+
+               if (!isArc)
+               {
+                       trigger();
+                       setStatus(SetCenter);
+               }
+               else
+                       setStatus(SetAngle1);
+       }
+       break;
 
-void RS_ActionDrawEllipseAxis::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetCenter:
-        center = mouse;
-        graphicView->moveRelativeZero(mouse);
-        setStatus(SetMajor);
-        break;
-
-    case SetMajor:
-        major = mouse-center;
-        setStatus(SetMinor);
-        break;
-
-    case SetMinor: {
-            RS_Line line(NULL, RS_LineData(center-major, center+major));
-            double d = line.getDistanceToPoint(mouse);
-            ratio = d/(line.getLength()/2);
-            if (!isArc) {
-                trigger();
-                setStatus(SetCenter);
-            } else {
-                setStatus(SetAngle1);
-            }
-        }
-        break;
-
-    case SetAngle1: {
-        //angle1 = center.angleTo(mouse);
+       case SetAngle1:
+       {
+               //angle1 = center.angleTo(mouse);
                Vector m = mouse;
                m.rotate(center, -major.angle());
-               Vector v = m-center;
-               v.scale(Vector(1.0, 1.0/ratio));
+               Vector v = m - center;
+               v.scale(Vector(1.0, 1.0 / ratio));
                angle1 = v.angle();
-        setStatus(SetAngle2);
-               } break;
+               setStatus(SetAngle2);
+       }
+       break;
 
-    case SetAngle2: {
-        //angle2 = center.angleTo(mouse);
+       case SetAngle2:
+       {
+               //angle2 = center.angleTo(mouse);
                Vector m = mouse;
                m.rotate(center, -major.angle());
-               Vector v = m-center;
-               v.scale(Vector(1.0, 1.0/ratio));
+               Vector v = m - center;
+               v.scale(Vector(1.0, 1.0 / ratio));
                angle2 = v.angle();
-        trigger();
-        } break;
+               trigger();
+       }
+       break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+void RS_ActionDrawEllipseAxis::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
 
-void RS_ActionDrawEllipseAxis::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetMinor: {
-            bool ok;
-            double m = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                ratio = m / major.magnitude();
-                if (!isArc) {
-                    trigger();
-                } else {
-                    setStatus(SetAngle1);
-                }
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    case SetAngle1: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                angle1 = RS_Math::deg2rad(a);
-                setStatus(SetAngle2);
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    case SetAngle2: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                angle2 = RS_Math::deg2rad(a);
-                trigger();
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
-}
+       switch (getStatus())
+       {
+       case SetMinor: {
+               bool ok;
+               double m = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+               {
+                       ratio = m / major.magnitude();
+
+                       if (!isArc)
+                               trigger();
+                       else
+                               setStatus(SetAngle1);
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
+       }
+       break;
 
+       case SetAngle1: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
 
-QStringList RS_ActionDrawEllipseAxis::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
-}
+               if (ok == true)
+               {
+                       angle1 = RS_Math::deg2rad(a);
+                       setStatus(SetAngle2);
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
+       }
+       break;
 
+       case SetAngle2: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
 
-void RS_ActionDrawEllipseAxis::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetCenter:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify ellipse center"),
-                                                tr("Cancel"));
-            break;
-
-        case SetMajor:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify endpoint of major axis"),
-                                                tr("Back"));
-            break;
-
-        case SetMinor:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify endpoint or length of minor axis:"),
-                tr("Back"));
-            break;
-
-        case SetAngle1:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify start angle"),
-                                                tr("Back"));
-            break;
-
-        case SetAngle2:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify end angle"),
-                                                tr("Back"));
-            break;
-
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
-}
+               if (ok == true)
+               {
+                       angle2 = RS_Math::deg2rad(a);
+                       trigger();
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
+       }
+       break;
 
+       default:
+               break;
+       }
+}
 
-void RS_ActionDrawEllipseAxis::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+QStringList RS_ActionDrawEllipseAxis::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
+void RS_ActionDrawEllipseAxis::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetCenter:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify ellipse center"),
+                               tr("Cancel"));
+                       break;
+
+               case SetMajor:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify endpoint of major axis"),
+                               tr("Back"));
+                       break;
+
+               case SetMinor:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify endpoint or length of minor axis:"),
+                               tr("Back"));
+                       break;
+
+               case SetAngle1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify start angle"),
+                               tr("Back"));
+                       break;
+
+               case SetAngle2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify end angle"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
+}
 
+void RS_ActionDrawEllipseAxis::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
-void RS_ActionDrawEllipseAxis::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarEllipses);
-        }
-    }
+void RS_ActionDrawEllipseAxis::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarEllipses);
+       }
 }
 
 // EOF
index 04917f07e35deb10e4ccec2239018b98fbcc0bdd..67796f7312f45d1c971b1152a9017de96b88c07f 100644 (file)
@@ -1,34 +1,8 @@
-/****************************************************************************
-** $Id: rs_actiondrawellipseaxis.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWELLIPSEAXIS_H
 #define RS_ACTIONDRAWELLIPSEAXIS_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_ellipse.h"
+#include "rs_previewactioninterface.h"
 
 /**
  * This action class can handle user events to draw ellipses
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawEllipseAxis : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetCenter,   /**< Settinge the center.  */
-        SetMajor,    /**< Setting endpoint of major axis. */
-        SetMinor,    /**< Setting minor/major ratio. */
-        SetAngle1,   /**< Setting start angle. */
-        SetAngle2    /**< Setting end angle. */
-    };
-
-public:
-    RS_ActionDrawEllipseAxis(RS_EntityContainer& container,
-                             RS_GraphicView& graphicView,
-                             bool isArc);
-    ~RS_ActionDrawEllipseAxis();
-       
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /** Center of ellipse */
-    Vector center;
-    /** Endpoint of major axis */
-    Vector major;
-    /** Ratio major / minor */
-    double ratio;
-    /** Start angle */
-    double angle1;
-    /** End angle */
-    double angle2;
-    /** Do we produce an arc (true) or full ellipse (false) */
-    bool isArc;
+class RS_ActionDrawEllipseAxis: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetCenter,   /**< Settinge the center.  */
+                       SetMajor,    /**< Setting endpoint of major axis. */
+                       SetMinor,    /**< Setting minor/major ratio. */
+                       SetAngle1,   /**< Setting start angle. */
+                       SetAngle2    /**< Setting end angle. */
+               };
+
+       public:
+               RS_ActionDrawEllipseAxis(RS_EntityContainer & container, RS_GraphicView & graphicView, bool isArc);
+               ~RS_ActionDrawEllipseAxis();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /** Center of ellipse */
+               Vector center;
+               /** Endpoint of major axis */
+               Vector major;
+               /** Ratio major / minor */
+               double ratio;
+               /** Start angle */
+               double angle1;
+               /** End angle */
+               double angle2;
+               /** Do we produce an arc (true) or full ellipse (false) */
+               bool isArc;
 };
 
 #endif
index 8d01bf52efe2017ab80bb17c48aad8cecec0651c..096d959eb9fae2217ea3a4219c4d3d703cda67cc 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawhatch.cpp 2381 2005-05-16 17:05:44Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawhatch.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  05/22/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawhatch.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 #include "rs_graphicview.h"
 #include "rs_information.h"
 
-RS_ActionDrawHatch::RS_ActionDrawHatch(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionDrawHatch::RS_ActionDrawHatch(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw Hatch", container, graphicView)
 {
-    hatch = NULL;
+       hatch = NULL;
 }
 
-QAction * RS_ActionDrawHatch::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawHatch::~RS_ActionDrawHatch()
 {
-       QAction * action = new QAction(tr("&Hatch"), 0);
-//     QAction* action = new QAction(tr("Hatch"), tr("&Hatch"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw Hatches and Solid Fills"));
-       return action;
 }
 
 void RS_ActionDrawHatch::init(int status)
 {
-    RS_ActionInterface::init(status);
-
-    clearPreview();
-
-    RS_Hatch tmp(container, data);
-    tmp.setLayerToActive();
-    tmp.setPenToActive();
-    if (RS_DIALOGFACTORY->requestHatchDialog(&tmp)) {
-        data = tmp.getData();
-        trigger();
-        finish();
-        graphicView->redraw();
-    } else {
-        finish();
-    }
+       RS_ActionInterface::init(status);
+       clearPreview();
+
+       RS_Hatch tmp(container, data);
+       tmp.setLayerToActive();
+       tmp.setPenToActive();
+
+       if (RS_DIALOGFACTORY->requestHatchDialog(&tmp))
+       {
+               data = tmp.getData();
+               trigger();
+               finish();
+               graphicView->redraw();
+       }
+       else
+               finish();
 }
 
+void RS_ActionDrawHatch::trigger()
+{
+       RS_DEBUG->print("RS_ActionDrawHatch::trigger()");
 
-
-void RS_ActionDrawHatch::trigger() {
-
-    RS_DEBUG->print("RS_ActionDrawHatch::trigger()");
-
-    //if (pos.valid) {
-    //deletePreview();
-    deleteSnapper();
-       RS_Entity* e;
+       //if (pos.valid) {
+       //deletePreview();
+       deleteSnapper();
+       RS_Entity * e;
 
        // deselect unhatchable entities:
-    for (e=container->firstEntity(RS2::ResolveNone); e!=NULL;
-            e=container->nextEntity(RS2::ResolveNone)) {
-        if (e->isSelected() &&
-                   (e->rtti()==RS2::EntityHatch ||
-                        e->rtti()==RS2::EntityEllipse || e->rtti()==RS2::EntityPoint ||
-                        e->rtti()==RS2::EntityText ||
-                        RS_Information::isDimension(e->rtti()))) {
+       for (e = container->firstEntity(RS2::ResolveNone); e != NULL;
+            e = container->nextEntity(RS2::ResolveNone))
+               if (e->isSelected()
+                   && (e->rtti() == RS2::EntityHatch
+                       || e->rtti() == RS2::EntityEllipse || e->rtti() == RS2::EntityPoint
+                       || e->rtti() == RS2::EntityText
+                       || RS_Information::isDimension(e->rtti())))
                        e->setSelected(false);
-        }
-    }
-    for (e=container->firstEntity(RS2::ResolveAll); e!=NULL;
-            e=container->nextEntity(RS2::ResolveAll)) {
-        if (e->isSelected() &&
-                   (e->rtti()==RS2::EntityHatch ||
-                        e->rtti()==RS2::EntityEllipse || e->rtti()==RS2::EntityPoint ||
-                        e->rtti()==RS2::EntityText ||
-                        RS_Information::isDimension(e->rtti()))) {
+
+
+       for (e = container->firstEntity(RS2::ResolveAll); e != NULL;
+            e = container->nextEntity(RS2::ResolveAll))
+               if (e->isSelected()
+                   && (e->rtti() == RS2::EntityHatch
+                       || e->rtti() == RS2::EntityEllipse || e->rtti() == RS2::EntityPoint
+                       || e->rtti() == RS2::EntityText
+                       || RS_Information::isDimension(e->rtti())))
                        e->setSelected(false);
-        }
-    }
 
        // look for selected contours:
-    bool haveContour = false;
-    for (e=container->firstEntity(RS2::ResolveAll); e!=NULL;
-            e=container->nextEntity(RS2::ResolveAll)) {
-        if (e->isSelected()) {
-            haveContour = true;
-        }
-    }
-
-    if (!haveContour) {
-        std::cerr << "no contour selected\n";
-        return;
-    }
-
-    hatch = new RS_Hatch(container, data);
-    hatch->setLayerToActive();
-    hatch->setPenToActive();
-    RS_EntityContainer* loop = new RS_EntityContainer(hatch);
-    loop->setPen(RS_Pen(RS2::FlagInvalid));
-
-    // add selected contour:
-    for (RS_Entity* e=container->firstEntity(RS2::ResolveAll); e!=NULL;
-            e=container->nextEntity(RS2::ResolveAll)) {
-
-        if (e->isSelected()) {
-            e->setSelected(false);
+       bool haveContour = false;
+
+       for (e = container->firstEntity(RS2::ResolveAll); e != NULL;
+            e = container->nextEntity(RS2::ResolveAll))
+               if (e->isSelected())
+                       haveContour = true;
+
+       if (!haveContour)
+       {
+               std::cerr << "no contour selected\n";
+               return;
+       }
+
+       hatch = new RS_Hatch(container, data);
+       hatch->setLayerToActive();
+       hatch->setPenToActive();
+       RS_EntityContainer * loop = new RS_EntityContainer(hatch);
+       loop->setPen(RS_Pen(RS2::FlagInvalid));
+
+       // add selected contour:
+       for (RS_Entity * e = container->firstEntity(RS2::ResolveAll); e != NULL;
+            e = container->nextEntity(RS2::ResolveAll))
+
+               if (e->isSelected())
+               {
+                       e->setSelected(false);
+
                        // entity is part of a complex entity (spline, polyline, ..):
-                       if (e->getParent()!=NULL &&
-                           (e->getParent()->rtti()==RS2::EntitySpline ||
-                                e->getParent()->rtti()==RS2::EntityPolyline)) {
+                       if (e->getParent() != NULL
+                           && (e->getParent()->rtti() == RS2::EntitySpline
+                               || e->getParent()->rtti() == RS2::EntityPolyline))
                                e->getParent()->setSelected(false);
-                       }
-            RS_Entity* cp = e->clone();
-            cp->setPen(RS_Pen(RS2::FlagInvalid));
-            cp->reparent(loop);
-            loop->addEntity(cp);
-        }
-    }
-
-    hatch->addEntity(loop);
-       if (hatch->validate()) {
+                       RS_Entity * cp = e->clone();
+                       cp->setPen(RS_Pen(RS2::FlagInvalid));
+                       cp->reparent(loop);
+                       loop->addEntity(cp);
+               }
+
+       hatch->addEntity(loop);
+
+       if (hatch->validate())
+       {
                container->addEntity(hatch);
 
-               if (document) {
+               if (document)
+               {
                        document->startUndoCycle();
                        document->addUndoable(hatch);
                        document->endUndoCycle();
@@ -152,74 +134,74 @@ void RS_ActionDrawHatch::trigger() {
 
                RS_DIALOGFACTORY->commandMessage(tr("Hatch created successfully."));
        }
-       else {
+       else
+       {
                delete hatch;
                hatch = NULL;
                RS_DIALOGFACTORY->commandMessage(tr("Invalid hatch area. Please check that "
-               "the entities chosen form one or more closed contours."));
+                               "the entities chosen form one or more closed contours."));
        }
-    //}
+       //}
 }
 
+void RS_ActionDrawHatch::mouseMoveEvent(QMouseEvent *)
+{
+       RS_DEBUG->print("RS_ActionDrawHatch::mouseMoveEvent begin");
 
-
-void RS_ActionDrawHatch::mouseMoveEvent(QMouseEvent*) {
-    RS_DEBUG->print("RS_ActionDrawHatch::mouseMoveEvent begin");
-
-    /*if (getStatus()==SetPos) {
-        Vector mouse = snapPoint(e);
-        pos = mouse;
+       /*if (getStatus()==SetPos) {
+           Vector mouse = snapPoint(e);
+           pos = mouse;
 
 
-        deletePreview();
-        if (hatch!=NULL && !hatch->isVisible()) {
-            hatch->setVisible(true);
-        }
-        offset = Vector(graphicView->toGuiDX(pos.x),
-                           -graphicView->toGuiDY(pos.y));
-        drawPreview();
-}*/
+           deletePreview();
+           if (hatch!=NULL && !hatch->isVisible()) {
+               hatch->setVisible(true);
+           }
+           offset = Vector(graphicView->toGuiDX(pos.x),
+                              -graphicView->toGuiDY(pos.y));
+           drawPreview();
+          }*/
 
-    RS_DEBUG->print("RS_ActionDrawHatch::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDrawHatch::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawHatch::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        Vector mouse = snapPoint(e);
-
-        switch (getStatus()) {
-        case ShowDialog:
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        //deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawHatch::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector mouse = snapPoint(e);
+
+               switch (getStatus())
+               {
+               case ShowDialog:
+                       break;
+
+               default:
+                       break;
+               }
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               //deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawHatch::updateMouseButtonHints() {
-    RS_DIALOGFACTORY->updateMouseWidget("", "");
+void RS_ActionDrawHatch::updateMouseButtonHints()
+{
+       RS_DIALOGFACTORY->updateMouseWidget("", "");
 }
 
-
-
-void RS_ActionDrawHatch::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawHatch::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawHatch::updateToolBar() {
-    RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+void RS_ActionDrawHatch::updateToolBar()
+{
+       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
 }
 
-
-// EOF
index 618f66e98550a42592469f96420fea4a8615704c..c632753e2d435080765d5ed355c39cf8c5204aea 100644 (file)
@@ -1,69 +1,39 @@
-/****************************************************************************
-** $Id: rs_actiondrawhatch.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWHATCH_H
 #define RS_ACTIONDRAWHATCH_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_hatch.h"
-
+#include "rs_previewactioninterface.h"
 
 /**
  * This action class can handle user events to draw hatches.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawHatch : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        ShowDialog           /**< Showing the hatch dialog. */
-    };
-
-public:
-    RS_ActionDrawHatch(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView);
-    ~RS_ActionDrawHatch() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_HatchData data;
-       RS_Hatch* hatch;
+class RS_ActionDrawHatch: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       ShowDialog           /**< Showing the hatch dialog. */
+               };
+
+       public:
+               RS_ActionDrawHatch(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawHatch();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_HatchData data;
+               RS_Hatch * hatch;
 };
 
 #endif
index 65ae1c9dd00f8df63ccec215765f9e6c6bba5172..d68e5b517fd86cd4a4566048f8ab97b2d676c057 100644 (file)
@@ -1,40 +1,28 @@
-/****************************************************************************
-** $Id: rs_actiondrawimage.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawimage.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  05/22/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawimage.h"
 
 #include "rs_creation.h"
-#include "commands.h"
-#include "rs_modification.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 /**
  * Constructor.
  */
-RS_ActionDrawImage::RS_ActionDrawImage(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDrawImage::RS_ActionDrawImage(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Image", container, graphicView)
 {
 }
@@ -43,13 +31,9 @@ RS_ActionDrawImage::~RS_ActionDrawImage()
 {
 }
 
-QAction * RS_ActionDrawImage::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionDrawImage::rtti()
 {
-       QAction * action = new QAction(tr("&Image"), 0);
-//     QAction* action = new QAction(tr("Image"), tr("&Image"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Insert Image (Bitmap)"));
-       return action;
+       return RS2::ActionDrawImage;
 }
 
 void RS_ActionDrawImage::init(int status)
@@ -79,12 +63,12 @@ void RS_ActionDrawImage::init(int status)
 void RS_ActionDrawImage::reset()
 {
        data = RS_ImageData(0,
-               Vector(0.0,0.0),
-               Vector(1.0,0.0),
-               Vector(0.0,1.0),
-               Vector(1.0,1.0),
-               "",
-               50, 50, 0);
+                       Vector(0.0, 0.0),
+                       Vector(1.0, 0.0),
+                       Vector(0.0, 1.0),
+                       Vector(1.0, 1.0),
+                       "",
+                       50, 50, 0);
 }
 
 void RS_ActionDrawImage::trigger()
@@ -120,15 +104,15 @@ void RS_ActionDrawImage::mouseMoveEvent(QMouseEvent * e)
                line = new RS_Line(preview, RS_LineData(Vector(0, 0), Vector(img.width(), 0)));
                preview->addEntity(line);
                line = new RS_Line(preview,
-                       RS_LineData(Vector(img.width(), 0), Vector(img.width(), img.height())));
+                               RS_LineData(Vector(img.width(), 0), Vector(img.width(), img.height())));
                preview->addEntity(line);
                line = new RS_Line(preview,
-                       RS_LineData(Vector(img.width(), img.height()), Vector(0, img.height())));
+                               RS_LineData(Vector(img.width(), img.height()), Vector(0, img.height())));
                preview->addEntity(line);
                line = new RS_Line(preview, RS_LineData(Vector(0, img.height()), Vector(0, 0)));
                preview->addEntity(line);
-               preview->scale(Vector(0,0), Vector(data.uVector.magnitude(), data.uVector.magnitude()));
-               preview->rotate(Vector(0,0), data.uVector.angle());
+               preview->scale(Vector(0, 0), Vector(data.uVector.magnitude(), data.uVector.magnitude()));
+               preview->rotate(Vector(0, 0), data.uVector.angle());
                preview->move(data.insertionPoint);
 
                drawPreview();
@@ -141,12 +125,14 @@ void RS_ActionDrawImage::mouseMoveEvent(QMouseEvent * e)
 
 void RS_ActionDrawImage::mouseReleaseEvent(QMouseEvent * e)
 {
-       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+//     if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
-       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+//     else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
        {
                deleteSnapper();
                //init(getStatus()-1);
@@ -154,12 +140,12 @@ void RS_ActionDrawImage::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawImage::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawImage::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       data.insertionPoint = e->getCoordinate();
+       data.insertionPoint = *e;
        trigger();
 }
 
@@ -177,6 +163,7 @@ void RS_ActionDrawImage::commandEvent(RS_CommandEvent * e)
        switch (getStatus())
        {
        case SetTargetPoint:
+
                if (checkCommand("angle", c))
                {
                        deleteSnapper();
@@ -197,31 +184,31 @@ void RS_ActionDrawImage::commandEvent(RS_CommandEvent * e)
 
        case SetAngle:
        {
-                       bool ok;
-                       double a = RS_Math::eval(c, &ok);
-                       if (ok==true) {
-                               setAngle(RS_Math::deg2rad(a));
-                       } else {
-                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                       }
-                       RS_DIALOGFACTORY->requestOptions(this, true, true);
-                       setStatus(lastStatus);
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       setAngle(RS_Math::deg2rad(a));
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
        }
-               break;
+       break;
 
        case SetFactor:
        {
-                       bool ok;
-                       double f = RS_Math::eval(c, &ok);
-                       if (ok==true) {
-                               setFactor(f);
-                       } else {
-                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                       }
-                       RS_DIALOGFACTORY->requestOptions(this, true, true);
-                       setStatus(lastStatus);
+               bool ok;
+               double f = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       setFactor(f);
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
        }
-               break;
+       break;
 
        default:
                break;
@@ -238,6 +225,7 @@ QStringList RS_ActionDrawImage::getAvailableCommands()
                cmd += command("angle");
                cmd += command("factor");
                break;
+
        default:
                break;
        }
@@ -266,12 +254,15 @@ void RS_ActionDrawImage::updateMouseButtonHints()
        case SetTargetPoint:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
                break;
+
        case SetAngle:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Enter angle:"), "");
                break;
+
        case SetFactor:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Enter factor:"), "");
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
@@ -285,9 +276,33 @@ void RS_ActionDrawImage::updateMouseCursor()
 
 void RS_ActionDrawImage::updateToolBar()
 {
-       if (!isFinished()) {
+       if (!isFinished())
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-       } else {
+       else
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-       }
 }
+
+double RS_ActionDrawImage::getAngle()
+{
+       return data.uVector.angle();
+}
+
+void RS_ActionDrawImage::setAngle(double a)
+{
+       double l = data.uVector.magnitude();
+       data.uVector.setPolar(l, a);
+       data.vVector.setPolar(l, a + M_PI / 2);
+}
+
+double RS_ActionDrawImage::getFactor()
+{
+       return data.uVector.magnitude();
+}
+
+void RS_ActionDrawImage::setFactor(double f)
+{
+       double a = data.uVector.angle();
+       data.uVector.setPolar(f, a);
+       data.vVector.setPolar(f, a + M_PI / 2);
+}
+
index aa5061f0f83a9242f2152f4574cfcbbf31e984a3..284208deadd857da4070dc8fd2b2847eb3e64879 100644 (file)
@@ -1,34 +1,9 @@
-/****************************************************************************
-** $Id: rs_actiondrawimage.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWIMAGE_H
 #define RS_ACTIONDRAWIMAGE_H
 
-#include "rs_previewactioninterface.h"
+#include <QtGui>
 #include "rs_image.h"
+#include "rs_previewactioninterface.h"
 
 /**
  * This action class can handle user events for inserting bitmaps into the
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawImage : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-               ShowDialog,        /**< Dialog. */
-        SetTargetPoint,    /**< Setting the reference point. */
-               SetAngle,          /**< Setting angle in the command line. */
-               SetFactor          /**< Setting factor in the command line. */
-               //SetColumns,        /**< Setting columns in the command line. */
-               //SetRows,           /**< Setting rows in the command line. */
-               //SetColumnSpacing,  /**< Setting column spacing in the command line. */
-               //SetRowSpacing      /**< Setting row spacing in the command line. */
-    };
-
-public:
-    RS_ActionDrawImage(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionDrawImage();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawImage;
-       }
-
-    virtual void init(int status=0);
-
-       void reset();
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-       virtual void showOptions();
-       virtual void hideOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       double getAngle() {
-               return data.uVector.angle();
-       }
-
-       void setAngle(double a) {
-               double l = data.uVector.magnitude();
-               data.uVector.setPolar(l, a);
-               data.vVector.setPolar(l, a+M_PI/2);
-       }
-
-       double getFactor() {
-               return data.uVector.magnitude();
-       }
-
-       void setFactor(double f) {
-               double a = data.uVector.angle();
-               data.uVector.setPolar(f, a);
-               data.vVector.setPolar(f, a+M_PI/2);
-       }
-
-protected:
-       RS_ImageData data;
-       QImage img;
-       
-       /** Last status before entering option. */
-       Status lastStatus;
+class RS_ActionDrawImage: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       ShowDialog,        /**< Dialog. */
+                       SetTargetPoint,    /**< Setting the reference point. */
+                       SetAngle,          /**< Setting angle in the command line. */
+                       SetFactor          /**< Setting factor in the command line. */
+                       //SetColumns,        /**< Setting columns in the command line. */
+                       //SetRows,           /**< Setting rows in the command line. */
+                       //SetColumnSpacing,  /**< Setting column spacing in the command line. */
+                       //SetRowSpacing      /**< Setting row spacing in the command line. */
+               };
+
+       public:
+               RS_ActionDrawImage(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawImage();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               void reset();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void showOptions();
+               virtual void hideOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               double getAngle();
+               void setAngle(double a);
+               double getFactor();
+               void setFactor(double f);
+
+       protected:
+               RS_ImageData data;
+               QImage img;
+
+               /** Last status before entering option. */
+               Status lastStatus;
 };
 
 #endif
index 27c8006b8b95ef60a9223e5c5ff1bf6aeef24572..89a8ea5f4f00993c8ef81d052ade73cc9c1617e7 100644 (file)
 #include "rs_actiondrawline.h"
 
 #include "rs_actioneditundo.h"
-#include "rs_snapper.h"
+#include "commands.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw lines", container, graphicView)
 {
        RS_DEBUG->print("RS_ActionDrawLine::RS_ActionDrawLine");
@@ -37,16 +39,6 @@ RS_ActionDrawLine::~RS_ActionDrawLine()
        return RS2::ActionDrawLine;
 }
 
-/*static*/ QAction * RS_ActionDrawLine::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
-       QAction * action = new QAction(tr("&2 Points"), 0);
-       action->setEnabled(true);
-//     QAction* action = new QAction(tr("Line: 2 Points"), tr("&2 Points"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw lines"));
-       return action;
-}
-
 void RS_ActionDrawLine::reset()
 {
        RS_DEBUG->print("RS_ActionDrawLine::reset");
@@ -123,7 +115,7 @@ void RS_ActionDrawLine::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -135,7 +127,7 @@ void RS_ActionDrawLine::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawLine::coordinateEvent(Vector * e)
 {
        RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent");
 
@@ -145,7 +137,7 @@ void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent * e)
                return;
        }
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
        switch (getStatus())
        {
@@ -183,6 +175,7 @@ void RS_ActionDrawLine::commandEvent(RS_CommandEvent * e)
        switch (getStatus())
        {
        case SetStartpoint:
+
                if (checkCommand("help", c))
                {
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
@@ -192,6 +185,7 @@ void RS_ActionDrawLine::commandEvent(RS_CommandEvent * e)
                break;
 
        case SetEndpoint:
+
                if (checkCommand("close", c))
                {
                        close();
@@ -222,7 +216,9 @@ QStringList RS_ActionDrawLine::getAvailableCommands()
        {
        case SetStartpoint:
                break;
+
        case SetEndpoint:
+
                if (history.count() >= 2)
                        cmd += command("undo");
 
@@ -230,6 +226,7 @@ QStringList RS_ActionDrawLine::getAvailableCommands()
                        cmd += command("close");
 
                break;
+
        default:
                break;
        }
@@ -244,6 +241,7 @@ void RS_ActionDrawLine::updateMouseButtonHints()
        case SetStartpoint:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
                break;
+
        case SetEndpoint:
        {
                QString msg = "";
@@ -255,16 +253,15 @@ void RS_ActionDrawLine::updateMouseButtonHints()
                }
 
                if (history.count() >= 2)
-               {
                        msg += RS_COMMANDS->command("undo");
-               }
 
                if (history.count() >= 2)
                        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point or [%1]").arg(msg), tr("Back"));
                else
                        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point"), tr("Back"));
        }
-               break;
+       break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
@@ -310,9 +307,7 @@ void RS_ActionDrawLine::close()
                graphicView->moveRelativeZero(start);
        }
        else
-       {
                RS_DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet."));
-       }
 }
 
 void RS_ActionDrawLine::undo()
@@ -327,9 +322,7 @@ void RS_ActionDrawLine::undo()
                graphicView->moveRelativeZero(data.startpoint);
        }
        else
-       {
                RS_DIALOGFACTORY->commandMessage(tr("Cannot undo: Not enough entities defined yet."));
-       }
 }
 
 void RS_ActionDrawLine::ClearHistory(void)
@@ -337,3 +330,4 @@ void RS_ActionDrawLine::ClearHistory(void)
        while (!history.isEmpty())
                delete history.takeFirst();
 }
+
index 10710e1cfab1d15add5b9beaf5b5e1d65f5dc908..ef3d668742ef4a0235569a8829af5b2ec2c109c0 100644 (file)
  */
 class RS_ActionDrawLine: public RS_PreviewActionInterface
 {
-//No slots/signals...  //Q_OBJECT
-
        public:
                /**
-               * Action States.
-               */
+                * Action States.
+                */
                enum Status
                {
                        SetStartpoint = 0,   /**< Setting the startpoint.  */
@@ -30,26 +28,19 @@ class RS_ActionDrawLine: public RS_PreviewActionInterface
                virtual ~RS_ActionDrawLine();
 
                virtual RS2::ActionType rtti();
-               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
                void reset();
-
                virtual void init(int status = 0);
                virtual void trigger();
-
                virtual void mouseMoveEvent(QMouseEvent * e);
                virtual void mouseReleaseEvent(QMouseEvent * e);
-
-               virtual void coordinateEvent(RS_CoordinateEvent * e);
+               virtual void coordinateEvent(Vector * e);
                virtual void commandEvent(RS_CommandEvent * e);
                virtual QStringList getAvailableCommands();
-
                virtual void showOptions();
                virtual void hideOptions();
-
                virtual void updateMouseButtonHints();
                virtual void updateMouseCursor();
                virtual void updateToolBar();
-
                void close();
                void undo();
 
@@ -68,7 +59,6 @@ class RS_ActionDrawLine: public RS_PreviewActionInterface
                /**
                 * Point history (for undo)
                 */
-//             Q3PtrList<Vector> history;
                QList<Vector *> history;
 };
 
index de3036d0ba1bdad3858f5ae854142e5b7e17d49b..188d8c41bbe491786632f0858169b8a7498085a6 100644 (file)
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/22/2010  Added this text. :-)
+// JLH  06/03/2010  Moved implementation from header to this file
 //
 
 #include "rs_actiondrawlineangle.h"
-#include "rs_snapper.h"
-
-RS_ActionDrawLineAngle::RS_ActionDrawLineAngle(RS_EntityContainer& container,
-        RS_GraphicView& graphicView,
-        double angle,
-        bool fixedAngle)
-        :RS_PreviewActionInterface("Draw lines with given angle",
-                           container, graphicView)
+
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
+
+RS_ActionDrawLineAngle::RS_ActionDrawLineAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle, bool fixedAngle):
+       RS_PreviewActionInterface("Draw lines with given angle",
+               container, graphicView)
 {
-    this->angle = angle;
-    length = 1.0;
-    snpPoint = 0;
-    this->fixedAngle = fixedAngle;
-    pos = Vector(false);
-    reset();
+       this->angle = angle;
+       length = 1.0;
+       snpPoint = 0;
+       this->fixedAngle = fixedAngle;
+       pos = Vector(false);
+       reset();
 }
 
 RS_ActionDrawLineAngle::~RS_ActionDrawLineAngle()
 {
 }
 
-QAction * RS_ActionDrawLineAngle::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionDrawLineAngle::rtti()
 {
-       QAction * action = NULL;
-
-       if (type == RS2::ActionDrawLineAngle)
-       {
-               action = new QAction(tr("&Angle"), 0);
-//             action = new QAction(tr("Line: Angle"), tr("&Angle"),
-//                                                                     QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw lines with a given angle"));
-       }
-       else if (type == RS2::ActionDrawLineHorizontal)
-       {
-               action = new QAction(tr("&Horizontal"), 0);
-//             action = new QAction(tr("Line: Horizontal"), tr("&Horizontal"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw horizontal lines"));
-       }
-       else if (type == RS2::ActionDrawLineVertical)
-       {
-               action = new QAction(tr("H&orizontal / Vertical"), 0);
-//             action = new QAction(tr("hor./vert. line"), tr("H&orizontal / Vertical"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw horizontal/vertical lines"));
-       }
-
-       return action;
+       return RS2::ActionDrawLineAngle;
 }
 
 void RS_ActionDrawLineAngle::reset()
@@ -68,238 +45,275 @@ void RS_ActionDrawLineAngle::reset()
        data = RS_LineData(Vector(false), Vector(false));
 }
 
+void RS_ActionDrawLineAngle::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-
-void RS_ActionDrawLineAngle::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+       reset();
 }
 
+void RS_ActionDrawLineAngle::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 
+       preparePreview();
+       RS_Line * line = new RS_Line(container,
+                       data);
+       line->setLayerToActive();
+       line->setPenToActive();
+       container->addEntity(line);
 
-void RS_ActionDrawLineAngle::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    preparePreview();
-    RS_Line* line = new RS_Line(container,
-                                data);
-    line->setLayerToActive();
-    line->setPenToActive();
-    container->addEntity(line);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(line);
-        document->endUndoCycle();
-    }
-    deleteSnapper();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(line);
-    graphicView->moveRelativeZero(data.startpoint);
-    RS_DEBUG->print("RS_ActionDrawLineAngle::trigger(): line added: %d",
-                    line->getId());
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(line);
+               document->endUndoCycle();
+       }
+       deleteSnapper();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(line);
+       graphicView->moveRelativeZero(data.startpoint);
+       RS_DEBUG->print("RS_ActionDrawLineAngle::trigger(): line added: %d",
+               line->getId());
 }
 
+void RS_ActionDrawLineAngle::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineAngle::mouseMoveEvent begin");
 
+       if (getStatus() == SetPos)
+       {
+               pos = snapPoint(e);
+               deletePreview();
+               clearPreview();
+               preparePreview();
+               preview->addEntity(new RS_Line(preview,
+                               data));
+               drawPreview();
+       }
 
-void RS_ActionDrawLineAngle::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineAngle::mouseMoveEvent begin");
-
-    if (getStatus()==SetPos) {
-        pos = snapPoint(e);
-        deletePreview();
-        clearPreview();
-        preparePreview();
-        preview->addEntity(new RS_Line(preview,
-                                       data));
-        drawPreview();
-    }
-
-    RS_DEBUG->print("RS_ActionDrawLineAngle::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDrawLineAngle::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawLineAngle::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        if (getStatus()==SetPos) {
-            RS_CoordinateEvent ce(snapPoint(e));
-            coordinateEvent(&ce);
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawLineAngle::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               if (getStatus() == SetPos)
+               {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-void RS_ActionDrawLineAngle::preparePreview() {
-    Vector p1, p2;
-    // End:
-    if (snpPoint == 2) {
-        p2.setPolar(length * -1, angle);
-    } else {
-        p2.setPolar(length, angle);
-    }
-
-    // Middle:
-    if (snpPoint == 1) {
-        p1 = pos - (p2 / 2);
-    } else {
-        p1 = pos;
-    }
-
-    p2 += p1;
-    data = RS_LineData(p1, p2);
+void RS_ActionDrawLineAngle::preparePreview()
+{
+       Vector p1, p2;
+
+       // End:
+       if (snpPoint == 2)
+               p2.setPolar(length * -1, angle);
+       else
+               p2.setPolar(length, angle);
+
+       // Middle:
+       if (snpPoint == 1)
+               p1 = pos - (p2 / 2);
+       else
+               p1 = pos;
+
+       p2 += p1;
+       data = RS_LineData(p1, p2);
 }
 
+void RS_ActionDrawLineAngle::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-void RS_ActionDrawLineAngle::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPos:
-        pos = e->getCoordinate();
-        trigger();
-        break;
+       switch (getStatus())
+       {
+       case SetPos:
+               pos = *e;
+               trigger();
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+void RS_ActionDrawLineAngle::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
 
-void RS_ActionDrawLineAngle::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPos:
-        if (!fixedAngle && checkCommand("angle", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetAngle);
-        } else if (checkCommand("length", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetLength);
-        }
-        break;
-
-    case SetAngle: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                angle = RS_Math::deg2rad(a);
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(SetPos);
-        }
-        break;
-
-    case SetLength: {
-            bool ok;
-            double l = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                length = l;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(SetPos);
-        }
-        break;
-
-    default:
-        break;
-    }
+       switch (getStatus())
+       {
+       case SetPos:
+
+               if (!fixedAngle && checkCommand("angle", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetAngle);
+               }
+               else if (checkCommand("length", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetLength);
+               }
+               break;
+
+       case SetAngle: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       angle = RS_Math::deg2rad(a);
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(SetPos);
+       }
+       break;
+
+       case SetLength: {
+               bool ok;
+               double l = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       length = l;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(SetPos);
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionDrawLineAngle::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetPos:
 
-QStringList RS_ActionDrawLineAngle::getAvailableCommands() {
-    QStringList cmd;
+               if (!fixedAngle)
+                       cmd += command("angle");
+               cmd += command("length");
+               break;
 
-    switch (getStatus()) {
-    case SetPos:
-        if (!fixedAngle) {
-            cmd += command("angle");
-        }
-        cmd += command("length");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
+void RS_ActionDrawLineAngle::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetPos:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"),
+                       tr("Cancel"));
+               break;
 
-void RS_ActionDrawLineAngle::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetPos:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"),
-                                            tr("Cancel"));
-        break;
-
-    case SetAngle:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter angle:"), tr("Back"));
-        break;
+       case SetAngle:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter angle:"), tr("Back"));
+               break;
 
-    case SetLength:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter length:"), tr("Back"));
-        break;
+       case SetLength:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter length:"), tr("Back"));
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+void RS_ActionDrawLineAngle::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
+       RS_DIALOGFACTORY->requestOptions(this, true);
+}
 
-void RS_ActionDrawLineAngle::showOptions() {
-    RS_ActionInterface::showOptions();
+void RS_ActionDrawLineAngle::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
+void RS_ActionDrawLineAngle::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
+void RS_ActionDrawLineAngle::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+}
 
-void RS_ActionDrawLineAngle::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+void RS_ActionDrawLineAngle::setSnapPoint(int sp)
+{
+       snpPoint = sp;
 }
 
+int RS_ActionDrawLineAngle::getSnapPoint()
+{
+       return snpPoint;
+}
 
+void RS_ActionDrawLineAngle::setAngle(double a)
+{
+       angle = a;
+}
 
-void RS_ActionDrawLineAngle::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+double RS_ActionDrawLineAngle::getAngle()
+{
+       return angle;
 }
 
+void RS_ActionDrawLineAngle::setLength(double l)
+{
+       length = l;
+}
 
+double RS_ActionDrawLineAngle::getLength()
+{
+       return length;
+}
 
-void RS_ActionDrawLineAngle::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-    }
+bool RS_ActionDrawLineAngle::hasFixedAngle()
+{
+       return fixedAngle;
 }
 
-// EOF
index 537a635f45e5b12c7575fc6a3e63f61bf1579042..71c5ec46dde1541dbc5a56bb6696e199cc80818f 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlineangle.h 1092 2004-03-16 18:01:08Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEANGLE_H
 #define RS_ACTIONDRAWLINEANGLE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_line.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * simple lines at a gien angle.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineAngle : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetPos,       /**< Setting the position.  */
-               SetAngle,     /**< Setting angle in the command line. */
-               SetLength     /**< Setting length in the command line. */
-    };
-       
-    RS_ActionDrawLineAngle(RS_EntityContainer& container,
-                           RS_GraphicView& graphicView,
-                           double angle=0.0,
-                           bool fixedAngle=false);
-    ~RS_ActionDrawLineAngle();
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLineAngle;
-       }
-
-    void reset();
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       void preparePreview();
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       void setSnapPoint(int sp) {
-               snpPoint = sp;
-       }
-
-       int getSnapPoint() {
-               return snpPoint;
-       }
-
-       void setAngle(double a) {
-               angle = a;
-       }
-
-       double getAngle() {
-               return angle;
-       }
-
-       void setLength(double l) {
-               length = l;
-       }
-
-       double getLength() {
-               return length;
-       }
-
-       bool hasFixedAngle() {
-               return fixedAngle;
-       }
-
-protected:
-    /**
-     * Line data defined so far.
-     */
-    RS_LineData data;
-       /**
-        * Position.
-        */
-       Vector pos;
-    /**
-     * Line angle.
-     */
-    double angle;
-       /**
-        * Line length.
-        */
-       double length;
-    /**
-     * Is the angle fixed?
-     */
-    bool fixedAngle;
-    /**
-     * Snap point (start, middle, end).
-     */
-    int snpPoint;
+class RS_ActionDrawLineAngle: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetPos,       /**< Setting the position.  */
+                       SetAngle,     /**< Setting angle in the command line. */
+                       SetLength     /**< Setting length in the command line. */
+               };
+
+               RS_ActionDrawLineAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+               ~RS_ActionDrawLineAngle();
+
+               virtual RS2::ActionType rtti();
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               void preparePreview();
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setSnapPoint(int sp);
+               int getSnapPoint();
+               void setAngle(double a);
+               double getAngle();
+               void setLength(double l);
+               double getLength();
+               bool hasFixedAngle();
+
+       protected:
+               /**
+                * Line data defined so far.
+                */
+               RS_LineData data;
+               /**
+                * Position.
+                */
+               Vector pos;
+               /**
+                * Line angle.
+                */
+               double angle;
+               /**
+                * Line length.
+                */
+               double length;
+               /**
+                * Is the angle fixed?
+                */
+               bool fixedAngle;
+               /**
+                * Snap point (start, middle, end).
+                */
+               int snpPoint;
 };
 
 #endif
index d5c03f5bb9c3f4d429b41288ff164069b8fb205d..c3760951d1c40298032ffa186d9c7e959e8ee907 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinebisector.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinebisector.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/03/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinebisector.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDrawLineBisector::RS_ActionDrawLineBisector(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Bisectors", container, graphicView) {
-
-    bisector = NULL;
-    length = 10.0;
-    line1 = NULL;
-    line2 = NULL;
-    number = 1;
-    coord1 = Vector(false);
-    coord2 = Vector(false);
-    lastStatus = SetLine1;
+RS_ActionDrawLineBisector::RS_ActionDrawLineBisector(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Draw Bisectors", container, graphicView)
+{
+       bisector = NULL;
+       length = 10.0;
+       line1 = NULL;
+       line2 = NULL;
+       number = 1;
+       coord1 = Vector(false);
+       coord2 = Vector(false);
+       lastStatus = SetLine1;
 }
 
-QAction* RS_ActionDrawLineBisector::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineBisector::~RS_ActionDrawLineBisector()
 {
-       QAction * action = new QAction(tr("&Bisector"), 0);
-//     QAction* action = new QAction(tr("Bisector"), tr("&Bisector"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw bisectors"));
-       return action;
 }
 
-
-void RS_ActionDrawLineBisector::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    //if (bisector!=NULL) {
-    RS_Creation creation(container, graphicView);
-    creation.createBisector(coord1,
-                            coord2,
-                            length,
-                            number,
-                            line1,
-                            line2);
-    /*RS_Entity* newEntity = NULL;
-
-    newEntity = new RS_Line(container,
-                            bisector->getData());
-
-    if (newEntity!=NULL) {
-        newEntity->setLayerToActive();
-        newEntity->setPenToActive();
-        container->addEntity(newEntity);
-
-        // upd. undo list:
-        if (document!=NULL) {
-            document->startUndoCycle();
-            document->addUndoable(newEntity);
-            document->endUndoCycle();
-        }
-        graphicView->drawEntity(newEntity);
-        setStatus(SetLine1);
-}
-    //reset();
-    delete bisector;
-    bisector = NULL;
-    */
-    /*} else {
-        RS_DEBUG->print("RS_ActionDrawLineBisector::trigger:"
-                        " Entity is NULL\n");
-}*/
+/*virtual*/ RS2::ActionType RS_ActionDrawLineBisector::rtti()
+{
+       return RS2::ActionDrawLineBisector;
 }
 
-
-
-void RS_ActionDrawLineBisector::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent begin");
-
-    Vector mouse = Vector(graphicView->toGraphX(e->x()),
-                                graphicView->toGraphY(e->y()));
-
-    switch (getStatus()) {
-    case SetLine1:
-        break;
-
-    case SetLine2: {
-            coord2 = mouse;
-            RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-            if (en!=NULL && en->rtti()==RS2::EntityLine) {
-                line2 = (RS_Line*)en;
-
-                deletePreview();
-                clearPreview();
-
-                RS_Creation creation(preview, NULL, false);
-                creation.createBisector(coord1,
-                                        coord2,
-                                        length,
-                                        number,
-                                        line1,
-                                        line2);
-                drawPreview();
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent end");
+void RS_ActionDrawLineBisector::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       //if (bisector!=NULL) {
+       RS_Creation creation(container, graphicView);
+       creation.createBisector(coord1,
+               coord2,
+               length,
+               number,
+               line1,
+               line2);
+       /*RS_Entity* newEntity = NULL;
+
+          newEntity = new RS_Line(container,
+                               bisector->getData());
+
+          if (newEntity!=NULL) {
+           newEntity->setLayerToActive();
+           newEntity->setPenToActive();
+           container->addEntity(newEntity);
+
+           // upd. undo list:
+           if (document!=NULL) {
+               document->startUndoCycle();
+               document->addUndoable(newEntity);
+               document->endUndoCycle();
+           }
+           graphicView->drawEntity(newEntity);
+           setStatus(SetLine1);
+          }
+          //reset();
+          delete bisector;
+          bisector = NULL;
+        */
+       /*} else {
+           RS_DEBUG->print("RS_ActionDrawLineBisector::trigger:"
+                           " Entity is NULL\n");
+          }*/
 }
 
-
-
-void RS_ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent* e) {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        clearPreview();
-        init(getStatus()-1);
-    } else {
-
-        Vector mouse = Vector(graphicView->toGraphX(e->x()),
-                                    graphicView->toGraphY(e->y()));
-
-        switch (getStatus()) {
-        case SetLine1: {
-                coord1 = mouse;
-                RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-                if (en!=NULL && en->rtti()==RS2::EntityLine) {
-                    line1 = (RS_Line*)en;
-                }
-            }
-            setStatus(SetLine2);
-            break;
-
-        case SetLine2:
-            coord2 = mouse;
-            trigger();
-            setStatus(SetLine1);
-            break;
-        }
-    }
-
+void RS_ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent begin");
+
+       Vector mouse = Vector(graphicView->toGraphX(e->x()),
+                       graphicView->toGraphY(e->y()));
+
+       switch (getStatus())
+       {
+       case SetLine1:
+               break;
+
+       case SetLine2: {
+               coord2 = mouse;
+               RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+               if (en != NULL && en->rtti() == RS2::EntityLine)
+               {
+                       line2 = (RS_Line *)en;
+
+                       deletePreview();
+                       clearPreview();
+
+                       RS_Creation creation(preview, NULL, false);
+                       creation.createBisector(coord1,
+                               coord2,
+                               length,
+                               number,
+                               line1,
+                               line2);
+                       drawPreview();
+               }
+       }
+       break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent end");
 }
 
-
-void RS_ActionDrawLineBisector::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetLine1:
-    case SetLine2:
-        lastStatus = (Status)getStatus();
-        if (checkCommand("length", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetLength);
-        } else if (checkCommand("number", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetNumber);
-        }
-        break;
-
-    case SetLength: {
-            bool ok;
-            double l = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                length = l;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetNumber: {
-            bool ok;
-            int n = (int)RS_Math::eval(c, &ok);
-            if (ok==true) {
-                number = n;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-
-    default:
-        break;
-    }
+void RS_ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               clearPreview();
+               init(getStatus() - 1);
+       }
+       else
+       {
+               Vector mouse = Vector(graphicView->toGraphX(e->x()),
+                               graphicView->toGraphY(e->y()));
+
+               switch (getStatus())
+               {
+               case SetLine1: {
+                       coord1 = mouse;
+                       RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+                       if (en != NULL && en->rtti() == RS2::EntityLine)
+                               line1 = (RS_Line *)en;
+               }
+                       setStatus(SetLine2);
+                       break;
+
+               case SetLine2:
+                       coord2 = mouse;
+                       trigger();
+                       setStatus(SetLine1);
+                       break;
+               }
+       }
 }
 
+void RS_ActionDrawLineBisector::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetLine1:
+       case SetLine2:
+               lastStatus = (Status)getStatus();
+
+               if (checkCommand("length", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetLength);
+               }
+               else if (checkCommand("number", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetNumber);
+               }
+               break;
+
+       case SetLength: {
+               bool ok;
+               double l = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       length = l;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetNumber: {
+               bool ok;
+               int n = (int)RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       number = n;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       default:
+               break;
+       }
+}
 
+QStringList RS_ActionDrawLineBisector::getAvailableCommands()
+{
+       QStringList cmd;
 
-QStringList RS_ActionDrawLineBisector::getAvailableCommands() {
-    QStringList cmd;
+       switch (getStatus())
+       {
+       case SetLine1:
+       case SetLine2:
+               cmd += command("length");
+               cmd += command("number");
+               break;
 
-    switch (getStatus()) {
-    case SetLine1:
-    case SetLine2:
-        cmd += command("length");
-        cmd += command("number");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-void RS_ActionDrawLineBisector::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetLine1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"),
-                                            tr("Cancel"));
-        break;
-    case SetLine2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"),
-                                            tr("Back"));
-        break;
-    case SetLength:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"),
-                                            tr("Back"));
-        break;
-    case SetNumber:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDrawLineBisector::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetLine1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"),
+                       tr("Cancel"));
+               break;
+
+       case SetLine2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"),
+                       tr("Back"));
+               break;
+
+       case SetLength:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"),
+                       tr("Back"));
+               break;
+
+       case SetNumber:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDrawLineBisector::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDrawLineBisector::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDrawLineBisector::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawLineBisector::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionDrawLineBisector::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineBisector::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionDrawLineBisector::updateToolBar()
+{
+       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+}
 
+void RS_ActionDrawLineBisector::setLength(double l)
+{
+       length = l;
+}
 
-void RS_ActionDrawLineBisector::updateToolBar() {
-    RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+double RS_ActionDrawLineBisector::getLength()
+{
+       return length;
 }
 
+void RS_ActionDrawLineBisector::setNumber(int n)
+{
+       number = n;
+}
 
+int RS_ActionDrawLineBisector::getNumber()
+{
+       return number;
+}
 
-// EOF
index dfd3e14d07fadfd903e9d63a45e3b78549efbc53..2caf564b3de61eb3e13e8e86f3c97d220dd369e7 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinebisector.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEBISECTOR_H
 #define RS_ACTIONDRAWLINEBISECTOR_H
 
+#include "rs_line.h"
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Line;
 
 /**
  * This action class can handle user events to draw bisectors.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineBisector : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetLine1,     /**< Choose the 1st line. */
-        SetLine2,     /**< Choose the 2nd line. */
-               SetLength,    /**< Set length in command line. */
-               SetNumber     /**< Set number in command line. */
-    };
-
-public:
-    RS_ActionDrawLineBisector(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineBisector() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLineBisector;
-       }
-
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-       
-       void setLength(double l) {
-               length = l;
-       }
+class RS_ActionDrawLineBisector: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetLine1,     /**< Choose the 1st line. */
+                       SetLine2,     /**< Choose the 2nd line. */
+                       SetLength,    /**< Set length in command line. */
+                       SetNumber     /**< Set number in command line. */
+               };
 
-       double getLength() {
-               return length;
-       }
-       
-       void setNumber(int n) {
-               number = n;
-       }
+       public:
+               RS_ActionDrawLineBisector(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineBisector();
 
-       int getNumber() {
-               return number;
-       }
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setLength(double l);
+               double getLength();
+               void setNumber(int n);
+               int getNumber();
 
-private:
-    /** Closest bisector. */
-    RS_Line* bisector;
-    /** First chosen entity */
-    RS_Line* line1;
-    /** Second chosen entity */
-    RS_Line* line2;
-    /** Data of new bisector */
-    RS_LineData data;
-    /** Length of the bisector. */
-    double length;
-       /** Number of bisectors to create. */
-       int number;
-       /** Mouse pos when choosing the 1st line */
-       Vector coord1;
-       /** Mouse pos when choosing the 2nd line */
-       Vector coord2;
-       /** Last status before entering length or number. */
-       Status lastStatus;
+       private:
+               /** Closest bisector. */
+               RS_Line * bisector;
+               /** First chosen entity */
+               RS_Line * line1;
+               /** Second chosen entity */
+               RS_Line * line2;
+               /** Data of new bisector */
+               RS_LineData data;
+               /** Length of the bisector. */
+               double length;
+               /** Number of bisectors to create. */
+               int number;
+               /** Mouse pos when choosing the 1st line */
+               Vector coord1;
+               /** Mouse pos when choosing the 2nd line */
+               Vector coord2;
+               /** Last status before entering length or number. */
+               Status lastStatus;
 };
 
 #endif
index 05aeb833eef8db17e2475e236264b11bd8d0a447..f2d18e7c32cd7323f453f2fca294333b0ea4b3cf 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinefree.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinefree.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinefree.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_polyline.h"
 
-
-RS_ActionDrawLineFree::RS_ActionDrawLineFree(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Draw freehand lines",
-                    container, graphicView) {
-    vertex = Vector(false);
-    polyline = NULL;
-}
-
-RS_ActionDrawLineFree::~RS_ActionDrawLineFree() {
-    if (polyline!=NULL) {
-        delete polyline;
-    }
+RS_ActionDrawLineFree::RS_ActionDrawLineFree(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Draw freehand lines",
+               container, graphicView)
+{
+       vertex = Vector(false);
+       polyline = NULL;
 }
 
-QAction* RS_ActionDrawLineFree::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineFree::~RS_ActionDrawLineFree()
 {
-       QAction * action = new QAction(tr("&Freehand Line"), 0);
-//     QAction* action = new QAction(tr("Line: Freehand"), tr("&Freehand Line"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw freehand lines"));
-       return action;
+       if (polyline != NULL)
+               delete polyline;
 }
 
-void RS_ActionDrawLineFree::trigger() {
-    if (polyline!=NULL) {
-        container->addEntity(polyline);
-        deleteSnapper();
-
-        if (document) {
-            document->startUndoCycle();
-            document->addUndoable(polyline);
-            document->endUndoCycle();
-        }
-
-        RS_DEBUG->print("RS_ActionDrawLineFree::trigger():"
-                        " polyline added: %d", polyline->getId());
-        polyline = NULL;
-    }
+void RS_ActionDrawLineFree::trigger()
+{
+       if (polyline != NULL)
+       {
+               container->addEntity(polyline);
+               deleteSnapper();
+
+               if (document)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(polyline);
+                       document->endUndoCycle();
+               }
+
+               RS_DEBUG->print("RS_ActionDrawLineFree::trigger():"
+                       " polyline added: %d", polyline->getId());
+               polyline = NULL;
+       }
 }
 
-
-
-void RS_ActionDrawLineFree::mouseMoveEvent(QMouseEvent* e) {
-    if (vertex.valid && polyline!=NULL) {
-        Vector v = snapPoint(e);
-        RS_Entity* ent = polyline->addVertex(v);
-        ent->setLayerToActive();
-        ent->setPenToActive();
-
-        deleteSnapper();
-        graphicView->drawEntity(ent);
-        drawSnapper();
-
-        vertex = v;
-
-        RS_DEBUG->print("RS_ActionDrawLineFree::mouseMoveEvent():"
-                        " line added: %d", ent->getId());
-    }
+void RS_ActionDrawLineFree::mouseMoveEvent(QMouseEvent * e)
+{
+       if (vertex.valid && polyline != NULL)
+       {
+               Vector v = snapPoint(e);
+               RS_Entity * ent = polyline->addVertex(v);
+               ent->setLayerToActive();
+               ent->setPenToActive();
+
+               deleteSnapper();
+               graphicView->drawEntity(ent);
+               drawSnapper();
+
+               vertex = v;
+
+               RS_DEBUG->print("RS_ActionDrawLineFree::mouseMoveEvent():"
+                       " line added: %d", ent->getId());
+       }
 }
 
-
-
-void RS_ActionDrawLineFree::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        vertex = snapPoint(e);
-        polyline = new RS_Polyline(container,
-                                   RS_PolylineData(vertex, vertex, 0));
-        polyline->setLayerToActive();
-        polyline->setPenToActive();
-    }
-    //else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton && !vertex.valid) {
-    //}
+void RS_ActionDrawLineFree::mousePressEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               vertex = snapPoint(e);
+               polyline = new RS_Polyline(container, RS_PolylineData(vertex, vertex, 0));
+               polyline->setLayerToActive();
+               polyline->setPenToActive();
+       }
+       //else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton && !vertex.valid) {
+       //}
 }
 
-
-
-void RS_ActionDrawLineFree::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        vertex = Vector(false);
-        trigger();
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        if (polyline!=NULL) {
-            delete polyline;
-            polyline = NULL;
-        }
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawLineFree::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               vertex = Vector(false);
+               trigger();
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               if (polyline != NULL)
+               {
+                       delete polyline;
+                       polyline = NULL;
+               }
+
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawLineFree::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case 0:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Click and drag to draw a line"), tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDrawLineFree::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case 0:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Click and drag to draw a line"), tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLineFree::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineFree::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawLineFree::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-    }
+void RS_ActionDrawLineFree::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
 }
 
-// EOF
index b78af4a98be470d91a0ee5b6ecb4c5e275935302..b8e01ed2373ab35d25ccc7a8fb4345d086424d8f 100644 (file)
@@ -1,60 +1,33 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinefree.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEFREE_H
 #define RS_ACTIONDRAWLINEFREE_H
 
 #include "rs_actioninterface.h"
-#include "rs_polyline.h"
+#include "vector.h"
+
+class RS_Polyline;
 
 /**
  * This action class can handle user events to draw freehand lines.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineFree : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionDrawLineFree(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineFree();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionDrawLineFree: public RS_ActionInterface
+{
+       public:
+               RS_ActionDrawLineFree(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineFree();
 
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
 
-protected:
-    Vector vertex;
-    RS_Polyline* polyline;
+       protected:
+               Vector vertex;
+               RS_Polyline * polyline;
 };
 
 #endif
index d8e41e1edd028713048e47fcc47af777ee866699..67be5e2e34752c1bf2cb4cac27aed6ab882a89f2 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinehorvert.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinehorvert.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinehorvert.h"
-#include "rs_snapper.h"
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-RS_ActionDrawLineHorVert::RS_ActionDrawLineHorVert(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw horizontal/vertical lines",
-                           container, graphicView) {
-    reset();
-    RS_DEBUG->print("RS_ActionDrawLineHorVert::constructor");
-}
-
-
-
-RS_ActionDrawLineHorVert::~RS_ActionDrawLineHorVert() {}
-
-
-QAction* RS_ActionDrawLineHorVert::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineHorVert::RS_ActionDrawLineHorVert(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw horizontal/vertical lines",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("H&orizontal / Vertical"), 0);
-//     QAction* action = new QAction(tr("hor./vert. line"),
-//                                                                     tr("H&orizontal / Vertical"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw horizontal/vertical lines"));
-       return action;
+       reset();
+       RS_DEBUG->print("RS_ActionDrawLineHorVert::constructor");
 }
 
-void RS_ActionDrawLineHorVert::reset() {
-    data = RS_LineData(Vector(false),
-                       Vector(false));
+RS_ActionDrawLineHorVert::~RS_ActionDrawLineHorVert()
+{
 }
 
-
-
-void RS_ActionDrawLineHorVert::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
-    RS_DEBUG->print("RS_ActionDrawLineHorVert::init");
+void RS_ActionDrawLineHorVert::reset()
+{
+       data = RS_LineData(Vector(false), Vector(false));
 }
 
-
-
-void RS_ActionDrawLineHorVert::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    RS_Line* line = new RS_Line(container, data);
-    line->setLayerToActive();
-    line->setPenToActive();
-    container->addEntity(line);
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(line);
-        document->endUndoCycle();
-    }
-
-    deleteSnapper();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(line);
-    graphicView->moveRelativeZero(line->getMiddlepoint());
-    RS_DEBUG->print("RS_ActionDrawLineHorVert::trigger():"
-                    " line added: %d", line->getId());
-
+void RS_ActionDrawLineHorVert::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
+       reset();
+       RS_DEBUG->print("RS_ActionDrawLineHorVert::init");
 }
 
-
-
-void RS_ActionDrawLineHorVert::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineHorVert::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
-    if (getStatus()==SetEndpoint && p1.valid) {
-        Vector p2x = Vector(mouse.x, p1.y);
-        Vector p2y = Vector(p1.x, mouse.y);
-        if (mouse.distanceTo(p2y) > mouse.distanceTo(p2x))
-            p2 = p2x;
-        else
-            p2 = p2y;
-        deletePreview();
-        clearPreview();
-        data = RS_LineData(p1, p2);
-        preview->addEntity(new RS_Line(preview, data));
-        drawPreview();
-    }
-
-    RS_DEBUG->print("RS_ActionDrawLineHorVert::mouseMoveEvent end");
+void RS_ActionDrawLineHorVert::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       RS_Line * line = new RS_Line(container, data);
+       line->setLayerToActive();
+       line->setPenToActive();
+       container->addEntity(line);
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(line);
+               document->endUndoCycle();
+       }
+
+       deleteSnapper();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(line);
+       graphicView->moveRelativeZero(line->getMiddlepoint());
+       RS_DEBUG->print("RS_ActionDrawLineHorVert::trigger():"
+               " line added: %d", line->getId());
 }
 
+void RS_ActionDrawLineHorVert::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineHorVert::mouseMoveEvent begin");
 
+       Vector mouse = snapPoint(e);
 
-void RS_ActionDrawLineHorVert::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        Vector mouse = snapPoint(e);
+       if (getStatus() == SetEndpoint && p1.valid)
+       {
+               Vector p2x = Vector(mouse.x, p1.y);
+               Vector p2y = Vector(p1.x, mouse.y);
 
-        switch (getStatus()) {
-        case SetStartpoint:
-            p1 = mouse;
-            setStatus(SetEndpoint);
-            break;
+               if (mouse.distanceTo(p2y) > mouse.distanceTo(p2x))
+                       p2 = p2x;
+               else
+                       p2 = p2y;
 
-        case SetEndpoint:
-            p2 = mouse;
-            trigger();
-            setStatus(SetStartpoint);
-            break;
+               deletePreview();
+               clearPreview();
+               data = RS_LineData(p1, p2);
+               preview->addEntity(new RS_Line(preview, data));
+               drawPreview();
+       }
 
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+       RS_DEBUG->print("RS_ActionDrawLineHorVert::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawLineHorVert::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetStartpoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"),
-                                            tr("Cancel"));
-        break;
-    case SetEndpoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionDrawLineHorVert::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               Vector mouse = snapPoint(e);
+
+               switch (getStatus())
+               {
+               case SetStartpoint:
+                       p1 = mouse;
+                       setStatus(SetEndpoint);
+                       break;
+
+               case SetEndpoint:
+                       p2 = mouse;
+                       trigger();
+                       setStatus(SetStartpoint);
+                       break;
+
+               default:
+                       break;
+               }
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-void RS_ActionDrawLineHorVert::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineHorVert::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetStartpoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
+               break;
+
+       case SetEndpoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second point"), tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDrawLineHorVert::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
-void RS_ActionDrawLineHorVert::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-    }
+void RS_ActionDrawLineHorVert::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
 }
 
-// EOF
index 2254c15411c902eb763d7e87be0e9bd78b8d4b9f..618ed84accb0318851e9b9e2b27657c43b728bec 100644 (file)
@@ -1,81 +1,52 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinehorvert.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEHORVERT_H
 #define RS_ACTIONDRAWLINEHORVERT_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_line.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * horizontal/vertical lines from a given startpoint
  * to an endpoint closest to a second given point.
  * OBSOLETE
  *
  * @author Ulf Lehnert
  */
-class RS_ActionDrawLineHorVert : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetStartpoint,      /**< Setting the 1st point.  */
-        SetEndpoint       /**< Setting the 2nd point. */
-    };
-
-public:
-    RS_ActionDrawLineHorVert(RS_EntityContainer& container,
-                             RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineHorVert();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    void reset();
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /**
-     * Line data.
-     */
-    RS_LineData data;
-    /**
-     * 2 points
-     */
-    Vector p1;
-    Vector p2;
+class RS_ActionDrawLineHorVert: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetStartpoint,      /**< Setting the 1st point.  */
+                       SetEndpoint       /**< Setting the 2nd point. */
+               };
+
+       public:
+               RS_ActionDrawLineHorVert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineHorVert();
+
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /**
+                * Line data.
+                */
+               RS_LineData data;
+               /**
+                * 2 points
+                */
+               Vector p1;
+               Vector p2;
 };
 
 #endif
index 769f73a9c58562aefad606e8853b4b01bc7db47d..03ab2682e229a6643d21c87b913138b24b85855c 100644 (file)
 
 #include "rs_actiondrawlineparallel.h"
 
-#include "rs_creation.h"
-#include "rs_snapper.h"
 #include "rs_actiondrawlineparallelthrough.h"
+#include "commands.h"
+#include "rs_creation.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDrawLineParallel::RS_ActionDrawLineParallel(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Parallels", container, graphicView)
+RS_ActionDrawLineParallel::RS_ActionDrawLineParallel(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Parallels",
+               container, graphicView)
 {
-    parallel = NULL;
-    entity = NULL;
-    distance = 1.0;
-    number = 1;
-    coord = Vector(false);
+       parallel = NULL;
+       entity = NULL;
+       distance = 1.0;
+       number = 1;
+       coord = Vector(false);
 }
 
-QAction * RS_ActionDrawLineParallel::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionDrawLineParallel::~RS_ActionDrawLineParallel()
 {
-       QAction * action = NULL;
-
-       if (type == RS2::ActionDrawLineParallel)
-       {
-               action = new QAction(tr("Para&llel"), 0);
-//             action = new QAction(tr("Parallel"), tr("Para&llel"),
-//                                                             QKeySequence(), NULL);
-       }
-       else if (type == RS2::ActionDrawArcParallel)
-       {
-               action = new QAction(tr("&Concentric"), 0);
-//             action = new QAction(tr("Concentric"), tr("&Concentric"),
-//                                                             QKeySequence(), NULL);
-       }
-       else if (type == RS2::ActionDrawCircleParallel)
-       {
-               action = new QAction(tr("&Concentric"), 0);
-//             action = new QAction(tr("Concentric"), tr("&Concentric"),
-//                                                             QKeySequence(), NULL);
-       }
+}
 
-       action->setStatusTip(tr("Draw parallels to existing lines, arcs, circles"));
-       return action;
+/*virtual*/ RS2::ActionType RS_ActionDrawLineParallel::rtti()
+{
+       return RS2::ActionDrawLineParallel;
 }
 
 void RS_ActionDrawLineParallel::trigger()
 {
-    RS_PreviewActionInterface::trigger();
+       RS_PreviewActionInterface::trigger();
 
-    RS_Creation creation(container, graphicView);
-    RS_Entity* e = creation.createParallel(coord,
-                                           distance, number,
-                                           entity);
+       RS_Creation creation(container, graphicView);
+       RS_Entity * e = creation.createParallel(coord, distance, number, entity);
 
-    if (e==NULL) {
-        RS_DEBUG->print("RS_ActionDrawLineParallel::trigger:"
-                        " No parallels added\n");
-    }
+       if (e == NULL)
+               RS_DEBUG->print("RS_ActionDrawLineParallel::trigger: No parallels added\n");
 }
 
+void RS_ActionDrawLineParallel::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent begin");
+       coord = Vector(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
+       entity = catchEntity(e, RS2::ResolveAll);
 
+       switch (getStatus())
+       {
+       case SetEntity:
+       {
+               deletePreview();
+               clearPreview();
+               RS_Creation creation(preview, NULL, false);
+               creation.createParallel(coord, distance, number, entity);
+               drawPreview();
+       }
+       break;
 
-void RS_ActionDrawLineParallel::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent begin");
-
-    coord = Vector(graphicView->toGraphX(e->x()),
-                      graphicView->toGraphY(e->y()));
-
-    entity = catchEntity(e, RS2::ResolveAll);
-
-    switch (getStatus()) {
-    case SetEntity: {
-            deletePreview();
-            clearPreview();
-
-            RS_Creation creation(preview, NULL, false);
-            creation.createParallel(coord,
-                                    distance, number,
-                                    entity);
-
-            drawPreview();
-        }
-        break;
-
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent end");
 }
 
+void RS_ActionDrawLineParallel::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       if (e->button() == Qt::RightButton)
+               init(getStatus() - 1);
+       else
+               trigger();
+}
 
-
-void RS_ActionDrawLineParallel::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-        trigger();
-    }
+void RS_ActionDrawLineParallel::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetEntity:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify Distance <%1> or select entity or [%2]")
+                               .arg(distance).arg(RS_COMMANDS->command("through")),
+                               tr("Cancel"));
+                       break;
+
+               case SetNumber:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number:"), "");
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
+void RS_ActionDrawLineParallel::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 
-void RS_ActionDrawLineParallel::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetEntity:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify Distance <%1> or select entity or [%2]")
-                .arg(distance).arg(RS_COMMANDS->command("through")),
-                tr("Cancel"));
-            break;
+       updateMouseButtonHints();
+}
 
-        case SetNumber:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number:"), "");
-            break;
+void RS_ActionDrawLineParallel::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
+void RS_ActionDrawLineParallel::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
 
-void RS_ActionDrawLineParallel::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
-    updateMouseButtonHints();
-}
+               return;
+       }
 
+       switch (getStatus())
+       {
+       case SetEntity:
+               if (checkCommand("through", c))
+               {
+                       finish();
+                       graphicView->setCurrentAction(new RS_ActionDrawLineParallelThrough(*container,
+                                       *graphicView));
+               }
+               else if (checkCommand("number", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetNumber);
+               }
+               else
+               {
+                       bool ok;
+                       double d = RS_Math::eval(c, &ok);
+
+                       if (ok && d > 1.0e-10)
+                               distance = d;
+                       else    if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+
+                       if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->requestOptions(this, true, true);
+
+                       updateMouseButtonHints();
+                       //setStatus(SetEntity);
+               }
+               break;
+
+       case SetNumber:
+       {
+               bool ok;
+               int n = c.toInt(&ok);
 
+               if (ok)
+               {
+                       if (n > 0 && n < 100)
+                               number = n;
+                       else    if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. Try 1..99"));
 
-void RS_ActionDrawLineParallel::hideOptions() {
-    RS_ActionInterface::hideOptions();
+               }
+               else    if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
-}
 
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
 
+               setStatus(SetEntity);
+       }
+       break;
 
-void RS_ActionDrawLineParallel::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetEntity: {
-            if (checkCommand("through", c)) {
-                finish();
-                graphicView->setCurrentAction(
-                    new RS_ActionDrawLineParallelThrough(*container,
-                                                         *graphicView));
-            } else if (checkCommand("number", c)) {
-                deleteSnapper();
-                deletePreview();
-                clearPreview();
-                setStatus(SetNumber);
-            } else {
-                bool ok;
-                double d = RS_Math::eval(c, &ok);
-                if (ok==true && d>1.0e-10) {
-                    distance = d;
-                } else {
-                    if (RS_DIALOGFACTORY!=NULL) {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                    }
-                }
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->requestOptions(this, true, true);
-                }
-                updateMouseButtonHints();
-                //setStatus(SetEntity);
-            }
-        }
-        break;
-
-    case SetNumber: {
-            bool ok;
-            int n = c.toInt(&ok);
-            if (ok==true) {
-                if (n>0 && n<100) {
-                    number = n;
-                } else {
-                    if (RS_DIALOGFACTORY!=NULL) {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
-                                                            "Try 1..99"));
-                    }
-                }
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(SetEntity);
-        }
-        break;
-
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionDrawLineParallel::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetEntity:
+               cmd += command("number");
+               cmd += command("through");
+               break;
 
-QStringList RS_ActionDrawLineParallel::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetEntity:
-        cmd += command("number");
-        cmd += command("through");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
+void RS_ActionDrawLineParallel::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
-
-void RS_ActionDrawLineParallel::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineParallel::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
 }
 
+double RS_ActionDrawLineParallel::getDistance()
+{
+       return distance;
+}
 
+void RS_ActionDrawLineParallel::setDistance(double d)
+{
+       distance = d;
+}
 
-void RS_ActionDrawLineParallel::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-    }
+int RS_ActionDrawLineParallel::getNumber()
+{
+       return number;
 }
 
+void RS_ActionDrawLineParallel::setNumber(int n)
+{
+       number = n;
+}
 
-// EOF
index d357e0a6fb3558a0b07beded0cf2461ac5aa45b5..162e2deb0ef31704a57121b795e7d0f9144966de 100644 (file)
@@ -1,8 +1,11 @@
 #ifndef RS_ACTIONDRAWLINEPARALLEL_H
 #define RS_ACTIONDRAWLINEPARALLEL_H
 
+#include "rs_line.h"
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to draw parallel
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineParallel : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetEntity,    /**< Choose original entity. */
-               //SetDistance,  /**< Setting distance in the command line. */
-               SetNumber     /**< Setting number in the command line. */
-               //SetThrough     /**< Setting a point for the parallel to go through. */
-       };
-
-public:
-    RS_ActionDrawLineParallel(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineParallel() {}
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLineParallel;
-       }
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       double getDistance() {
-               return distance;
-       }
-
-       void setDistance(double d) {
-               distance = d;
-       }
-
-       int getNumber() {
-               return number;
-       }
-
-       void setNumber(int n) {
-               number = n;
-       }
-
-private:
-    /** Closest parallel. */
-    RS_Entity* parallel;
-    /** Data of new line */
-    RS_LineData data;
-    /** Distance of the parallel. */
-    double distance;
-       /** Number of parallels. */
-       int number;
-       /** Coordinate of the mouse. */
-       Vector coord;
-       /** Original entity. */
-       RS_Entity* entity;
-       /**
-        * Commands
-        */
-       /*
-       QString cmdDistance;
-       QString cmdDistance2;
-       QString cmdDistance3;
-
-       QString cmdNumber;
-       QString cmdNumber2;
-       QString cmdNumber3;
-       */
+class RS_ActionDrawLineParallel: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetEntity,    /**< Choose original entity. */
+                       //SetDistance,  /**< Setting distance in the command line. */
+                       SetNumber     /**< Setting number in the command line. */
+                       //SetThrough     /**< Setting a point for the parallel to go through. */
+               };
+
+       public:
+               RS_ActionDrawLineParallel(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineParallel();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               double getDistance();
+               void setDistance(double d);
+               int getNumber();
+               void setNumber(int n);
+
+       private:
+               /** Closest parallel. */
+               RS_Entity * parallel;
+               /** Data of new line */
+               RS_LineData data;
+               /** Distance of the parallel. */
+               double distance;
+               /** Number of parallels. */
+               int number;
+               /** Coordinate of the mouse. */
+               Vector coord;
+               /** Original entity. */
+               RS_Entity * entity;
 };
 
 #endif
index 79203c8e8283534ddd4b1b7711b799f661af6513..aa9db00cb0de92c8faba12b4998b2fc7f985f82e 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlineparallelthrough.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlineparallelthrough.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlineparallelthrough.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
-
-
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 RS_ActionDrawLineParallelThrough::RS_ActionDrawLineParallelThrough(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Parallels", container, graphicView) {
-
-    parallel = NULL;
-    entity = NULL;
-    distance = 1.0;
-    number = 1;
-    coord = Vector(false);
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Draw Parallels", container, graphicView)
+{
+       parallel = NULL;
+       entity = NULL;
+       distance = 1.0;
+       number = 1;
+       coord = Vector(false);
 }
 
-
-QAction* RS_ActionDrawLineParallelThrough::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineParallelThrough::~RS_ActionDrawLineParallelThrough()
 {
-       QAction * action = new QAction(tr("Par&allel through point"), 0);
-//     QAction* action = new QAction(tr("Parallel through point"),
-//                                                                     tr("Par&allel through point"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw parallel through a given point"));
-       return action;
 }
 
-void RS_ActionDrawLineParallelThrough::trigger() {
-    RS_PreviewActionInterface::trigger();
-    deleteSnapper();
-
-    if (entity!=NULL) {
-        RS_Creation creation(container, graphicView);
-        RS_Entity* e = creation.createParallelThrough(coord,
-                       number,
-                       entity);
-
-        if (e==NULL) {
-            RS_DEBUG->print("RS_ActionDrawLineParallelThrough::trigger:"
-                            " No parallels added\n");
-        }
-    }
+/*virtual*/ RS2::ActionType RS_ActionDrawLineParallelThrough::rtti()
+{
+       return RS2::ActionDrawLineParallelThrough;
 }
 
-
-
-void RS_ActionDrawLineParallelThrough::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineParallelThrough::mouseMoveEvent begin");
-
-
-    switch (getStatus()) {
-    case SetEntity: {
-            entity = catchEntity(e, RS2::ResolveAll);
-            /*deletePreview();
-            clearPreview();
-
-            RS_Creation creation(preview, NULL, false);
-            creation.createParallelThrough(coord,
-                                           number,
-                                           entity);
-
-            drawPreview();*/
-        }
-        break;
-
-    case SetPos: {
-            coord = snapPoint(e);
-            //Vector(graphicView->toGraphX(e->x()),
-            //                  graphicView->toGraphY(e->y()));
-            deletePreview();
-            clearPreview();
-
-            RS_Creation creation(preview, NULL, false);
-            creation.createParallelThrough(coord,
-                                           number,
-                                           entity);
-
-            drawPreview();
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDrawLineParallelThrough::mouseMoveEvent end");
+void RS_ActionDrawLineParallelThrough::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+       deleteSnapper();
+
+       if (entity != NULL)
+       {
+               RS_Creation creation(container, graphicView);
+               RS_Entity * e = creation.createParallelThrough(coord, number, entity);
+
+               if (e == NULL)
+                       RS_DEBUG->print("RS_ActionDrawLineParallelThrough::trigger:"
+                               " No parallels added\n");
+       }
 }
 
-
-
-void RS_ActionDrawLineParallelThrough::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetEntity:
-            entity = catchEntity(e, RS2::ResolveAll);
-            if (entity!=NULL) {
-                entity->setHighlighted(true);
-                graphicView->drawEntity(entity);
-                setStatus(SetPos);
-            }
-            break;
-        case SetPos: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        if (entity!=NULL) {
-            entity->setHighlighted(false);
-            graphicView->drawEntity(entity);
-            entity=NULL;
-        }
-        init(getStatus()-1);
-    }
+void RS_ActionDrawLineParallelThrough::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineParallelThrough::mouseMoveEvent begin");
+
+       switch (getStatus())
+       {
+       case SetEntity:
+               entity = catchEntity(e, RS2::ResolveAll);
+               /*deletePreview();
+                  clearPreview();
+
+                  RS_Creation creation(preview, NULL, false);
+                  creation.createParallelThrough(coord,
+                                                                               number,
+                                                                               entity);
+
+                  drawPreview();*/
+               break;
+
+       case SetPos:
+       {
+               coord = snapPoint(e);
+               //Vector(graphicView->toGraphX(e->x()),
+               //                  graphicView->toGraphY(e->y()));
+               deletePreview();
+               clearPreview();
+
+               RS_Creation creation(preview, NULL, false);
+               creation.createParallelThrough(coord,
+                       number,
+                       entity);
+
+               drawPreview();
+       }
+       break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionDrawLineParallelThrough::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawLineParallelThrough::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetPos:
-        coord = mouse;
-        trigger();
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLineParallelThrough::mouseReleaseEvent(QMouseEvent * e)
+{
+//     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton)
+       if (e->button() == Qt::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity:
+                       entity = catchEntity(e, RS2::ResolveAll);
+
+                       if (entity != NULL)
+                       {
+                               entity->setHighlighted(true);
+                               graphicView->drawEntity(entity);
+                               setStatus(SetPos);
+                       }
+
+                       break;
+
+               case SetPos:
+               {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+
+               default:
+                       break;
+               }
+       }
+//     else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton)
+       else if (e->button() == Qt::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+
+               if (entity != NULL)
+               {
+                       entity->setHighlighted(false);
+                       graphicView->drawEntity(entity);
+                       entity = NULL;
+               }
+
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionDrawLineParallelThrough::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
+       Vector mouse = *e;
 
-void RS_ActionDrawLineParallelThrough::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select entity"), tr("Cancel"));
-        break;
-
-    case SetPos:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify through point"),
-                                            tr("Back"));
-        break;
-
-    case SetNumber:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Number:"), tr("Back"));
-        break;
+       switch (getStatus())
+       {
+       case SetPos:
+               coord = mouse;
+               trigger();
+               break;
 
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLineParallelThrough::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
-    updateMouseButtonHints();
+void RS_ActionDrawLineParallelThrough::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select entity"), tr("Cancel"));
+               break;
+
+       case SetPos:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify through point"), tr("Back"));
+               break;
+
+       case SetNumber:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Number:"), tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionDrawLineParallelThrough::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDrawLineParallelThrough::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, true);
+       updateMouseButtonHints();
 }
 
+void RS_ActionDrawLineParallelThrough::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawLineParallelThrough::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetEntity:
-    case SetPos: {
-            if (checkCommand("number", c)) {
-                deleteSnapper();
-                deletePreview();
-                clearPreview();
-                lastStatus = (Status)getStatus();
-                setStatus(SetNumber);
-            }
-        }
-        break;
-
-    case SetNumber: {
-            bool ok;
-            int n = c.toInt(&ok);
-            if (ok==true) {
-                if (n>0 && n<100) {
-                    number = n;
-                } else {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
-                                                        "Try 1..99"));
-                }
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    default:
-        break;
-    }
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
+void RS_ActionDrawLineParallelThrough::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetEntity:
+       case SetPos:
+
+               if (checkCommand("number", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetNumber);
+               }
+               break;
+
+       case SetNumber: {
+               bool ok;
+               int n = c.toInt(&ok);
+
+               if (ok == true)
+               {
+                       if (n > 0 && n < 100)
+                               number = n;
+                       else
+                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
+                                               "Try 1..99"));
+               }
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       default:
+               break;
+       }
+}
 
+QStringList RS_ActionDrawLineParallelThrough::getAvailableCommands()
+{
+       QStringList cmd;
 
-QStringList RS_ActionDrawLineParallelThrough::getAvailableCommands() {
-    QStringList cmd;
+       switch (getStatus())
+       {
+       case SetEntity:
+               cmd += command("number");
+               break;
 
-    switch (getStatus()) {
-    case SetEntity:
-        cmd += command("number");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-
-void RS_ActionDrawLineParallelThrough::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineParallelThrough::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionDrawLineParallelThrough::updateToolBar()
+{
+       if (getStatus() == SetPos && !isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+}
 
-
-void RS_ActionDrawLineParallelThrough::updateToolBar() {
-    if (getStatus()==SetPos && !isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-    }
+int RS_ActionDrawLineParallelThrough::getNumber()
+{
+       return number;
 }
 
+void RS_ActionDrawLineParallelThrough::setNumber(int n)
+{
+       number = n;
+}
 
-// EOF
index d71d1a5c17e811d69b3b7fa41afda8901ed4cf39..4963bc87f23fa425abb314553f6b8c216d3a4df1 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlineparallelthrough.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEPARALLELTHROUGH_H
 #define RS_ACTIONDRAWLINEPARALLELTHROUGH_H
 
+#include "rs_line.h"
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
- * This action class can handle user events to draw parallel 
+ * This action class can handle user events to draw parallel
  * lines, arcs and circles.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineParallelThrough : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetEntity,    /**< Choose original entity. */
-               SetPos,       /**< Setting point for this parallel to go through. */
-               SetNumber     /**< Setting number in the command line. */
-       };
-       
-public:
-    RS_ActionDrawLineParallelThrough(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineParallelThrough() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLineParallelThrough;
-       }
-
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       int getNumber() {
-               return number;
-       }
-
-       void setNumber(int n) {
-               number = n;
-       }
-
-private:
-    /** Closest parallel. */
-    RS_Entity* parallel;
-    /** Data of new line */
-    RS_LineData data;
-       /** Number of parallels. */
-       int number;
-       /** Coordinate of the mouse. */
-       Vector coord;
-       /** Original entity. */
-       RS_Entity* entity;
-       /** Last status before entering length or number. */
-       Status lastStatus;
-       /**
-        * Commands
-        */
-       /*
-       QString cmdDistance;
-       QString cmdDistance2;
-       QString cmdDistance3;
-       
-       QString cmdNumber;
-       QString cmdNumber2;
-       QString cmdNumber3;
-       */
+class RS_ActionDrawLineParallelThrough: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetEntity,    /**< Choose original entity. */
+                       SetPos,       /**< Setting point for this parallel to go through. */
+                       SetNumber     /**< Setting number in the command line. */
+               };
+
+       public:
+               RS_ActionDrawLineParallelThrough(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineParallelThrough();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               int getNumber();
+               void setNumber(int n);
+
+       private:
+               /** Closest parallel. */
+               RS_Entity * parallel;
+               /** Data of new line */
+               RS_LineData data;
+               /** Number of parallels. */
+               int number;
+               /** Coordinate of the mouse. */
+               Vector coord;
+               /** Original entity. */
+               RS_Entity * entity;
+               /** Last status before entering length or number. */
+               Status lastStatus;
 };
 
 #endif
index 2a43957ab6ec872d0f4269a8bdaef1f2c38681c9..c32d062fead7ab1416e832f185765b77f3ac06ed 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinepolygon.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinepolygon.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinepolygon.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
+RS_ActionDrawLinePolygon::RS_ActionDrawLinePolygon(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Polygons",
+               container, graphicView)
+{
+       center = Vector(false);
+       corner = Vector(false);
 
-
-RS_ActionDrawLinePolygon::RS_ActionDrawLinePolygon(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Polygons", container, graphicView) {
-
-    center = Vector(false);
-    corner = Vector(false);
-
-    number = 3;
+       number = 3;
 }
 
-QAction* RS_ActionDrawLinePolygon::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLinePolygon::~RS_ActionDrawLinePolygon()
 {
-       QAction * action = new QAction(tr("Pol&ygon (Cen,Cor)"), 0);
-//     QAction* action = new QAction(tr("Polygon"), tr("Pol&ygon (Cen,Cor)"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw polygon with center and corner"));
-       return action;
 }
 
+/*virtual*/ RS2::ActionType RS_ActionDrawLinePolygon::rtti()
+{
+       return RS2::ActionDrawLinePolygon;
+}
 
-void RS_ActionDrawLinePolygon::trigger() {
-    RS_PreviewActionInterface::trigger();
+void RS_ActionDrawLinePolygon::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 
-    deleteSnapper();
-    deletePreview();
-    clearPreview();
+       deleteSnapper();
+       deletePreview();
+       clearPreview();
 
-    RS_Creation creation(container, graphicView);
-    bool ok = creation.createPolygon(center, corner, number);
+       RS_Creation creation(container, graphicView);
+       bool ok = creation.createPolygon(center, corner, number);
 
-    if (!ok) {
-        RS_DEBUG->print("RS_ActionDrawLinePolygon::trigger:"
-                        " No polygon added\n");
-    }
+       if (!ok)
+               RS_DEBUG->print("RS_ActionDrawLinePolygon::trigger: No polygon added\n");
 }
 
+void RS_ActionDrawLinePolygon::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLinePolygon::mouseMoveEvent begin");
 
+       Vector mouse = snapPoint(e);
 
-void RS_ActionDrawLinePolygon::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLinePolygon::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
+       switch (getStatus())
+       {
+       case SetCenter:
+               break;
 
-    switch (getStatus()) {
-    case SetCenter:
-        break;
+       case SetCorner:
 
-    case SetCorner:
-        if (center.valid) {
-            corner = mouse;
-            deletePreview();
-            clearPreview();
+               if (center.valid)
+               {
+                       corner = mouse;
+                       deletePreview();
+                       clearPreview();
 
-            RS_Creation creation(preview, NULL, false);
-            creation.createPolygon(center, corner, number);
+                       RS_Creation creation(preview, NULL, false);
+                       creation.createPolygon(center, corner, number);
 
-            drawPreview();
-        }
-        break;
+                       drawPreview();
+               }
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLinePolygon::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        clearPreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawLinePolygon::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               clearPreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawLinePolygon::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetCenter:
-        center = mouse;
-        setStatus(SetCorner);
-        graphicView->moveRelativeZero(mouse);
-        break;
-
-    case SetCorner:
-        corner = mouse;
-        trigger();
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLinePolygon::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetCenter:
+               center = mouse;
+               setStatus(SetCorner);
+               graphicView->moveRelativeZero(mouse);
+               break;
+
+       case SetCorner:
+               corner = mouse;
+               trigger();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLinePolygon::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetCenter:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify center"),
-                                                "");
-            break;
-
-        case SetCorner:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify a corner"), "");
-            break;
-
-        case SetNumber:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number:"), "");
-            break;
-
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawLinePolygon::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetCenter:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify center"),
+                               "");
+                       break;
+
+               case SetCorner:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify a corner"), "");
+                       break;
+
+               case SetNumber:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number:"), "");
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
+void RS_ActionDrawLinePolygon::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDrawLinePolygon::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDrawLinePolygon::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawLinePolygon::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionDrawLinePolygon::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetCenter:
-    case SetCorner:
-        if (checkCommand("number", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetNumber);
-        }
-        break;
-
-    case SetNumber: {
-            bool ok;
-            int n = c.toInt(&ok);
-            if (ok==true) {
-                if (n>0 && n<10000) {
-                    number = n;
-                } else {
-                    if (RS_DIALOGFACTORY!=NULL) {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
-                                                            "Try 1..9999"));
-                    }
-                }
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(lastStatus);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLinePolygon::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetCenter:
+       case SetCorner:
+
+               if (checkCommand("number", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetNumber);
+               }
+               break;
+
+       case SetNumber: {
+               bool ok;
+               int n = c.toInt(&ok);
+
+               if (ok == true)
+               {
+                       if (n > 0 && n < 10000)
+                               number = n;
+                       else if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
+                                               "Try 1..9999"));
+
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionDrawLinePolygon::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetCenter:
+       case SetCorner:
+               cmd += command("number");
+               break;
 
-QStringList RS_ActionDrawLinePolygon::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetCenter:
-    case SetCorner:
-        cmd += command("number");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-
-void RS_ActionDrawLinePolygon::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLinePolygon::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionDrawLinePolygon::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+       }
+}
 
-
-void RS_ActionDrawLinePolygon::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-        }
-    }
+int RS_ActionDrawLinePolygon::getNumber()
+{
+       return number;
 }
 
+void RS_ActionDrawLinePolygon::setNumber(int n)
+{
+       number = n;
+}
 
-// EOF
index dd588ad56af3713a8f6cee6b61ffc25297512154..13a377ef5642f9477c1c7459298100712e6dbfa6 100644 (file)
@@ -1,93 +1,51 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinepolygon.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEPOLYGON_H
 #define RS_ACTIONDRAWLINEPOLYGON_H
 
 #include "rs_previewactioninterface.h"
-
+#include "vector.h"
 
 /**
  * This action class can handle user events to draw polygons.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLinePolygon : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetCenter,    /**< Setting center. */
-               SetCorner,    /**< Setting corner. */
-               SetNumber     /**< Setting number in the command line. */
-       };
-       
-public:
-    RS_ActionDrawLinePolygon(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLinePolygon() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLinePolygon;
-       }
-
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       int getNumber() {
-               return number;
-       }
-
-       void setNumber(int n) {
-               number = n;
-       }
-
-private:
-       /** Center of polygon */
-       Vector center;
-       /** Edge */
-       Vector corner;
-       /** Number of edges. */
-       int number;
-       /** Last status before entering text. */
-       Status lastStatus;
+class RS_ActionDrawLinePolygon: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetCenter,    /**< Setting center. */
+                       SetCorner,    /**< Setting corner. */
+                       SetNumber     /**< Setting number in the command line. */
+               };
+
+       public:
+               RS_ActionDrawLinePolygon(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLinePolygon();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               int getNumber();
+               void setNumber(int n);
+
+       private:
+               /** Center of polygon */
+               Vector center;
+               /** Edge */
+               Vector corner;
+               /** Number of edges. */
+               int number;
+               /** Last status before entering text. */
+               Status lastStatus;
 };
 
 #endif
index 3489ab4ed995d57f6290e9d0325cda1cb5d8252d..feaa99f98f04a164ae39ec5b2d6b1942caddb825 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinepolygon2.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinepolygon2.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinepolygon2.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
+RS_ActionDrawLinePolygon2::RS_ActionDrawLinePolygon2(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Polygons",
+               container, graphicView)
+{
+       corner1 = Vector(false);
+       corner2 = Vector(false);
 
-
-RS_ActionDrawLinePolygon2::RS_ActionDrawLinePolygon2(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Polygons", container, graphicView) {
-
-    corner1 = Vector(false);
-    corner2 = Vector(false);
-
-    number = 3;
+       number = 3;
 }
 
-QAction* RS_ActionDrawLinePolygon2::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLinePolygon2::~RS_ActionDrawLinePolygon2()
 {
-       QAction * action = new QAction(tr("Polygo&n (Cor,Cor)"), 0);
-//     QAction* action = new QAction(tr("Polygon"), tr("Polygo&n (Cor,Cor)"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw polygon with two corners"));
-       return action;
 }
 
+/*virtual*/ RS2::ActionType RS_ActionDrawLinePolygon2::rtti()
+{
+       return RS2::ActionDrawLinePolygon2;
+}
 
-void RS_ActionDrawLinePolygon2::trigger() {
-    RS_PreviewActionInterface::trigger();
+void RS_ActionDrawLinePolygon2::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 
-    deleteSnapper();
-    deletePreview();
-    clearPreview();
+       deleteSnapper();
+       deletePreview();
+       clearPreview();
 
-    RS_Creation creation(container, graphicView);
-    bool ok = creation.createPolygon2(corner1, corner2, number);
+       RS_Creation creation(container, graphicView);
+       bool ok = creation.createPolygon2(corner1, corner2, number);
 
-    if (!ok) {
-        RS_DEBUG->print("RS_ActionDrawLinePolygon2::trigger:"
-                        " No polygon added\n");
-    }
+       if (!ok)
+               RS_DEBUG->print("RS_ActionDrawLinePolygon2::trigger: No polygon added\n");
 }
 
+void RS_ActionDrawLinePolygon2::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLinePolygon2::mouseMoveEvent begin");
 
+       Vector mouse = snapPoint(e);
 
-void RS_ActionDrawLinePolygon2::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLinePolygon2::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
+       switch (getStatus())
+       {
+       case SetCorner1:
+               break;
 
-    switch (getStatus()) {
-    case SetCorner1:
-        break;
+       case SetCorner2:
 
-    case SetCorner2:
-        if (corner1.valid) {
-            corner2 = mouse;
-            deletePreview();
-            clearPreview();
+               if (corner1.valid)
+               {
+                       corner2 = mouse;
+                       deletePreview();
+                       clearPreview();
 
-            RS_Creation creation(preview, NULL, false);
-            creation.createPolygon2(corner1, corner2, number);
+                       RS_Creation creation(preview, NULL, false);
+                       creation.createPolygon2(corner1, corner2, number);
 
-            drawPreview();
-        }
-        break;
+                       drawPreview();
+               }
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLinePolygon2::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        clearPreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawLinePolygon2::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               clearPreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawLinePolygon2::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetCorner1:
-        corner1 = mouse;
-        setStatus(SetCorner2);
-        graphicView->moveRelativeZero(mouse);
-        break;
-
-    case SetCorner2:
-        corner2 = mouse;
-        trigger();
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLinePolygon2::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetCorner1:
+               corner1 = mouse;
+               setStatus(SetCorner2);
+               graphicView->moveRelativeZero(mouse);
+               break;
+
+       case SetCorner2:
+               corner2 = mouse;
+               trigger();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLinePolygon2::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetCorner1:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
-                                                tr("Cancel"));
-            break;
-
-        case SetCorner2:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
-                                                tr("Back"));
-            break;
-
-        case SetNumber:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Number:"), tr("Back"));
-            break;
-
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawLinePolygon2::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetCorner1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
+                               tr("Cancel"));
+                       break;
+
+               case SetCorner2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
+                               tr("Back"));
+                       break;
+
+               case SetNumber:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Number:"), tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
+void RS_ActionDrawLinePolygon2::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDrawLinePolygon2::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDrawLinePolygon2::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawLinePolygon2::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionDrawLinePolygon2::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetCorner1:
-    case SetCorner2:
-        if (checkCommand("number", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetNumber);
-        }
-        break;
-
-    case SetNumber: {
-            bool ok;
-            int n = c.toInt(&ok);
-            if (ok==true) {
-                if (n>0 && n<10000) {
-                    number = n;
-                } else {
-                    if (RS_DIALOGFACTORY!=NULL) {
-                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
-                                                            "Try 1..9999"));
-                    }
-                }
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression."));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(lastStatus);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLinePolygon2::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetCorner1:
+       case SetCorner2:
+
+               if (checkCommand("number", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetNumber);
+               }
+               break;
+
+       case SetNumber: {
+               bool ok;
+               int n = c.toInt(&ok);
+
+               if (ok == true)
+               {
+                       if (n > 0 && n < 10000)
+                               number = n;
+                       else if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
+                                               "Try 1..9999"));
+
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression."));
+
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionDrawLinePolygon2::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetCorner1:
+       case SetCorner2:
+               cmd += command("number");
+               break;
 
-QStringList RS_ActionDrawLinePolygon2::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case SetCorner1:
-    case SetCorner2:
-        cmd += command("number");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-
-void RS_ActionDrawLinePolygon2::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLinePolygon2::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionDrawLinePolygon2::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+       }
+}
 
-
-void RS_ActionDrawLinePolygon2::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-        }
-    }
+int RS_ActionDrawLinePolygon2::getNumber()
+{
+       return number;
 }
 
+void RS_ActionDrawLinePolygon2::setNumber(int n)
+{
+       number = n;
+}
 
-// EOF
index 24b15b246719dd890a286794405a58fb7181b973..e8569768a51ef04c6b1e5e9e6522a254ab32f94b 100644 (file)
@@ -1,93 +1,51 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinepolygon2.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINEPOLYGON2_H
 #define RS_ACTIONDRAWLINEPOLYGON2_H
 
 #include "rs_previewactioninterface.h"
-
+#include "vector.h"
 
 /**
  * This action class can handle user events to draw polygons.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLinePolygon2 : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetCorner1,    /**< Setting center 1. */
-               SetCorner2,    /**< Setting corner 2. */
-               SetNumber      /**< Setting number in the command line. */
-       };
-       
-public:
-    RS_ActionDrawLinePolygon2(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLinePolygon2() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLinePolygon2;
-       }
-
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       int getNumber() {
-               return number;
-       }
-
-       void setNumber(int n) {
-               number = n;
-       }
-
-private:
-       /** 1st corner */
-       Vector corner1;
-       /** 2nd corner */
-       Vector corner2;
-       /** Number of edges. */
-       int number;
-       /** Last status before entering text. */
-       Status lastStatus;
+class RS_ActionDrawLinePolygon2: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetCorner1,    /**< Setting center 1. */
+                       SetCorner2,    /**< Setting corner 2. */
+                       SetNumber      /**< Setting number in the command line. */
+               };
+
+       public:
+               RS_ActionDrawLinePolygon2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLinePolygon2();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               int getNumber();
+               void setNumber(int n);
+
+       private:
+               /** 1st corner */
+               Vector corner1;
+               /** 2nd corner */
+               Vector corner2;
+               /** Number of edges. */
+               int number;
+               /** Last status before entering text. */
+               Status lastStatus;
 };
 
 #endif
index e8ef45c98d1de585a7ba6a0cb6c38e566e6188b5..3dc5b2d6c9e1609c787be785b15d187331c20dd9 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinerectangle.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinerectangle.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinerectangle.h"
-#include "rs_snapper.h"
-
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 RS_ActionDrawLineRectangle::RS_ActionDrawLineRectangle(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw rectangles",
-                           container, graphicView) {
-    reset();
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Draw rectangles", container, graphicView)
+{
+       reset();
 }
 
-
-
-RS_ActionDrawLineRectangle::~RS_ActionDrawLineRectangle() {}
-
-QAction* RS_ActionDrawLineRectangle::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineRectangle::~RS_ActionDrawLineRectangle()
 {
-       QAction * action = new QAction(tr("&Rectangle"), 0);
-//     QAction* action = new QAction(tr("Rectangle"), tr("&Rectangle"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw rectangles"));
-       return action;
 }
 
-
-void RS_ActionDrawLineRectangle::reset() {
-    for (int i=0; i<4; ++i) {
-        data[i] = RS_LineData(Vector(false),
-                              Vector(false));
-    }
+void RS_ActionDrawLineRectangle::reset()
+{
+       for (int i = 0; i < 4; ++i)
+               data[i] = RS_LineData(Vector(false), Vector(false));
 }
 
-
-
-void RS_ActionDrawLineRectangle::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+void RS_ActionDrawLineRectangle::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
+       reset();
 }
 
-
-
-void RS_ActionDrawLineRectangle::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    RS_Line* line[4];
-    preparePreview();
-
-    // create and add rectangle:
-    for (int i=0; i<4; ++i) {
-        line[i] = new RS_Line(container,
-                              data[i]);
-        line[i]->setLayerToActive();
-        line[i]->setPenToActive();
-        container->addEntity(line[i]);
-    }
-
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        for (int i=0; i<4; ++i) {
-            document->addUndoable(line[i]);
-        }
-        document->endUndoCycle();
-    }
-
-    // upd. view
-    deleteSnapper();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    for (int i=0; i<4; ++i) {
-        graphicView->drawEntity(line[i]);
-        RS_DEBUG->print("RS_ActionDrawLineRectangle::trigger():"
-                        " line added: %d",
-                        line[i]->getId());
-    }
-    graphicView->moveRelativeZero(corner2);
+void RS_ActionDrawLineRectangle::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       RS_Line * line[4];
+       preparePreview();
+
+       // create and add rectangle:
+       for (int i = 0; i < 4; ++i)
+       {
+               line[i] = new RS_Line(container,
+                               data[i]);
+               line[i]->setLayerToActive();
+               line[i]->setPenToActive();
+               container->addEntity(line[i]);
+       }
+
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+
+               for (int i = 0; i < 4; ++i)
+                       document->addUndoable(line[i]);
+               document->endUndoCycle();
+       }
+
+       // upd. view
+       deleteSnapper();
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+
+       for (int i = 0; i < 4; ++i)
+       {
+               graphicView->drawEntity(line[i]);
+               RS_DEBUG->print("RS_ActionDrawLineRectangle::trigger():"
+                       " line added: %d",
+                       line[i]->getId());
+       }
+       graphicView->moveRelativeZero(corner2);
 }
 
+void RS_ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineRectangle::mouseMoveEvent begin");
 
+       Vector mouse = snapPoint(e);
 
-void RS_ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineRectangle::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
-    if (getStatus()==SetCorner2 && corner1.valid) {
-        corner2 = mouse;
-        deletePreview();
-        clearPreview();
+       if (getStatus() == SetCorner2 && corner1.valid)
+       {
+               corner2 = mouse;
+               deletePreview();
+               clearPreview();
 
-        preparePreview();
+               preparePreview();
 
-        for (int i=0; i<4; ++i) {
-            preview->addEntity(new RS_Line(preview, data[i]));
-        }
-        drawPreview();
-    }
+               for (int i = 0; i < 4; ++i)
+                       preview->addEntity(new RS_Line(preview, data[i]));
+               drawPreview();
+       }
 
-    RS_DEBUG->print("RS_ActionDrawLineRectangle::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionDrawLineRectangle::mouseMoveEvent end");
 }
 
-
-void RS_ActionDrawLineRectangle::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionDrawLineRectangle::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionDrawLineRectangle::preparePreview() {
-    data[0] = RS_LineData(corner1, Vector(corner2.x, corner1.y));
-    data[1] = RS_LineData(Vector(corner2.x, corner1.y), corner2);
-    data[2] = RS_LineData(corner2, Vector(corner1.x, corner2.y));
-    data[3] = RS_LineData(Vector(corner1.x, corner2.y), corner1);
+void RS_ActionDrawLineRectangle::preparePreview()
+{
+       data[0] = RS_LineData(corner1, Vector(corner2.x, corner1.y));
+       data[1] = RS_LineData(Vector(corner2.x, corner1.y), corner2);
+       data[2] = RS_LineData(corner2, Vector(corner1.x, corner2.y));
+       data[3] = RS_LineData(Vector(corner1.x, corner2.y), corner1);
 }
 
-
-void RS_ActionDrawLineRectangle::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetCorner1:
-        corner1 = mouse;
-        graphicView->moveRelativeZero(mouse);
-        setStatus(SetCorner2);
-        break;
-
-    case SetCorner2:
-        corner2 = mouse;
-        trigger();
-        setStatus(SetCorner1);
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLineRectangle::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetCorner1:
+               corner1 = mouse;
+               graphicView->moveRelativeZero(mouse);
+               setStatus(SetCorner2);
+               break;
+
+       case SetCorner2:
+               corner2 = mouse;
+               trigger();
+               setStatus(SetCorner1);
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionDrawLineRectangle::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
+void RS_ActionDrawLineRectangle::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
 }
 
-
-
-QStringList RS_ActionDrawLineRectangle::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+QStringList RS_ActionDrawLineRectangle::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
-
-void RS_ActionDrawLineRectangle::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetCorner1:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
-                                                tr("Cancel"));
-            break;
-        case SetCorner2:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
-                                                tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawLineRectangle::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetCorner1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
+                               tr("Cancel"));
+                       break;
+
+               case SetCorner2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-void RS_ActionDrawLineRectangle::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineRectangle::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-void RS_ActionDrawLineRectangle::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-        }
-    }
+void RS_ActionDrawLineRectangle::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+       }
 }
 
 // EOF
index d74ef74dd3d9ec99bc3898f593e1a980827e55b7..6097a155000d8bb1d16067b4efcae1eca06d2dd2 100644 (file)
@@ -1,88 +1,57 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinerectangle.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINERECTANGLE_H
 #define RS_ACTIONDRAWLINERECTANGLE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_line.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
- * This action class can handle user events to draw 
+ * This action class can handle user events to draw
  * rectangles with two corners given.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineRectangle : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetCorner1,      /**< Setting the 1st corner.  */
-        SetCorner2       /**< Setting the 2nd corner. */
-    };
-
-public:
-    RS_ActionDrawLineRectangle(RS_EntityContainer& container,
-                               RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineRectangle();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    void reset();
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       void preparePreview();
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    /**
-     * Line data for the 4 lines.
-     */
-    RS_LineData data[4];
-    /**
-     * 1st corner.
-     */
-    Vector corner1;
-    /**
-     * 2nd corner.
-     */
-    Vector corner2;
+class RS_ActionDrawLineRectangle: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetCorner1,      /**< Setting the 1st corner.  */
+                       SetCorner2       /**< Setting the 2nd corner. */
+               };
+
+       public:
+               RS_ActionDrawLineRectangle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineRectangle();
+
+               void reset();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               void preparePreview();
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               /**
+                * Line data for the 4 lines.
+                */
+               RS_LineData data[4];
+               /**
+                * 1st corner.
+                */
+               Vector corner1;
+               /**
+                * 2nd corner.
+                */
+               Vector corner2;
 };
 
 #endif
index 3ac5f82850dc7f6b210e32d16c7642c4c1aac9ab..4e69092356a99b7da0761a1ce841831308b2a00d 100644 (file)
 #include "rs_actiondrawlinerelangle.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
-
-RS_ActionDrawLineRelAngle::RS_ActionDrawLineRelAngle(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView,
-    double angle,
-    bool fixedAngle)
-        :RS_PreviewActionInterface("Draw Lines with relative angles",
-                           container, graphicView) {
-
-    entity = NULL;
-    this->angle = angle;
-    this->fixedAngle = fixedAngle;
-    length = 10.0;
-    pos = Vector(false);
-}
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-QAction * RS_ActionDrawLineRelAngle::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionDrawLineRelAngle::RS_ActionDrawLineRelAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle, bool fixedAngle):
+       RS_PreviewActionInterface("Draw Lines with relative angles",
+               container, graphicView)
 {
-       QAction * action = NULL;
+       entity = NULL;
+       this->angle = angle;
+       this->fixedAngle = fixedAngle;
+       length = 10.0;
+       pos = Vector(false);
+}
 
-       if (type == RS2::ActionDrawLineRelAngle)
-       {
-               action = new QAction(tr("R&elative angle"), 0);
-//             action = new QAction(tr("Relative angle"), tr("R&elative angle"),
-//                                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw line with relative angle"));
-       }
-       else if (type == RS2::ActionDrawLineOrthogonal)
-       {
-               action = new QAction(tr("&Orthogonal"), 0);
-//             action = new QAction(tr("Orthogonal"), tr("&Orthogonal"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Draw orthogonal line"));
-       }
+RS_ActionDrawLineRelAngle::~RS_ActionDrawLineRelAngle()
+{
+}
 
-       return action;
+/*virtual*/ RS2::ActionType RS_ActionDrawLineRelAngle::rtti()
+{
+       return RS2::ActionDrawLineRelAngle;
 }
 
 void RS_ActionDrawLineRelAngle::trigger()
 {
-    RS_PreviewActionInterface::trigger();
-
-    deleteSnapper();
-    deletePreview();
-    clearPreview();
-
-    RS_Creation creation(container, graphicView);
-    creation.createLineRelAngle(pos,
-                                entity,
-                                angle,
-                                length);
-
-    /*
-       if (line!=NULL) {
-           RS_Entity* newEntity = NULL;
-
-           newEntity = new RS_Line(container,
-                                   line->getData());
-
-           if (newEntity!=NULL) {
-               newEntity->setLayerToActive();
-               newEntity->setPenToActive();
-               container->addEntity(newEntity);
-
-               // upd. undo list:
-               if (document!=NULL) {
-                   document->startUndoCycle();
-                   document->addUndoable(newEntity);
-                   document->endUndoCycle();
-               }
-               deleteSnapper();
-               graphicView->drawEntity(newEntity);
-               setStatus(SetEntity);
-           }
-           //reset();
-           delete line;
-           line = NULL;
-       } else {
-           RS_DEBUG->print("RS_ActionDrawLineRelAngle::trigger:"
-                           " Line is NULL\n");
-       }
-    */
+       RS_PreviewActionInterface::trigger();
+
+       deleteSnapper();
+       deletePreview();
+       clearPreview();
+
+       RS_Creation creation(container, graphicView);
+       creation.createLineRelAngle(pos,
+               entity,
+               angle,
+               length);
+
+       /*
+          if (line!=NULL) {
+              RS_Entity* newEntity = NULL;
+
+              newEntity = new RS_Line(container,
+                                      line->getData());
+
+              if (newEntity!=NULL) {
+                  newEntity->setLayerToActive();
+                  newEntity->setPenToActive();
+                  container->addEntity(newEntity);
+
+                  // upd. undo list:
+                  if (document!=NULL) {
+                      document->startUndoCycle();
+                      document->addUndoable(newEntity);
+                      document->endUndoCycle();
+                  }
+                  deleteSnapper();
+                  graphicView->drawEntity(newEntity);
+                  setStatus(SetEntity);
+              }
+              //reset();
+              delete line;
+              line = NULL;
+          } else {
+              RS_DEBUG->print("RS_ActionDrawLineRelAngle::trigger:"
+                              " Line is NULL\n");
+          }
+        */
 }
 
+void RS_ActionDrawLineRelAngle::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent begin");
 
+       Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
 
-void RS_ActionDrawLineRelAngle::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent begin");
-
-    Vector mouse(graphicView->toGraphX(e->x()),
-                    graphicView->toGraphY(e->y()));
-
-    switch (getStatus()) {
-    case SetEntity:
-        entity = catchEntity(e, RS2::ResolveAll);
-        break;
-
-    case SetPos: {
-            //length = graphicView->toGraphDX(graphicView->getWidth());
-            //Vector mouse = snapPoint(e);
-            pos = snapPoint(e);
-
-            /*RS_Creation creation(NULL, NULL);
-            RS_Line* l = creation.createLineRelAngle(mouse,
-                         entity,
-                         angle,
-                         length);*/
-
-            deletePreview();
-            clearPreview();
-
-            RS_Creation creation(preview, NULL, false);
-            creation.createLineRelAngle(pos,
-                                        entity,
-                                        angle,
-                                        length);
-
-            drawPreview();
-
-            /*if (l!=NULL) {
-                if (line!=NULL) {
-                    delete line;
-                }
-                line = (RS_Line*)l->clone();
+       switch (getStatus())
+       {
+       case SetEntity:
+               entity = catchEntity(e, RS2::ResolveAll);
+               break;
+
+       case SetPos: {
+               //length = graphicView->toGraphDX(graphicView->getWidth());
+               //Vector mouse = snapPoint(e);
+               pos = snapPoint(e);
+
+               /*RS_Creation creation(NULL, NULL);
+                  RS_Line* l = creation.createLineRelAngle(mouse,
+                            entity,
+                            angle,
+                            length);*/
+
+               deletePreview();
+               clearPreview();
+
+               RS_Creation creation(preview, NULL, false);
+               creation.createLineRelAngle(pos,
+                       entity,
+                       angle,
+                       length);
+
+               drawPreview();
+
+               /*if (l!=NULL) {
+                   if (line!=NULL) {
+                       delete line;
+                   }
+                   line = (RS_Line*)l->clone();
+
+                   deletePreview();
+                   clearPreview();
+                   preview->addEntity(l);
+                   drawPreview();
+                  }*/
+       }
+       break;
 
-                deletePreview();
-                clearPreview();
-                preview->addEntity(l);
-                drawPreview();
-        }*/
-        }
-        break;
+       default:
+               break;
+       }
 
-    default:
-        break;
-    }
+       RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent end");
+}
 
-    RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent end");
+void RS_ActionDrawLineRelAngle::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity: {
+                       RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+                       if (en != NULL
+                           && (en->rtti() == RS2::EntityLine
+                               || en->rtti() == RS2::EntityArc
+                               || en->rtti() == RS2::EntityCircle))
+                       {
+                               entity = en;
+
+                               entity->setHighlighted(true);
+                               graphicView->drawEntity(entity);
+
+                               setStatus(SetPos);
+                       }
+               }
+               break;
+
+               case SetPos: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               clearPreview();
+
+               if (entity != NULL)
+               {
+                       entity->setHighlighted(false);
+                       graphicView->drawEntity(entity);
+               }
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionDrawLineRelAngle::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
+       switch (getStatus())
+       {
+       case SetPos:
+               pos = *e;
+               trigger();
+               break;
 
-void RS_ActionDrawLineRelAngle::mouseReleaseEvent(QMouseEvent* e) {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetEntity: {
-                RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-                if (en!=NULL &&
-                        (en->rtti()==RS2::EntityLine ||
-                         en->rtti()==RS2::EntityArc ||
-                         en->rtti()==RS2::EntityCircle)) {
-                    entity = en;
-
-                    entity->setHighlighted(true);
-                    graphicView->drawEntity(entity);
-
-                    setStatus(SetPos);
-                }
-            }
-            break;
-
-        case SetPos: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        clearPreview();
-        if (entity!=NULL) {
-            entity->setHighlighted(false);
-            graphicView->drawEntity(entity);
-        }
-        init(getStatus()-1);
-    }
+       default:
+               break;
+       }
 }
 
+void RS_ActionDrawLineRelAngle::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
 
-void RS_ActionDrawLineRelAngle::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPos:
-        pos = e->getCoordinate();
-        trigger();
-        break;
+       switch (getStatus())
+       {
+       case SetEntity:
+       case SetPos:
+
+               if (!fixedAngle && checkCommand("angle", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetAngle);
+               }
+               else if (checkCommand("length", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       setStatus(SetLength);
+               }
+               break;
+
+       case SetAngle: {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       angle = RS_Math::deg2rad(a);
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(SetPos);
+       }
+       break;
 
-    default:
-        break;
-    }
-}
+       case SetLength: {
+               bool ok;
+               double l = RS_Math::eval(c, &ok);
 
+               if (ok == true)
+                       length = l;
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(SetPos);
+       }
+       break;
 
-void RS_ActionDrawLineRelAngle::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetEntity:
-    case SetPos:
-        if (!fixedAngle && checkCommand("angle", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetAngle);
-        } else if (checkCommand("length", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            setStatus(SetLength);
-        }
-        break;
-
-    case SetAngle: {
-            bool ok;
-            double a = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                angle = RS_Math::deg2rad(a);
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(SetPos);
-        }
-        break;
-
-    case SetLength: {
-            bool ok;
-            double l = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                length = l;
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(SetPos);
-        }
-        break;
-
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionDrawLineRelAngle::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetPos:
+       case SetLength:
 
-QStringList RS_ActionDrawLineRelAngle::getAvailableCommands() {
-    QStringList cmd;
+               if (!fixedAngle)
+                       cmd += command("angle");
+               cmd += command("length");
+               break;
 
-    switch (getStatus()) {
-    case SetPos:
-    case SetLength:
-        if (!fixedAngle) {
-            cmd += command("angle");
-        }
-        cmd += command("length");
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
-
-void RS_ActionDrawLineRelAngle::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetEntity:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select base entity"),
-                                                tr("Cancel"));
-            break;
-        case SetPos:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"),
-                                                tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawLineRelAngle::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetEntity:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select base entity"),
+                               tr("Cancel"));
+                       break;
+
+               case SetPos:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
+void RS_ActionDrawLineRelAngle::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionDrawLineRelAngle::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDrawLineRelAngle::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionDrawLineRelAngle::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
+void RS_ActionDrawLineRelAngle::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
-
-void RS_ActionDrawLineRelAngle::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineRelAngle::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+       }
 }
 
+void RS_ActionDrawLineRelAngle::setAngle(double a)
+{
+       angle = a;
+}
 
+double RS_ActionDrawLineRelAngle::getAngle()
+{
+       return angle;
+}
 
-void RS_ActionDrawLineRelAngle::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-        }
-    }
+void RS_ActionDrawLineRelAngle::setLength(double l)
+{
+       length = l;
 }
 
+double RS_ActionDrawLineRelAngle::getLength()
+{
+       return length;
+}
 
+bool RS_ActionDrawLineRelAngle::hasFixedAngle()
+{
+       return fixedAngle;
+}
 
-// EOF
index 9bd1ca55b9e3a20e25e9343bacd9ef3fef7f6579..6908afad7402809b4a8c8319c93a2ca9f447578c 100644 (file)
@@ -1,8 +1,11 @@
 #ifndef RS_ACTIONDRAWLINERELANGLE_H
 #define RS_ACTIONDRAWLINERELANGLE_H
 
+#include "rs_line.h"
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to draw lines with a given angle
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineRelAngle : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetEntity,     /**< Choose entity. */
-        SetPos,        /**< Choose position. */
-               SetAngle,      /**< Set angle in console. */
-               SetLength      /**< Set length in console. */
-    };
-
-public:
-    RS_ActionDrawLineRelAngle(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView,
-                              double angle=0.0,
-                              bool fixedAngle=false);
-    ~RS_ActionDrawLineRelAngle() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionDrawLineRelAngle;
-       }
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void hideOptions();
-    virtual void showOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       void setAngle(double a) {
-               angle = a;
-       }
-
-       double getAngle() {
-               return angle;
-       }
-
-       void setLength(double l) {
-               length = l;
-       }
-
-       double getLength() {
-               return length;
-       }
-
-       bool hasFixedAngle() {
-               return fixedAngle;
-       }
-
-private:
-    /** new line */
-    //RS_Line* line;
-    /** Chosen entity */
-    RS_Entity* entity;
-    /** Chosen position */
-    Vector pos;
-    /** Data of new line */
-    RS_LineData data;
-    /**
-     * Line angle.
-     */
-    double angle;
-    /**
-     * Line length.
-     */
-    double length;
-    /**
-     * Is the angle fixed?
-     */
-    bool fixedAngle;
+class RS_ActionDrawLineRelAngle: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetEntity,     /**< Choose entity. */
+                       SetPos,        /**< Choose position. */
+                       SetAngle,      /**< Set angle in console. */
+                       SetLength      /**< Set length in console. */
+               };
+
+       public:
+               RS_ActionDrawLineRelAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+               ~RS_ActionDrawLineRelAngle();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setAngle(double a);
+               double getAngle();
+               void setLength(double l);
+               double getLength();
+               bool hasFixedAngle();
+
+       private:
+               /** Chosen entity */
+               RS_Entity * entity;
+               /** Chosen position */
+               Vector pos;
+               /** Data of new line */
+               RS_LineData data;
+               /**
+                * Line angle.
+                */
+               double angle;
+               /**
+                * Line length.
+                */
+               double length;
+               /**
+                * Is the angle fixed?
+                */
+               bool fixedAngle;
 };
 
 #endif
index 37dd3fd2c4c07c817167db6e742c3317ade5f53b..a39f4dfc1fa6ba8933e2636209b3eb1e0b4ceacd 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinetangent1.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinetangent1.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinetangent1.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionDrawLineTangent1::RS_ActionDrawLineTangent1(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Tangents 1", container, graphicView) {
-
-    tangent = NULL;
-    point = Vector(false);
-    circle = NULL;
+RS_ActionDrawLineTangent1::RS_ActionDrawLineTangent1(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Tangents 1",
+               container, graphicView)
+{
+       tangent = NULL;
+       point = Vector(false);
+       circle = NULL;
 }
 
-
-QAction* RS_ActionDrawLineTangent1::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineTangent1::~RS_ActionDrawLineTangent1()
 {
-       QAction * action = new QAction(tr("&Tangent (P,C)"), 0);
-//     QAction* action = new QAction(tr("Tangent (P,C)"), tr("&Tangent (P,C)"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw tangent (point, circle)"));
-       return action;
 }
 
-void RS_ActionDrawLineTangent1::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    if (tangent!=NULL) {
-        RS_Entity* newEntity = NULL;
-
-        newEntity = new RS_Line(container,
-                                tangent->getData());
-
-        if (newEntity!=NULL) {
-            newEntity->setLayerToActive();
-            newEntity->setPenToActive();
-            container->addEntity(newEntity);
-
-            // upd. undo list:
-            if (document!=NULL) {
-                document->startUndoCycle();
-                document->addUndoable(newEntity);
-                document->endUndoCycle();
-            }
-
-            deleteSnapper();
-            graphicView->drawEntity(newEntity);
-
-            setStatus(SetPoint);
-        }
-        delete tangent;
-        tangent = NULL;
-    } else {
-        RS_DEBUG->print("RS_ActionDrawLineTangent1::trigger:"
-                        " Entity is NULL\n");
-    }
+void RS_ActionDrawLineTangent1::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       if (tangent != NULL)
+       {
+               RS_Entity * newEntity = NULL;
+               newEntity = new RS_Line(container, tangent->getData());
+
+               if (newEntity != NULL)
+               {
+                       newEntity->setLayerToActive();
+                       newEntity->setPenToActive();
+                       container->addEntity(newEntity);
+
+                       // upd. undo list:
+                       if (document != NULL)
+                       {
+                               document->startUndoCycle();
+                               document->addUndoable(newEntity);
+                               document->endUndoCycle();
+                       }
+
+                       deleteSnapper();
+                       graphicView->drawEntity(newEntity);
+
+                       setStatus(SetPoint);
+               }
+
+               delete tangent;
+               tangent = NULL;
+       }
+       else
+               RS_DEBUG->print("RS_ActionDrawLineTangent1::trigger:"
+                       " Entity is NULL\n");
 }
 
-
-
-void RS_ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent begin");
-
-    Vector mouse(graphicView->toGraphX(e->x()),
-                    graphicView->toGraphY(e->y()));
-
-    switch (getStatus()) {
-    case SetPoint:
-        point = snapPoint(e);
-        break;
-
-    case SetCircle: {
-            RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-            if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
-                             en->rtti()==RS2::EntityArc ||
-                             en->rtti()==RS2::EntityEllipse)) {
-                circle = en;
-
-                RS_Creation creation(NULL, NULL);
-                RS_Line* t = creation.createTangent1(mouse,
-                                                     point,
-                                                     circle);
-
-                if (t!=NULL) {
-                    if (tangent!=NULL) {
-                        delete tangent;
-                    }
-                    tangent = (RS_Line*)t->clone();
-
-                    deletePreview();
-                    clearPreview();
-                    preview->addEntity(t);
-                    drawPreview();
-                }
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent end");
+void RS_ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent begin");
+
+       Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
+
+       switch (getStatus())
+       {
+       case SetPoint:
+               point = snapPoint(e);
+               break;
+
+       case SetCircle: {
+               RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+               if (en != NULL && (en->rtti() == RS2::EntityCircle
+                                  || en->rtti() == RS2::EntityArc
+                                  || en->rtti() == RS2::EntityEllipse))
+               {
+                       circle = en;
+
+                       RS_Creation creation(NULL, NULL);
+                       RS_Line * t = creation.createTangent1(mouse,
+                                       point,
+                                       circle);
+
+                       if (t != NULL)
+                       {
+                               if (tangent != NULL)
+                                       delete tangent;
+                               tangent = (RS_Line *)t->clone();
+
+                               deletePreview();
+                               clearPreview();
+                               preview->addEntity(t);
+                               drawPreview();
+                       }
+               }
+       }
+       break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent* e) {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        clearPreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    } else {
-        switch (getStatus()) {
-        case SetPoint: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-
-        case SetCircle:
-            trigger();
-            break;
-        }
-    }
-
+void RS_ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               clearPreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
+       else
+       {
+               switch (getStatus())
+               {
+               case SetPoint: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+
+               case SetCircle:
+                       trigger();
+                       break;
+               }
+       }
 }
 
-
-void RS_ActionDrawLineTangent1::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetPoint:
-        point = e->getCoordinate();
-        deleteSnapper();
-        graphicView->moveRelativeZero(point);
-        setStatus(SetCircle);
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionDrawLineTangent1::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       switch (getStatus())
+       {
+       case SetPoint:
+               point = *e;
+               deleteSnapper();
+               graphicView->moveRelativeZero(point);
+               setStatus(SetCircle);
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionDrawLineTangent1::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetPoint:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"),
-                                                tr("Cancel"));
-            break;
-        case SetCircle:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select circle, arc or ellipse"),
-                                                tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawLineTangent1::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetPoint:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"),
+                               tr("Cancel"));
+                       break;
+
+               case SetCircle:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select circle, arc or ellipse"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionDrawLineTangent1::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineTangent1::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawLineTangent1::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-        }
-    }
+void RS_ActionDrawLineTangent1::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
+       }
 }
 
-
-
 // EOF
index 51cd30444b6da9335dc9be477e7c16b5fe2841c9..0269434c6f06cfb9bcdb044c95cc3a43ffbebd61 100644 (file)
@@ -1,34 +1,12 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinetangent1.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINETANGENT1_H
 #define RS_ACTIONDRAWLINETANGENT1_H
 
+#include "rs_line.h"
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Line;
+class RS_Entity;
 
 /**
  * This action class can handle user events to draw tangents from points
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineTangent1 : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetPoint,     /**< Choose the startpoint. */
-        SetCircle      /**< Choose the circle / arc. */
-    };
-
-public:
-    RS_ActionDrawLineTangent1(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineTangent1() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    /** Closest tangent. */
-    RS_Line* tangent;
-    /** Chosen startpoint */
-    Vector point;
-    /** Chosen entity */
-    RS_Entity* circle;
-    /** Data of new tangent */
-    RS_LineData data;
+class RS_ActionDrawLineTangent1: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetPoint,     /**< Choose the startpoint. */
+                       SetCircle      /**< Choose the circle / arc. */
+               };
+
+       public:
+               RS_ActionDrawLineTangent1(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineTangent1();
+
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               /** Closest tangent. */
+               RS_Line * tangent;
+               /** Chosen startpoint */
+               Vector point;
+               /** Chosen entity */
+               RS_Entity * circle;
+               /** Data of new tangent */
+               RS_LineData data;
 };
 
 #endif
index 3d759b433e05f0966c1506c4bc74bd20c155c952..98027d396d96f16ea35a4efef54ac99a25cf77c1 100644 (file)
-/****************************************************************************
-** $Id: rs_actiondrawlinetangent2.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawlinetangent2.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawlinetangent2.h"
 
 #include "rs_creation.h"
-#include "rs_snapper.h"
-
-
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 RS_ActionDrawLineTangent2::RS_ActionDrawLineTangent2(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Draw Tangents 2", container, graphicView) {
-
-    tangent = NULL;
-    circle1 = NULL;
-    circle2 = NULL;
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Draw Tangents 2", container, graphicView)
+{
+       tangent = NULL;
+       circle1 = NULL;
+       circle2 = NULL;
 }
 
-QAction* RS_ActionDrawLineTangent2::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionDrawLineTangent2::~RS_ActionDrawLineTangent2()
 {
-       QAction * action = new QAction(tr("Tan&gent (C,C)"), 0);
-//     QAction* action = new QAction(tr("Tangent (C,C)"), tr("Tan&gent (C,C)"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw tangent (circle, circle)"));
-
-       return action;
 }
 
-
-void RS_ActionDrawLineTangent2::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    if (tangent!=NULL) {
-        RS_Entity* newEntity = NULL;
-
-        newEntity = new RS_Line(container,
-                                tangent->getData());
-
-        if (newEntity!=NULL) {
-            newEntity->setLayerToActive();
-            newEntity->setPenToActive();
-            container->addEntity(newEntity);
-
-            // upd. undo list:
-            if (document!=NULL) {
-                document->startUndoCycle();
-                document->addUndoable(newEntity);
-                document->endUndoCycle();
-            }
-            graphicView->drawEntity(newEntity);
-            setStatus(SetCircle1);
-        }
-        delete tangent;
-        tangent = NULL;
-    } else {
-        RS_DEBUG->print("RS_ActionDrawLineTangent2::trigger:"
-                        " Entity is NULL\n");
-    }
+void RS_ActionDrawLineTangent2::trigger()
+{
+       RS_PreviewActionInterface::trigger();
+
+       if (tangent != NULL)
+       {
+               RS_Entity * newEntity = NULL;
+               newEntity = new RS_Line(container, tangent->getData());
+
+               if (newEntity != NULL)
+               {
+                       newEntity->setLayerToActive();
+                       newEntity->setPenToActive();
+                       container->addEntity(newEntity);
+
+                       // upd. undo list:
+                       if (document != NULL)
+                       {
+                               document->startUndoCycle();
+                               document->addUndoable(newEntity);
+                               document->endUndoCycle();
+                       }
+                       graphicView->drawEntity(newEntity);
+                       setStatus(SetCircle1);
+               }
+
+               delete tangent;
+               tangent = NULL;
+       }
+       else
+               RS_DEBUG->print("RS_ActionDrawLineTangent2::trigger:"
+                       " Entity is NULL\n");
 }
 
-
-
-void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent begin");
-
-    Vector mouse(graphicView->toGraphX(e->x()),
-                    graphicView->toGraphY(e->y()));
-
-    switch (getStatus()) {
-    case SetCircle1: {
-            RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-            if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
-                             en->rtti()==RS2::EntityArc)) {
-                circle1 = en;
-            }
-        }
-        break;
-
-    case SetCircle2: {
-            RS_Entity* en = catchEntity(e, RS2::ResolveAll);
-            if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
-                             en->rtti()==RS2::EntityArc)) {
-                circle2 = en;
-
-                RS_Creation creation(NULL, NULL);
-                RS_Line* t = creation.createTangent2(mouse,
-                                                     circle1,
-                                                     circle2);
-
-                if (t!=NULL) {
-                    if (tangent!=NULL) {
-                        delete tangent;
-                    }
-                    tangent = (RS_Line*)t->clone();
-
-                    deletePreview();
-                    clearPreview();
-                    preview->addEntity(t);
-                    drawPreview();
-                }
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent end");
+void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent begin");
+
+       Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
+
+       switch (getStatus())
+       {
+       case SetCircle1: {
+               RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+               if (en != NULL && (en->rtti() == RS2::EntityCircle
+                                  || en->rtti() == RS2::EntityArc))
+                       circle1 = en;
+       }
+       break;
+
+       case SetCircle2: {
+               RS_Entity * en = catchEntity(e, RS2::ResolveAll);
+
+               if (en != NULL && (en->rtti() == RS2::EntityCircle
+                                  || en->rtti() == RS2::EntityArc))
+               {
+                       circle2 = en;
+
+                       RS_Creation creation(NULL, NULL);
+                       RS_Line * t = creation.createTangent2(mouse,
+                                       circle1,
+                                       circle2);
+
+                       if (t != NULL)
+                       {
+                               if (tangent != NULL)
+                                       delete tangent;
+                               tangent = (RS_Line *)t->clone();
+
+                               deletePreview();
+                               clearPreview();
+                               preview->addEntity(t);
+                               drawPreview();
+                       }
+               }
+       }
+       break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent* e) {
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        clearPreview();
-        init(getStatus()-1);
-    } else {
-        switch (getStatus()) {
-        case SetCircle1:
-            setStatus(SetCircle2);
-            break;
-
-        case SetCircle2:
-            trigger();
-            break;
-        }
-    }
-
+void RS_ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               clearPreview();
+               init(getStatus() - 1);
+       }
+       else
+       {
+               switch (getStatus())
+               {
+               case SetCircle1:
+                       setStatus(SetCircle2);
+                       break;
+
+               case SetCircle2:
+                       trigger();
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionDrawLineTangent2::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetCircle1:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
-                                                tr("Cancel"));
-            break;
-        case SetCircle2:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
-                                                tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionDrawLineTangent2::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetCircle1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
+                               tr("Cancel"));
+                       break;
+
+               case SetCircle2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionDrawLineTangent2::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawLineTangent2::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionDrawLineTangent2::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
-    }
+void RS_ActionDrawLineTangent2::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
 }
 
-
-
 // EOF
index 665b5a390881cd3b2ae3b7921170b91f011bf40c..7b7cd5cefc8b5b38bfd1ee60b18cc89eee125953 100644 (file)
@@ -1,74 +1,46 @@
-/****************************************************************************
-** $Id: rs_actiondrawlinetangent2.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWLINETANGENT2_H
 #define RS_ACTIONDRAWLINETANGENT2_H
 
+#include "rs_line.h"
 #include "rs_previewactioninterface.h"
 
-
+class RS_Entity;
 /**
  * This action class can handle user events to draw tangents from circle to
  * circle.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawLineTangent2 : public RS_PreviewActionInterface {
-       //Q_OBJECT
-private:
-    enum Status {
-        SetCircle1,     /**< Choose the startpoint. */
-        SetCircle2      /**< Choose the circle / arc. */
-    };
-
-public:
-    RS_ActionDrawLineTangent2(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionDrawLineTangent2() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    //virtual void hideOptions();
-    //virtual void showOptions();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    /** Closest tangent. */
-    RS_Line* tangent;
-    /** 1st chosen entity */
-    RS_Entity* circle1;
-    /** 2nd chosen entity */
-    RS_Entity* circle2;
-    /** Data of new tangent */
-    RS_LineData data;
+class RS_ActionDrawLineTangent2: public RS_PreviewActionInterface
+{
+       private:
+               enum Status {
+                       SetCircle1,     /**< Choose the startpoint. */
+                       SetCircle2      /**< Choose the circle / arc. */
+               };
+
+       public:
+               RS_ActionDrawLineTangent2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionDrawLineTangent2();
+
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               //virtual void hideOptions();
+               //virtual void showOptions();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               /** Closest tangent. */
+               RS_Line * tangent;
+               /** 1st chosen entity */
+               RS_Entity * circle1;
+               /** 2nd chosen entity */
+               RS_Entity * circle2;
+               /** Data of new tangent */
+               RS_LineData data;
 };
 
 #endif
index 79e599443081e9789ba892004f71e7a6cd45861d..8ec3a810a5f2f29e8a8fe295564a7671e739581e 100644 (file)
 
 #include "rs_actiondrawpoint.h"
 
-#include "rs_snapper.h"
-#include "rs_point.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDrawPoint::RS_ActionDrawPoint(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDrawPoint::RS_ActionDrawPoint(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw Points", container, graphicView)
 {
 }
@@ -27,16 +27,6 @@ RS_ActionDrawPoint::~RS_ActionDrawPoint()
 {
 }
 
-QAction * RS_ActionDrawPoint::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
-{
-       QAction * action = new QAction(tr("&Points") + QString("\tpo"), 0);
-//     QAction* action = new QAction(tr("Points"), tr("&Points"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw Points"));
-
-       return action;
-}
-
 void RS_ActionDrawPoint::trigger()
 {
        if (pt.valid)
@@ -61,14 +51,14 @@ void RS_ActionDrawPoint::trigger()
 
 void RS_ActionDrawPoint::mouseMoveEvent(QMouseEvent * e)
 {
-               snapPoint(e);
+       snapPoint(e);
 }
 
 void RS_ActionDrawPoint::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -78,12 +68,12 @@ void RS_ActionDrawPoint::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawPoint::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawPoint::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
        pt = mouse;
        trigger();
@@ -118,6 +108,7 @@ void RS_ActionDrawPoint::updateMouseButtonHints()
                case 0:
                        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify location"), tr("Cancel"));
                        break;
+
                default:
                        RS_DIALOGFACTORY->updateMouseWidget("", "");
                        break;
@@ -125,8 +116,9 @@ void RS_ActionDrawPoint::updateMouseButtonHints()
        }
 }
 
-void RS_ActionDrawPoint::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawPoint::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
 void RS_ActionDrawPoint::updateToolBar()
@@ -139,3 +131,4 @@ void RS_ActionDrawPoint::updateToolBar()
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarPoints);
        }
 }
+
index 84035ed0f6142dba25e5e95445e4aacdbe53895c..be4fb01956d45da52d3d304848ba7168c9ca66d1 100644 (file)
@@ -2,31 +2,25 @@
 #define RS_ACTIONDRAWPOINT_H
 
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to draw points.
  *
  * @author Andrew Mustun
  */
-class RS_ActionDrawPoint : public RS_PreviewActionInterface
+class RS_ActionDrawPoint: public RS_PreviewActionInterface
 {
-       //Q_OBJECT
        public:
-               RS_ActionDrawPoint(RS_EntityContainer& container,
-                                               RS_GraphicView& graphicView);
+               RS_ActionDrawPoint(RS_EntityContainer & container, RS_GraphicView & graphicView);
                ~RS_ActionDrawPoint();
 
-               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
                virtual void trigger();
-
-               virtual void mouseMoveEvent(QMouseEvent* e);
-               virtual void mouseReleaseEvent(QMouseEvent* e);
-
-               virtual void coordinateEvent(RS_CoordinateEvent* e);
-               virtual void commandEvent(RS_CommandEvent* e);
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
                virtual QStringList getAvailableCommands();
-
                virtual void updateMouseButtonHints();
                virtual void updateMouseCursor();
                virtual void updateToolBar();
index f62a25260cd498f3e1c99561c4de81a8918618ff..ba4e6811fef276d981bcd1578f5f77a70d53b548 100644 (file)
@@ -1,36 +1,25 @@
-/****************************************************************************
-** $Id: rs_actiondrawspline.cpp 1140 2004-07-24 23:14:15Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiondrawspline.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actiondrawspline.h"
 
-#include "rs_actioneditundo.h"
-#include "rs_snapper.h"
+#include "commands.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-RS_ActionDrawSpline::RS_ActionDrawSpline(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionDrawSpline::RS_ActionDrawSpline(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Draw splines", container, graphicView)
 {
        reset();
@@ -49,65 +38,54 @@ RS_ActionDrawSpline::~RS_ActionDrawSpline()
        return RS2::ActionDrawSpline;
 }
 
-QAction * RS_ActionDrawSpline::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
-       QAction * action = new QAction(tr("&Spline"), 0);
-//     QAction* action = new QAction(tr("Spline"), tr("&Spline"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Draw splines"));
-       return action;
-}
-
 void RS_ActionDrawSpline::reset()
 {
        spline = NULL;
-    //start = Vector(false);
-    history.clear();
-    //bHistory.clear();
+       //start = Vector(false);
+       history.clear();
+       //bHistory.clear();
 }
 
+void RS_ActionDrawSpline::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-
-void RS_ActionDrawSpline::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    reset();
+       reset();
 }
 
+void RS_ActionDrawSpline::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 
-
-void RS_ActionDrawSpline::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-       if (spline==NULL) {
+       if (spline == NULL)
                return;
-       }
 
        // add the entity
-    //RS_Spline* spline = new RS_Spline(container, data);
-    spline->setLayerToActive();
-    spline->setPenToActive();
+       //RS_Spline* spline = new RS_Spline(container, data);
+       spline->setLayerToActive();
+       spline->setPenToActive();
        spline->update();
-    container->addEntity(spline);
+       container->addEntity(spline);
 
-    // upd. undo list:
-    if (document!=NULL) {
-        document->startUndoCycle();
-        document->addUndoable(spline);
-        document->endUndoCycle();
-    }
+       // upd. undo list:
+       if (document != NULL)
+       {
+               document->startUndoCycle();
+               document->addUndoable(spline);
+               document->endUndoCycle();
+       }
 
        // upd view
-    deleteSnapper();
+       deleteSnapper();
        Vector r = graphicView->getRelativeZero();
-    graphicView->moveRelativeZero(Vector(0.0,0.0));
-    graphicView->drawEntity(spline);
-    graphicView->moveRelativeZero(r);
-    drawSnapper();
-    RS_DEBUG->print("RS_ActionDrawSpline::trigger(): spline added: %d", spline->getId());
+       graphicView->moveRelativeZero(Vector(0.0, 0.0));
+       graphicView->drawEntity(spline);
+       graphicView->moveRelativeZero(r);
+       drawSnapper();
+       RS_DEBUG->print("RS_ActionDrawSpline::trigger(): spline added: %d", spline->getId());
 
        spline = NULL;
-    //history.clear();
+       //history.clear();
 }
 
 void RS_ActionDrawSpline::mouseMoveEvent(QMouseEvent * e)
@@ -131,7 +109,7 @@ void RS_ActionDrawSpline::mouseMoveEvent(QMouseEvent * e)
                QList<Vector> cpts = tmpSpline->getControlPoints();
                QList<Vector>::iterator it;
 
-               for(it=cpts.begin(); it!=cpts.end(); ++it)
+               for (it = cpts.begin(); it != cpts.end(); ++it)
                        preview->addEntity(new RS_Point(preview, RS_PointData(*it)));
 
                drawPreview();
@@ -142,64 +120,66 @@ void RS_ActionDrawSpline::mouseMoveEvent(QMouseEvent * e)
 
 void RS_ActionDrawSpline::mouseReleaseEvent(QMouseEvent * e)
 {
-    if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    }
-    else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
        {
                if (getStatus() == SetNextPoint)
-               {
                        trigger();
-               }
-        deletePreview();
-        clearPreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+               deletePreview();
+               clearPreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionDrawSpline::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
+       Vector mouse = *e;
 
-void RS_ActionDrawSpline::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetStartpoint:
+       switch (getStatus())
+       {
+       case SetStartpoint:
                //data.startpoint = mouse;
-        //point = mouse;
-        history.clear();
-        history.append(new Vector(mouse));
-               if (spline==NULL) {
+               //point = mouse;
+               history.clear();
+               history.append(new Vector(mouse));
+
+               if (spline == NULL)
+               {
                        spline = new RS_Spline(container, data);
                        spline->addControlPoint(mouse);
                }
-        //bHistory.clear();
-        //bHistory.append(new double(0.0));
-        //start = mouse;
-        setStatus(SetNextPoint);
-        graphicView->moveRelativeZero(mouse);
-        updateMouseButtonHints();
-        break;
-
-    case SetNextPoint:
-       graphicView->moveRelativeZero(mouse);
-        //point = mouse;
-        history.append(new Vector(mouse));
-        //bHistory.append(new double(0.0));
-               if (spline!=NULL) {
+
+               //bHistory.clear();
+               //bHistory.append(new double(0.0));
+               //start = mouse;
+               setStatus(SetNextPoint);
+               graphicView->moveRelativeZero(mouse);
+               updateMouseButtonHints();
+               break;
+
+       case SetNextPoint:
+               graphicView->moveRelativeZero(mouse);
+               //point = mouse;
+               history.append(new Vector(mouse));
+               //bHistory.append(new double(0.0));
+
+               if (spline != NULL)
+               {
                        //graphicView->deleteEntity(spline);
                        spline->addControlPoint(mouse);
                        //spline->setEndpoint(mouse);
                        //if (spline->count()==1) {
-                       //spline->setLayerToActive();
-                       //spline->setPenToActive();
-                               //container->addEntity(spline);
+                       //spline->setLayerToActive();
+                       //spline->setPenToActive();
+                       //container->addEntity(spline);
                        //}
                        deletePreview();
                        clearPreview();
@@ -207,150 +187,156 @@ void RS_ActionDrawSpline::coordinateEvent(RS_CoordinateEvent* e) {
                        //graphicView->drawEntity(spline);
                        drawSnapper();
                }
-        //trigger();
-        //data.startpoint = data.endpoint;
-        updateMouseButtonHints();
-        //graphicView->moveRelativeZero(mouse);
-        break;
 
-    default:
-        break;
-    }
-}
+               //trigger();
+               //data.startpoint = data.endpoint;
+               updateMouseButtonHints();
+               //graphicView->moveRelativeZero(mouse);
+               break;
 
+       default:
+               break;
+       }
+}
 
+void RS_ActionDrawSpline::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
-void RS_ActionDrawSpline::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
+       switch (getStatus())
+       {
+       case SetStartpoint:
 
-    switch (getStatus()) {
-    case SetStartpoint:
-        if (checkCommand("help", c)) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-            return;
-        }
-        break;
+               if (checkCommand("help", c))
+               {
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+                       return;
+               }
+               break;
 
-    case SetNextPoint:
-        /*if (checkCommand("close", c)) {
-            close();
-            updateMouseButtonHints();
-            return;
-        }*/
+       case SetNextPoint:
+               /*if (checkCommand("close", c)) {
+                   close();
+                   updateMouseButtonHints();
+                   return;
+                  }*/
 
-        if (checkCommand("undo", c)) {
-            undo();
-            updateMouseButtonHints();
-            return;
-        }
-        break;
+               if (checkCommand("undo", c))
+               {
+                       undo();
+                       updateMouseButtonHints();
+                       return;
+               }
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionDrawSpline::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case SetStartpoint:
+               break;
 
-QStringList RS_ActionDrawSpline::getAvailableCommands() {
-    QStringList cmd;
+       case SetNextPoint:
 
-    switch (getStatus()) {
-    case SetStartpoint:
-        break;
-    case SetNextPoint:
-        if (history.count()>=2) {
-            cmd += command("undo");
-        }
-        if (history.count()>=3) {
-            cmd += command("close");
-        }
-        break;
-    default:
-        break;
-    }
+               if (history.count() >= 2)
+                       cmd += command("undo");
 
-    return cmd;
-}
 
+               if (history.count() >= 3)
+                       cmd += command("close");
+               break;
 
+       default:
+               break;
+       }
 
-void RS_ActionDrawSpline::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetStartpoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first control point"),
-                                            tr("Cancel"));
-        break;
-    case SetNextPoint: {
-            QString msg = "";
-
-            if (history.count()>=3) {
-                msg += RS_COMMANDS->command("close");
-                msg += "/";
-            }
-            if (history.count()>=2) {
-                msg += RS_COMMANDS->command("undo");
-            }
-
-            if (history.count()>=2) {
-                RS_DIALOGFACTORY->updateMouseWidget(
-                    tr("Specify next control point or [%1]").arg(msg),
-                    tr("Back"));
-            } else {
-                RS_DIALOGFACTORY->updateMouseWidget(
-                    tr("Specify next control point"),
-                    tr("Back"));
-            }
-        }
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+       return cmd;
 }
 
+void RS_ActionDrawSpline::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetStartpoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first control point"),
+                       tr("Cancel"));
+               break;
 
-void RS_ActionDrawSpline::showOptions() {
-    RS_ActionInterface::showOptions();
+       case SetNextPoint: {
+               QString msg = "";
 
-    RS_DIALOGFACTORY->requestOptions(this, true);
-}
+               if (history.count() >= 3)
+               {
+                       msg += RS_COMMANDS->command("close");
+                       msg += "/";
+               }
 
+               if (history.count() >= 2)
+                       msg += RS_COMMANDS->command("undo");
+
+               if (history.count() >= 2)
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify next control point or [%1]").arg(msg),
+                               tr("Back"));
+               else
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify next control point"),
+                               tr("Back"));
+       }
+       break;
 
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
+}
 
-void RS_ActionDrawSpline::hideOptions() {
-    RS_ActionInterface::hideOptions();
+void RS_ActionDrawSpline::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionDrawSpline::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-void RS_ActionDrawSpline::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-void RS_ActionDrawSpline::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSplines);
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-    }
+void RS_ActionDrawSpline::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionDrawSpline::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSplines);
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+}
 
 /*
-void RS_ActionDrawSpline::close() {
+   void RS_ActionDrawSpline::close() {
     if (history.count()>2 && start.valid) {
         //data.endpoint = start;
         //trigger();
-               if (spline!=NULL) {
-                       RS_CoordinateEvent e(spline->getStartpoint());
-                       coordinateEvent(&e);
-               }
-               trigger();
+                if (spline!=NULL) {
+                        Vector e(spline->getStartpoint());
+                        coordinateEvent(&e);
+                }
+                trigger();
         setStatus(SetStartpoint);
         graphicView->moveRelativeZero(start);
     } else {
@@ -358,55 +344,64 @@ void RS_ActionDrawSpline::close() {
             tr("Cannot close sequence of lines: "
                "Not enough entities defined yet."));
     }
-}
-*/
-
-void RS_ActionDrawSpline::undo() {
-    if (history.count()>1) {
-        history.removeLast();
-        //bHistory.removeLast();
-        deletePreview();
-        clearPreview();
-        //graphicView->setCurrentAction(
-        //    new RS_ActionEditUndo(true, *container, *graphicView));
-               if (history.last()!=NULL) {
-               //point = *history.last();
+   }
+ */
+
+void RS_ActionDrawSpline::undo()
+{
+       if (history.count() > 1)
+       {
+               history.removeLast();
+               //bHistory.removeLast();
+               deletePreview();
+               clearPreview();
+
+               //graphicView->setCurrentAction(
+               //    new RS_ActionEditUndo(true, *container, *graphicView));
+               if (history.last() != NULL)
+               {
+                       //point = *history.last();
                }
-               if (spline!=NULL) {
+
+               if (spline != NULL)
+               {
                        spline->removeLastControlPoint();
-                       Vector* v = history.last();
-                       if (v!=NULL) {
-                       graphicView->moveRelativeZero(*v);
-                       }
+                       Vector * v = history.last();
+
+                       if (v != NULL)
+                               graphicView->moveRelativeZero(*v);
                        graphicView->redraw();
                }
-    } else {
-        RS_DIALOGFACTORY->commandMessage(
-            tr("Cannot undo: "
-               "Not enough entities defined yet."));
-    }
+       }
+       else
+               RS_DIALOGFACTORY->commandMessage(
+                       tr("Cannot undo: "
+                               "Not enough entities defined yet."));
 }
 
-
-void RS_ActionDrawSpline::setDegree(int deg) {
+void RS_ActionDrawSpline::setDegree(int deg)
+{
        data.degree = deg;
-       if (spline!=NULL) {
+
+       if (spline != NULL)
                spline->setDegree(deg);
-       }
 }
 
-int RS_ActionDrawSpline::getDegree() {
+int RS_ActionDrawSpline::getDegree()
+{
        return data.degree;
 }
 
-void RS_ActionDrawSpline::setClosed(bool c) {
+void RS_ActionDrawSpline::setClosed(bool c)
+{
        data.closed = c;
-       if (spline!=NULL) {
+
+       if (spline != NULL)
                spline->setClosed(c);
-       }
 }
 
-bool RS_ActionDrawSpline::isClosed() {
+bool RS_ActionDrawSpline::isClosed()
+{
        return data.closed;
 }
 
index 9b1cc7ef7a32b472812d8b26073b5472676d64a1..4e484ca889d936d3897814acff21a142e955a9dd 100644 (file)
@@ -1,29 +1,3 @@
-/****************************************************************************
-** $Id: rs_actiondrawspline.h 1155 2004-11-18 16:01:06Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONDRAWSPLINE_H
 #define RS_ACTIONDRAWSPLINE_H
 
  */
 class RS_ActionDrawSpline: public RS_PreviewActionInterface
 {
-//hm   //Q_OBJECT
        public:
                /**
-               * Action States.
-               */
+                * Action States.
+                */
                enum Status {
                        SetStartpoint,   /**< Setting the startpoint.  */
                        SetNextPoint      /**< Setting the next point. */
@@ -53,13 +26,13 @@ class RS_ActionDrawSpline: public RS_PreviewActionInterface
                virtual ~RS_ActionDrawSpline();
 
                virtual RS2::ActionType rtti();
-               static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
+               //static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
                void reset();
-               virtual void init(int status=0);
+               virtual void init(int status = 0);
                virtual void trigger();
                virtual void mouseMoveEvent(QMouseEvent * e);
                virtual void mouseReleaseEvent(QMouseEvent * e);
-               virtual void coordinateEvent(RS_CoordinateEvent * e);
+               virtual void coordinateEvent(Vector * e);
                virtual void commandEvent(RS_CommandEvent * e);
                virtual QStringList getAvailableCommands();
                virtual void showOptions();
@@ -77,35 +50,19 @@ class RS_ActionDrawSpline: public RS_PreviewActionInterface
 
        protected:
                /**
-               * Spline data defined so far.
-               */
+                * Spline data defined so far.
+                */
                RS_SplineData data;
 
                /**
-               * Polyline entity we're working on.
-               */
+                * Polyline entity we're working on.
+                */
                RS_Spline * spline;
 
                /**
-               * last point.
-               */
-               //Vector point;
-
-               /**
-               * Start point of the series of nodes. Used for close function.
-               */
-               //Vector start;
-
-               /**
-               * Point history (for undo)
-               */
-//             Q3PtrList<Vector> history;
+                * Point history (for undo)
+                */
                QList<Vector *> history;
-
-               /**
-               * Bulge history (for undo)
-               */
-               //Q3PtrList<double> bHistory;
 };
 
 #endif
index c4f2d24fa1097479bff58b8dea8a7f5039f1e03f..55b9ae64587c2760e3763b2523013e46fc3152c2 100644 (file)
 
 #include "rs_actiondrawtext.h"
 
+#include "rs_dialogfactory.h"
 #include "rs_graphicview.h"
-#include "rs_snapper.h"
+#include "rs_preview.h"
 
-RS_ActionDrawText::RS_ActionDrawText(RS_EntityContainer & container,
-       RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Text", container, graphicView)
+RS_ActionDrawText::RS_ActionDrawText(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Text", container, graphicView)
 {
        pos = Vector(false);
        textChanged = true;
@@ -68,7 +68,7 @@ void RS_ActionDrawText::init(int status)
 
                graphicView->redraw();
        }
-               break;
+       break;
 
        case SetPos:
                RS_DIALOGFACTORY->requestOptions(this, true, true);
@@ -81,9 +81,9 @@ void RS_ActionDrawText::init(int status)
 
 void RS_ActionDrawText::reset()
 {
-    data = RS_TextData(Vector(0.0, 0.0), 1.0, 100.0, RS2::VAlignTop,
-               RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, data.text,
-               "standard", 0.0, RS2::Update);
+       data = RS_TextData(Vector(0.0, 0.0), 1.0, 100.0, RS2::VAlignTop,
+                       RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, data.text,
+                       "standard", 0.0, RS2::Update);
 }
 
 void RS_ActionDrawText::trigger()
@@ -158,7 +158,7 @@ void RS_ActionDrawText::mouseReleaseEvent(QMouseEvent * e)
 {
        if (e->button() == Qt::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (e->button() == Qt::RightButton)
@@ -176,12 +176,12 @@ void RS_ActionDrawText::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawText::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawText::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
        switch (getStatus())
        {
@@ -205,16 +205,15 @@ void RS_ActionDrawText::commandEvent(RS_CommandEvent * e)
        if (checkCommand("help", c))
        {
                if (RS_DIALOGFACTORY != NULL)
-               {
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                + getAvailableCommands().join(", "));
-               }
                return;
        }
 
        switch (getStatus())
        {
        case SetPos:
+
                if (checkCommand("text", c))
                {
                        deleteSnapper();
@@ -277,9 +276,11 @@ void RS_ActionDrawText::updateMouseButtonHints()
        case SetPos:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify insertion point"), tr("Cancel"));
                break;
+
        case SetText:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Enter text:"), tr("Back"));
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
@@ -288,12 +289,12 @@ void RS_ActionDrawText::updateMouseButtonHints()
 
 void RS_ActionDrawText::updateMouseCursor()
 {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
 void RS_ActionDrawText::updateToolBar()
 {
-    if (RS_DIALOGFACTORY == NULL)
+       if (RS_DIALOGFACTORY == NULL)
                return;
 
        switch (getStatus())
@@ -301,6 +302,7 @@ void RS_ActionDrawText::updateToolBar()
        case SetPos:
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
                break;
+
        default:
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
                break;
@@ -309,22 +311,23 @@ void RS_ActionDrawText::updateToolBar()
 
 void RS_ActionDrawText::setText(const QString & t)
 {
-    data.text = t;
-    textChanged = true;
+       data.text = t;
+       textChanged = true;
 }
 
 QString RS_ActionDrawText::getText()
 {
-    return data.text;
+       return data.text;
 }
 
 void RS_ActionDrawText::setAngle(double a)
 {
-    data.angle = a;
-    textChanged = true;
+       data.angle = a;
+       textChanged = true;
 }
 
 double RS_ActionDrawText::getAngle()
 {
-    return data.angle;
+       return data.angle;
 }
+
index 7e8cebf7870f253701d5050cb45116abd15eadf0..dcafd561ca8441e8d5df62268974fd478f22a8ec 100644 (file)
@@ -33,7 +33,7 @@ class RS_ActionDrawText: public RS_PreviewActionInterface
                void preparePreview();
                virtual void mouseMoveEvent(QMouseEvent * e);
                virtual void mouseReleaseEvent(QMouseEvent * e);
-               virtual void coordinateEvent(RS_CoordinateEvent * e);
+               virtual void coordinateEvent(Vector * e);
                virtual void commandEvent(RS_CommandEvent * e);
                virtual QStringList getAvailableCommands();
                virtual void hideOptions();
index 64f139a3227b8cfa2a0fe338eae3c3c395f70e08..bbb70d6d9bf35e2886951d097a5a42f6f4ca7a22 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "rs_actioneditcopy.h"
 
+#include "rs_dialogfactory.h"
 #include "rs_modification.h"
 
 /**
  *
  * @param undo true for undo and false for redo.
  */
-RS_ActionEditCopy::RS_ActionEditCopy(bool copy,
-       RS_EntityContainer& container, RS_GraphicView& graphicView):
+RS_ActionEditCopy::RS_ActionEditCopy(bool copy, RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Edit Copy", container, graphicView)
 {
-    this->copy = copy;
+       this->copy = copy;
 }
 
 RS_ActionEditCopy::~RS_ActionEditCopy()
 {
 }
 
-QAction * RS_ActionEditCopy::createGUIAction(RS2::ActionType type, QObject * parent)
-{
-       QAction * action;
-
-       if (type == RS2::ActionEditCopy)
-       {
-               //QPixmap icon = QPixmap(editcopy_xpm);
-               action = new QAction(QIcon(":/res/editcopy2.png"), tr("&Copy"), parent);
-               action->setShortcut(Qt::CTRL + Qt::Key_C);
-//             action = new QAction(tr("Copy"), QPixmap::fromMimeSource("editcopy2.png"), tr("&Copy"),
-//                                                             CTRL+Key_C, parent);
-               action->setStatusTip(tr("Copies entities to the clipboard"));
-       }
-       else
-       {
-               //icon = QPixmap(editcut_xpm);
-               action = new QAction(QIcon(":/res/editcut2.png"), tr("Cu&t"), parent);
-               action->setShortcut(Qt::CTRL + Qt::Key_X);
-//             action = new QAction(tr("Cut"), QPixmap::fromMimeSource("editcut2.png"), tr("Cu&t"),
-//                                                             CTRL+Key_X, parent);
-               action->setStatusTip(tr("Cuts entities to the clipboard"));
-       }
-
-       return action;
-}
-
 void RS_ActionEditCopy::init(int status)
 {
-    RS_ActionInterface::init(status);
-    //trigger();
+       RS_ActionInterface::init(status);
+       //trigger();
 }
 
+void RS_ActionEditCopy::trigger()
+{
+       deleteSnapper();
 
+       RS_Modification m(*container, graphicView);
+       m.copy(referencePoint, !copy);
 
-void RS_ActionEditCopy::trigger() {
-
-    deleteSnapper();
-
-    RS_Modification m(*container, graphicView);
-    m.copy(referencePoint, !copy);
-
-    //graphicView->redraw();
-    finish();
-    graphicView->killSelectActions();
-    //init(getStatus()-1);
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       //graphicView->redraw();
+       finish();
+       graphicView->killSelectActions();
+       //init(getStatus()-1);
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent* e) {
-    snapPoint(e);
+void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent * e)
+{
+       snapPoint(e);
 }
 
-
-
-void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionEditCopy::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-
-void RS_ActionEditCopy::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    referencePoint = e->getCoordinate();
-    trigger();
+       referencePoint = *e;
+       trigger();
 }
 
-
-
-void RS_ActionEditCopy::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionEditCopy::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
+                       tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionEditCopy::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionEditCopy::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionEditCopy::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-    }
+void RS_ActionEditCopy::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
 }
 
-
 // EOF
index 94d0ca5bf21a8974b32cde6c49127d89a526c903..98033ac5f015d5dfbd8aa3cd0994ca4b0b8f0d23 100644 (file)
@@ -2,6 +2,7 @@
 #define RS_ACTIONEDITCOPY_H
 
 #include "rs_actioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events for copying or cutting entities
  */
 class RS_ActionEditCopy: public RS_ActionInterface
 {
-       //Q_OBJECT
        public:
                /**
-               * Action States.
-               */
+                * Action States.
+                */
                enum Status {
                        SetReferencePoint    /**< Setting the reference point. */
                };
 
        public:
-               RS_ActionEditCopy(bool copy,
-                                               RS_EntityContainer& container,
-                                               RS_GraphicView& graphicView);
+               RS_ActionEditCopy(bool copy, RS_EntityContainer & container, RS_GraphicView & graphicView);
                ~RS_ActionEditCopy();
 
-               static QAction* createGUIAction(RS2::ActionType type, QObject* parent);
-
-               virtual void init(int status=0);
-
+               virtual void init(int status = 0);
                virtual void trigger();
-
                virtual void mouseMoveEvent(QMouseEvent * e);
                virtual void mouseReleaseEvent(QMouseEvent * e);
-
-               virtual void coordinateEvent(RS_CoordinateEvent * e);
-
+               virtual void coordinateEvent(Vector * e);
                virtual void updateMouseButtonHints();
                virtual void updateMouseCursor();
                virtual void updateToolBar();
index 78514c34d7e80a37414a3f24a0ddf17054133e8f..f4b7aa987d872c2be82b40df4eab1a79ee8ce518 100644 (file)
@@ -1,33 +1,23 @@
-/****************************************************************************
-** $Id: rs_actioneditpaste.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioneditpaste.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioneditpaste.h"
 
 #include "rs_clipboard.h"
+#include "rs_dialogfactory.h"
 #include "rs_modification.h"
+#include "rs_preview.h"
 #include "rs_units.h"
 
 /**
  *
  * @param undo true for undo and false for redo.
  */
-RS_ActionEditPaste::RS_ActionEditPaste( RS_EntityContainer& container,
-                                        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Edit Paste",
-                           container, graphicView)
+RS_ActionEditPaste::RS_ActionEditPaste(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Edit Paste",
+               container, graphicView)
 {
 }
 
@@ -46,115 +34,102 @@ RS_ActionEditPaste::~RS_ActionEditPaste()
 {
 }
 
-QAction* RS_ActionEditPaste::createGUIAction(RS2::ActionType /*type*/, QObject* parent)
-{
-       //icon = QPixmap(editpaste_xpm);
-       QAction * action = new QAction(QIcon(":/res/editpaste2.png"), tr("&Paste"), parent);
-       action->setShortcut(Qt::CTRL + Qt::Key_V);
-//     QAction* action = new QAction(tr("Paste"),
-//                                                                     qPixmapFromMimeSource("editpaste2.png"), tr("&Paste"),
-//                                                                     Qt::CTRL+Qt::Key_V, parent);
-       action->setStatusTip(tr("Pastes the clipboard contents"));
-       return action;
-}
-
 void RS_ActionEditPaste::init(int status)
 {
-    RS_PreviewActionInterface::init(status);
-    //trigger();
+       RS_PreviewActionInterface::init(status);
+       //trigger();
 }
 
 void RS_ActionEditPaste::trigger()
 {
-    deleteSnapper();
-    deletePreview();
-    clearPreview();
+       deleteSnapper();
+       deletePreview();
+       clearPreview();
 
-    RS_Modification m(*container, graphicView);
-    m.paste(RS_PasteData(targetPoint, 1.0, 0.0, false, ""));
-    //std::cout << *RS_Clipboard::instance();
+       RS_Modification m(*container, graphicView);
+       m.paste(RS_PasteData(targetPoint, 1.0, 0.0, false, ""));
+       //std::cout << *RS_Clipboard::instance();
 
-    graphicView->redraw();
-    finish();
+       graphicView->redraw();
+       finish();
 }
 
-
-void RS_ActionEditPaste::mouseMoveEvent(QMouseEvent* e) {
-    switch (getStatus()) {
-    case SetTargetPoint:
-        targetPoint = snapPoint(e);
-
-        deletePreview();
-        clearPreview();
-        preview->addAllFrom(*RS_CLIPBOARD->getGraphic());
-        preview->move(targetPoint);
-
-               if (graphic!=NULL) {
+void RS_ActionEditPaste::mouseMoveEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
+       case SetTargetPoint:
+               targetPoint = snapPoint(e);
+
+               deletePreview();
+               clearPreview();
+               preview->addAllFrom(*RS_CLIPBOARD->getGraphic());
+               preview->move(targetPoint);
+
+               if (graphic != NULL)
+               {
                        RS2::Unit sourceUnit = RS_CLIPBOARD->getGraphic()->getUnit();
                        RS2::Unit targetUnit = graphic->getUnit();
                        double f = RS_Units::convert(1.0, sourceUnit, targetUnit);
-               preview->scale(targetPoint, Vector(f,f));
+                       preview->scale(targetPoint, Vector(f, f));
                }
-        drawPreview();
-        break;
+               drawPreview();
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionEditPaste::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionEditPaste::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionEditPaste::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-
-void RS_ActionEditPaste::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    targetPoint = e->getCoordinate();
-    trigger();
+       targetPoint = *e;
+       trigger();
 }
 
-
-
-void RS_ActionEditPaste::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Set reference point"),
-                                            tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionEditPaste::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Set reference point"),
+                       tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionEditPaste::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionEditPaste::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionEditPaste::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-    }
+void RS_ActionEditPaste::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
 }
 
-
 // EOF
index 34dc0db7e3d206bc5b0dde16df1d039b421d733d..decb09d0b08d1c05a8dfe967f5cc883df58e878d 100644 (file)
@@ -1,33 +1,8 @@
-/****************************************************************************
-** $Id: rs_actioneditpaste.h 1155 2004-11-18 16:01:06Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONEDITPASTE_H
 #define RS_ACTIONEDITPASTE_H
 
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events for pasting entities from
  *
  * @author Andrew Mustun
  */
-class RS_ActionEditPaste : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetTargetPoint    /**< Setting the reference point. */
-    };
-
-public:
-    RS_ActionEditPaste( RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionEditPaste();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void coordinateEvent(RS_CoordinateEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    Vector targetPoint;
+class RS_ActionEditPaste: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetTargetPoint    /**< Setting the reference point. */
+               };
+
+       public:
+               RS_ActionEditPaste(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionEditPaste();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               Vector targetPoint;
 };
 
 #endif
index 939fe95e470a277eefab89b45802b772b14e88aa..3a9cfeac6578dfa63705b14eae8653315d2b4caf 100644 (file)
 //
 
 #include "rs_actioneditundo.h"
-#include "rs_snapper.h"
-//Added by qt3to4:
-//#include <QIcon>//needed???
+
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 
 /**
  * Constructor.
  *
  * @param undo true for undo and false for redo.
  */
-RS_ActionEditUndo::RS_ActionEditUndo(bool undo, RS_EntityContainer & container,
-       RS_GraphicView & graphicView): RS_ActionInterface("Edit Undo", container, graphicView)
+RS_ActionEditUndo::RS_ActionEditUndo(bool undo, RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Edit Undo", container, graphicView)
 {
        this->undo = undo;
 }
@@ -32,34 +31,6 @@ RS_ActionEditUndo::~RS_ActionEditUndo()
 {
 }
 
-QAction * RS_ActionEditUndo::createGUIAction(RS2::ActionType type, QObject * parent)
-{
-       QAction * action;
-
-       if (type == RS2::ActionEditUndo)
-       {
-               action = new QAction(QIcon(":/res/undo2.png"), tr("&Undo")/*+ QString("\too")*/, parent);
-               QList<QKeySequence> ks;
-               ks.append(QKeySequence(tr("o, o", "Edit|Undo")));
-               ks.append(Qt::CTRL + Qt::Key_Z);
-//             action->setShortcut(Qt::CTRL + Qt::Key_Z);
-               action->setShortcuts(ks);
-               action->setStatusTip(tr("Undoes last action"));
-       }
-       else
-       {
-               action = new QAction(QIcon(":/res/redo2.png"), tr("&Redo")/* + QString("\tuu")*/, parent);
-               QList<QKeySequence> ks;
-               ks.append(QKeySequence(tr("u, u", "Edit|Redo")));
-               ks.append(Qt::CTRL + Qt::SHIFT + Qt::Key_Z);
-//             action->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Z);
-               action->setShortcuts(ks);
-               action->setStatusTip(tr("Redoes last action"));
-       }
-
-       return action;
-}
-
 void RS_ActionEditUndo::init(int status)
 {
        RS_ActionInterface::init(status);
@@ -80,3 +51,4 @@ void RS_ActionEditUndo::trigger()
        finish();
        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
+
index 2e8bb7c1737b97166ff6012d07c9db2b2031e903..6ae1c625f2d17a50cab1194210b188a83c3b4a51 100644 (file)
@@ -2,23 +2,18 @@
 #define RS_ACTIONEDITUNDO_H
 
 #include "rs_actioninterface.h"
-#include "rs_undo.h"
 
 /**
  * This action class can handle user events for undo / redo.
  *
  * @author Andrew Mustun
  */
-class RS_ActionEditUndo : public RS_ActionInterface
+class RS_ActionEditUndo: public RS_ActionInterface
 {
-       //Q_OBJECT
        public:
-               RS_ActionEditUndo(bool undo, RS_EntityContainer & container,
-                       RS_GraphicView & graphicView);
+               RS_ActionEditUndo(bool undo, RS_EntityContainer & container, RS_GraphicView & graphicView);
                ~RS_ActionEditUndo();
 
-               static QAction * createGUIAction(RS2::ActionType type, QObject * parent);
-
                virtual void init(int status = 0);
                virtual void trigger();
 
index 7c9c5ecbe66153cd5e53eeb5a3780f77f39e2184..980e4b9bb87a3f872e8be0ef22c932c4a5f40214 100644 (file)
@@ -1,68 +1,47 @@
-/****************************************************************************
-** $Id: rs_actionfilenew.cpp 1090 2004-03-16 10:02:59Z js $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionfilenew.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionfilenew.h"
 
-#include "drawing.h"
+//#include "drawing.h"
 
-RS_ActionFileNew::RS_ActionFileNew(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionFileNew::RS_ActionFileNew(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("File New", container, graphicView)
 {
 }
 
-QAction * RS_ActionFileNew::createGUIAction(RS2::ActionType /*type*/, QObject * parent)
+RS_ActionFileNew::~RS_ActionFileNew()
 {
-       QAction * action = new QAction(QIcon(":/res/filenew.png"), tr("&New"), parent);
-       action->setShortcut(Qt::CTRL + Qt::Key_N);
-//     QAction* action = new QAction(tr("New Drawing"), QPixmap::fromMimeSource("filenew.png"),
-//                                                     tr("&New"), CTRL+Key_N, parent);
-       action->setStatusTip(tr("Creates a new drawing"));
-       return action;
 }
 
 void RS_ActionFileNew::trigger()
 {
-    /*
-    // Not supported currently
-    RS_DEBUG->print("RS_ActionFileNew::trigger");
-
-    QString fileName; //= RS_DIALOGFACTORY->requestFileNewDialog();
-    if (graphic!=NULL && !fileName.isEmpty()) {
-        graphic->open(fileName, );
-}
-    */
-    finish();
+       /*
+          // Not supported currently
+          RS_DEBUG->print("RS_ActionFileNew::trigger");
+
+          QString fileName; //= RS_DIALOGFACTORY->requestFileNewDialog();
+          if (graphic!=NULL && !fileName.isEmpty()) {
+               graphic->open(fileName, );
+          }
+        */
+       finish();
 }
 
-
 void RS_ActionFileNew::init(int status)
 {
-    RS_ActionInterface::init(status);
-    trigger();
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index 9c1474f0ff8553c8a422c50e95919553b48b8e9a..fe8ddc6c814e2a212df41e9ee50942d44710a235 100644 (file)
@@ -1,51 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionfilenew.h 1155 2004-11-18 16:01:06Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONFILENEW_H
 #define RS_ACTIONFILENEW_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to create new blank documents.
  *
  * @author Andrew Mustun
  */
-class RS_ActionFileNew : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionFileNew(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView);
-    ~RS_ActionFileNew() {}
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* parent);
+class RS_ActionFileNew: public RS_ActionInterface
+{
+       public:
+               RS_ActionFileNew(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionFileNew();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 7093bbcbd235e842448511b75e0af063b353cbe4..517670f17b5492fc5e12c43ed7b6b140b8b687ca 100644 (file)
@@ -1,10 +1,22 @@
+// rs_actionfileopen.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionfileopen.h"
 
-#include "drawing.h"
+//#include "drawing.h"
 
-RS_ActionFileOpen::RS_ActionFileOpen(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionFileOpen::RS_ActionFileOpen(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("File Open", container, graphicView)
 {
 }
@@ -13,34 +25,23 @@ RS_ActionFileOpen::~RS_ActionFileOpen()
 {
 }
 
-QAction * RS_ActionFileOpen::createGUIAction(RS2::ActionType /*type*/, QObject * parent)
-{
-       //icon = QPixmap(fileopen_xpm);
-       QAction * action = new QAction(QIcon(":/res/fileopen2.png"), tr("&Open..."), parent);
-       action->setShortcut(Qt::CTRL + Qt::Key_O);
-//     QAction* action = new QAction(tr("Open Drawing"),
-//                                                                     QPixmap::fromMimeSource("fileopen2.png"),
-//                                                                     tr("&Open..."), CTRL+Key_O, parent);
-       action->setStatusTip(tr("Opens an existing drawing"));
-       return action;
-}
-
 void RS_ActionFileOpen::trigger()
 {
-    /*
-    // Not supported currently
-    RS_DEBUG->print("RS_ActionFileOpen::trigger");
-
-    QString fileName; //= RS_DIALOGFACTORY->requestFileOpenDialog();
-    if (graphic!=NULL && !fileName.isEmpty()) {
-        graphic->open(fileName, );
-}
-    */
-    finish();
+       /*
+          // Not supported currently
+          RS_DEBUG->print("RS_ActionFileOpen::trigger");
+
+          QString fileName; //= RS_DIALOGFACTORY->requestFileOpenDialog();
+          if (graphic!=NULL && !fileName.isEmpty()) {
+               graphic->open(fileName, );
+          }
+        */
+       finish();
 }
 
 void RS_ActionFileOpen::init(int status)
 {
-    RS_ActionInterface::init(status);
-    trigger();
+       RS_ActionInterface::init(status);
+       trigger();
 }
+
index 955292c32eb5c3c1f0410437c951151add32f9a9..110a30cbb3a03d3b932df811f31713517b9c9e3a 100644 (file)
  */
 class RS_ActionFileOpen: public RS_ActionInterface
 {
-       //Q_OBJECT
        public:
                RS_ActionFileOpen(RS_EntityContainer & container, RS_GraphicView & graphicView);
                ~RS_ActionFileOpen();
 
-               static QAction * createGUIAction(RS2::ActionType type, QObject * parent);
-
                virtual void init(int status = 0);
                virtual void trigger();
 };
index 4446afcce7ebfb6e6368a0f5406970cd269d299e..dc040c8ee8a518a5ad075999ed8222538d9fcc35 100644 (file)
@@ -1,51 +1,28 @@
-/****************************************************************************
-** $Id: rs_actionfilesave.cpp 1096 2004-03-17 11:54:02Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionfilesave.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionfilesave.h"
 
 #include "drawing.h"
-//Added by qt3to4:
-//#include <QPixmap>
 
-RS_ActionFileSave::RS_ActionFileSave(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionFileSave::RS_ActionFileSave(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("File Save", container, graphicView)
 {
 }
 
-QAction* RS_ActionFileSave::createGUIAction(RS2::ActionType /*type*/, QObject* parent)
+RS_ActionFileSave::~RS_ActionFileSave()
 {
-       //icon = QPixmap(filesave_xpm);
-       QAction * action = new QAction(QIcon(":/res/filesave2.png"), tr("&Save"), parent);
-       action->setShortcut(Qt::CTRL + Qt::Key_S);
-//     QAction* action = new QAction(tr("Save Drawing"),
-//                                                                     QPixmap::fromMimeSource("filesave2.png"),
-//                                                                     tr("&Save"), CTRL+Key_S, parent);
-       action->setStatusTip(tr("Saves the current drawing"));
-       return action;
 }
 
 void RS_ActionFileSave::trigger()
@@ -53,18 +30,14 @@ void RS_ActionFileSave::trigger()
        RS_DEBUG->print("RS_ActionFileSave::trigger");
 
        if (graphic != NULL)
-       {
                graphic->save();
-       }
 
        finish();
 }
 
-
-
-void RS_ActionFileSave::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionFileSave::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index 49b59e9ae12ad6e0273b26fdcfd08f684fba20e4..c5463fdfdd138d60c8fdb43d2f9e73b6ef2aee80 100644 (file)
@@ -1,51 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionfilesave.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONFILESAVE_H
 #define RS_ACTIONFILESAVE_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to save the current file.
  *
  * @author Andrew Mustun
  */
-class RS_ActionFileSave : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionFileSave(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView);
-    ~RS_ActionFileSave() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* parent);
+class RS_ActionFileSave: public RS_ActionInterface
+{
+       public:
+               RS_ActionFileSave(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionFileSave();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 8a5d23e8f67704cd0467c298cf750a55d5f16304..6f2b65622adb358dba31682f3437cec607cee780 100644 (file)
@@ -1,66 +1,44 @@
-/****************************************************************************
-** $Id: rs_actionfilesaveas.cpp 1090 2004-03-16 10:02:59Z js $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionfilesaveas.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionfilesaveas.h"
 
 #include "drawing.h"
-//Added by qt3to4:
-//#include <QPixmap>
 
-RS_ActionFileSaveAs::RS_ActionFileSaveAs(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionFileSaveAs::RS_ActionFileSaveAs(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Add Layer", container, graphicView)
 {
 }
 
-QAction * RS_ActionFileSaveAs::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionFileSaveAs::~RS_ActionFileSaveAs()
 {
-       QAction * action = new QAction(QIcon("filesaveas.png"), tr("Save &as..."), 0);
-//     QAction* action = new QAction(tr("Save Drawing As"), QPixmap::fromMimeSource("filesaveas.png"), tr("Save &as..."),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Saves the current drawing under a new filename"));
-       return action;
 }
 
 void RS_ActionFileSaveAs::trigger()
 {
-    RS_DEBUG->print("RS_ActionFileSaveAs::trigger");
-
-    QString fileName; // = RS_DIALOGFACTORY->requestFileSaveAsDialog();
-    if (graphic!=NULL && !fileName.isEmpty()) {
-        graphic->saveAs(fileName, RS2::FormatUnknown);
-    }
-    finish();
-}
+       RS_DEBUG->print("RS_ActionFileSaveAs::trigger");
+       QString fileName; // = RS_DIALOGFACTORY->requestFileSaveAsDialog();
 
+       if (graphic != NULL && !fileName.isEmpty())
+               graphic->saveAs(fileName, RS2::FormatUnknown);
 
+       finish();
+}
 
-void RS_ActionFileSaveAs::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionFileSaveAs::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index 071efb9f3f01c8d5fc466c2c5675d94273b75cea..8df2c4f10f90d941c073e7aab39b19fc7c13ff29 100644 (file)
@@ -1,52 +1,22 @@
-/****************************************************************************
-** $Id: rs_actionfilesaveas.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONFILESAVEAS_H
 #define RS_ACTIONFILESAVEAS_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to export files
  * in various formats.
  *
  * @author Andrew Mustun
  */
-class RS_ActionFileSaveAs : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionFileSaveAs(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionFileSaveAs() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionFileSaveAs: public RS_ActionInterface
+{
+       public:
+               RS_ActionFileSaveAs(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionFileSaveAs();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 70abb781ed5f9d31caa2ba60a2b9716d72c80244..c6fa7ddfc8b116816a698e5d4e155d6136e9abea 100644 (file)
-/****************************************************************************
-** $Id: rs_actioninfoangle.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioninfoangle.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioninfoangle.h"
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 #include "rs_information.h"
-#include "rs_snapper.h"
 
-
-
-RS_ActionInfoAngle::RS_ActionInfoAngle(RS_EntityContainer& container,
-                                       RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Info Angle",
-                           container, graphicView) {}
-
-
-QAction * RS_ActionInfoAngle::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionInfoAngle::RS_ActionInfoAngle(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Info Angle",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Angle between two lines"), 0);
-//     QAction* action = new QAction(tr("Angle between two lines"),
-//                                                                     tr("&Angle between two lines"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Measures the angle between two lines"));
-       return action;
 }
 
-
-void RS_ActionInfoAngle::init(int status) {
-    RS_ActionInterface::init(status);
-
+RS_ActionInfoAngle::~RS_ActionInfoAngle()
+{
 }
 
-
-
-void RS_ActionInfoAngle::trigger() {
-
-    RS_DEBUG->print("RS_ActionInfoAngle::trigger()");
-    deleteSnapper();
-
-    if (entity1!=NULL && entity2!=NULL) {
-        VectorSolutions sol =
-            RS_Information::getIntersection(entity1, entity2, false);
-
-        if (sol.hasValid()) {
-            intersection = sol.get(0);
-
-            if (intersection.valid && point1.valid && point2.valid) {
-                double angle1 = intersection.angleTo(point1);
-                double angle2 = intersection.angleTo(point2);
-                double angle = fabs(angle2-angle1);
-
-                QString str;
-                str.sprintf("%.6f", RS_Math::rad2deg(angle));
-                RS_DIALOGFACTORY->commandMessage(tr("Angle: %1%2")
-                                                 .arg(str).arg(QChar(0xB0)));
-            }
-        } else {
-            RS_DIALOGFACTORY->commandMessage(tr("Lines are parallel"));
-        }
-    }
+void RS_ActionInfoAngle::init(int status)
+{
+       RS_ActionInterface::init(status);
 }
 
+void RS_ActionInfoAngle::trigger()
+{
+       RS_DEBUG->print("RS_ActionInfoAngle::trigger()");
+       deleteSnapper();
+
+       if (entity1 != NULL && entity2 != NULL)
+       {
+               VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
+
+               if (sol.hasValid())
+               {
+                       intersection = sol.get(0);
+
+                       if (intersection.valid && point1.valid && point2.valid)
+                       {
+                               double angle1 = intersection.angleTo(point1);
+                               double angle2 = intersection.angleTo(point2);
+                               double angle = fabs(angle2 - angle1);
+
+                               QString str;
+                               str.sprintf("%.6f", RS_Math::rad2deg(angle));
+                               RS_DIALOGFACTORY->commandMessage(tr("Angle: %1%2").arg(str).arg(QChar(0xB0)));
+                       }
+               }
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Lines are parallel"));
+       }
+}
 
+void RS_ActionInfoAngle::mouseMoveEvent(QMouseEvent * /*e*/)
+{
+       RS_DEBUG->print("RS_ActionInfoAngle::mouseMoveEvent begin");
 
-void RS_ActionInfoAngle::mouseMoveEvent(QMouseEvent* /*e*/) {
-    RS_DEBUG->print("RS_ActionInfoAngle::mouseMoveEvent begin");
-
-    switch (getStatus()) {
-    case SetEntity1:
-        break;
+       switch (getStatus())
+       {
+       case SetEntity1:
+               break;
 
-    case SetEntity2:
-        break;
+       case SetEntity2:
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionInfoAngle::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionInfoAngle::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionInfoAngle::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-
-        Vector mouse(graphicView->toGraphX(e->x()),
-                        graphicView->toGraphY(e->y()));
-
-        switch (getStatus()) {
-        case SetEntity1:
-            entity1 = catchEntity(e);
-            if (entity1!=NULL && entity1->rtti()==RS2::EntityLine) {
-                point1 = entity1->getNearestPointOnEntity(mouse);
-                setStatus(SetEntity2);
-            }
-            break;
-
-        case SetEntity2:
-            entity2 = catchEntity(e);
-            if (entity2!=NULL && entity2->rtti()==RS2::EntityLine) {
-                point2 = entity2->getNearestPointOnEntity(mouse);
-                trigger();
-                setStatus(SetEntity1);
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionInfoAngle::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
+
+               switch (getStatus())
+               {
+               case SetEntity1:
+                       entity1 = catchEntity(e);
+
+                       if (entity1 != NULL && entity1->rtti() == RS2::EntityLine)
+                       {
+                               point1 = entity1->getNearestPointOnEntity(mouse);
+                               setStatus(SetEntity2);
+                       }
+
+                       break;
+
+               case SetEntity2:
+                       entity2 = catchEntity(e);
+
+                       if (entity2 != NULL && entity2->rtti() == RS2::EntityLine)
+                       {
+                               point2 = entity2->getNearestPointOnEntity(mouse);
+                               trigger();
+                               setStatus(SetEntity1);
+                       }
+
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionInfoAngle::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetEntity1:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify first line"),
-            tr("Cancel"));
-        break;
-    case SetEntity2:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify second line"),
-            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionInfoAngle::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetEntity1:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify first line"), tr("Cancel"));
+               break;
+
+       case SetEntity2:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify second line"), tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionInfoAngle::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionInfoAngle::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionInfoAngle::updateToolBar() {
-    switch (getStatus()) {
-    case SetEntity1:
-    case SetEntity2:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
-        break;
-    }
+void RS_ActionInfoAngle::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetEntity1:
+       case SetEntity2:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
+               break;
+       }
 }
 
-
-// EOF
index b3486ed488c734405023f70fc56154dcf232ab17..ca336877a14c4a958abccb31e068a7f79f725c5f 100644 (file)
@@ -1,74 +1,47 @@
-/****************************************************************************
-** $Id: rs_actioninfoangle.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONINFOANGLE_H
 #define RS_ACTIONINFOANGLE_H
 
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to measure angles.
  *
  * @author Andrew Mustun
  */
-class RS_ActionInfoAngle : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetEntity1,    /**< Setting the 1st entity. */
-        SetEntity2     /**< Setting the 2nd entity. */
-    };
-
-public:
-    RS_ActionInfoAngle(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionInfoAngle() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-       RS_Entity* entity1;
-       Vector point1;
-
-    RS_Entity* entity2;
-       Vector point2;
-
-       Vector intersection;
+class RS_ActionInfoAngle: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetEntity1,    /**< Setting the 1st entity. */
+                       SetEntity2     /**< Setting the 2nd entity. */
+               };
+
+       public:
+               RS_ActionInfoAngle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionInfoAngle();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_Entity * entity1;
+               Vector point1;
+
+               RS_Entity * entity2;
+               Vector point2;
+
+               Vector intersection;
 };
 
 #endif
index 9d09a4b6ca045cdc9a5d9f2da08ba800a36eafde..34e16468e789d469313a396de1e672fb79472c65 100644 (file)
-/****************************************************************************
-** $Id: rs_actioninfoarea.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioninfoarea.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioninfoarea.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionInfoArea::RS_ActionInfoArea(RS_EntityContainer& container,
-                                     RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Info Area",
-                           container, graphicView) {}
-
-
-QAction* RS_ActionInfoArea::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionInfoArea::RS_ActionInfoArea(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Info Area",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Polygonal Area"), 0);
-//     QAction* action = new QAction(tr("Polygonal Area"),
-//                                                                     tr("&Polygonal Area"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Measures the area of a polygon"));
-       return action;
 }
 
-
-void RS_ActionInfoArea::init(int status) {
-    RS_ActionInterface::init(status);
-
-    currentLine = NULL;
-    closingLine = NULL;
-
-    //std::cout << "RS_ActionInfoArea::init: " << status << "\n";
+RS_ActionInfoArea::~RS_ActionInfoArea()
+{
 }
 
+void RS_ActionInfoArea::init(int status)
+{
+       RS_ActionInterface::init(status);
 
+       currentLine = NULL;
+       closingLine = NULL;
 
-void RS_ActionInfoArea::trigger() {
-
-    RS_DEBUG->print("RS_ActionInfoArea::trigger()");
-    if (ia.isValid()) {
-        ia.close();
-        ia.calculate();
-        double area = ia.getArea();
-        double circ = ia.getCircumference();
-
-        RS_DEBUG->print("RS_ActionInfoArea::trigger: area: %f", area);
-        RS_DIALOGFACTORY->commandMessage(tr("Area: %1").arg(area));
-        RS_DIALOGFACTORY->commandMessage(tr("Circumference: %1").arg(circ));
-    }
-
-    ia.reset();
-
-    /*
-    if (point1.valid && point2.valid) {
-        double dist = point1.distanceTo(point2);
-        QString str;
-        str.sprintf("%.6f", dist);
-        RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
+       //std::cout << "RS_ActionInfoArea::init: " << status << "\n";
 }
-    */
+
+void RS_ActionInfoArea::trigger()
+{
+       RS_DEBUG->print("RS_ActionInfoArea::trigger()");
+
+       if (ia.isValid())
+       {
+               ia.close();
+               ia.calculate();
+               double area = ia.getArea();
+               double circ = ia.getCircumference();
+
+               RS_DEBUG->print("RS_ActionInfoArea::trigger: area: %f", area);
+               RS_DIALOGFACTORY->commandMessage(tr("Area: %1").arg(area));
+               RS_DIALOGFACTORY->commandMessage(tr("Circumference: %1").arg(circ));
+       }
+
+       ia.reset();
+
+       /*
+          if (point1.valid && point2.valid) {
+           double dist = point1.distanceTo(point2);
+           QString str;
+           str.sprintf("%.6f", dist);
+           RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
+          }
+        */
 }
 
+void RS_ActionInfoArea::mouseMoveEvent(QMouseEvent * e)
+{
+       //RS_DEBUG->print("RS_ActionInfoArea::mouseMoveEvent begin");
 
+       if (getStatus() == SetFirstPoint
+           || getStatus() == SetNextPoint)
+       {
+               Vector mouse = snapPoint(e);
 
-void RS_ActionInfoArea::mouseMoveEvent(QMouseEvent* e) {
-    //RS_DEBUG->print("RS_ActionInfoArea::mouseMoveEvent begin");
+               switch (getStatus())
+               {
+               case SetFirstPoint:
+                       break;
 
-    if (getStatus()==SetFirstPoint ||
-            getStatus()==SetNextPoint) {
+               case SetNextPoint:
 
-        Vector mouse = snapPoint(e);
+                       if (prev.valid)
+                       {
+                               deletePreview();
 
-        switch (getStatus()) {
-        case SetFirstPoint:
-            break;
+                               if (currentLine != NULL)
+                               {
+                                       preview->removeEntity(currentLine);
+                                       currentLine = NULL;
+                               }
 
-        case SetNextPoint:
-            if (prev.valid) {
-                deletePreview();
-                if (currentLine!=NULL) {
-                    preview->removeEntity(currentLine);
-                    currentLine = NULL;
-                }
-                if (closingLine!=NULL) {
-                    preview->removeEntity(closingLine);
-                    closingLine = NULL;
-                }
+                               if (closingLine != NULL)
+                               {
+                                       preview->removeEntity(closingLine);
+                                       closingLine = NULL;
+                               }
 
-                currentLine = new RS_Line(preview,
-                                          RS_LineData(prev,
-                                                      mouse));
-                preview->addEntity(currentLine);
+                               currentLine = new RS_Line(preview,
+                                               RS_LineData(prev,
+                                                       mouse));
+                               preview->addEntity(currentLine);
 
-                               if (preview->count()>1) {
-                       closingLine = new RS_Line(preview,
-                                          RS_LineData(mouse,
-                                                      point1));
+                               if (preview->count() > 1)
+                               {
+                                       closingLine = new RS_Line(preview,
+                                                       RS_LineData(mouse,
+                                                               point1));
 
-                       preview->addEntity(closingLine);
+                                       preview->addEntity(closingLine);
                                }
 
-                drawPreview();
-            }
-            break;
+                               drawPreview();
+                       }
+                       break;
 
-        default:
-            break;
-        }
-    }
+               default:
+                       break;
+               }
+       }
 
-    //RS_DEBUG->print("RS_ActionInfoArea::mouseMoveEvent end");
+       //RS_DEBUG->print("RS_ActionInfoArea::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionInfoArea::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        //deletePreview();
-        //clearPreview();
-
-        // close the polygon (preview)
-        if (getStatus()==SetNextPoint && prev.valid) {
-            deletePreview();
-
-            if (currentLine!=NULL) {
-                preview->removeEntity(currentLine);
-                currentLine = NULL;
-            }
-            if (closingLine!=NULL) {
-                preview->removeEntity(closingLine);
-                closingLine = NULL;
-            }
-
-            currentLine = new RS_Line(preview,
-                                      RS_LineData(prev,
-                                                  point1));
-
-            preview->addEntity(currentLine);
-
-            drawPreview();
-        }
-
-        deleteSnapper();
-        trigger();
-        init(getStatus()-1);
-    }
+void RS_ActionInfoArea::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               //deletePreview();
+               //clearPreview();
+
+               // close the polygon (preview)
+               if (getStatus() == SetNextPoint && prev.valid)
+               {
+                       deletePreview();
+
+                       if (currentLine != NULL)
+                       {
+                               preview->removeEntity(currentLine);
+                               currentLine = NULL;
+                       }
+
+                       if (closingLine != NULL)
+                       {
+                               preview->removeEntity(closingLine);
+                               closingLine = NULL;
+                       }
+
+                       currentLine = new RS_Line(preview,
+                                       RS_LineData(prev,
+                                               point1));
+
+                       preview->addEntity(currentLine);
+
+                       drawPreview();
+               }
+
+               deleteSnapper();
+               trigger();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionInfoArea::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetFirstPoint:
-        point1 = mouse;
-
-        deletePreview();
-        clearPreview();
-
-        ia.addPoint(mouse);
-        RS_DIALOGFACTORY->commandMessage(tr("Point: %1/%2")
-                                         .arg(mouse.x).arg(mouse.y));
-
-        graphicView->moveRelativeZero(point1);
-        prev = mouse;
-
-        setStatus(SetNextPoint);
-        break;
-
-    case SetNextPoint:
-        if (point1.valid) {
-            //point2 = mouse;
-            /*deletePreview();
-            clearPreview();
-            */
-            ia.addPoint(mouse);
-            RS_DIALOGFACTORY->commandMessage(tr("Point: %1/%2")
-                                             .arg(mouse.x).arg(mouse.y));
-
-            currentLine = NULL;
-
-            graphicView->moveRelativeZero(mouse);
-            prev = mouse;
-
-            // automatically detect that the polyline is now closed
-            if (ia.isClosed()) {
-                trigger();
-                setStatus(SetFirstPoint);
-            }
-            //trigger();
-            //setStatus(SetFirstPoint);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionInfoArea::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetFirstPoint:
+               point1 = mouse;
+
+               deletePreview();
+               clearPreview();
+
+               ia.addPoint(mouse);
+               RS_DIALOGFACTORY->commandMessage(tr("Point: %1/%2").arg(mouse.x).arg(mouse.y));
+
+               graphicView->moveRelativeZero(point1);
+               prev = mouse;
+
+               setStatus(SetNextPoint);
+               break;
+
+       case SetNextPoint:
+
+               if (point1.valid)
+               {
+                       //point2 = mouse;
+                       /*deletePreview();
+                          clearPreview();
+                        */
+                       ia.addPoint(mouse);
+                       RS_DIALOGFACTORY->commandMessage(tr("Point: %1/%2").arg(mouse.x).arg(mouse.y));
+
+                       currentLine = NULL;
+
+                       graphicView->moveRelativeZero(mouse);
+                       prev = mouse;
+
+                       // automatically detect that the polyline is now closed
+                       if (ia.isClosed())
+                       {
+                               trigger();
+                               setStatus(SetFirstPoint);
+                       }
+                       //trigger();
+                       //setStatus(SetFirstPoint);
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionInfoArea::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetFirstPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify first point of polygon"),
-            tr("Cancel"));
-        break;
-    case SetNextPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify next point of polygon"),
-            tr("Terminate"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionInfoArea::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetFirstPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify first point of polygon"),
+                       tr("Cancel"));
+               break;
+
+       case SetNextPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify next point of polygon"),
+                       tr("Terminate"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionInfoArea::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionInfoArea::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionInfoArea::updateToolBar() {
-    switch (getStatus()) {
-    case SetFirstPoint:
-    case SetNextPoint:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
-        break;
-    }
+void RS_ActionInfoArea::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetFirstPoint:
+       case SetNextPoint:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
+               break;
+       }
 }
 
-
 // EOF
index 1437ca7b71cb05d554d757d576b5a94079373c97..0f701acb60f2064eeccf64f40ce5f421de9dcb6d 100644 (file)
@@ -1,79 +1,48 @@
-/****************************************************************************
-** $Id: rs_actioninfoarea.h 1133 2004-07-11 20:42:18Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONINFOAREA_H
 #define RS_ACTIONINFOAREA_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_infoarea.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
- * This action class can handle user events to measure distances between 
+ * This action class can handle user events to measure distances between
  * two points.
  *
  * @author Andrew Mustun
  */
-class RS_ActionInfoArea : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetFirstPoint,    /**< Setting the 1st point of the polygon. */
-        SetNextPoint      /**< Setting a next point. */
-    };
-
-public:
-    RS_ActionInfoArea(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionInfoArea() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    Vector point1;
-    Vector prev;
-       RS_Entity* currentLine;
-       RS_Entity* closingLine;
-    //Vector point2;
-       RS_InfoArea ia;
+class RS_ActionInfoArea: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetFirstPoint,    /**< Setting the 1st point of the polygon. */
+                       SetNextPoint      /**< Setting a next point. */
+               };
+
+       public:
+               RS_ActionInfoArea(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionInfoArea();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               Vector point1;
+               Vector prev;
+               RS_Entity * currentLine;
+               RS_Entity * closingLine;
+               RS_InfoArea ia;
 };
 
 #endif
index a3c2e8f8518148fa6e0556f41a3313b6c0eee76a..2c3a6ad07fde133705850742ff8f9889d1c8e078 100644 (file)
-/****************************************************************************
-** $Id: rs_actioninfodist.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioninfodist.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioninfodist.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionInfoDist::RS_ActionInfoDist(RS_EntityContainer& container,
-                                     RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Info Dist",
-                           container, graphicView) {}
-
-
-QAction* RS_ActionInfoDist::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionInfoDist::RS_ActionInfoDist(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Info Dist",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Distance Point to Point"), 0);
-//     QAction* action = new QAction(tr("Distance Point to Point"),
-//                                                     tr("&Distance Point to Point"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Measures the distance between two points"));
-       return action;
 }
 
-
-void RS_ActionInfoDist::init(int status) {
-    RS_ActionInterface::init(status);
-
+RS_ActionInfoDist::~RS_ActionInfoDist()
+{
 }
 
-
-
-void RS_ActionInfoDist::trigger() {
-
-    RS_DEBUG->print("RS_ActionInfoDist::trigger()");
-
-    if (point1.valid && point2.valid) {
-        double dist = point1.distanceTo(point2);
-        QString str;
-        str.sprintf("%.6f", dist);
-        RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
-    }
+void RS_ActionInfoDist::init(int status)
+{
+       RS_ActionInterface::init(status);
 }
 
+void RS_ActionInfoDist::trigger()
+{
+       RS_DEBUG->print("RS_ActionInfoDist::trigger()");
+
+       if (point1.valid && point2.valid)
+       {
+               double dist = point1.distanceTo(point2);
+               QString str;
+               str.sprintf("%.6f", dist);
+               RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
+       }
+}
 
+void RS_ActionInfoDist::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionInfoDist::mouseMoveEvent begin");
 
-void RS_ActionInfoDist::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionInfoDist::mouseMoveEvent begin");
+       if (getStatus() == SetPoint1
+           || getStatus() == SetPoint2)
+       {
+               Vector mouse = snapPoint(e);
 
-    if (getStatus()==SetPoint1 ||
-            getStatus()==SetPoint2) {
+               switch (getStatus())
+               {
+               case SetPoint1:
+                       break;
 
-        Vector mouse = snapPoint(e);
-        switch (getStatus()) {
-        case SetPoint1:
-            break;
+               case SetPoint2:
 
-        case SetPoint2:
-            if (point1.valid) {
-                point2 = mouse;
+                       if (point1.valid)
+                       {
+                               point2 = mouse;
 
-                deletePreview();
-                clearPreview();
+                               deletePreview();
+                               clearPreview();
 
-                preview->addEntity(new RS_Line(preview,
-                                               RS_LineData(point1,
-                                                           point2)));
+                               preview->addEntity(new RS_Line(preview,
+                                               RS_LineData(point1,
+                                                       point2)));
 
-                drawPreview();
-            }
-            break;
+                               drawPreview();
+                       }
+                       break;
 
-        default:
-            break;
-        }
-    }
+               default:
+                       break;
+               }
+       }
 
-    RS_DEBUG->print("RS_ActionInfoDist::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionInfoDist::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionInfoDist::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionInfoDist::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionInfoDist::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetPoint1:
-        point1 = mouse;
-       graphicView->moveRelativeZero(point1);
-        setStatus(SetPoint2);
-        break;
-
-    case SetPoint2:
-        if (point1.valid) {
-            point2 = mouse;
-            deletePreview();
-            clearPreview();
-               graphicView->moveRelativeZero(point2);
-            trigger();
-            setStatus(SetPoint1);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionInfoDist::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetPoint1:
+               point1 = mouse;
+               graphicView->moveRelativeZero(point1);
+               setStatus(SetPoint2);
+               break;
+
+       case SetPoint2:
+
+               if (point1.valid)
+               {
+                       point2 = mouse;
+                       deletePreview();
+                       clearPreview();
+                       graphicView->moveRelativeZero(point2);
+                       trigger();
+                       setStatus(SetPoint1);
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionInfoDist::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetPoint1:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify first point of distance"),
-            tr("Cancel"));
-        break;
-    case SetPoint2:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify second point of distance"),
-            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionInfoDist::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetPoint1:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify first point of distance"),
+                       tr("Cancel"));
+               break;
+
+       case SetPoint2:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify second point of distance"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionInfoDist::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionInfoDist::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionInfoDist::updateToolBar() {
-    switch (getStatus()) {
-    case SetPoint1:
-    case SetPoint2:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
-        break;
-    }
+void RS_ActionInfoDist::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetPoint1:
+       case SetPoint2:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
+               break;
+       }
 }
 
-
 // EOF
index 7c7f7f9f4c398fb2058ef03a17b8e91f453c7fea..91e02cbad07dc271ce6395cdb1fda26877328263 100644 (file)
@@ -1,74 +1,42 @@
-/****************************************************************************
-** $Id: rs_actioninfodist.h 1113 2004-04-01 20:53:39Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONINFODIST_H
 #define RS_ACTIONINFODIST_H
 
 #include "rs_previewactioninterface.h"
-
+#include "vector.h"
 
 /**
- * This action class can handle user events to measure distances between 
+ * This action class can handle user events to measure distances between
  * two points.
  *
  * @author Andrew Mustun
  */
-class RS_ActionInfoDist : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetPoint1,    /**< Setting the 1st point of the distance. */
-        SetPoint2     /**< Setting the 2nd point of the distance. */
-    };
-
-public:
-    RS_ActionInfoDist(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionInfoDist() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    Vector point1;
-    Vector point2;
+class RS_ActionInfoDist: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetPoint1,    /**< Setting the 1st point of the distance. */
+                       SetPoint2     /**< Setting the 2nd point of the distance. */
+               };
+
+       public:
+               RS_ActionInfoDist(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionInfoDist();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               Vector point1;
+               Vector point2;
 };
 
 #endif
index 95bbb3f343fdb46d3047ece8133703459308c2cf..f051c92b7823f1406fbd894e6187e80eef47a3b2 100644 (file)
-/****************************************************************************
-** $Id: rs_actioninfodist2.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioninfodist2.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioninfodist2.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionInfoDist2::RS_ActionInfoDist2(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionInfoDist2::RS_ActionInfoDist2(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Info Dist2", container, graphicView)
 {
 }
 
-QAction * RS_ActionInfoDist2::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionInfoDist2::~RS_ActionInfoDist2()
 {
-       QAction * action = new QAction(tr("&Distance Entity to Point"), 0);
-//     QAction* action = new QAction(tr("Distance Entity to Point"),
-//                                                                     tr("&Distance Entity to Point"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Measures the distance between an entity and a point"));
-       return action;
 }
 
 void RS_ActionInfoDist2::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 }
 
-
-
-void RS_ActionInfoDist2::trigger() {
-
-    RS_DEBUG->print("RS_ActionInfoDist2::trigger()");
-    deleteSnapper();
-
-    if (point.valid && entity!=NULL) {
-        double dist = entity->getDistanceToPoint(point);
-        QString str;
-        str.sprintf("%.6f", dist);
-        RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
-    }
+void RS_ActionInfoDist2::trigger()
+{
+       RS_DEBUG->print("RS_ActionInfoDist2::trigger()");
+       deleteSnapper();
+
+       if (point.valid && entity != NULL)
+       {
+               double dist = entity->getDistanceToPoint(point);
+               QString str;
+               str.sprintf("%.6f", dist);
+               RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
+       }
 }
 
+void RS_ActionInfoDist2::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionInfoDist2::mouseMoveEvent begin");
 
+       switch (getStatus())
+       {
+       case SetEntity:
+               //entity = catchEntity(e);
+               break;
 
-void RS_ActionInfoDist2::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionInfoDist2::mouseMoveEvent begin");
-
-    switch (getStatus()) {
-    case SetEntity:
-        //entity = catchEntity(e);
-        break;
+       case SetPoint:
 
-    case SetPoint:
-        if (entity!=NULL) {
-            point = snapPoint(e);
-        }
-        break;
+               if (entity != NULL)
+                       point = snapPoint(e);
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionInfoDist2::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionInfoDist2::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionInfoDist2::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-
-        switch (getStatus()) {
-        case SetEntity:
-            entity = catchEntity(e);
-            if (entity!=NULL) {
-                setStatus(SetPoint);
-            }
-            break;
-
-        case SetPoint: {
-                RS_CoordinateEvent ce(snapPoint(e));
-                coordinateEvent(&ce);
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionInfoDist2::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity:
+                       entity = catchEntity(e);
+
+                       if (entity != NULL)
+                               setStatus(SetPoint);
+                       break;
+
+               case SetPoint: {
+                       Vector ce(snapPoint(e));
+                       coordinateEvent(&ce);
+               }
+               break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-void RS_ActionInfoDist2::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    if (getStatus()==SetPoint && entity!=NULL) {
-        point = e->getCoordinate();
-        graphicView->moveRelativeZero(point);
-        trigger();
-        setStatus(SetEntity);
-    }
+void RS_ActionInfoDist2::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       if (getStatus() == SetPoint && entity != NULL)
+       {
+               point = *e;
+               graphicView->moveRelativeZero(point);
+               trigger();
+               setStatus(SetEntity);
+       }
 }
 
-
-
-void RS_ActionInfoDist2::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify entity"),
-            tr("Cancel"));
-        break;
-    case SetPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Specify point"),
-            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionInfoDist2::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify entity"),
+                       tr("Cancel"));
+               break;
+
+       case SetPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Specify point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionInfoDist2::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionInfoDist2::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionInfoDist2::updateToolBar() {
-    switch (getStatus()) {
-    case SetPoint:
-    case SetEntity:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
-        break;
-    }
+void RS_ActionInfoDist2::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetPoint:
+       case SetEntity:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
+               break;
+       }
 }
 
-
 // EOF
index edfc53d26be9c2303a01c4210ce7e19e0fee0bf7..a5de1ab8aff2b4e28eb4b978aea0239aa7e04d19 100644 (file)
@@ -1,34 +1,10 @@
-/****************************************************************************
-** $Id: rs_actioninfodist2.h 1113 2004-04-01 20:53:39Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONINFODIST2_H
 #define RS_ACTIONINFODIST2_H
 
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to measure distances between
  *
  * @author Andrew Mustun
  */
-class RS_ActionInfoDist2 : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetEntity,    /**< Setting the entity. */
-        SetPoint      /**< Setting the point of the distance. */
-    };
-
-public:
-    RS_ActionInfoDist2(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionInfoDist2() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-       RS_Entity* entity;
-    Vector point;
+class RS_ActionInfoDist2: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetEntity,    /**< Setting the entity. */
+                       SetPoint      /**< Setting the point of the distance. */
+               };
+
+       public:
+               RS_ActionInfoDist2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionInfoDist2();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_Entity * entity;
+               Vector point;
 };
 
 #endif
index 2af49c9d618e3e6fb3571c1d506a9fb7e1d58f91..9417b4dc8f1549c4d6334f277b210437190d35f4 100644 (file)
-/****************************************************************************
-** $Id: rs_actioninfoinside.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioninfoinside.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioninfoinside.h"
+
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 #include "rs_information.h"
-#include "rs_snapper.h"
 
-RS_ActionInfoInside::RS_ActionInfoInside(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionInfoInside::RS_ActionInfoInside(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Info Inside", container, graphicView)
 {
        contour = new RS_EntityContainer(NULL, false);
 
-       for(RS_Entity* e=container.firstEntity(); e!=NULL; e=container.nextEntity())
-       {
+       for (RS_Entity * e = container.firstEntity(); e != NULL; e = container.nextEntity())
                if (e->isSelected())
-               {
                        contour->addEntity(e);
-               }
-       }
 }
 
 RS_ActionInfoInside::~RS_ActionInfoInside()
 {
-    delete contour;
-}
-
-QAction* RS_ActionInfoInside::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
-{
-       QAction * action = new QAction(tr("&Point inside contour"), 0);
-//     QAction* action = new QAction(tr("Point inside contour"),
-//                                                                     tr("&Point inside contour"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Checks if a given point is inside the selected contour"));
-
-       return action;
+       delete contour;
 }
 
 void RS_ActionInfoInside::trigger()
 {
-    deleteSnapper();
-    bool onContour = false;
-    if (RS_Information::isPointInsideContour(pt, contour, &onContour)) {
-        RS_DIALOGFACTORY->commandMessage(tr("Point is inside selected contour."));
-    } else {
-        RS_DIALOGFACTORY->commandMessage(tr("Point is outside selected contour."));
-    }
-    finish();
-}
-
+       deleteSnapper();
+       bool onContour = false;
 
+       if (RS_Information::isPointInsideContour(pt, contour, &onContour))
+               RS_DIALOGFACTORY->commandMessage(tr("Point is inside selected contour."));
+       else
+               RS_DIALOGFACTORY->commandMessage(tr("Point is outside selected contour."));
 
-void RS_ActionInfoInside::mouseMoveEvent(QMouseEvent* e) {
-    //Vector mouse = snapPoint(e);
-    //bool onContour = false;
-    /*if (RS_Information::isPointInsideContour(mouse, contour, &onContour)) {
-    } else {
-    }*/
+       finish();
 }
 
-
-
-void RS_ActionInfoInside::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    } else {
-        pt = snapPoint(e);
-        trigger();
-    }
+void RS_ActionInfoInside::mouseMoveEvent(QMouseEvent * /*e*/)
+{
+       //Vector mouse = snapPoint(e);
+       //bool onContour = false;
+       /*if (RS_Information::isPointInsideContour(mouse, contour, &onContour)) {
+          } else {
+          }*/
 }
 
-
-
-void RS_ActionInfoInside::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case 0:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"),
-                                            tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionInfoInside::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
+       else
+       {
+               pt = snapPoint(e);
+               trigger();
+       }
 }
 
+void RS_ActionInfoInside::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case 0:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
+               break;
 
-
-void RS_ActionInfoInside::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
+void RS_ActionInfoInside::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
-
-void RS_ActionInfoInside::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
-    }
+void RS_ActionInfoInside::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
 }
 
-// EOF
index 1494e440d8541d897a8d0b9514e8271dea52dbc0..a1f1a0821c23b93ba8a02a9713afa9590355e7fd 100644 (file)
@@ -1,60 +1,30 @@
-/****************************************************************************
-** $Id: rs_actioninfoinside.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONINFOINSIDE_H
 #define RS_ACTIONINFOINSIDE_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events for checking if
  * a given point is inside or outside the selected contour.
  *
  * @author Andrew Mustun
  */
-class RS_ActionInfoInside : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionInfoInside(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionInfoInside();
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionInfoInside: public RS_ActionInterface
+{
+       public:
+               RS_ActionInfoInside(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionInfoInside();
 
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
 
-private:
-    Vector pt;
-       RS_EntityContainer* contour;
+       private:
+               Vector pt;
+               RS_EntityContainer * contour;
 };
 
 #endif
index b1acd760b76a3f2213e946dfe50c6d83dc05faa9..5b96dac41fe11452bfbda618335c1b3ae4d26ac8 100644 (file)
-/****************************************************************************
-** $Id: rs_actioninfototallength.cpp 1072 2004-02-18 16:03:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actioninfototallength.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actioninfototallength.h"
 
-#include "rs_actionselectsingle.h"
-#include "rs_modification.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
+#include "rs_dialogfactory.h"
 
-
-
-RS_ActionInfoTotalLength::RS_ActionInfoTotalLength(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Info Total Length",
-                    container, graphicView) {}
-
-
-QAction* RS_ActionInfoTotalLength::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionInfoTotalLength::RS_ActionInfoTotalLength(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Info Total Length",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Total length of selected entities"), 0);
-//     QAction* action = new QAction(tr("Total length of selected entities"),
-//                                                                     tr("&Total length of selected entities"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Measures the total length of all selected entities"));
-
-       return action;
 }
 
-void RS_ActionInfoTotalLength::init(int status) {
-    RS_ActionInterface::init(status);
-
-    trigger();
+RS_ActionInfoTotalLength::~RS_ActionInfoTotalLength()
+{
 }
 
-
-
-void RS_ActionInfoTotalLength::trigger() {
-
-    RS_DEBUG->print("RS_ActionInfoTotalLength::trigger()");
-
-    double len = 0.0;
-    for (RS_Entity* e = container->firstEntity(RS2::ResolveNone);
-            e != NULL;
-            e = container->nextEntity(RS2::ResolveNone)) {
-
-        if (e->isVisible() && e->isSelected()) {
-            double l = e->getLength();
-            if (l<0.0) {
-                len = -1.0;
-                break;
-            } else {
-                len += l;
-            }
-        }
-    }
-
-    if (len>0.0) {
-        RS_DIALOGFACTORY->commandMessage(
-            tr("Total Length of selected entities: %1").arg(len));
-    } else {
-        RS_DIALOGFACTORY->commandMessage(tr("At least one of the selected "
-                                            "entities cannot be measured."));
-    }
-
-    finish();
+void RS_ActionInfoTotalLength::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-
-
-void RS_ActionInfoTotalLength::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-        }
-    }
+void RS_ActionInfoTotalLength::trigger()
+{
+       RS_DEBUG->print("RS_ActionInfoTotalLength::trigger()");
+
+       double len = 0.0;
+
+       for (RS_Entity * e = container->firstEntity(RS2::ResolveNone);
+            e != NULL;
+            e = container->nextEntity(RS2::ResolveNone))
+
+               if (e->isVisible() && e->isSelected())
+               {
+                       double l = e->getLength();
+
+                       if (l < 0.0)
+                       {
+                               len = -1.0;
+                               break;
+                       }
+                       else
+                               len += l;
+               }
+
+       if (len > 0.0)
+               RS_DIALOGFACTORY->commandMessage(
+                       tr("Total Length of selected entities: %1").arg(len));
+       else
+               RS_DIALOGFACTORY->commandMessage(tr("At least one of the selected "
+                               "entities cannot be measured."));
+
+       finish();
 }
 
+void RS_ActionInfoTotalLength::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+       }
+}
 
 // EOF
index 723b89462005ab22a0c562cd91d091e782dcebe7..cd75db9b68323c812750cd1eff781342defc8155 100644 (file)
@@ -1,60 +1,30 @@
-/****************************************************************************
-** $Id: rs_actioninfototallength.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONINFOTOTALLENGTH_H
 #define RS_ACTIONINFOTOTALLENGTH_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to delete entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionInfoTotalLength : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        Acknowledge    /**< Acknowledge or cancel. */
-    };
+class RS_ActionInfoTotalLength: public RS_ActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       Acknowledge    /**< Acknowledge or cancel. */
+               };
 
-public:
-    RS_ActionInfoTotalLength(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionInfoTotalLength() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+       public:
+               RS_ActionInfoTotalLength(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionInfoTotalLength();
 
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void updateToolBar();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void updateToolBar();
 };
 
 #endif
index f200b943e2fa19afbc225c60b57f70a6deb6754c..594e824a5ebd9a665ac2fb38210c0f2c2726e9a3 100644 (file)
@@ -1,69 +1,49 @@
-/****************************************************************************
-** $Id: rs_actionlayersadd.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlayersadd.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlayersadd.h"
 
+#include "rs_dialogfactory.h"
 #include "drawing.h"
 
-
-
-RS_ActionLayersAdd::RS_ActionLayersAdd(RS_EntityContainer& container,
-                                       RS_GraphicView& graphicView)
-        :RS_ActionInterface("Add Layer", container, graphicView) {}
-
-
-QAction* RS_ActionLayersAdd::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionLayersAdd::RS_ActionLayersAdd(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Add Layer", container, graphicView)
 {
-       QAction * action = new QAction(tr("&Add Layer"), 0);
-//     QAction* action = new QAction(tr("Add Layer"), tr("&Add Layer"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Add Layer"));
+}
 
-       return action;
+RS_ActionLayersAdd::~RS_ActionLayersAdd()
+{
 }
 
-void RS_ActionLayersAdd::trigger() {
-    RS_DEBUG->print("add layer");
+void RS_ActionLayersAdd::trigger()
+{
+       RS_DEBUG->print("add layer");
 
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (graphic) {
-            RS_Layer* layer = RS_DIALOGFACTORY->requestNewLayerDialog(
-                                  graphic->getLayerList());
-            if (layer!=NULL)
-                graphic->addLayer(layer);
-        }
-    }
-    finish();
-}
+       if (RS_DIALOGFACTORY != NULL && graphic)
+       {
+               RS_Layer * layer = RS_DIALOGFACTORY->requestNewLayerDialog(graphic->getLayerList());
 
+               if (layer != NULL)
+                       graphic->addLayer(layer);
+       }
 
+       finish();
+}
 
-void RS_ActionLayersAdd::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionLayersAdd::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index 221a7e8c405ab9d3c1f0cb45c3cbf8447daa42c1..d650279a26cb73185aee46c48bd967a54c1af9dd 100644 (file)
@@ -1,53 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionlayersadd.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLAYERSADD_H
 #define RS_ACTIONLAYERSADD_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to add layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionLayersAdd : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionLayersAdd(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionLayersAdd() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
+class RS_ActionLayersAdd: public RS_ActionInterface
+{
+       public:
+               RS_ActionLayersAdd(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionLayersAdd();
 
-private:
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 879da0196ad1f441ab32fe2939b1fda3a6229d8d..cd55b241b11ce282979bd6b4d3a74bcbba52ec49 100644 (file)
@@ -1,83 +1,65 @@
-/****************************************************************************
-** $Id: rs_actionlayersedit.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlayersedit.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlayersedit.h"
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 #include "drawing.h"
 
-
-
-RS_ActionLayersEdit::RS_ActionLayersEdit(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Edit Layer", container, graphicView) {}
-
-
-QAction* RS_ActionLayersEdit::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionLayersEdit::RS_ActionLayersEdit(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Edit Layer", container, graphicView)
 {
-       QAction * action = new QAction(tr("&Edit Layer"), 0);
-//     QAction* action = new QAction(tr("Edit Layer"), tr("&Edit Layer"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Edit Layer"));
-       return action;
 }
 
-void RS_ActionLayersEdit::trigger() {
-    RS_DEBUG->print("RS_ActionLayersEdit::trigger");
-
-    RS_Layer* layer = NULL;
-
-    if (graphic!=NULL) {
-        layer =
-            RS_DIALOGFACTORY->requestEditLayerDialog(graphic->getLayerList());
-
-        if (layer!=NULL) {
-            graphic->editLayer(graphic->getActiveLayer(), *layer);
-
-            // update updateable entities on the layer that has changed
-            for (RS_Entity* e=graphic->firstEntity(RS2::ResolveNone);
-                    e!=NULL;
-                    e=graphic->nextEntity(RS2::ResolveNone)) {
-
-                RS_Layer* l = e->getLayer();
-                if (l!=NULL && l->getName()==layer->getName()) {
-                    e->update();
-                }
-            }
-        }
-    }
-    finish();
-
-    graphicView->redraw();
+RS_ActionLayersEdit::~RS_ActionLayersEdit()
+{
 }
 
+void RS_ActionLayersEdit::trigger()
+{
+       RS_DEBUG->print("RS_ActionLayersEdit::trigger");
+       RS_Layer * layer = NULL;
+
+       if (graphic != NULL)
+       {
+               layer = RS_DIALOGFACTORY->requestEditLayerDialog(graphic->getLayerList());
+
+               if (layer != NULL)
+               {
+                       graphic->editLayer(graphic->getActiveLayer(), *layer);
+
+                       // update updateable entities on the layer that has changed
+                       for (RS_Entity * e = graphic->firstEntity(RS2::ResolveNone);
+                            e != NULL; e = graphic->nextEntity(RS2::ResolveNone))
+                       {
+                               RS_Layer * l = e->getLayer();
+
+                               if (l != NULL && l->getName() == layer->getName())
+                                       e->update();
+                       }
+               }
+       }
+
+       finish();
+       graphicView->redraw();
+}
 
-
-void RS_ActionLayersEdit::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionLayersEdit::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
 // EOF
index 98d39889752298e27a74c66c3a024ea31888cb30..415afdcd0761d41475d822dfcb3fa8913320f7ef 100644 (file)
@@ -1,52 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionlayersedit.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLAYERSEDIT_H
 #define RS_ACTIONLAYERSEDIT_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to edit layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionLayersEdit : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionLayersEdit(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionLayersEdit() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
+class RS_ActionLayersEdit: public RS_ActionInterface
+{
+       public:
+               RS_ActionLayersEdit(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionLayersEdit();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 7e7dc9088dcea233fd62ea6340bd851c753a4480..d94ffc89f8c022510a4912b9d04527caccea0ff5 100644 (file)
 
 #include "drawing.h"
 
-RS_ActionLayersFreezeAll::RS_ActionLayersFreezeAll(bool freeze,
-        RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Freeze all Layers",
-                    container, graphicView) {
-
-    this->freeze = freeze;
+RS_ActionLayersFreezeAll::RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Freeze all Layers", container, graphicView)
+{
+       this->freeze = freeze;
 }
 
-QAction * RS_ActionLayersFreezeAll::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionLayersFreezeAll::~RS_ActionLayersFreezeAll()
 {
-       QAction * action = NULL;
-
-       if (type == RS2::ActionLayersFreezeAll)
-       {
-               action = new QAction(tr("&Freeze all"), 0);
-//             action = new QAction(tr("Freeze all"), tr("&Freeze all"),
-//                                                                     QKeySequence(), NULL);
-               action->setStatusTip(tr("Freeze all layers"));
-       }
-       else if (type == RS2::ActionLayersDefreezeAll)
-       {
-               action = new QAction(tr("&Defreeze all"), 0);
-//             action = new QAction(tr("Defreeze all"), tr("&Defreeze all"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Defreeze all layers"));
-       }
-
-       return action;
 }
 
-
 void RS_ActionLayersFreezeAll::trigger()
 {
-    RS_DEBUG->print("RS_ActionLayersFreezeAll::trigger");
-    if (graphic!=NULL)
-       {
-        //RS_Layer* layer = graphic->getActiveLayer();
-        graphic->freezeAllLayers(freeze);
-    }
-    finish();
-}
+       RS_DEBUG->print("RS_ActionLayersFreezeAll::trigger");
 
+       if (graphic != NULL)
+               //RS_Layer* layer = graphic->getActiveLayer();
+               graphic->freezeAllLayers(freeze);
 
+       finish();
+}
 
-void RS_ActionLayersFreezeAll::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionLayersFreezeAll::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index de0840537ac3b051122b3a43f1e8dcf3de1a3ff6..ac6c29d02c3bc95ac742831d4d2ed957ab1c2dbc 100644 (file)
  */
 class RS_ActionLayersFreezeAll: public RS_ActionInterface
 {
-       //Q_OBJECT
        public:
-               RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container,
-                       RS_GraphicView & graphicView);
-               ~RS_ActionLayersFreezeAll() {}
-
-               static QAction * createGUIAction(RS2::ActionType type, QObject* /*parent*/);
+               RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionLayersFreezeAll();
 
                virtual void init(int status = 0);
                virtual void trigger();
index 937dda1dad71c24cd78ec1122121301e56184a7c..82aaa473eaecec69ce9536d9a7d943c8816e5fcf 100644 (file)
@@ -1,90 +1,72 @@
-/****************************************************************************
-** $Id: rs_actionlayersremove.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlayersedit.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlayersremove.h"
 
+#include "rs_dialogfactory.h"
 #include "drawing.h"
 
-
-
-RS_ActionLayersRemove::RS_ActionLayersRemove(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Remove Layer", container, graphicView) {}
-
-
-QAction * RS_ActionLayersRemove::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionLayersRemove::RS_ActionLayersRemove(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Remove Layer", container, graphicView)
 {
-       QAction * action = new QAction(tr("&Remove Layer"), 0);
-//     QAction * action = new QAction(tr("Remove Layer"), tr("&Remove Layer"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Remove Layer"));
-       return action;
 }
 
+RS_ActionLayersRemove::~RS_ActionLayersRemove()
+{
+}
 
-void RS_ActionLayersRemove::trigger() {
-    RS_DEBUG->print("RS_ActionLayersRemove::trigger");
+void RS_ActionLayersRemove::trigger()
+{
+       RS_DEBUG->print("RS_ActionLayersRemove::trigger");
 
-    if (graphic!=NULL) {
-        RS_Layer* layer =
-            RS_DIALOGFACTORY->requestLayerRemovalDialog(graphic->getLayerList());
+       if (graphic != NULL)
+       {
+               RS_Layer * layer =
+                       RS_DIALOGFACTORY->requestLayerRemovalDialog(graphic->getLayerList());
 
-        /*
-              if (layer!=NULL && layer->getName()!="0") {
+               /*
+                     if (layer!=NULL && layer->getName()!="0") {
 
-                  graphic->startUndoCycle();
-                  for (RS_Entity* e=graphic->firstEntity(RS2::ResolveNone);
-                          e!=NULL;
-                          e=graphic->nextEntity(RS2::ResolveNone)) {
+                         graphic->startUndoCycle();
+                         for (RS_Entity* e=graphic->firstEntity(RS2::ResolveNone);
+                                 e!=NULL;
+                                 e=graphic->nextEntity(RS2::ResolveNone)) {
 
-                      if (e->getLayer()!=NULL &&
-                              e->getLayer()->getName()==layer->getName()) {
+                             if (e->getLayer()!=NULL &&
+                                     e->getLayer()->getName()==layer->getName()) {
 
-                          e->setUndoState(true);
-                          e->setLayer("0");
-                          graphic->addUndoable(e);
-                      }
-                  }
+                                 e->setUndoState(true);
+                                 e->setLayer("0");
+                                 graphic->addUndoable(e);
+                             }
+                         }
 
 
-                  graphic->endUndoCycle();
-        */
+                         graphic->endUndoCycle();
+                */
 
-        // Now remove the layer from the layer list:
-        graphic->removeLayer(layer);
-    }
-    finish();
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+               // Now remove the layer from the layer list:
+               graphic->removeLayer(layer);
+       }
+       finish();
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-
-void RS_ActionLayersRemove::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionLayersRemove::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
 // EOF
index 76c8c2a42777961b062a302158971ceb0e723976..a73770339bc66aeb820fb96e81c114e3e4d5eb66 100644 (file)
@@ -1,51 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionlayersremove.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLAYERSREMOVE_H
 #define RS_ACTIONLAYERSREMOVE_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to remove layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionLayersRemove : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionLayersRemove(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionLayersRemove() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionLayersRemove: public RS_ActionInterface
+{
+       public:
+               RS_ActionLayersRemove(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionLayersRemove();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index fe09a12ce26d2f6e028563030014fbf1fd0567cf..b8ac38965d77a0efbf4c4d792b31081647011969 100644 (file)
@@ -1,89 +1,66 @@
-/****************************************************************************
-** $Id: rs_actionlayerstogglelock.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlayerstogglelock.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlayerstogglelock.h"
 
+#include "rs_graphicview.h"
 #include "drawing.h"
 
+RS_ActionLayersToggleLock::RS_ActionLayersToggleLock(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Toggle Layer Visibility",
+               container, graphicView)
+{
+}
 
-
-RS_ActionLayersToggleLock::RS_ActionLayersToggleLock(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Toggle Layer Visibility",
-                    container, graphicView) {}
-
-
-QAction* RS_ActionLayersToggleLock::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionLayersToggleLock::~RS_ActionLayersToggleLock()
 {
-       QAction * action = new QAction(tr("&Toggle Lock"), 0);
-//     QAction* action = new QAction(tr("Toggle Layer Lock"),
-//                                                                     tr("&Toggle Lock"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Toggle Lock"));
-       return action;
 }
 
 void RS_ActionLayersToggleLock::trigger()
 {
-    RS_DEBUG->print("toggle layer");
-    if (graphic!=NULL) {
-        RS_Layer* layer = graphic->getActiveLayer();
-        if (layer!=NULL) {
-            graphic->toggleLayerLock(layer);
-
-            // deselect entities on locked layer:
-            if (layer->isLocked()) {
-                for (RS_Entity* e=container->firstEntity(); e!=NULL;
-                        e=container->nextEntity()) {
-                    if (e!=NULL && e->isVisible() && e->getLayer()==layer) {
-
-                        if (graphicView!=NULL) {
-                            graphicView->deleteEntity(e);
-                        }
-
-                        e->setSelected(false);
-
-                        if (graphicView!=NULL) {
-                            graphicView->drawEntity(e);
-                        }
-                    }
-                }
-            }
-        }
-
-    }
-    finish();
+       RS_DEBUG->print("toggle layer");
+
+       if (graphic != NULL)
+       {
+               RS_Layer * layer = graphic->getActiveLayer();
+
+               if (layer != NULL)
+               {
+                       graphic->toggleLayerLock(layer);
+
+                       // deselect entities on locked layer:
+                       if (layer->isLocked())
+                               for (RS_Entity * e = container->firstEntity(); e != NULL;
+                                    e = container->nextEntity())
+                                       if (e != NULL && e->isVisible() && e->getLayer() == layer)
+                                       {
+                                               if (graphicView != NULL)
+                                                       graphicView->deleteEntity(e);
+
+                                               e->setSelected(false);
+
+                                               if (graphicView != NULL)
+                                                       graphicView->drawEntity(e);
+                                       }
+               }
+       }
+
+       finish();
 }
 
-
-
-void RS_ActionLayersToggleLock::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionLayersToggleLock::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index a41f1990f85316efac84c3d46c8426a3965a8d2f..b27c9e28b092fd523b8b3818ec017530a5bc895d 100644 (file)
@@ -1,52 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionlayerstogglelock.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLAYERSTOGGLELOCK_H
 #define RS_ACTIONLAYERSTOGGLELOCK_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to edit layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionLayersToggleLock : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionLayersToggleLock(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionLayersToggleLock() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
+class RS_ActionLayersToggleLock: public RS_ActionInterface
+{
+       public:
+               RS_ActionLayersToggleLock(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionLayersToggleLock();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 14e8990782d8640873444b7e986d0c9efa112fd4..e61ce40e0a91acb334aef2022e5fa1768fbd8616 100644 (file)
@@ -1,66 +1,46 @@
-/****************************************************************************
-** $Id: rs_actionlayerstoggleview.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlayerstoggleview.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlayerstoggleview.h"
 
 #include "drawing.h"
 
-
-
-RS_ActionLayersToggleView::RS_ActionLayersToggleView(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Toggle Layer Visibility",
-                    container, graphicView) {}
-
-
-QAction* RS_ActionLayersToggleView::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionLayersToggleView::RS_ActionLayersToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Toggle Layer Visibility",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Toggle Layer"), 0);
-//     QAction* action = new QAction(tr("Toggle Layer Visibility"),
-//                                                                     tr("&Toggle Layer"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Toggle Layer"));
-       return action;
 }
 
-void RS_ActionLayersToggleView::trigger() {
-    RS_DEBUG->print("toggle layer");
-    if (graphic!=NULL) {
-        RS_Layer* layer = graphic->getActiveLayer();
-        graphic->toggleLayer(layer);
-    }
-    finish();
+RS_ActionLayersToggleView::~RS_ActionLayersToggleView()
+{
 }
 
+void RS_ActionLayersToggleView::trigger()
+{
+       RS_DEBUG->print("toggle layer");
+
+       if (graphic != NULL)
+       {
+               RS_Layer * layer = graphic->getActiveLayer();
+               graphic->toggleLayer(layer);
+       }
 
+       finish();
+}
 
-void RS_ActionLayersToggleView::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
+void RS_ActionLayersToggleView::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-// EOF
index 56ded2cac68609eb8ac1f576de9e4d66537307ae..202a769487217323028cb4ff69a98dcbc9217b16 100644 (file)
@@ -1,52 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionlayerstoggleview.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLAYERSTOGGLEVIEW_H
 #define RS_ACTIONLAYERSTOGGLEVIEW_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to edit layers.
  *
  * @author Andrew Mustun
  */
-class RS_ActionLayersToggleView : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionLayersToggleView(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionLayersToggleView() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
+class RS_ActionLayersToggleView: public RS_ActionInterface
+{
+       public:
+               RS_ActionLayersToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionLayersToggleView();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index e6881cd2edc153bb6518c72ea8d879feb75aebd5..4fdab2ff80b04d5a1efdcb2a0574b17af57a7dd6 100644 (file)
@@ -1,41 +1,28 @@
-/****************************************************************************
-** $Id: rs_actionlibraryinsert.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlibraryinsert.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlibraryinsert.h"
 
-#include "commands.h"
-#include "rs_creation.h"
-#include "rs_modification.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 #include "rs_units.h"
 
 /**
  * Constructor.
  */
-RS_ActionLibraryInsert::RS_ActionLibraryInsert(RS_EntityContainer & container,
-       RS_GraphicView & graphicView):
+RS_ActionLibraryInsert::RS_ActionLibraryInsert(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Library Insert", container, graphicView)
 {
 }
@@ -44,14 +31,9 @@ RS_ActionLibraryInsert::~RS_ActionLibraryInsert()
 {
 }
 
-QAction * RS_ActionLibraryInsert::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionLibraryInsert::rtti()
 {
-       QAction * action = new QAction(tr("&Insert Library Object"), 0);
-//     QAction* action = new QAction(tr("Insert Library Object"),
-//                                                                     tr("&Insert Library Object"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Inserts an Object from the part library."));
-       return action;
+       return RS2::ActionLibraryInsert;
 }
 
 void RS_ActionLibraryInsert::init(int status)
@@ -60,13 +42,13 @@ void RS_ActionLibraryInsert::init(int status)
 
        reset();
 
-    /*if (graphic!=NULL) {
-        block = graphic->getActiveBlock();
-        if (block!=NULL) {
-            data.name = block->getName();
-        }
-}*/
-    //trigger();
+       /*if (graphic!=NULL) {
+           block = graphic->getActiveBlock();
+           if (block!=NULL) {
+               data.name = block->getName();
+           }
+          }*/
+       //trigger();
 }
 
 void RS_ActionLibraryInsert::setFile(const QString & file)
@@ -79,14 +61,14 @@ void RS_ActionLibraryInsert::setFile(const QString & file)
 
 void RS_ActionLibraryInsert::reset()
 {
-    /*data = RS_InsertData("",
-                         Vector(0.0,0.0),
-                         Vector(1.0,1.0),
-                         0.0,
-                         1, 1,
-                         Vector(1.0,1.0),
-                         NULL,
-                         RS2::Update);*/
+       /*data = RS_InsertData("",
+                            Vector(0.0,0.0),
+                            Vector(1.0,1.0),
+                            0.0,
+                            1, 1,
+                            Vector(1.0,1.0),
+                            NULL,
+                            RS2::Update);*/
 
        data.insertionPoint = Vector(false);
        data.factor = 1.0;
@@ -118,7 +100,8 @@ void RS_ActionLibraryInsert::mouseMoveEvent(QMouseEvent * e)
                preview->addAllFrom(prev);
                preview->move(data.insertionPoint);
                preview->scale(data.insertionPoint,
-                                               Vector(data.factor, data.factor));
+                       Vector(data.factor, data.factor));
+
                // unit conversion:
                if (graphic != NULL)
                {
@@ -143,7 +126,7 @@ void RS_ActionLibraryInsert::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -153,12 +136,12 @@ void RS_ActionLibraryInsert::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionLibraryInsert::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionLibraryInsert::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       data.insertionPoint = e->getCoordinate();
+       data.insertionPoint = *e;
        trigger();
 }
 
@@ -175,6 +158,7 @@ void RS_ActionLibraryInsert::commandEvent(RS_CommandEvent * e)
        switch (getStatus())
        {
        case SetTargetPoint:
+
                if (checkCommand("angle", c))
                {
                        deleteSnapper();
@@ -199,18 +183,14 @@ void RS_ActionLibraryInsert::commandEvent(RS_CommandEvent * e)
                double a = RS_Math::eval(c, &ok);
 
                if (ok == true)
-               {
                        data.angle = RS_Math::deg2rad(a);
-               }
                else
-               {
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-               }
 
                RS_DIALOGFACTORY->requestOptions(this, true, true);
                setStatus(lastStatus);
        }
-               break;
+       break;
 
        case SetFactor:
        {
@@ -218,18 +198,14 @@ void RS_ActionLibraryInsert::commandEvent(RS_CommandEvent * e)
                double f = RS_Math::eval(c, &ok);
 
                if (ok == true)
-               {
                        setFactor(f);
-               }
                else
-               {
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-               }
 
                RS_DIALOGFACTORY->requestOptions(this, true, true);
                setStatus(lastStatus);
        }
-               break;
+       break;
 
        default:
                break;
@@ -245,8 +221,8 @@ QStringList RS_ActionLibraryInsert::getAvailableCommands()
        case SetTargetPoint:
                cmd += command("angle");
                cmd += command("factor");
-               ;
                break;
+
        default:
                break;
        }
@@ -275,12 +251,15 @@ void RS_ActionLibraryInsert::updateMouseButtonHints()
        case SetTargetPoint:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
                break;
+
        case SetAngle:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Enter angle:"), "");
                break;
+
        case SetFactor:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Enter factor:"), "");
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
@@ -300,3 +279,23 @@ void RS_ActionLibraryInsert::updateToolBar()
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
 }
 
+double RS_ActionLibraryInsert::getAngle()
+{
+       return data.angle;
+}
+
+void RS_ActionLibraryInsert::setAngle(double a)
+{
+       data.angle = a;
+}
+
+double RS_ActionLibraryInsert::getFactor()
+{
+       return data.factor;
+}
+
+void RS_ActionLibraryInsert::setFactor(double f)
+{
+       data.factor = f;
+}
+
index fa8ec4e3fe32d6b5dab9c7edfd4efe7ace335f1d..c64f8db3dabd833ec89fb06e48fa1b8e61730866 100644 (file)
-/****************************************************************************
-** $Id: rs_actionlibraryinsert.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLIBRARYINSERT_H
 #define RS_ACTIONLIBRARYINSERT_H
 
-#include "rs_previewactioninterface.h"
-
 #include "rs_creation.h"
-#include "rs_insert.h"
+#include "drawing.h"
+#include "rs_previewactioninterface.h"
 
 /**
- * This action class can handle user events for inserting library items 
+ * This action class can handle user events for inserting library items
  * (or any other DXF files) into the current drawing (as block/insert).
  *
  * @author Andrew Mustun
  */
-class RS_ActionLibraryInsert : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetTargetPoint,    /**< Setting the reference point. */
-               SetAngle,          /**< Setting angle in the command line. */
-               SetFactor          /**< Setting factor in the command line. */
-               //SetColumns,        /**< Setting columns in the command line. */
-               //SetRows,           /**< Setting rows in the command line. */
-               //SetColumnSpacing,  /**< Setting column spacing in the command line. */
-               //SetRowSpacing      /**< Setting row spacing in the command line. */
-    };
-
-public:
-    RS_ActionLibraryInsert(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    virtual ~RS_ActionLibraryInsert();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionLibraryInsert;
-       }
-
-    virtual void init(int status=0);
-
-       void reset();
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-       virtual void showOptions();
-       virtual void hideOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       void setFile(const QString& file);
-
-       double getAngle() {
-               return data.angle;
-       }
-
-       void setAngle(double a) {
-               data.angle = a;
-       }
-
-       double getFactor() {
-               return data.factor;
-       }
-
-       void setFactor(double f) {
-               data.factor = f;
-       }
-
-       /*int getColumns() {
-               return data.cols;
-       }
-
-       void setColumns(int c) {
-               data.cols = c;
-       }
-       
-       int getRows() {
-               return data.rows;
-       }
-
-       void setRows(int r) {
-               data.rows = r;
-       }
-
-       double getColumnSpacing() {
-               return data.spacing.x;
-       }
-
-       void setColumnSpacing(double cs) {
-               data.spacing.x = cs;
-       }
-       
-       double getRowSpacing() {
-               return data.spacing.y;
-       }
-
-       void setRowSpacing(double rs) {
-               data.spacing.y = rs;
-       }*/
-
-protected:
-       //RS_Block* block;
-       //RS_InsertData data;
-       Drawing prev;
-       RS_LibraryInsertData data;
-       
-       /** Last status before entering option. */
-       Status lastStatus;
+class RS_ActionLibraryInsert: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetTargetPoint,    /**< Setting the reference point. */
+                       SetAngle,          /**< Setting angle in the command line. */
+                       SetFactor          /**< Setting factor in the command line. */
+                       //SetColumns,        /**< Setting columns in the command line. */
+                       //SetRows,           /**< Setting rows in the command line. */
+                       //SetColumnSpacing,  /**< Setting column spacing in the command line. */
+                       //SetRowSpacing      /**< Setting row spacing in the command line. */
+               };
+
+       public:
+               RS_ActionLibraryInsert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               virtual ~RS_ActionLibraryInsert();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               void reset();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void showOptions();
+               virtual void hideOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setFile(const QString & file);
+               double getAngle();
+               void setAngle(double a);
+               double getFactor();
+               void setFactor(double f);
+
+       protected:
+               Drawing prev;
+               RS_LibraryInsertData data;
+
+               /** Last status before entering option. */
+               Status lastStatus;
 };
 
 #endif
index 51bbaef139a49ce6cd400faea82be84fb14568e6..6f7f641823db3c3301423c3179f4a0cc3ddbb0ef 100644 (file)
@@ -1,66 +1,41 @@
-/****************************************************************************
-** $Id: rs_actionlockrelativezero.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionlockrelativezero.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionlockrelativezero.h"
 
-#include "rs_snapper.h"
-#include "rs_point.h"
-
-
+#include "rs_graphicview.h"
 
 RS_ActionLockRelativeZero::RS_ActionLockRelativeZero(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView,
-    bool on)
-        :RS_ActionInterface("(Un-)lock the relative Zero",
-                    container, graphicView) {
-
-    this->on = on;
+       RS_EntityContainer & container, RS_GraphicView & graphicView, bool on):
+       RS_ActionInterface("(Un-)lock the relative Zero", container, graphicView)
+{
+       this->on = on;
 }
 
-
-QAction* RS_ActionLockRelativeZero::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionLockRelativeZero::~RS_ActionLockRelativeZero()
 {
-       QAction * action = new QAction(tr("(Un-)&Lock Relative Zero"), 0);
-       action->setCheckable(true);
-//     QAction* action = new QAction(tr("(Un-)Lock Relative Zero"),
-//                                                                     tr("(Un-)&Lock Relative Zero"),
-//                                                                     QKeySequence(), NULL, 0, true);
-       action->setStatusTip(tr("(Un-)Lock relative Zero"));
-       return action;
 }
 
-void RS_ActionLockRelativeZero::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
-    finish();
+void RS_ActionLockRelativeZero::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
+       finish();
 }
 
-void RS_ActionLockRelativeZero::trigger() {
-    graphicView->lockRelativeZero(on);
+void RS_ActionLockRelativeZero::trigger()
+{
+       graphicView->lockRelativeZero(on);
 }
 
-// EOF
index 9cd4782dcfdb648b98bd0dad6fdfe43e56ea13b1..146d65414fe90854045ffe85d8860294177fb8e9 100644 (file)
@@ -1,35 +1,8 @@
-/****************************************************************************
-** $Id: rs_actionlockrelativezero.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONLOCKRELATIVEZERO_H
 #define RS_ACTIONLOCKRELATIVEZERO_H
 
 #include "rs_previewactioninterface.h"
 
-
 /**
  * This action class can handle user events to lock or unlock
  * the relative Zero point.
  *
  * @author Ulf Lehnert
  */
-class RS_ActionLockRelativeZero : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionLockRelativeZero(RS_EntityContainer& container,
-                             RS_GraphicView& graphicView,
-                                                        bool on);
-    ~RS_ActionLockRelativeZero() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionLockRelativeZero: public RS_ActionInterface
+{
+       public:
+               RS_ActionLockRelativeZero(RS_EntityContainer & container, RS_GraphicView & graphicView, bool on);
+               ~RS_ActionLockRelativeZero();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-private:
-       bool on;
+       private:
+               bool on;
 };
 
 #endif
index b04de7e2dca5abeb9e3c218fc687ca6964a9de5a..50b54a67998e43abb3d1a0f39c4854a05f49299b 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifyattributes.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyattributes.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyattributes.h"
 
+#include "rs_dialogfactory.h"
+#include "drawing.h"
+#include "rs_graphicview.h"
 #include "rs_modification.h"
-#include "rs_snapper.h"
-
-
 
 RS_ActionModifyAttributes::RS_ActionModifyAttributes(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Change Attributes",
-                    container, graphicView) {}
-
-
-QAction* RS_ActionModifyAttributes::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Change Attributes", container, graphicView)
 {
-       QAction * action = new QAction(tr("&Attributes"), 0);
-//     QAction* action = new QAction(tr("Attributes"), tr("&Attributes"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Modify Entity Attributes"));
-
-       return action;
 }
 
-
-void RS_ActionModifyAttributes::init(int status) {
-    RS_ActionInterface::init(status);
-
-    trigger();
+RS_ActionModifyAttributes::~RS_ActionModifyAttributes()
+{
 }
 
-
-
-void RS_ActionModifyAttributes::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyAttributes::trigger()");
-
-    RS_AttributesData data;
-    data.pen = RS_Pen();
-    data.layer = "0";
-    data.changeColor = false;
-    data.changeLineType = false;
-    data.changeWidth = false;
-    data.changeLayer = false;
-
-    if (graphic!=NULL) {
-        if (RS_DIALOGFACTORY->requestAttributesDialog(data,
-                *graphic->getLayerList())) {
-            RS_Modification m(*container, graphicView);
-            m.changeAttributes(data);
-        }
-    }
-
-    finish();
-    graphicView->killSelectActions();
-
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+void RS_ActionModifyAttributes::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
-
-
-void RS_ActionModifyAttributes::updateMouseButtonHints() {
-    switch (getStatus()) {
-        //case Acknowledge:
-        //RS_DIALOGFACTORY->updateMouseWidget(tr("Acknowledge"), tr("Cancel"));
-        //break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyAttributes::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyAttributes::trigger()");
+
+       RS_AttributesData data;
+       data.pen = RS_Pen();
+       data.layer = "0";
+       data.changeColor = false;
+       data.changeLineType = false;
+       data.changeWidth = false;
+       data.changeLayer = false;
+
+       if (graphic != NULL)
+               if (RS_DIALOGFACTORY->requestAttributesDialog(data,
+                           *graphic->getLayerList()))
+               {
+                       RS_Modification m(*container, graphicView);
+                       m.changeAttributes(data);
+               }
+
+       finish();
+       graphicView->killSelectActions();
+
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-
-void RS_ActionModifyAttributes::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::DelCursor);
+void RS_ActionModifyAttributes::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       //case Acknowledge:
+       //RS_DIALOGFACTORY->updateMouseWidget(tr("Acknowledge"), tr("Cancel"));
+       //break;
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyAttributes::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-    }
+void RS_ActionModifyAttributes::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::DelCursor);
 }
 
+void RS_ActionModifyAttributes::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+}
 
-// EOF
index 2f62ba6f49c35c112192b836244ef0cc8dcf717a..af0858d35875d36d3d961e817486bd583ef6f567 100644 (file)
@@ -1,63 +1,33 @@
-/****************************************************************************
-** $Id: rs_actionmodifyattributes.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYATTRIBUTES_H
 #define RS_ACTIONMODIFYATTRIBUTES_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to change the attributes of
  * entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyAttributes : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        Acknowledge    /**< Acknowledge or cancel. */
-    };
+class RS_ActionModifyAttributes: public RS_ActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       Acknowledge    /**< Acknowledge or cancel. */
+               };
 
-public:
-    RS_ActionModifyAttributes(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionModifyAttributes() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+       public:
+               RS_ActionModifyAttributes(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyAttributes();
 
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
 };
 
 #endif
index a16beffb687e63f19a280e7f88197e4163fa53d2..34fce8dea8935b3ef973ef80c0d8ef7d874d1281 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifybevel.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifybevel.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifybevel.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 #include "rs_information.h"
 
-
-RS_ActionModifyBevel::RS_ActionModifyBevel(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Bevel Entities",
-                           container, graphicView) {
-
-    entity1 = NULL;
-    coord1 = Vector(false);
-    entity2 = NULL;
-    coord2 = Vector(false);
+RS_ActionModifyBevel::RS_ActionModifyBevel(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Bevel Entities",
+               container, graphicView)
+{
+       entity1 = NULL;
+       coord1 = Vector(false);
+       entity2 = NULL;
+       coord2 = Vector(false);
 }
 
-
-QAction* RS_ActionModifyBevel::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyBevel::~RS_ActionModifyBevel()
 {
-       QAction * action = new QAction(tr("&Bevel"), 0);
-//     QAction* action = new QAction(tr("Bevel"), tr("&Bevel"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Bevel Entities"));
-       return action;
 }
 
+/*virtual*/ RS2::ActionType RS_ActionModifyBevel::rtti()
+{
+       return RS2::ActionModifyBevel;
+}
 
-void RS_ActionModifyBevel::init(int status) {
-    RS_ActionInterface::init(status);
+void RS_ActionModifyBevel::init(int status)
+{
+       RS_ActionInterface::init(status);
 
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
 }
 
+void RS_ActionModifyBevel::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyBevel::trigger()");
+
+       if (entity1 != NULL && entity1->isAtomic()
+           && entity2 != NULL && entity2->isAtomic())
+       {
+               RS_Modification m(*container, graphicView);
+               m.bevel(coord1, (RS_AtomicEntity *)entity1,
+                       coord2, (RS_AtomicEntity *)entity2,
+                       data);
+
+               entity1 = NULL;
+               entity2 = NULL;
+               setStatus(SetEntity1);
+
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
+}
 
+void RS_ActionModifyBevel::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyBevel::mouseMoveEvent begin");
 
-void RS_ActionModifyBevel::trigger() {
+       Vector mouse = graphicView->toGraph(e->x(), e->y());
+       RS_Entity * se = catchEntity(e, RS2::ResolveAll);
 
-    RS_DEBUG->print("RS_ActionModifyBevel::trigger()");
+       switch (getStatus())
+       {
+       case SetEntity1:
+               coord1 = mouse;
+               entity1 = se;
+               break;
 
-    if (entity1!=NULL && entity1->isAtomic() &&
-            entity2!=NULL && entity2->isAtomic()) {
+       case SetEntity2:
 
-        RS_Modification m(*container, graphicView);
-        m.bevel(coord1, (RS_AtomicEntity*)entity1,
-                coord2, (RS_AtomicEntity*)entity2,
-                data);
+               if (entity1 != NULL && RS_Information::isTrimmable(entity1))
+               {
+                       coord2 = mouse;
+                       entity2 = se;
+               }
+               break;
 
-        entity1 = NULL;
-        entity2 = NULL;
-        setStatus(SetEntity1);
+       default:
+               break;
+       }
 
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    }
+       RS_DEBUG->print("RS_ActionModifyBevel::mouseMoveEvent end");
 }
 
+void RS_ActionModifyBevel::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity1:
 
+                       if (entity1 != NULL && entity1->isAtomic())
+                               setStatus(SetEntity2);
+                       break;
 
-void RS_ActionModifyBevel::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyBevel::mouseMoveEvent begin");
-
-    Vector mouse = graphicView->toGraph(e->x(), e->y());
-    RS_Entity* se = catchEntity(e, RS2::ResolveAll);
+               case SetEntity2:
 
-    switch (getStatus()) {
-    case SetEntity1:
-        coord1 = mouse;
-        entity1 = se;
-        break;
+                       if (entity2 != NULL && entity2->isAtomic()
+                           && RS_Information::isTrimmable(entity1, entity2))
+                               trigger();
+                       break;
 
-    case SetEntity2:
-               if (entity1!=NULL && RS_Information::isTrimmable(entity1)) {
-               coord2 = mouse;
-               entity2 = se;
+               default:
+                       break;
                }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionModifyBevel::mouseMoveEvent end");
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyBevel::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetEntity1:
-            if (entity1!=NULL && entity1->isAtomic()) {
-                setStatus(SetEntity2);
-            }
-            break;
-
-        case SetEntity2:
-            if (entity2!=NULL && entity2->isAtomic() &&
-                           RS_Information::isTrimmable(entity1, entity2)) {
-                trigger();
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyBevel::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case SetEntity1:
+       case SetEntity2:
+
+               if (checkCommand("length1", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetLength1);
+               }
+               else if (checkCommand("length2", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetLength2);
+               }
+               else if (checkCommand("trim", c))
+               {
+                       //deleteSnapper();
+                       //deletePreview();
+                       //clearPreview();
+                       //lastStatus = (Status)getStatus();
+                       //setStatus(SetTrim);
+                       data.trim = !data.trim;
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               }
+               break;
+
+       case SetLength1: {
+               bool ok;
+               double l = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.length1 = l;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       case SetLength2: {
+               bool ok;
+               double l = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.length2 = l;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       /*case SetTrim: {
+          if (checkCommand()) {
+          data.trim = true;
+          } else if (c==cmdNo.toLower() || c==cmdNo2) {
+          data.trim = false;
+               } else {
+                   RS_DIALOGFACTORY->commandMessage(tr("Please enter 'Yes' "
+              "or 'No'"));
+               }
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+           }
+           break;*/
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyBevel::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetEntity1:
-    case SetEntity2:
-        if (checkCommand("length1", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetLength1);
-        } else if (checkCommand("length2", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetLength2);
-        } else if (checkCommand("trim", c)) {
-            //deleteSnapper();
-            //deletePreview();
-            //clearPreview();
-            //lastStatus = (Status)getStatus();
-            //setStatus(SetTrim);
-            data.trim = !data.trim;
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-        }
-        break;
-
-    case SetLength1: {
-            bool ok;
-            double l = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.length1 = l;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-    case SetLength2: {
-            bool ok;
-            double l = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.length2 = l;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(lastStatus);
-        }
-        break;
-
-        /*case SetTrim: {
-        if (checkCommand()) {
-        data.trim = true;
-    } else if (c==cmdNo.toLower() || c==cmdNo2) {
-        data.trim = false;
-                } else {
-                    RS_DIALOGFACTORY->commandMessage(tr("Please enter 'Yes' "
-               "or 'No'"));
-                }
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-                setStatus(lastStatus);
-            }
-            break;*/
-
-    default:
-        break;
-    }
+QStringList RS_ActionModifyBevel::getAvailableCommands()
+{
+       QStringList cmd;
+
+       switch (getStatus())
+       {
+       case SetEntity1:
+       case SetEntity2:
+               cmd += command("length1");
+               cmd += command("length2");
+               cmd += command("trim");
+               break;
+
+       default:
+               break;
+       }
+       return cmd;
 }
 
+void RS_ActionModifyBevel::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-QStringList RS_ActionModifyBevel::getAvailableCommands() {
-    QStringList cmd;
-    switch (getStatus()) {
-    case SetEntity1:
-    case SetEntity2:
-        cmd += command("length1");
-        cmd += command("length2");
-        cmd += command("trim");
-        break;
-    default:
-        break;
-    }
-    return cmd;
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionModifyBevel::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionModifyBevel::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionModifyBevel::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+void RS_ActionModifyBevel::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetEntity1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
+                       tr("Cancel"));
+               break;
+
+       case SetEntity2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
+                       tr("Back"));
+               break;
+
+       case SetLength1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter length 1:"),
+                       tr("Back"));
+               break;
+
+       case SetLength2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter length 2:"),
+                       tr("Back"));
+               break;
+
+       /*case SetTrim:
+           RS_DIALOGFACTORY->updateMouseWidget(tr("Trim on? (yes/no):"),
+                                               "");
+           break;*/
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyBevel::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetEntity1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
-                                            tr("Cancel"));
-        break;
-    case SetEntity2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
-                                            tr("Back"));
-        break;
-    case SetLength1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter length 1:"),
-                                            tr("Back"));
-        break;
-    case SetLength2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter length 2:"),
-                                            tr("Back"));
-        break;
-        /*case SetTrim:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Trim on? (yes/no):"),
-                                                "");
-            break;*/
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyBevel::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionModifyBevel::updateToolBar()
+{
+       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+}
 
+void RS_ActionModifyBevel::setLength1(double l1)
+{
+       data.length1 = l1;
+}
 
-void RS_ActionModifyBevel::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+double RS_ActionModifyBevel::getLength1()
+{
+       return data.length1;
 }
 
+void RS_ActionModifyBevel::setLength2(double l2)
+{
+       data.length2 = l2;
+}
 
+double RS_ActionModifyBevel::getLength2()
+{
+       return data.length2;
+}
 
-void RS_ActionModifyBevel::updateToolBar() {
-    RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+void RS_ActionModifyBevel::setTrim(bool t)
+{
+       data.trim = t;
 }
 
+bool RS_ActionModifyBevel::isTrimOn()
+{
+       return data.trim;
+}
 
-// EOF
index e02b79b7a0b58a4d275deba3e872a7082c527a8d..8a6d05e7e0d93bb77560048d70db31c8e945c74b 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifybevel.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYBEVEL_H
 #define RS_ACTIONMODIFYBEVEL_H
 
 #include "rs_previewactioninterface.h"
 #include "rs_modification.h"
 
-
 /**
  * This action class can handle user events to bevel corners.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyBevel : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetEntity1,      /**< Choosing the 1st entity. */
-        SetEntity2,      /**< Choosing the 2nd entity. */
-               SetLength1,      /**< Setting length 1 in command line. */
-               SetLength2       /**< Setting length 2 in command line. */
-               //SetTrim             /**< Setting trim flag in command line. */
-    };
-
-public:
-    RS_ActionModifyBevel(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyBevel() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionModifyBevel;
-       }
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       void setLength1(double l1) {
-               data.length1 = l1;
-       }
-
-       double getLength1() {
-               return data.length1;
-       }
-       
-       void setLength2(double l2) {
-               data.length2 = l2;
-       }
-
-       double getLength2() {
-               return data.length2;
-       }
-
-       void setTrim(bool t) {
-               data.trim = t;
-       }
-
-       bool isTrimOn() {
-               return data.trim;
-       }
-
-private:
-    RS_Entity* entity1;
-       Vector coord1;
-    RS_Entity* entity2;
-       Vector coord2;
-       RS_BevelData data;
-       /** Last status before entering angle. */
-       Status lastStatus;
+class RS_ActionModifyBevel: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetEntity1,      /**< Choosing the 1st entity. */
+                       SetEntity2,      /**< Choosing the 2nd entity. */
+                       SetLength1,      /**< Setting length 1 in command line. */
+                       SetLength2       /**< Setting length 2 in command line. */
+                       //SetTrim             /**< Setting trim flag in command line. */
+               };
+
+       public:
+               RS_ActionModifyBevel(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyBevel();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setLength1(double l1);
+               double getLength1();
+               void setLength2(double l2);
+               double getLength2();
+               void setTrim(bool t);
+               bool isTrimOn();
+
+       private:
+               RS_Entity * entity1;
+               Vector coord1;
+               RS_Entity * entity2;
+               Vector coord2;
+               RS_BevelData data;
+               /** Last status before entering angle. */
+               Status lastStatus;
 };
 
 #endif
index dc762a2286221e22a1b01a73c80bd96d106b1f8e..54c721469764c25b1a24bd8e2624d9c3458ce9e2 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifycut.cpp 2420 2005-07-01 16:47:35Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifycut.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifycut.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_modification.h"
 
-
-RS_ActionModifyCut::RS_ActionModifyCut(RS_EntityContainer& container,
-                                       RS_GraphicView& graphicView)
-        :RS_ActionInterface("Cut Entity",
-                    container, graphicView) {
-
-    cutEntity = NULL;
-    cutCoord = Vector(false);
+RS_ActionModifyCut::RS_ActionModifyCut(RS_EntityContainer & container,
+       RS_GraphicView & graphicView): RS_ActionInterface("Cut Entity",
+               container, graphicView)
+{
+       cutEntity = NULL;
+       cutCoord = Vector(false);
 }
 
-QAction* RS_ActionModifyCut::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyCut::~RS_ActionModifyCut()
 {
-       QAction * action = new QAction(tr("&Divide"), 0);
-//     QAction* action = new QAction(tr("Divide"), tr("&Divide"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Cut Entities"));
-       return action;
 }
 
-
 void RS_ActionModifyCut::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 }
 
+void RS_ActionModifyCut::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyCut::trigger()");
 
+       if (cutEntity != NULL && cutEntity->isAtomic() && cutCoord.valid
+           && cutEntity->isPointOnEntity(cutCoord))
+       {
+               cutEntity->setHighlighted(false);
+               graphicView->drawEntity(cutEntity);
 
-void RS_ActionModifyCut::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyCut::trigger()");
-
-    if (cutEntity!=NULL && cutEntity->isAtomic() && cutCoord.valid &&
-            cutEntity->isPointOnEntity(cutCoord)) {
-
-        cutEntity->setHighlighted(false);
-        graphicView->drawEntity(cutEntity);
-
-        RS_Modification m(*container, graphicView);
-        m.cut(cutCoord, (RS_AtomicEntity*)cutEntity);
+               RS_Modification m(*container, graphicView);
+               m.cut(cutCoord, (RS_AtomicEntity *)cutEntity);
 
-        cutEntity = NULL;
-        cutCoord = Vector(false);
-        setStatus(ChooseCutEntity);
+               cutEntity = NULL;
+               cutCoord = Vector(false);
+               setStatus(ChooseCutEntity);
 
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    }
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
 }
 
+void RS_ActionModifyCut::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyCut::mouseMoveEvent begin");
 
+       switch (getStatus())
+       {
+       case ChooseCutEntity:
+               break;
 
-void RS_ActionModifyCut::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyCut::mouseMoveEvent begin");
-
-    switch (getStatus()) {
-    case ChooseCutEntity:
-        break;
-
-    case SetCutCoord:
-        snapPoint(e);
-        break;
+       case SetCutCoord:
+               snapPoint(e);
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionModifyTrim::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionModifyTrim::mouseMoveEvent end");
 }
 
-
-void RS_ActionModifyCut::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case ChooseCutEntity:
-            cutEntity = catchEntity(e);
-            if (cutEntity==NULL) {
-                RS_DIALOGFACTORY->commandMessage(tr("No Entity found."));
-            } else if (cutEntity->rtti()!=RS2::EntityLine &&
-                       cutEntity->rtti()!=RS2::EntityArc &&
-                       cutEntity->rtti()!=RS2::EntityCircle &&
-                       cutEntity->rtti()!=RS2::EntityEllipse) {
-
-                RS_DIALOGFACTORY->commandMessage(
-                    tr("Entity must be a line, arc, circle or ellipse."));
-            } else {
-                cutEntity->setHighlighted(true);
-                graphicView->drawEntity(cutEntity);
-                setStatus(SetCutCoord);
-            }
-            break;
-
-        case SetCutCoord:
-            cutCoord = snapPoint(e);
-            if (cutEntity==NULL) {
-                RS_DIALOGFACTORY->commandMessage(tr("No Entity found."));
-            } else if (!cutCoord.valid) {
-                RS_DIALOGFACTORY->commandMessage(tr("Cutting point is invalid."));
-            } else if (!cutEntity->isPointOnEntity(cutCoord)) {
-                RS_DIALOGFACTORY->commandMessage(
-                    tr("Cutting point is not on entity."));
-            } else {
-                deleteSnapper();
-                trigger();
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        if (cutEntity!=NULL) {
-            cutEntity->setHighlighted(false);
-            graphicView->drawEntity(cutEntity);
-        }
-        init(getStatus()-1);
-    }
+void RS_ActionModifyCut::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case ChooseCutEntity:
+                       cutEntity = catchEntity(e);
+
+                       if (cutEntity == NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("No Entity found."));
+                       else if (cutEntity->rtti() != RS2::EntityLine
+                               && cutEntity->rtti() != RS2::EntityArc
+                               && cutEntity->rtti() != RS2::EntityCircle
+                               && cutEntity->rtti() != RS2::EntityEllipse)
+
+                               RS_DIALOGFACTORY->commandMessage(
+                                       tr("Entity must be a line, arc, circle or ellipse."));
+                       else
+                       {
+                               cutEntity->setHighlighted(true);
+                               graphicView->drawEntity(cutEntity);
+                               setStatus(SetCutCoord);
+                       }
+                       break;
+
+               case SetCutCoord:
+                       cutCoord = snapPoint(e);
+
+                       if (cutEntity == NULL)
+                               RS_DIALOGFACTORY->commandMessage(tr("No Entity found."));
+                       else if (!cutCoord.valid)
+                               RS_DIALOGFACTORY->commandMessage(tr("Cutting point is invalid."));
+                       else if (!cutEntity->isPointOnEntity(cutCoord))
+                               RS_DIALOGFACTORY->commandMessage(
+                                       tr("Cutting point is not on entity."));
+                       else
+                       {
+                               deleteSnapper();
+                               trigger();
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deleteSnapper();
+
+               if (cutEntity != NULL)
+               {
+                       cutEntity->setHighlighted(false);
+                       graphicView->drawEntity(cutEntity);
+               }
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyCut::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case ChooseCutEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify entity to cut"),
-                                            tr("Cancel"));
-        break;
-    case SetCutCoord:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify cutting point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyCut::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case ChooseCutEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify entity to cut"),
+                       tr("Cancel"));
+               break;
+
+       case SetCutCoord:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify cutting point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyCut::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyCut::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyCut::updateToolBar() {
-
-    switch (getStatus()) {
-    case SetCutCoord:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    case ChooseCutEntity:
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        break;
-    }
+void RS_ActionModifyCut::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetCutCoord:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       case ChooseCutEntity:
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               break;
+       }
 }
-
-
-// EOF
index e54f4601a2b82548035092f4c9dbd7141ddc79ac..041f3bee7973c41fdafda7dff3786765a2017475 100644 (file)
@@ -1,70 +1,42 @@
-/****************************************************************************
-** $Id: rs_actionmodifycut.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYCUT_H
 #define RS_ACTIONMODIFYCUT_H
 
 #include "rs_actioninterface.h"
-#include "rs_modification.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to divide entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyCut : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        ChooseCutEntity,      /**< Choosing the entity to cut in two. */
-        SetCutCoord        /**< Choosing the cutting point. */
-    };
-
-public:
-    RS_ActionModifyCut(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyCut() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_Entity* cutEntity;
-       Vector cutCoord;
+class RS_ActionModifyCut: public RS_ActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       ChooseCutEntity,      /**< Choosing the entity to cut in two. */
+                       SetCutCoord        /**< Choosing the cutting point. */
+               };
+
+       public:
+               RS_ActionModifyCut(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyCut();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_Entity * cutEntity;
+               Vector cutCoord;
 };
 
 #endif
index bae019693fb14c82c66f29df7e96a5009c2942b3..15668e7d9a34b7598a7ccb69432cae253698ed1c 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifydelete.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifydelete.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifydelete.h"
 
-#include "rs_actionselectsingle.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 #include "rs_modification.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
 
-
-
-RS_ActionModifyDelete::RS_ActionModifyDelete(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Delete Entities",
-                    container, graphicView) {}
-
-QAction* RS_ActionModifyDelete::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyDelete::RS_ActionModifyDelete(RS_EntityContainer & container,
+       RS_GraphicView & graphicView): RS_ActionInterface("Delete Entities",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Delete"), 0);
-//     QAction* action = new QAction(tr("Delete"), tr("&Delete"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Delete Entities"));
-       return action;
 }
 
-
-void RS_ActionModifyDelete::init(int status) {
-    RS_ActionInterface::init(status);
-
-    trigger();
+RS_ActionModifyDelete::~RS_ActionModifyDelete()
+{
 }
 
-
-
-void RS_ActionModifyDelete::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyDelete::trigger()");
-
-    RS_Modification m(*container, graphicView);
-    m.remove();
-
-    finish();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    }
+void RS_ActionModifyDelete::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
+void RS_ActionModifyDelete::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyDelete::trigger()");
+       RS_Modification m(*container, graphicView);
+       m.remove();
+       finish();
 
-
-void RS_ActionModifyDelete::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-            //case Acknowledge:
-            //    RS_DIALOGFACTORY->updateMouseWidget(tr("Acknowledge"),
-            // tr("Cancel"));
-            //    break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-
-void RS_ActionModifyDelete::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::DelCursor);
+void RS_ActionModifyDelete::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               //case Acknowledge:
+               //    RS_DIALOGFACTORY->updateMouseWidget(tr("Acknowledge"),
+               //      tr("Cancel"));
+               //    break;
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionModifyDelete::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-        }
-    }
+void RS_ActionModifyDelete::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::DelCursor);
 }
 
+void RS_ActionModifyDelete::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
+       }
+}
 
-// EOF
index a25b3b71ce332f0b5a8638381474256a0cb98833..dafa14ce6a5a3fac1f1084e3394a060a2a0dbfaf 100644 (file)
@@ -1,62 +1,32 @@
-/****************************************************************************
-** $Id: rs_actionmodifydelete.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYDELETE_H
 #define RS_ACTIONMODIFYDELETE_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to delete entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyDelete : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        Acknowledge    /**< Acknowledge or cancel. */
-    };
-
-public:
-    RS_ActionModifyDelete(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionModifyDelete() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
+class RS_ActionModifyDelete: public RS_ActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       Acknowledge /**< Acknowledge or cancel. */
+               };
+
+       public:
+               RS_ActionModifyDelete(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyDelete();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
 };
 
 #endif
index 8d2275c79dc85738c013746d8290655f1b398303..e7715ae0e20b9ec896853d5495964aa6db788644 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifydeletefree.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifydeletefree.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifydeletefree.h"
 
-#include "rs_point.h"
-#include "rs_polyline.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 #include "rs_modification.h"
-
-
+#include "rs_polyline.h"
+#include "rs_undo.h"
 
 RS_ActionModifyDeleteFree::RS_ActionModifyDeleteFree(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Delete Entities Freehand",
-                    container, graphicView) {}
-
-QAction* RS_ActionModifyDeleteFree::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Delete Entities Freehand",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Delete Freehand"), 0);
-//     QAction* action = new QAction(tr("Delete Freehand"), tr("&Delete Freehand"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Delete Freehand"));
-       return action;
 }
 
-
-void RS_ActionModifyDeleteFree::init(int status) {
-    RS_ActionInterface::init(status);
-    polyline = NULL;
-    e1 = e2 = NULL;
-    v1 = v2 = Vector(false);
-    setSnapMode(RS2::SnapOnEntity);
+RS_ActionModifyDeleteFree::~RS_ActionModifyDeleteFree()
+{
 }
 
-
-
-void RS_ActionModifyDeleteFree::trigger() {
-    if (e1!=NULL && e2!=NULL) {
-        RS_EntityContainer* parent = e2->getParent();
-        if (parent!=NULL) {
-            if (parent->rtti()==RS2::EntityPolyline) {
-                if(parent->getId() == polyline->getId()) {
-
-                    // deletes whole polyline on screen:
-                    graphicView->deleteEntity((RS_Entity*)polyline);
-
-                    // splits up the polyline in the container:
-                    RS_Polyline* pl1;
-                    RS_Polyline* pl2;
-                    RS_Modification m(*container);
-                    m.splitPolyline(*polyline,
-                                    *e1, v1,
-                                    *e2, v2,
-                                    &pl1, &pl2);
-
-                    if (document) {
-                        document->startUndoCycle();
-                        document->addUndoable(polyline);
-                        document->addUndoable(pl1);
-                        document->addUndoable(pl2);
-                        document->endUndoCycle();
-                    }
-
-                    // draws the new polylines on the screen:
-                    graphicView->drawEntity((RS_Entity*)pl1);
-                    graphicView->drawEntity((RS_Entity*)pl2);
-
-                    init();
-
-                    RS_DIALOGFACTORY->updateSelectionWidget(
-                        container->countSelected());
-                } else {
-                               RS_DIALOGFACTORY->commandMessage(tr("Entities not in the same polyline."));
-                }
-            } else {
-                       RS_DIALOGFACTORY->commandMessage(tr("Parent of second entity is not a polyline"));
-            }
-        } else {
-               RS_DIALOGFACTORY->commandMessage(tr("Parent of second entity is NULL"));
-        }
-    } else {
-        RS_DIALOGFACTORY->commandMessage(tr("One of the chosen entities is NULL"));
-    }
+void RS_ActionModifyDeleteFree::init(int status)
+{
+       RS_ActionInterface::init(status);
+       polyline = NULL;
+       e1 = e2 = NULL;
+       v1 = v2 = Vector(false);
+       setSnapMode(RS2::SnapOnEntity);
 }
 
-
-
-void RS_ActionModifyDeleteFree::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-
-        switch (getStatus()) {
-        case 0: {
-                v1 = snapPoint(e);
-                e1 = getKeyEntity();
-                if (e1!=NULL) {
-                    RS_EntityContainer* parent = e1->getParent();
-                    if (parent!=NULL) {
-                        if (parent->rtti()==RS2::EntityPolyline) {
-                            polyline = (RS_Polyline*)parent;
-                            setStatus(1);
-                        } else {
-                                               RS_DIALOGFACTORY->commandMessage(
-                                                               tr("Parent of first entity is not a polyline"));
-                        }
-                    } else {
-                                       RS_DIALOGFACTORY->commandMessage(
-                                                       tr("Parent of first entity is NULL"));
-                    }
-                } else {
-                               RS_DIALOGFACTORY->commandMessage(
-                                               tr("First entity is NULL"));
-                }
-            }
-            break;
-
-        case 1: {
-                v2 = snapPoint(e);
-                e2 = getKeyEntity();
-
-                if (e2!=NULL) {
-                    trigger();
-                } else {
-                               RS_DIALOGFACTORY->commandMessage(tr("Second entity is NULL"));
-                }
-            }
-            break;
-        }
-    }
+void RS_ActionModifyDeleteFree::trigger()
+{
+       if (e1 != NULL && e2 != NULL)
+       {
+               RS_EntityContainer * parent = e2->getParent();
+
+               if (parent != NULL)
+               {
+                       if (parent->rtti() == RS2::EntityPolyline)
+                       {
+                               if (parent->getId() == polyline->getId())
+                               {
+                                       // deletes whole polyline on screen:
+                                       graphicView->deleteEntity((RS_Entity *)polyline);
+
+                                       // splits up the polyline in the container:
+                                       RS_Polyline * pl1;
+                                       RS_Polyline * pl2;
+                                       RS_Modification m(*container);
+                                       m.splitPolyline(*polyline,
+                                               *e1, v1,
+                                               *e2, v2,
+                                               &pl1, &pl2);
+
+                                       if (document)
+                                       {
+                                               document->startUndoCycle();
+                                               document->addUndoable(polyline);
+                                               document->addUndoable(pl1);
+                                               document->addUndoable(pl2);
+                                               document->endUndoCycle();
+                                       }
+
+                                       // draws the new polylines on the screen:
+                                       graphicView->drawEntity((RS_Entity *)pl1);
+                                       graphicView->drawEntity((RS_Entity *)pl2);
+
+                                       init();
+
+                                       RS_DIALOGFACTORY->updateSelectionWidget(
+                                               container->countSelected());
+                               }
+                               else
+                                       RS_DIALOGFACTORY->commandMessage(tr("Entities not in the same polyline."));
+                       }
+                       else
+                               RS_DIALOGFACTORY->commandMessage(tr("Parent of second entity is not a polyline"));
+               }
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Parent of second entity is NULL"));
+       }
+       else
+               RS_DIALOGFACTORY->commandMessage(tr("One of the chosen entities is NULL"));
 }
 
+void RS_ActionModifyDeleteFree::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else
+       {
+               switch (getStatus())
+               {
+               case 0:
+                       v1 = snapPoint(e);
+                       e1 = getKeyEntity();
+
+                       if (e1 != NULL)
+                       {
+                               RS_EntityContainer * parent = e1->getParent();
+
+                               if (parent != NULL)
+                               {
+                                       if (parent->rtti() == RS2::EntityPolyline)
+                                       {
+                                               polyline = (RS_Polyline *)parent;
+                                               setStatus(1);
+                                       }
+                                       else
+                                               RS_DIALOGFACTORY->commandMessage(
+                                                       tr("Parent of first entity is not a polyline"));
+                               }
+                               else
+                                       RS_DIALOGFACTORY->commandMessage(
+                                               tr("Parent of first entity is NULL"));
+                       }
+                       else
+                               RS_DIALOGFACTORY->commandMessage(
+                                       tr("First entity is NULL"));
+
+                       break;
+
+               case 1:
+                       v2 = snapPoint(e);
+                       e2 = getKeyEntity();
+
+                       if (e2 != NULL)
+                               trigger();
+                       else
+                               RS_DIALOGFACTORY->commandMessage(tr("Second entity is NULL"));
+
+                       break;
+               }
+       }
+}
 
-
-void RS_ActionModifyDeleteFree::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case 0:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first break point "
-                                               "on a polyline"), tr("Cancel"));
-        break;
-    case 1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second break point "
-                                               "on the same polyline"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyDeleteFree::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case 0:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first break point "
+                               "on a polyline"), tr("Cancel"));
+               break;
+
+       case 1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second break point "
+                               "on the same polyline"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-// EOF
index 4a6d941feb6f2ae98269f88b862e50b0c933caa0..c7fd4fe92bf5053502c88792ee79c0d493ce17cd 100644 (file)
@@ -1,60 +1,34 @@
-/****************************************************************************
-** $Id: rs_actionmodifydeletefree.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYDELETEFREE_H
 #define RS_ACTIONMODIFYDELETEFREE_H
 
 #include "rs_actioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
+class RS_Polyline;
 
 /**
  * This action class can handle user events to delete entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyDeleteFree : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionModifyDeleteFree(RS_EntityContainer& container,
-                              RS_GraphicView& graphicView);
-    ~RS_ActionModifyDeleteFree() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-
-private:
-    RS_Polyline* polyline;
-    RS_Entity* e1;
-    Vector v1;
-    RS_Entity* e2;
-    Vector v2;
+class RS_ActionModifyDeleteFree: public RS_ActionInterface
+{
+       public:
+               RS_ActionModifyDeleteFree(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyDeleteFree();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+
+       private:
+               RS_Polyline * polyline;
+               RS_Entity * e1;
+               Vector v1;
+               RS_Entity * e2;
+               Vector v2;
 };
 
 #endif
index 1ffb1272abf57436e710a8bd8a5ec627f60b7ba6..89f001bab2ae0e836a05ad86955564731b329054 100644 (file)
@@ -1,55 +1,31 @@
-/****************************************************************************
-** $Id: rs_actionmodifydeletequick.cpp 1144 2004-08-18 17:07:54Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifydeletequick.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifydeletequick.h"
 
-#include "rs_actionselectsingle.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 
 RS_ActionModifyDeleteQuick::RS_ActionModifyDeleteQuick(
-       RS_EntityContainer& container, RS_GraphicView& graphicView):
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Quick Delete Entities", container, graphicView)
 {
-    en = NULL;
+       en = NULL;
 }
 
-QAction * RS_ActionModifyDeleteQuick::createGUIAction(RS2::ActionType /*type*/, QObject * parent)
+RS_ActionModifyDeleteQuick::~RS_ActionModifyDeleteQuick()
 {
-       QAction * action = new QAction(tr("&Delete selected"), parent);
-#ifdef __APPLE__
-       action->setShortcut(Qt::Key_Backspace);
-#else
-       action->setShortcut(Qt::Key_Delete);
-#endif
-//     QAction* action = new QAction(tr("Delete selected"),
-//                                             tr("&Delete selected"),
-//                                                     s, parent);
-       action->setStatusTip(tr("Delete selected entities"));
-       return action;
 }
 
 /**
@@ -57,60 +33,63 @@ QAction * RS_ActionModifyDeleteQuick::createGUIAction(RS2::ActionType /*type*/,
  */
 void RS_ActionModifyDeleteQuick::trigger()
 {
-    RS_DEBUG->print("RS_ActionModifyDeleteQuick::trigger()");
+       RS_DEBUG->print("RS_ActionModifyDeleteQuick::trigger()");
 
-    if (en!=NULL)
+       if (en != NULL)
        {
-        RS_DEBUG->print("Entity found");
-        RS_EntityContainer* parent = en->getParent();
-        if (parent!=NULL) {
-            en->setSelected(false);
-            graphicView->deleteEntity(en);
-            en->changeUndoState();
-
-            if (document) {
-                document->startUndoCycle();
-                document->addUndoable(en);
-                document->endUndoCycle();
-            }
-        }
-
-       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    } else {
-        RS_DEBUG->print("RS_ActionModifyDeleteQuick::mousePressEvent:"
-                        " Entity is NULL\n");
-    }
+               RS_DEBUG->print("Entity found");
+               RS_EntityContainer * parent = en->getParent();
+
+               if (parent != NULL)
+               {
+                       en->setSelected(false);
+                       graphicView->deleteEntity(en);
+                       en->changeUndoState();
+
+                       if (document)
+                       {
+                               document->startUndoCycle();
+                               document->addUndoable(en);
+                               document->endUndoCycle();
+                       }
+               }
+
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
+       else
+               RS_DEBUG->print("RS_ActionModifyDeleteQuick::mousePressEvent:"
+                       " Entity is NULL\n");
 }
 
-
-
-void RS_ActionModifyDeleteQuick::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-        en = catchEntity(e);
-        trigger();
-    }
+void RS_ActionModifyDeleteQuick::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else
+       {
+               en = catchEntity(e);
+               trigger();
+       }
 }
 
-
-
-void RS_ActionModifyDeleteQuick::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case 0:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entity to delete"),
-                                       tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyDeleteQuick::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case 0:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entity to delete"),
+                       tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyDeleteQuick::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::DelCursor);
+void RS_ActionModifyDeleteQuick::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::DelCursor);
 }
 
 // EOF
index 6f6b819c32d65d173e6945521f3e625fc03ab944..25b732d86885092197caa7c55a89239e9353a37f 100644 (file)
@@ -1,34 +1,9 @@
-/****************************************************************************
-** $Id: rs_actionmodifydeletequick.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYDELETEQUICK_H
 #define RS_ACTIONMODIFYDELETEQUICK_H
 
 #include "rs_actioninterface.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to delete entities
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyDeleteQuick : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionModifyDeleteQuick(RS_EntityContainer& container,
-                               RS_GraphicView& graphicView);
-    ~RS_ActionModifyDeleteQuick() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* parent);
-
-    virtual void trigger();
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-
-private:
-    RS_Entity* en;
+class RS_ActionModifyDeleteQuick: public RS_ActionInterface
+{
+       public:
+               RS_ActionModifyDeleteQuick(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyDeleteQuick();
+
+               virtual void trigger();
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+
+       private:
+               RS_Entity * en;
 };
 
 #endif
index 74912ab9f6ff0738b2788f76f44f6fab1ac12495..051304650c43f5206b6ec02810c0c5d9624beed0 100644 (file)
@@ -1,99 +1,83 @@
-/****************************************************************************
-** $Id: rs_actionmodifyentity.cpp 1149 2004-09-19 11:06:35Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyentity.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyentity.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 
-
-
-RS_ActionModifyEntity::RS_ActionModifyEntity(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Modify Entity", container, graphicView) {
-
-    en = NULL;
+RS_ActionModifyEntity::RS_ActionModifyEntity(RS_EntityContainer & container,
+       RS_GraphicView & graphicView):
+       RS_ActionInterface("Modify Entity", container, graphicView)
+{
+       en = NULL;
 }
 
-
-QAction* RS_ActionModifyEntity::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyEntity::~RS_ActionModifyEntity()
 {
-       QAction * action = new QAction(tr("&Properties"), 0);
-//     QAction* action = new QAction(tr("Properties"), tr("&Properties"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Modify Entity Properties"));
-       return action;
 }
 
 void RS_ActionModifyEntity::trigger()
 {
-    if (en!=NULL) {
-        RS_Entity* clone = en->clone();
-        if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone)) {
-            container->addEntity(clone);
+       if (en != NULL)
+       {
+               RS_Entity * clone = en->clone();
+
+               if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
+               {
+                       container->addEntity(clone);
 
-            graphicView->deleteEntity(en);
+                       graphicView->deleteEntity(en);
                        en->setSelected(false);
 
                        clone->setSelected(false);
-            graphicView->drawEntity(clone);
-
-            if (document!=NULL) {
-                document->startUndoCycle();
-
-                document->addUndoable(clone);
-                en->setUndoState(true);
-                document->addUndoable(en);
-
-                document->endUndoCycle();
-            }
-            RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-        } else {
-            delete clone;
-        }
-
-    } else {
-        RS_DEBUG->print("RS_ActionModifyEntity::trigger: Entity is NULL\n");
-    }
+                       graphicView->drawEntity(clone);
+
+                       if (document != NULL)
+                       {
+                               document->startUndoCycle();
+
+                               document->addUndoable(clone);
+                               en->setUndoState(true);
+                               document->addUndoable(en);
+
+                               document->endUndoCycle();
+                       }
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+               }
+               else
+                       delete clone;
+
+       }
+       else
+               RS_DEBUG->print("RS_ActionModifyEntity::trigger: Entity is NULL\n");
 }
 
-
-
-void RS_ActionModifyEntity::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-        en = catchEntity(e);
-        trigger();
-    }
+void RS_ActionModifyEntity::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else
+       {
+               en = catchEntity(e);
+               trigger();
+       }
 }
 
-
-
-void RS_ActionModifyEntity::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionModifyEntity::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
 
 // EOF
index 323f9df0c3991528915400dcdb12df22b039c203..f790bc4e079560fd3d54d4970bd1f74d3c36de1e 100644 (file)
@@ -1,55 +1,28 @@
-/****************************************************************************
-** $Id: rs_actionmodifyentity.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYENTITY_H
 #define RS_ACTIONMODIFYENTITY_H
 
 #include "rs_actioninterface.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to select entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyEntity : public RS_ActionInterface {
+class RS_ActionModifyEntity: public RS_ActionInterface
+{
        //Q_OBJECT
-public:
-    RS_ActionModifyEntity(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionModifyEntity() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+       public:
+               RS_ActionModifyEntity(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyEntity();
 
-    virtual void trigger();
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseCursor();
+               virtual void trigger();
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseCursor();
 
-private:
-    RS_Entity* en;
+       private:
+               RS_Entity * en;
 };
 
 #endif
index bfe7af7cb25c471cc922c032bbb8fb7f44eabf08..a5037a2b5f6a5742d5f27da13e42b3c4b8ecea32 100644 (file)
@@ -1,28 +1,16 @@
-/****************************************************************************
-** $Id: rs_actionmodifyexplodetext.cpp 1077 2004-03-03 19:06:45Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyexplodetext.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyexplodetext.h"
 
 /**
  * Constructor.
  */
-RS_ActionModifyExplodeText::RS_ActionModifyExplodeText(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Blocks Explode",
-                           container, graphicView) {
+RS_ActionModifyExplodeText::RS_ActionModifyExplodeText(RS_EntityContainer & container,
+       RS_GraphicView & graphicView): RS_PreviewActionInterface("Blocks Explode",
+               container, graphicView)
+{
 }
 
-
-
-RS_ActionModifyExplodeText::~RS_ActionModifyExplodeText() {}
-
-
-QAction* RS_ActionModifyExplodeText::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyExplodeText::~RS_ActionModifyExplodeText()
 {
-       QAction * action = new QAction(tr("&Explode Text into Letters"), 0);
-//     QAction* action = new QAction(tr("Explode Text"),
-//                                                             tr("&Explode Text into Letters"),
-//                                                             QKeySequence(), NULL);
-       action->setStatusTip(tr("Explodes Text Entities into single Letters"));
-       return action;
 }
 
-
-void RS_ActionModifyExplodeText::init(int status) {
-    RS_PreviewActionInterface::init(status);
-
-    trigger();
-    finish();
+/*virtual*/ RS2::ActionType RS_ActionModifyExplodeText::rtti()
+{
+       return RS2::ActionModifyExplodeText;
 }
 
+void RS_ActionModifyExplodeText::init(int status)
+{
+       RS_PreviewActionInterface::init(status);
 
-
-void RS_ActionModifyExplodeText::trigger() {
-    RS_Modification m(*container, graphicView);
-    m.explodeTextIntoLetters();
+       trigger();
+       finish();
 }
 
-
-// EOF
+void RS_ActionModifyExplodeText::trigger()
+{
+       RS_Modification m(*container, graphicView);
+       m.explodeTextIntoLetters();
+}
index b4a76faa100ce0dcc4d07fb0f6c4f5c46986800c..d0ebe749a06092c8c4386e1f975555309e0a1656 100644 (file)
@@ -1,34 +1,7 @@
-/****************************************************************************
-** $Id: rs_actionmodifyexplodetext.h 1077 2004-03-03 19:06:45Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYEXPLODETEXT_H
 #define RS_ACTIONMODIFYEXPLODETEXT_H
 
 #include "rs_previewactioninterface.h"
-#include "rs_insert.h"
 
 /**
  * This action class can handle user events for exploding blocks and
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyExplodeText : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionModifyExplodeText(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyExplodeText();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionModifyExplodeText;
-       }
-
-    virtual void init(int status=0);
+class RS_ActionModifyExplodeText: public RS_PreviewActionInterface
+{
+       public:
+               RS_ActionModifyExplodeText(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyExplodeText();
 
-    virtual void trigger();
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 1f45971b3269091688d5cd623a90613d746aa5fe..fab05b2e65bb4a1bc1629f2a7bb824f0f0cea953 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifymirror.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifymirror.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifymirror.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_preview.h"
 
-RS_ActionModifyMirror::RS_ActionModifyMirror(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionModifyMirror::RS_ActionModifyMirror(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Mirror Entities", container, graphicView)
 {
 }
 
-QAction * RS_ActionModifyMirror::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionModifyMirror::~RS_ActionModifyMirror()
 {
-       QAction * action = new QAction(tr("&Mirror"), 0);
-//     QAction* action = new QAction(tr("Mirror"), tr("&Mirror"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Mirror Entities"));
-       return action;
 }
 
 void RS_ActionModifyMirror::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 }
 
 void RS_ActionModifyMirror::trigger()
 {
+       RS_DEBUG->print("RS_ActionModifyMirror::trigger()");
 
-    RS_DEBUG->print("RS_ActionModifyMirror::trigger()");
+       RS_Modification m(*container, graphicView);
+       m.mirror(data);
 
-    RS_Modification m(*container, graphicView);
-    m.mirror(data);
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
+void RS_ActionModifyMirror::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyMirror::mouseMoveEvent begin");
 
+       if (getStatus() == SetAxisPoint1
+           || getStatus() == SetAxisPoint2)
+       {
+               Vector mouse = snapPoint(e);
 
-void RS_ActionModifyMirror::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyMirror::mouseMoveEvent begin");
-
-    if (getStatus()==SetAxisPoint1 ||
-            getStatus()==SetAxisPoint2) {
+               switch (getStatus())
+               {
+               case SetAxisPoint1:
+                       axisPoint1 = mouse;
+                       break;
 
-        Vector mouse = snapPoint(e);
-        switch (getStatus()) {
-        case SetAxisPoint1:
-            axisPoint1 = mouse;
-            break;
+               case SetAxisPoint2:
 
-        case SetAxisPoint2:
-            if (axisPoint1.valid) {
-                axisPoint2 = mouse;
+                       if (axisPoint1.valid)
+                       {
+                               axisPoint2 = mouse;
 
-                deletePreview();
-                clearPreview();
-                preview->addSelectionFrom(*container);
-                preview->mirror(axisPoint1, axisPoint2);
+                               deletePreview();
+                               clearPreview();
+                               preview->addSelectionFrom(*container);
+                               preview->mirror(axisPoint1, axisPoint2);
 
-                preview->addEntity(new RS_Line(preview,
-                                               RS_LineData(axisPoint1,
-                                                           axisPoint2)));
+                               preview->addEntity(new RS_Line(preview,
+                                               RS_LineData(axisPoint1,
+                                                       axisPoint2)));
 
-                drawPreview();
-            }
-            break;
+                               drawPreview();
+                       }
+                       break;
 
-        default:
-            break;
-        }
-    }
+               default:
+                       break;
+               }
+       }
 
-    RS_DEBUG->print("RS_ActionModifyMirror::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionModifyMirror::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyMirror::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyMirror::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyMirror::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-        switch (getStatus()) {
-        case SetAxisPoint1:
-            axisPoint1 = mouse;
-            setStatus(SetAxisPoint2);
-               graphicView->moveRelativeZero(mouse);
-            break;
-
-        case SetAxisPoint2:
-            axisPoint2 = mouse;
-            setStatus(ShowDialog);
-               graphicView->moveRelativeZero(mouse);
-            if (RS_DIALOGFACTORY!=NULL) {
-                if (RS_DIALOGFACTORY->requestMirrorDialog(data)) {
-                    data.axisPoint1 = axisPoint1;
-                    data.axisPoint2 = axisPoint2;
-                    deletePreview();
-                    clearPreview();
-                    trigger();
-                    finish();
-                }
-            }
-            break;
-
-        default:
-            break;
-        }
+void RS_ActionModifyMirror::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetAxisPoint1:
+               axisPoint1 = mouse;
+               setStatus(SetAxisPoint2);
+               graphicView->moveRelativeZero(mouse);
+               break;
+
+       case SetAxisPoint2:
+               axisPoint2 = mouse;
+               setStatus(ShowDialog);
+               graphicView->moveRelativeZero(mouse);
+
+               if (RS_DIALOGFACTORY != NULL)
+               {
+                       if (RS_DIALOGFACTORY->requestMirrorDialog(data))
+                       {
+                               data.axisPoint1 = axisPoint1;
+                               data.axisPoint2 = axisPoint2;
+                               deletePreview();
+                               clearPreview();
+                               trigger();
+                               finish();
+                       }
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyMirror::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-            /*case Select:
-                RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
-                                               tr("Cancel"));
-                break;*/
-        case SetAxisPoint1:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify first point of mirror line"),
-                tr("Cancel"));
-            break;
-        case SetAxisPoint2:
-            RS_DIALOGFACTORY->updateMouseWidget(
-                tr("Specify second point of mirror line"),
-                tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionModifyMirror::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               /*case Select:
+                   RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
+                                                  tr("Cancel"));
+                   break;*/
+               case SetAxisPoint1:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify first point of mirror line"),
+                               tr("Cancel"));
+                       break;
+
+               case SetAxisPoint2:
+                       RS_DIALOGFACTORY->updateMouseWidget(
+                               tr("Specify second point of mirror line"),
+                               tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionModifyMirror::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyMirror::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyMirror::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetAxisPoint1:
-        case SetAxisPoint2:
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-            break;
-        default:
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-            break;
-        }
-    }
+void RS_ActionModifyMirror::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetAxisPoint1:
+               case SetAxisPoint2:
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+                       break;
+               }
+       }
 }
 
-
 // EOF
index 06045f6579af341f05b880de8fcd871e180d55da..83aeb56da3ee12a7a8733859dec3d275121b56c6 100644 (file)
@@ -1,73 +1,44 @@
-/****************************************************************************
-** $Id: rs_actionmodifymirror.h 1106 2004-03-24 16:34:24Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYMIRROR_H
 #define RS_ACTIONMODIFYMIRROR_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
-
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to mirror entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyMirror : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetAxisPoint1,    /**< Setting the 1st point of the axis. */
-        SetAxisPoint2,    /**< Setting the 2nd point of the axis. */
-        ShowDialog        /**< Showing the options dialog. */
-    };
-
-public:
-    RS_ActionModifyMirror(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyMirror() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_MirrorData data;
-    Vector axisPoint1;
-    Vector axisPoint2;
+class RS_ActionModifyMirror: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetAxisPoint1, /**< Setting the 1st point of the axis. */
+                       SetAxisPoint2, /**< Setting the 2nd point of the axis. */
+                       ShowDialog /**< Showing the options dialog. */
+               };
+
+       public:
+               RS_ActionModifyMirror(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyMirror();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void coordinateEvent(Vector * e);
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_MirrorData data;
+               Vector axisPoint1;
+               Vector axisPoint2;
 };
 
 #endif
index f38e236ab5a5b00bea5ea6508f8a8abfdbd2b23a..c5f43c9472df28c642af2aa2cb12c0e6590e8261 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifymove.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifymove.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifymove.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionModifyMove::RS_ActionModifyMove(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionModifyMove::RS_ActionModifyMove(RS_EntityContainer & container,
+       RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Move Entities", container, graphicView)
 {
 }
 
-QAction* RS_ActionModifyMove::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyMove::~RS_ActionModifyMove()
 {
-       QAction * action = new QAction(tr("&Move / Copy"), 0);
-//     QAction* action = new QAction(tr("Move / Copy"), tr("&Move / Copy"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Move or copy entities one or multiple times"));
-       return action;
 }
 
 void RS_ActionModifyMove::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 }
 
-
-
 void RS_ActionModifyMove::trigger()
 {
+       RS_DEBUG->print("RS_ActionModifyMove::trigger()");
 
-    RS_DEBUG->print("RS_ActionModifyMove::trigger()");
+       RS_Modification m(*container, graphicView);
+       m.move(data);
 
-    RS_Modification m(*container, graphicView);
-    m.move(data);
-
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-
-void RS_ActionModifyMove::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyMove::mouseMoveEvent begin");
-
-    if (getStatus()==SetReferencePoint ||
-            getStatus()==SetTargetPoint) {
-
-        Vector mouse = snapPoint(e);
-        switch (getStatus()) {
-        case SetReferencePoint:
-            referencePoint = mouse;
-            break;
-
-        case SetTargetPoint:
-            if (referencePoint.valid) {
-                targetPoint = mouse;
-
-                deletePreview();
-                clearPreview();
-                preview->addSelectionFrom(*container);
-                preview->move(targetPoint-referencePoint);
-                drawPreview();
-            }
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    RS_DEBUG->print("RS_ActionModifyMove::mouseMoveEvent end");
+void RS_ActionModifyMove::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyMove::mouseMoveEvent begin");
+
+       if (getStatus() == SetReferencePoint
+           || getStatus() == SetTargetPoint)
+       {
+               Vector mouse = snapPoint(e);
+
+               switch (getStatus())
+               {
+               case SetReferencePoint:
+                       referencePoint = mouse;
+                       break;
+
+               case SetTargetPoint:
+
+                       if (referencePoint.valid)
+                       {
+                               targetPoint = mouse;
+
+                               deletePreview();
+                               clearPreview();
+                               preview->addSelectionFrom(*container);
+                               preview->move(targetPoint - referencePoint);
+                               drawPreview();
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       RS_DEBUG->print("RS_ActionModifyMove::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyMove::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyMove::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-void RS_ActionModifyMove::coordinateEvent(RS_CoordinateEvent* e) {
-
-    if (e==NULL) {
-        return;
-    }
-
-    Vector pos = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetReferencePoint:
-        referencePoint = pos;
-        graphicView->moveRelativeZero(referencePoint);
-        setStatus(SetTargetPoint);
-        break;
-
-    case SetTargetPoint:
-        targetPoint = pos;
-        graphicView->moveRelativeZero(targetPoint);
-        setStatus(ShowDialog);
-        if (RS_DIALOGFACTORY->requestMoveDialog(data)) {
-            data.offset = targetPoint - referencePoint;
-            trigger();
-            finish();
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionModifyMove::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector pos = *e;
+
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               referencePoint = pos;
+               graphicView->moveRelativeZero(referencePoint);
+               setStatus(SetTargetPoint);
+               break;
+
+       case SetTargetPoint:
+               targetPoint = pos;
+               graphicView->moveRelativeZero(targetPoint);
+               setStatus(ShowDialog);
+
+               if (RS_DIALOGFACTORY->requestMoveDialog(data))
+               {
+                       data.offset = targetPoint - referencePoint;
+                       trigger();
+                       finish();
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionModifyMove::updateMouseButtonHints() {
-    switch (getStatus()) {
-        /*case Select:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
-                                           tr("Cancel"));
-            break;*/
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Cancel"));
-        break;
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyMove::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       /*case Select:
+           RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
+                                          tr("Cancel"));
+           break;*/
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
+                       tr("Cancel"));
+               break;
+
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyMove::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyMove::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyMove::updateToolBar() {
-    switch (getStatus()) {
-        /*case Select:
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
-            break;*/
-    case SetReferencePoint:
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        break;
-    }
+void RS_ActionModifyMove::updateToolBar()
+{
+       switch (getStatus())
+       {
+       /*case Select:
+           RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
+           break;*/
+       case SetReferencePoint:
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               break;
+       }
 }
 
-
 // EOF
index 019f267419c7059d481d4bcd0ff15e61160f4934..2610aabe3f76c42749f042a637d7605713232bf3 100644 (file)
@@ -1,77 +1,44 @@
-/****************************************************************************
-** $Id: rs_actionmodifymove.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYMOVE_H
 #define RS_ACTIONMODIFYMOVE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
-
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to move entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyMove : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetReferencePoint,    /**< Setting the reference point. */
-        SetTargetPoint,       /**< Setting the target point. */
-        ShowDialog            /**< Showing the options dialog. */
-    };
-
-public:
-    RS_ActionModifyMove(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyMove() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_MoveData data;
-    Vector referencePoint;
-    Vector targetPoint;
+class RS_ActionModifyMove: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetReferencePoint, /**< Setting the reference point. */
+                       SetTargetPoint, /**< Setting the target point. */
+                       ShowDialog /**< Showing the options dialog. */
+               };
+
+       public:
+               RS_ActionModifyMove(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyMove();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_MoveData data;
+               Vector referencePoint;
+               Vector targetPoint;
 };
 
 #endif
index d105c7ccd407c6e014dd2c66aca9d4a3f9aefff0..a241d799863cee6a4d2264bba3777f058c04b83b 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifymoverotate.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifymoverotate.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifymoverotate.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_preview.h"
 
 RS_ActionModifyMoveRotate::RS_ActionModifyMoveRotate(
-       RS_EntityContainer& container, RS_GraphicView& graphicView):
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Move and Rotate Entities", container, graphicView)
 {
 }
 
-QAction * RS_ActionModifyMoveRotate::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionModifyMoveRotate::~RS_ActionModifyMoveRotate()
 {
-       QAction * action = new QAction(tr("M&ove and Rotate"), 0);
-//     QAction* action = new QAction(tr("Move and Rotate"), tr("M&ove and Rotate"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Move and Rotate Entities"));
-       return action;
+}
+
+/*virtual*/ RS2::ActionType RS_ActionModifyMoveRotate::rtti()
+{
+       return RS2::ActionModifyMoveRotate;
 }
 
 void RS_ActionModifyMoveRotate::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 }
 
 void RS_ActionModifyMoveRotate::trigger()
 {
-    RS_DEBUG->print("RS_ActionModifyMoveRotate::trigger()");
+       RS_DEBUG->print("RS_ActionModifyMoveRotate::trigger()");
 
-    RS_Modification m(*container, graphicView);
-    m.moveRotate(data);
+       RS_Modification m(*container, graphicView);
+       m.moveRotate(data);
 
-    finish();
+       finish();
 
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
 void RS_ActionModifyMoveRotate::mouseMoveEvent(QMouseEvent * e)
 {
-    RS_DEBUG->print("RS_ActionModifyMoveRotate::mouseMoveEvent begin");
+       RS_DEBUG->print("RS_ActionModifyMoveRotate::mouseMoveEvent begin");
 
-    if (getStatus() == SetReferencePoint || getStatus() == SetTargetPoint)
+       if (getStatus() == SetReferencePoint || getStatus() == SetTargetPoint)
        {
+               Vector mouse = snapPoint(e);
 
-        Vector mouse = snapPoint(e);
-        switch (getStatus())
+               switch (getStatus())
                {
-        case SetReferencePoint:
-            data.referencePoint = mouse;
-            break;
+               case SetReferencePoint:
+                       data.referencePoint = mouse;
+                       break;
+
+               case SetTargetPoint:
 
-        case SetTargetPoint:
-            if (data.referencePoint.valid)
+                       if (data.referencePoint.valid)
                        {
-                targetPoint = mouse;
-                data.offset = targetPoint-data.referencePoint;
-
-                deletePreview();
-                clearPreview();
-                preview->addSelectionFrom(*container);
-                preview->rotate(data.referencePoint, data.angle);
-                preview->move(data.offset);
-                drawPreview();
-            }
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    RS_DEBUG->print("RS_ActionModifyMoveRotate::mouseMoveEvent end");
+                               targetPoint = mouse;
+                               data.offset = targetPoint - data.referencePoint;
+
+                               deletePreview();
+                               clearPreview();
+                               preview->addSelectionFrom(*container);
+                               preview->rotate(data.referencePoint, data.angle);
+                               preview->move(data.offset);
+                               drawPreview();
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       RS_DEBUG->print("RS_ActionModifyMoveRotate::mouseMoveEvent end");
 }
 
 void RS_ActionModifyMoveRotate::mouseReleaseEvent(QMouseEvent * e)
 {
        if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
@@ -112,35 +102,34 @@ void RS_ActionModifyMoveRotate::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionModifyMoveRotate::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionModifyMoveRotate::coordinateEvent(Vector * e)
 {
-    if (e == NULL)
-        return;
+       if (e == NULL)
+               return;
 
-    Vector pos = e->getCoordinate();
+       Vector pos = *e;
 
-    switch (getStatus())
+       switch (getStatus())
        {
-    case SetReferencePoint:
-        data.referencePoint = pos;
-        setStatus(SetTargetPoint);
-        break;
+       case SetReferencePoint:
+               data.referencePoint = pos;
+               setStatus(SetTargetPoint);
+               break;
 
-    case SetTargetPoint:
-        targetPoint = pos;
+       case SetTargetPoint:
+               targetPoint = pos;
 
-        setStatus(ShowDialog);
-        data.offset = targetPoint - data.referencePoint;
-        if (RS_DIALOGFACTORY->requestMoveRotateDialog(data))
-               {
-            trigger();
-            //finish();
-        }
-        break;
-
-    default:
-        break;
-    }
+               setStatus(ShowDialog);
+               data.offset = targetPoint - data.referencePoint;
+
+               if (RS_DIALOGFACTORY->requestMoveRotateDialog(data))
+                       trigger();
+                       //finish();
+               break;
+
+       default:
+               break;
+       }
 }
 
 void RS_ActionModifyMoveRotate::commandEvent(RS_CommandEvent * e)
@@ -158,6 +147,7 @@ void RS_ActionModifyMoveRotate::commandEvent(RS_CommandEvent * e)
        case SetReferencePoint:
        case SetTargetPoint:
 #warning "Bad comparison (in checkCommand -> rs_actioninterface)... !!! FIX !!!"
+
                if (!c.isEmpty() && checkCommand("angle", c))
 //             if (c == checkCommand("angle", c))
                {
@@ -170,95 +160,106 @@ void RS_ActionModifyMoveRotate::commandEvent(RS_CommandEvent * e)
                break;
 
        case SetAngle:
-               {
-                       bool ok;
-                       double a = RS_Math::eval(c, &ok);
+       {
+               bool ok;
+               double a = RS_Math::eval(c, &ok);
 
-                       if (ok)
-                               data.angle = RS_Math::deg2rad(a);
-                       else
-                               RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               if (ok)
+                       data.angle = RS_Math::deg2rad(a);
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
-                       RS_DIALOGFACTORY->requestOptions(this, true, true);
-                       setStatus(lastStatus);
-               }
-               break;
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
        }
 }
 
 QStringList RS_ActionModifyMoveRotate::getAvailableCommands()
 {
-    QStringList cmd;
+       QStringList cmd;
 
-    switch (getStatus())
+       switch (getStatus())
        {
-    case SetReferencePoint:
-    case SetTargetPoint:
-        cmd += command("angle");
-        break;
+       case SetReferencePoint:
+       case SetTargetPoint:
+               cmd += command("angle");
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
 void RS_ActionModifyMoveRotate::showOptions()
 {
-    //std::cout << "RS_ActionModifyMoveRotate::showOptions()\n";
+       //std::cout << "RS_ActionModifyMoveRotate::showOptions()\n";
 
-    RS_ActionInterface::showOptions();
+       RS_ActionInterface::showOptions();
 
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
 void RS_ActionModifyMoveRotate::hideOptions()
 {
-    //std::cout << "RS_ActionModifyMoveRotate::hideOptions()\n";
+       //std::cout << "RS_ActionModifyMoveRotate::hideOptions()\n";
 
-    RS_ActionInterface::hideOptions();
+       RS_ActionInterface::hideOptions();
 
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
 void RS_ActionModifyMoveRotate::updateMouseButtonHints()
 {
-    switch (getStatus())
+       switch (getStatus())
        {
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
-        break;
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"), tr("Back"));
-        break;
-    case SetAngle:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Enter rotation angle:"), tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
+               break;
+
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"), tr("Back"));
+               break;
+
+       case SetAngle:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter rotation angle:"), tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
 void RS_ActionModifyMoveRotate::updateMouseCursor()
 {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
 void RS_ActionModifyMoveRotate::updateToolBar()
 {
-    switch (getStatus())
+       switch (getStatus())
        {
-    case SetReferencePoint:
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        break;
-    }
+       case SetReferencePoint:
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               break;
+       }
 }
 
+void RS_ActionModifyMoveRotate::setAngle(double a)
+{
+       data.angle = a;
+}
 
-// EOF
+double RS_ActionModifyMoveRotate::getAngle()
+{
+       return data.angle;
+}
index 542abbb5d44c686e2080636562d5180f9edadacd..f370566cdc6b844e6bc1ba7daa18117eb073f0db 100644 (file)
@@ -1,35 +1,9 @@
-/****************************************************************************
-** $Id: rs_actionmodifymoverotate.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYMOVEROTATE_H
 #define RS_ACTIONMODIFYMOVEROTATE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
-
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to move and at the same
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyMoveRotate : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetReferencePoint,    /**< Setting the reference point. */
-        SetTargetPoint,       /**< Setting the target point. */
-        ShowDialog,           /**< Showing the options dialog. */
-               SetAngle              /**< Setting angle in command line. */ 
-    };
-
-public:
-    RS_ActionModifyMoveRotate(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyMoveRotate() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionModifyMoveRotate;
-       }
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       void setAngle(double a) {
-               data.angle = a;
-       }
-       double getAngle() {
-               return data.angle;
-       }
-
-private:
-    RS_MoveRotateData data;
-    Vector targetPoint;
-
-       /** Last status before entering angle. */
-       Status lastStatus;
-       /**
-        * Commands
-        */
-       QString cmdAngle;
-       QString cmdAngle2;
-       QString cmdAngle3;
+class RS_ActionModifyMoveRotate: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetReferencePoint, /**< Setting the reference point. */
+                       SetTargetPoint, /**< Setting the target point. */
+                       ShowDialog, /**< Showing the options dialog. */
+                       SetAngle      /**< Setting angle in command line. */
+               };
+
+       public:
+               RS_ActionModifyMoveRotate(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyMoveRotate();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setAngle(double a);
+               double getAngle();
+
+       private:
+               RS_MoveRotateData data;
+               Vector targetPoint;
+
+               /** Last status before entering angle. */
+               Status lastStatus;
+               /**
+                * Commands
+                */
+               QString cmdAngle;
+               QString cmdAngle2;
+               QString cmdAngle3;
 };
 
 #endif
index bbaf5a060a3f050abd2746f82b4d19ef6c406051..77c102bf1a44d2f80fe4aecbed8052e553325441 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifyrotate.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyrotate.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyrotate.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 
-
-
-RS_ActionModifyRotate::RS_ActionModifyRotate(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Rotate Entities",
-                           container, graphicView) {}
-
-
-QAction* RS_ActionModifyRotate::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyRotate::RS_ActionModifyRotate(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Rotate Entities",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Rotate"), 0);
-//     QAction* action = new QAction(tr("Rotate"), tr("&Rotate"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Rotate Entities"));
-       return action;
 }
 
-void RS_ActionModifyRotate::init(int status) {
-    RS_ActionInterface::init(status);
+RS_ActionModifyRotate::~RS_ActionModifyRotate()
+{
 }
 
+void RS_ActionModifyRotate::init(int status)
+{
+       RS_ActionInterface::init(status);
+}
 
+void RS_ActionModifyRotate::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyRotate::trigger()");
 
-void RS_ActionModifyRotate::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyRotate::trigger()");
-
-    RS_Modification m(*container, graphicView);
-    m.rotate(data);
+       RS_Modification m(*container, graphicView);
+       m.rotate(data);
 
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
+void RS_ActionModifyRotate::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent begin");
 
+       if (getStatus() == SetReferencePoint)
+       {
+               Vector mouse = snapPoint(e);
 
-void RS_ActionModifyRotate::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent begin");
-
-    if (getStatus()==SetReferencePoint) {
-        Vector mouse = snapPoint(e);
-        switch (getStatus()) {
-        case SetReferencePoint:
-            referencePoint = mouse;
-            break;
+               switch (getStatus())
+               {
+               case SetReferencePoint:
+                       referencePoint = mouse;
+                       break;
 
-        default:
-            break;
-        }
-    }
+               default:
+                       break;
+               }
+       }
 
-    RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyRotate::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyRotate::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyRotate::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector pos = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetReferencePoint:
-        referencePoint = pos;
-        setStatus(ShowDialog);
-        if (RS_DIALOGFACTORY->requestRotateDialog(data)) {
-            data.center = referencePoint;
-            trigger();
-            finish();
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionModifyRotate::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector pos = *e;
+
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               referencePoint = pos;
+               setStatus(ShowDialog);
+
+               if (RS_DIALOGFACTORY->requestRotateDialog(data))
+               {
+                       data.center = referencePoint;
+                       trigger();
+                       finish();
+               }
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyRotate::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyRotate::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyRotate::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyRotate::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyRotate::updateToolBar() {
-    switch (getStatus()) {
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        break;
-    }
+void RS_ActionModifyRotate::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               break;
+       }
 }
 
-
 // EOF
index 0f861c261e5a7f679f9d11a6d9ac9e1ac50a718e..ef99098a7d84982958459ad5caa5ce10ba0465d3 100644 (file)
@@ -1,76 +1,43 @@
-/****************************************************************************
-** $Id: rs_actionmodifyrotate.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYROTATE_H
 #define RS_ACTIONMODIFYROTATE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
-
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to move entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyRotate : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetReferencePoint,    /**< Setting the reference point. */
-        ShowDialog            /**< Showing the options dialog. */
-    };
-
-public:
-    RS_ActionModifyRotate(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionModifyRotate() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-       
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_RotateData data;
-    Vector referencePoint;
-    Vector targetPoint;
+class RS_ActionModifyRotate: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetReferencePoint, /**< Setting the reference point. */
+                       ShowDialog /**< Showing the options dialog. */
+               };
+
+       public:
+               RS_ActionModifyRotate(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyRotate();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_RotateData data;
+               Vector referencePoint;
+               Vector targetPoint;
 };
 
 #endif
index 96ba9728c9c90c2857783365a9bbea8e8fa21106..b62704542d82c6174d3c61f2827bfcd8e8012df5 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifyrotate2.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyrotate2.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyrotate2.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 
 RS_ActionModifyRotate2::RS_ActionModifyRotate2(
-       RS_EntityContainer& container, RS_GraphicView& graphicView):
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Rotate Entities around two centers", container, graphicView)
 {
 }
 
-QAction* RS_ActionModifyRotate2::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyRotate2::~RS_ActionModifyRotate2()
 {
-       QAction * action = new QAction(tr("Rotate T&wo"), 0);
-//     QAction* action = new QAction(tr("Rotate Two"), tr("Rotate T&wo"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Rotate Entities around two centers"));
-       return action;
 }
 
 void RS_ActionModifyRotate2::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 }
 
+void RS_ActionModifyRotate2::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyRotate2::trigger()");
 
+       RS_Modification m(*container, graphicView);
+       m.rotate2(data);
 
-void RS_ActionModifyRotate2::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyRotate2::trigger()");
-
-    RS_Modification m(*container, graphicView);
-    m.rotate2(data);
-
-    finish();
+       finish();
 
-       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-
-void RS_ActionModifyRotate2::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent begin");
-
-    if (getStatus()==SetReferencePoint1 ||
-            getStatus()==SetReferencePoint2) {
-
-        Vector mouse = snapPoint(e);
-        switch (getStatus()) {
-        case SetReferencePoint1:
-            data.center1 = mouse;
-            break;
-
-        case SetReferencePoint2:
-            if (data.center1.valid) {
-                data.center2 = mouse;
-                //data.offset = data.center2-data.center1;
-
-                /*deletePreview();
-                clearPreview();
-                preview->addSelectionFrom(*container);
-                preview->rotate(data.center1, data.angle);
-                preview->move(data.offset);
-                drawPreview();
-                */
-            }
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent end");
+void RS_ActionModifyRotate2::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent begin");
+
+       if (getStatus() == SetReferencePoint1
+           || getStatus() == SetReferencePoint2)
+       {
+               Vector mouse = snapPoint(e);
+
+               switch (getStatus())
+               {
+               case SetReferencePoint1:
+                       data.center1 = mouse;
+                       break;
+
+               case SetReferencePoint2:
+
+                       if (data.center1.valid)
+                               data.center2 = mouse;
+                               //data.offset = data.center2-data.center1;
+
+                               /*deletePreview();
+                                  clearPreview();
+                                  preview->addSelectionFrom(*container);
+                                  preview->rotate(data.center1, data.angle);
+                                  preview->move(data.offset);
+                                  drawPreview();
+                                */
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyRotate2::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyRotate2::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyRotate2::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector pos = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetReferencePoint1:
-        data.center1 = pos;
-        setStatus(SetReferencePoint2);
-        break;
-
-    case SetReferencePoint2:
-        data.center2 = pos;
-        setStatus(ShowDialog);
-        if (RS_DIALOGFACTORY->requestRotate2Dialog(data)) {
-            trigger();
-            //finish();
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionModifyRotate2::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector pos = *e;
+
+       switch (getStatus())
+       {
+       case SetReferencePoint1:
+               data.center1 = pos;
+               setStatus(SetReferencePoint2);
+               break;
+
+       case SetReferencePoint2:
+               data.center2 = pos;
+               setStatus(ShowDialog);
+
+               if (RS_DIALOGFACTORY->requestRotate2Dialog(data))
+                       trigger();
+                       //finish();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionModifyRotate2::commandEvent(RS_CommandEvent* /*e*/) {
+void RS_ActionModifyRotate2::commandEvent(RS_CommandEvent * /*e*/)
+{
 }
 
-
-
-QStringList RS_ActionModifyRotate2::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+QStringList RS_ActionModifyRotate2::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
-
-
-
-void RS_ActionModifyRotate2::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetReferencePoint1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify absolute reference point"),
-                                            tr("Cancel"));
-        break;
-    case SetReferencePoint2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify relative reference point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyRotate2::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetReferencePoint1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify absolute reference point"),
+                       tr("Cancel"));
+               break;
+
+       case SetReferencePoint2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify relative reference point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyRotate2::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyRotate2::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyRotate2::updateToolBar() {
-    switch (getStatus()) {
-    case SetReferencePoint1:
-    case SetReferencePoint2:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        break;
-    }
+void RS_ActionModifyRotate2::updateToolBar()
+{
+       switch (getStatus())
+       {
+       case SetReferencePoint1:
+       case SetReferencePoint2:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               break;
+       }
 }
 
-
 // EOF
index 9b8d18d78946743f9f40da015b9903c0d3c03465..af0a254d325b1db17f8321de63a4bca90baeba4d 100644 (file)
@@ -1,35 +1,8 @@
-/****************************************************************************
-** $Id: rs_actionmodifyrotate2.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYROTATE2_H
 #define RS_ACTIONMODIFYROTATE2_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
-
+#include "rs_previewactioninterface.h"
 
 /**
  * This action class can handle user events to rotate entities around
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyRotate2 : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetReferencePoint1,    /**< Setting the reference point. */
-        SetReferencePoint2,    /**< Setting the target point. */
-        ShowDialog             /**< Showing the options dialog. */
-    };
-
-public:
-    RS_ActionModifyRotate2(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyRotate2() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    //virtual void hideOptions();
-    //virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_Rotate2Data data;
+class RS_ActionModifyRotate2: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetReferencePoint1, /**< Setting the reference point. */
+                       SetReferencePoint2, /**< Setting the target point. */
+                       ShowDialog /**< Showing the options dialog. */
+               };
+
+       public:
+               RS_ActionModifyRotate2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyRotate2();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_Rotate2Data data;
 };
 
 #endif
index 8311997098d9d410091b6b5ee1db782c02a4363d..67c0503bd50107087a6ed501e1dca6946cc2edd4 100644 (file)
@@ -1,37 +1,25 @@
-/****************************************************************************
-** $Id: rs_actionmodifyround.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyround.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyround.h"
 
+#include "rs_dialogfactory.h"
 #include "rs_information.h"
-#include "rs_snapper.h"
+#include "rs_preview.h"
 
-RS_ActionModifyRound::RS_ActionModifyRound(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Round Entities", container, graphicView)
+RS_ActionModifyRound::RS_ActionModifyRound(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Round Entities", container, graphicView)
 {
        entity1 = NULL;
        entity2 = NULL;
@@ -39,297 +27,317 @@ RS_ActionModifyRound::RS_ActionModifyRound(RS_EntityContainer& container,
        coord2 = Vector(false);
 }
 
-QAction * RS_ActionModifyRound::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionModifyRound::~RS_ActionModifyRound()
 {
-       QAction * action = new QAction(tr("&Round"), 0);
-//     QAction* action = new QAction(tr("Round"), tr("&Round"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Round Entities"));
-       return action;
+}
+
+/*virtual*/ RS2::ActionType RS_ActionModifyRound::rtti()
+{
+       return RS2::ActionModifyRound;
 }
 
 void RS_ActionModifyRound::init(int status)
 {
-    RS_ActionInterface::init(status);
+       RS_ActionInterface::init(status);
 
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
 }
 
 void RS_ActionModifyRound::trigger()
 {
-    RS_DEBUG->print("RS_ActionModifyRound::trigger()");
+       RS_DEBUG->print("RS_ActionModifyRound::trigger()");
 
-    if (entity1!=NULL && entity1->isAtomic() &&
-            entity2!=NULL && entity2->isAtomic())
+       if (entity1 != NULL && entity1->isAtomic()
+           && entity2 != NULL && entity2->isAtomic())
        {
-        deletePreview();
-
-        RS_Modification m(*container, graphicView);
-        m.round(coord2,
-                coord1,
-                (RS_AtomicEntity*)entity1,
-                coord2,
-                (RS_AtomicEntity*)entity2,
-                data);
-
-        //coord = Vector(false);
-        coord1 = Vector(false);
-        entity1 = NULL;
-        coord2 = Vector(false);
-        entity2 = NULL;
-        setStatus(SetEntity1);
-
-        clearPreview();
-
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-        }
-    }
+               deletePreview();
+
+               RS_Modification m(*container, graphicView);
+               m.round(coord2,
+                       coord1,
+                       (RS_AtomicEntity *)entity1,
+                       coord2,
+                       (RS_AtomicEntity *)entity2,
+                       data);
+
+               //coord = Vector(false);
+               coord1 = Vector(false);
+               entity1 = NULL;
+               coord2 = Vector(false);
+               entity2 = NULL;
+               setStatus(SetEntity1);
+
+               clearPreview();
+
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
 }
 
+void RS_ActionModifyRound::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyRound::mouseMoveEvent begin");
 
+       Vector mouse = graphicView->toGraph(e->x(), e->y());
+       RS_Entity * se = catchEntity(e, RS2::ResolveAll);
 
-void RS_ActionModifyRound::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyRound::mouseMoveEvent begin");
-
-    Vector mouse = graphicView->toGraph(e->x(), e->y());
-    RS_Entity* se = catchEntity(e, RS2::ResolveAll);
-
-    switch (getStatus()) {
-    case SetEntity1:
-        entity1 = se;
-        coord1 = mouse;
-        break;
-
-    case SetEntity2:
-        entity2 = se;
-        coord2 = mouse;
-
-        if (entity1!=NULL && entity2!=NULL && entity2->isAtomic() &&
-                       RS_Information::isTrimmable(entity1, entity2)) {
-
-            deletePreview();
-            clearPreview();
-            //preview->addSelectionFrom(*container);
-            //preview->move(targetPoint-referencePoint);
-            RS_Entity* tmp1 = entity1->clone();
-            RS_Entity* tmp2 = entity2->clone();
-            tmp1->reparent(preview);
-            tmp2->reparent(preview);
-            preview->addEntity(tmp1);
-            preview->addEntity(tmp2);
-
-            bool trim = data.trim;
-            data.trim = false;
-            RS_Modification m(*preview, NULL, false);
-            m.round(coord2,
-                    coord1,
-                    (RS_AtomicEntity*)tmp1,
-                    coord2,
-                    (RS_AtomicEntity*)tmp2,
-                    data);
-            data.trim = trim;
-
-            preview->removeEntity(tmp1);
-            preview->removeEntity(tmp2);
-            drawPreview();
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionModifyRound::mouseMoveEvent end");
+       switch (getStatus())
+       {
+       case SetEntity1:
+               entity1 = se;
+               coord1 = mouse;
+               break;
+
+       case SetEntity2:
+               entity2 = se;
+               coord2 = mouse;
+
+               if (entity1 != NULL && entity2 != NULL && entity2->isAtomic()
+                   && RS_Information::isTrimmable(entity1, entity2))
+               {
+                       deletePreview();
+                       clearPreview();
+                       //preview->addSelectionFrom(*container);
+                       //preview->move(targetPoint-referencePoint);
+                       RS_Entity * tmp1 = entity1->clone();
+                       RS_Entity * tmp2 = entity2->clone();
+                       tmp1->reparent(preview);
+                       tmp2->reparent(preview);
+                       preview->addEntity(tmp1);
+                       preview->addEntity(tmp2);
+
+                       bool trim = data.trim;
+                       data.trim = false;
+                       RS_Modification m(*preview, NULL, false);
+                       m.round(coord2,
+                               coord1,
+                               (RS_AtomicEntity *)tmp1,
+                               coord2,
+                               (RS_AtomicEntity *)tmp2,
+                               data);
+                       data.trim = trim;
+
+                       preview->removeEntity(tmp1);
+                       preview->removeEntity(tmp2);
+                       drawPreview();
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionModifyRound::mouseMoveEvent end");
 }
 
+void RS_ActionModifyRound::mouseReleaseEvent(QMouseEvent * e)
+{
+       Vector mouse = graphicView->toGraph(e->x(), e->y());
+       RS_Entity * se = catchEntity(e, RS2::ResolveAll);
 
-
-void RS_ActionModifyRound::mouseReleaseEvent(QMouseEvent* e) {
-    Vector mouse = graphicView->toGraph(e->x(), e->y());
-    RS_Entity* se = catchEntity(e, RS2::ResolveAll);
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetEntity1:
-            entity1 = se;
-            coord1 = mouse;
-            if (entity1!=NULL && entity1->isAtomic() &&
-                               RS_Information::isTrimmable(entity1)) {
-                setStatus(SetEntity2);
-            }
-            break;
-
-        case SetEntity2:
-            entity2 = se;
-            coord2 = mouse;
-            if (entity2!=NULL && entity2->isAtomic() &&
-                           RS_Information::isTrimmable(entity1, entity2)) {
-                //setStatus(ChooseRounding);
-                trigger();
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetEntity1:
+                       entity1 = se;
+                       coord1 = mouse;
+
+                       if (entity1 != NULL && entity1->isAtomic()
+                           && RS_Information::isTrimmable(entity1))
+                               setStatus(SetEntity2);
+                       break;
+
+               case SetEntity2:
+                       entity2 = se;
+                       coord2 = mouse;
+
+                       if (entity2 != NULL && entity2->isAtomic()
+                           && RS_Information::isTrimmable(entity1, entity2))
+                               //setStatus(ChooseRounding);
+                               trigger();
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionModifyRound::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
 
+       if (checkCommand("help", c))
+       {
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                               + getAvailableCommands().join(", "));
+               return;
+       }
 
-void RS_ActionModifyRound::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        if (RS_DIALOGFACTORY!=NULL) {
-            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                             + getAvailableCommands().join(", "));
-        }
-        return;
-    }
-
-    switch (getStatus()) {
-    case SetEntity1:
-    case SetEntity2:
-        if (checkCommand("radius", c)) {
-            deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetRadius);
-        } else if (checkCommand("trim", c)) {
-            /*deleteSnapper();
-            deletePreview();
-            clearPreview();
-            lastStatus = (Status)getStatus();
-            setStatus(SetTrim);
-            */
-            data.trim = !data.trim;
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-        }
-        break;
-
-    case SetRadius: {
-            bool ok;
-            double r = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                data.radius = r;
-            } else {
-                if (RS_DIALOGFACTORY!=NULL) {
-                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-                }
-            }
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-            }
-            setStatus(lastStatus);
-        }
-        break;
-
-        /*case SetTrim: {
-        if (c==cmdYes.toLower() || c==cmdYes2) {
-        data.trim = true;
-    } else if (c==cmdNo.toLower() || c==cmdNo2) {
-        data.trim = false;
-                } else {
-                    RS_DIALOGFACTORY->commandMessage(tr("Please enter 'Yes' "
-               "or 'No'"));
-                }
-                RS_DIALOGFACTORY->requestOptions(this, true, true);
-                setStatus(lastStatus);
-            }
-            break;*/
-
-    default:
-        break;
-    }
+       switch (getStatus())
+       {
+       case SetEntity1:
+       case SetEntity2:
+
+               if (checkCommand("radius", c))
+               {
+                       deleteSnapper();
+                       deletePreview();
+                       clearPreview();
+                       lastStatus = (Status)getStatus();
+                       setStatus(SetRadius);
+               }
+               else if (checkCommand("trim", c))
+               {
+                       /*deleteSnapper();
+                          deletePreview();
+                          clearPreview();
+                          lastStatus = (Status)getStatus();
+                          setStatus(SetTrim);
+                        */
+                       data.trim = !data.trim;
+
+                       if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               }
+               break;
+
+       case SetRadius: {
+               bool ok;
+               double r = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       data.radius = r;
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+       }
+       break;
+
+       /*case SetTrim: {
+          if (c==cmdYes.toLower() || c==cmdYes2) {
+          data.trim = true;
+          } else if (c==cmdNo.toLower() || c==cmdNo2) {
+          data.trim = false;
+               } else {
+                   RS_DIALOGFACTORY->commandMessage(tr("Please enter 'Yes' "
+              "or 'No'"));
+               }
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(lastStatus);
+           }
+           break;*/
+
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionModifyRound::getAvailableCommands()
+{
+       QStringList cmd;
 
-
-QStringList RS_ActionModifyRound::getAvailableCommands() {
-    QStringList cmd;
-    switch (getStatus()) {
-    case SetEntity1:
-    case SetEntity2:
-        cmd += command("radius");
-        cmd += command("trim");
-        break;
-    default:
-        break;
-    }
-    return cmd;
+       switch (getStatus())
+       {
+       case SetEntity1:
+       case SetEntity2:
+               cmd += command("radius");
+               cmd += command("trim");
+               break;
+
+       default:
+               break;
+       }
+       return cmd;
 }
 
+void RS_ActionModifyRound::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-
-void RS_ActionModifyRound::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, true);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionModifyRound::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionModifyRound::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestOptions(this, false);
-    }
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-
-void RS_ActionModifyRound::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetEntity1:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first entity"),
-                                                tr("Back"));
-            break;
-        case SetEntity2:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second entity"),
-                                                tr("Back"));
-            break;
-        case SetRadius:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Enter radius:"),
-                                                tr("Cancel"));
-            break;
-            /*case SetTrim:
-                RS_DIALOGFACTORY->updateMouseWidget(tr("Trim on? (yes/no):"),
-                                                    "");
-                break;*/
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionModifyRound::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetEntity1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first entity"),
+                               tr("Back"));
+                       break;
+
+               case SetEntity2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second entity"),
+                               tr("Back"));
+                       break;
+
+               case SetRadius:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Enter radius:"),
+                               tr("Cancel"));
+                       break;
+
+               /*case SetTrim:
+                   RS_DIALOGFACTORY->updateMouseWidget(tr("Trim on? (yes/no):"),
+                                                       "");
+                   break;*/
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionModifyRound::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyRound::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionModifyRound::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+}
 
+void RS_ActionModifyRound::setRadius(double r)
+{
+       data.radius = r;
+}
 
-void RS_ActionModifyRound::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-    }
+double RS_ActionModifyRound::getRadius()
+{
+       return data.radius;
 }
 
+void RS_ActionModifyRound::setTrim(bool t)
+{
+       data.trim = t;
+}
 
-// EOF
+bool RS_ActionModifyRound::isTrimOn()
+{
+       return data.trim;
+}
index 1bff4d1b9f3c5e449ec92343562cf6422047628f..37f79c27bc931612606777a1aa4c0e4de4f98427 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifyround.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYROUND_H
 #define RS_ACTIONMODIFYROUND_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to round corners.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyRound : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetEntity1,         /**< Choosing the 1st entity. */
-        SetEntity2,         /**< Choosing the 2nd entity. */
-               SetRadius,          /**< Setting radius in command line. */
-               SetTrim             /**< Setting trim flag in command line. */
-    };
-
-public:
-    RS_ActionModifyRound(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyRound() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-       
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionModifyRound;
-       }
-
-    virtual void init(int status=0);
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-       
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-       
-       void setRadius(double r) {
-               data.radius = r;
-       }
-
-       double getRadius() {
-               return data.radius;
-       }
-
-       void setTrim(bool t) {
-               data.trim = t;
-       }
-
-       bool isTrimOn() {
-               return data.trim;
-       }
-
-private:
-       //Vector coord;
-       Vector coord1;
-    RS_Entity* entity1;
-       Vector coord2;
-    RS_Entity* entity2;
-       RS_RoundData data;
-       /** Last status before entering angle. */
-       Status lastStatus;
+class RS_ActionModifyRound: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetEntity1, /**< Choosing the 1st entity. */
+                       SetEntity2, /**< Choosing the 2nd entity. */
+                       SetRadius,  /**< Setting radius in command line. */
+                       SetTrim     /**< Setting trim flag in command line. */
+               };
+
+       public:
+               RS_ActionModifyRound(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyRound();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void setRadius(double r);
+               double getRadius();
+               void setTrim(bool t);
+               bool isTrimOn();
+
+       private:
+               Vector coord1;
+               RS_Entity * entity1;
+               Vector coord2;
+               RS_Entity * entity2;
+               RS_RoundData data;
+               /** Last status before entering angle. */
+               Status lastStatus;
 };
 
 #endif
index 0697ae390662c686121cf348abc7adfb58d24a58..38e3a5b8c9a4638ff4e467e5aa41a5bddfe72173 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifyscale.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifyscale.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifyscale.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 
-
-
-RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Scale Entities",
-                           container, graphicView) {}
-
-
-QAction* RS_ActionModifyScale::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_PreviewActionInterface("Scale Entities",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Scale"), 0);
-//     QAction* action = new QAction(tr("Scale"), tr("&Scale"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Scale Entities"));
-       return action;
 }
 
-void RS_ActionModifyScale::init(int status) {
-    RS_ActionInterface::init(status);
-
+RS_ActionModifyScale::~RS_ActionModifyScale()
+{
 }
 
+void RS_ActionModifyScale::init(int status)
+{
+       RS_ActionInterface::init(status);
+}
 
+void RS_ActionModifyScale::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyScale::trigger()");
 
-void RS_ActionModifyScale::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyScale::trigger()");
-
-    RS_Modification m(*container, graphicView);
-    m.scale(data);
+       RS_Modification m(*container, graphicView);
+       m.scale(data);
 
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
+void RS_ActionModifyScale::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent begin");
 
+       if (getStatus() == SetReferencePoint)
+       {
+               Vector mouse = snapPoint(e);
 
-void RS_ActionModifyScale::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent begin");
-
-    if (getStatus()==SetReferencePoint) {
-
-        Vector mouse = snapPoint(e);
-        switch (getStatus()) {
-        case SetReferencePoint:
-            referencePoint = mouse;
-            break;
+               switch (getStatus())
+               {
+               case SetReferencePoint:
+                       referencePoint = mouse;
+                       break;
 
-        default:
-            break;
-        }
-    }
+               default:
+                       break;
+               }
+       }
 
-    RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyScale::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        Vector mouse = snapPoint(e);
-
-        switch (getStatus()) {
-        case SetReferencePoint:
-            setStatus(ShowDialog);
-            if (RS_DIALOGFACTORY->requestScaleDialog(data)) {
-                data.referencePoint = referencePoint;
-                trigger();
-                finish();
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyScale::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector mouse = snapPoint(e);
+
+               switch (getStatus())
+               {
+               case SetReferencePoint:
+                       setStatus(ShowDialog);
+
+                       if (RS_DIALOGFACTORY->requestScaleDialog(data))
+                       {
+                               data.referencePoint = referencePoint;
+                               trigger();
+                               finish();
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyScale::updateMouseButtonHints() {
-    switch (getStatus()) {
-        /*case Select:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to scale"),
-                                           tr("Cancel"));
-            break;*/
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyScale::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       /*case Select:
+           RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to scale"),
+                                          tr("Cancel"));
+           break;*/
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
+                       tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyScale::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyScale::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyScale::updateToolBar() {
-    switch (getStatus()) {
-        /*case Select:
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
-            break;*/
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        break;
-    default:
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-        break;
-    }
+void RS_ActionModifyScale::updateToolBar()
+{
+       switch (getStatus())
+       {
+       /*case Select:
+           RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
+           break;*/
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               break;
+
+       default:
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+               break;
+       }
 }
 
-
 // EOF
index 048ffc6f3ceb598e841a9fc1e799cb379bb5956a..0b98a4a5a91fbf16425aba67654fa3aed742380f 100644 (file)
@@ -1,71 +1,42 @@
-/****************************************************************************
-** $Id: rs_actionmodifyscale.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYSCALE_H
 #define RS_ACTIONMODIFYSCALE_H
 
-#include "rs_previewactioninterface.h"
 #include "rs_modification.h"
-
+#include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to move entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyScale : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetReferencePoint,    /**< Setting the reference point. */
-        ShowDialog            /**< Showing the options dialog. */
-    };
-
-public:
-    RS_ActionModifyScale(RS_EntityContainer& container,
-                         RS_GraphicView& graphicView);
-    ~RS_ActionModifyScale() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_ScaleData data;
-    Vector referencePoint;
-    Vector targetPoint;
+class RS_ActionModifyScale: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetReferencePoint, /**< Setting the reference point. */
+                       ShowDialog /**< Showing the options dialog. */
+               };
+
+       public:
+               RS_ActionModifyScale(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyScale();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_ScaleData data;
+               Vector referencePoint;
+               Vector targetPoint;
 };
 
 #endif
index aeeecb9284b71fa2dcef3cf0cb5a67c01346334b..f71e10778c43519bfccb9ef557dd3224ef661173 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifystretch.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifystretch.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifystretch.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_modification.h"
+#include "rs_preview.h"
 
-
-
-RS_ActionModifyStretch::RS_ActionModifyStretch(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Stretch Entities",
-                           container, graphicView) {
-
-    firstCorner = Vector(false);
-    secondCorner = Vector(false);
-    referencePoint = Vector(false);
-    targetPoint = Vector(false);
+RS_ActionModifyStretch::RS_ActionModifyStretch(RS_EntityContainer & container,
+       RS_GraphicView & graphicView): RS_PreviewActionInterface("Stretch Entities",
+               container, graphicView)
+{
+       firstCorner = Vector(false);
+       secondCorner = Vector(false);
+       referencePoint = Vector(false);
+       targetPoint = Vector(false);
 }
 
-QAction* RS_ActionModifyStretch::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyStretch::~RS_ActionModifyStretch()
 {
-       QAction * action = new QAction(tr("&Stretch"), 0);
-//     QAction* action = new QAction(tr("Stretch"), tr("&Stretch"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Stretch Entities"));
-       return action;
 }
 
-
-void RS_ActionModifyStretch::init(int status) {
-    RS_ActionInterface::init(status);
-
+void RS_ActionModifyStretch::init(int status)
+{
+       RS_ActionInterface::init(status);
 }
 
+void RS_ActionModifyStretch::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyStretch::trigger()");
 
+       deletePreview();
+       clearPreview();
 
-void RS_ActionModifyStretch::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyStretch::trigger()");
-
-    deletePreview();
-    clearPreview();
-
-    deleteSnapper();
+       deleteSnapper();
 
-    RS_Modification m(*container, graphicView);
-    m.stretch(firstCorner, secondCorner, targetPoint-referencePoint);
+       RS_Modification m(*container, graphicView);
+       m.stretch(firstCorner, secondCorner, targetPoint - referencePoint);
 
-    drawSnapper();
+       drawSnapper();
 
-    setStatus(SetFirstCorner);
+       setStatus(SetFirstCorner);
 
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
 
-
-
-void RS_ActionModifyStretch::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyStretch::mouseMoveEvent begin");
-
-    Vector mouse = snapPoint(e);
-    switch (getStatus()) {
-    case SetFirstCorner:
-        break;
-
-    case SetSecondCorner:
-        if (firstCorner.valid) {
-            secondCorner = snapPoint(e);
-            deletePreview();
-            clearPreview();
-            preview->addEntity(
-                new RS_Line(preview,
-                            RS_LineData(Vector(firstCorner.x,
-                                                  firstCorner.y),
-                                        Vector(secondCorner.x,
-                                                  firstCorner.y))));
-            preview->addEntity(
-                new RS_Line(preview,
-                            RS_LineData(Vector(secondCorner.x,
-                                                  firstCorner.y),
-                                        Vector(secondCorner.x,
-                                                  secondCorner.y))));
-            preview->addEntity(
-                new RS_Line(preview,
-                            RS_LineData(Vector(secondCorner.x,
-                                                  secondCorner.y),
-                                        Vector(firstCorner.x,
-                                                  secondCorner.y))));
-            preview->addEntity(
-                new RS_Line(preview,
-                            RS_LineData(Vector(firstCorner.x,
-                                                  secondCorner.y),
-                                        Vector(firstCorner.x,
-                                                  firstCorner.y))));
-            drawPreview();
-        }
-        break;
-
-    case SetReferencePoint:
-        break;
-
-    case SetTargetPoint:
-        if (referencePoint.valid) {
-            targetPoint = mouse;
-
-            deletePreview();
-            clearPreview();
-            preview->addStretchablesFrom(*container, firstCorner, secondCorner);
-            //preview->move(targetPoint-referencePoint);
-            preview->stretch(firstCorner, secondCorner,
-                             targetPoint-referencePoint);
-            drawPreview();
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionModifyStretch::mouseMoveEvent end");
+void RS_ActionModifyStretch::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyStretch::mouseMoveEvent begin");
+
+       Vector mouse = snapPoint(e);
+
+       switch (getStatus())
+       {
+       case SetFirstCorner:
+               break;
+
+       case SetSecondCorner:
+
+               if (firstCorner.valid)
+               {
+                       secondCorner = snapPoint(e);
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(
+                               new RS_Line(preview,
+                                       RS_LineData(Vector(firstCorner.x,
+                                                       firstCorner.y),
+                                               Vector(secondCorner.x,
+                                                       firstCorner.y))));
+                       preview->addEntity(
+                               new RS_Line(preview,
+                                       RS_LineData(Vector(secondCorner.x,
+                                                       firstCorner.y),
+                                               Vector(secondCorner.x,
+                                                       secondCorner.y))));
+                       preview->addEntity(
+                               new RS_Line(preview,
+                                       RS_LineData(Vector(secondCorner.x,
+                                                       secondCorner.y),
+                                               Vector(firstCorner.x,
+                                                       secondCorner.y))));
+                       preview->addEntity(
+                               new RS_Line(preview,
+                                       RS_LineData(Vector(firstCorner.x,
+                                                       secondCorner.y),
+                                               Vector(firstCorner.x,
+                                                       firstCorner.y))));
+                       drawPreview();
+               }
+               break;
+
+       case SetReferencePoint:
+               break;
+
+       case SetTargetPoint:
+
+               if (referencePoint.valid)
+               {
+                       targetPoint = mouse;
+
+                       deletePreview();
+                       clearPreview();
+                       preview->addStretchablesFrom(*container, firstCorner, secondCorner);
+                       //preview->move(targetPoint-referencePoint);
+                       preview->stretch(firstCorner, secondCorner,
+                               targetPoint - referencePoint);
+                       drawPreview();
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionModifyStretch::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyStretch::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyStretch::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyStretch::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    Vector mouse = e->getCoordinate();
-
-    switch (getStatus()) {
-    case SetFirstCorner:
-        firstCorner = mouse;
-        setStatus(SetSecondCorner);
-        break;
-
-    case SetSecondCorner:
-        secondCorner = mouse;
-        deletePreview();
-        clearPreview();
-        setStatus(SetReferencePoint);
-        break;
-
-    case SetReferencePoint:
-        referencePoint = mouse;
-        graphicView->moveRelativeZero(referencePoint);
-        setStatus(SetTargetPoint);
-        break;
-
-    case SetTargetPoint:
-        targetPoint = mouse;
-        graphicView->moveRelativeZero(targetPoint);
-        trigger();
-        //finish();
-        break;
-
-    default:
-        break;
-    }
-
+void RS_ActionModifyStretch::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
+
+       Vector mouse = *e;
+
+       switch (getStatus())
+       {
+       case SetFirstCorner:
+               firstCorner = mouse;
+               setStatus(SetSecondCorner);
+               break;
+
+       case SetSecondCorner:
+               secondCorner = mouse;
+               deletePreview();
+               clearPreview();
+               setStatus(SetReferencePoint);
+               break;
+
+       case SetReferencePoint:
+               referencePoint = mouse;
+               graphicView->moveRelativeZero(referencePoint);
+               setStatus(SetTargetPoint);
+               break;
+
+       case SetTargetPoint:
+               targetPoint = mouse;
+               graphicView->moveRelativeZero(targetPoint);
+               trigger();
+               //finish();
+               break;
+
+       default:
+               break;
+       }
 }
 
-
-void RS_ActionModifyStretch::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetFirstCorner:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
-                                            tr("Cancel"));
-        break;
-    case SetSecondCorner:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
-                                            tr("Back"));
-        break;
-    case SetReferencePoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
-                                            tr("Back"));
-        break;
-    case SetTargetPoint:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyStretch::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetFirstCorner:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
+                       tr("Cancel"));
+               break;
+
+       case SetSecondCorner:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
+                       tr("Back"));
+               break;
+
+       case SetReferencePoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
+                       tr("Back"));
+               break;
+
+       case SetTargetPoint:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyStretch::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyStretch::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyStretch::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
-    }
+void RS_ActionModifyStretch::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
 }
 
-
 // EOF
index efa0074a4baaf3f4febd87b24ed4318991e4dd2a..f4c4849afec3e7c4124aa0605d1631fb2b6ad4e9 100644 (file)
@@ -1,77 +1,46 @@
-/****************************************************************************
-** $Id: rs_actionmodifystretch.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYSTRETCH_H
 #define RS_ACTIONMODIFYSTRETCH_H
 
 #include "rs_previewactioninterface.h"
-#include "rs_modification.h"
-
+#include "vector.h"
 
 /**
  * This action class can handle user events to move entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyStretch : public RS_PreviewActionInterface {
+class RS_ActionModifyStretch: public RS_PreviewActionInterface
+{
        //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-               SetFirstCorner,       /**< Setting first corner of selection. */
-               SetSecondCorner,      /**< Setting second corner of selection. */
-        SetReferencePoint,    /**< Setting the reference point. */
-        SetTargetPoint        /**< Setting the target point. */
-    };
-
-public:
-    RS_ActionModifyStretch(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyStretch() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-       Vector firstCorner;
-       Vector secondCorner;
-    Vector referencePoint;
-    Vector targetPoint;
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetFirstCorner, /**< Setting first corner of selection. */
+                       SetSecondCorner, /**< Setting second corner of selection. */
+                       SetReferencePoint, /**< Setting the reference point. */
+                       SetTargetPoint /**< Setting the target point. */
+               };
+
+       public:
+               RS_ActionModifyStretch(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyStretch();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void coordinateEvent(Vector * e);
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               Vector firstCorner;
+               Vector secondCorner;
+               Vector referencePoint;
+               Vector targetPoint;
 };
 
 #endif
index 281a455cf0c12079efd2370efd6e52f80133f9da..611d0128fb3125f82b5e0b15aa3d34a377463a94 100644 (file)
 
 #include "rs_actionmodifytrim.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_modification.h"
 
 /**
  * @param both Trim both entities.
  */
-RS_ActionModifyTrim::RS_ActionModifyTrim(RS_EntityContainer& container,
-        RS_GraphicView& graphicView, bool both)
-        :RS_PreviewActionInterface("Trim Entity",
-                           container, graphicView) {
-
-    trimEntity = NULL;
-    trimCoord = Vector(false);
-    limitEntity = NULL;
-    limitCoord = Vector(false);
-    this->both = both;
+RS_ActionModifyTrim::RS_ActionModifyTrim(RS_EntityContainer & container,
+       RS_GraphicView & graphicView, bool both): RS_PreviewActionInterface("Trim Entity",
+               container, graphicView)
+{
+       trimEntity = NULL;
+       trimCoord = Vector(false);
+       limitEntity = NULL;
+       limitCoord = Vector(false);
+       this->both = both;
 }
 
-QAction * RS_ActionModifyTrim::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionModifyTrim::~RS_ActionModifyTrim()
 {
-       QAction * action;
-
-       switch (type)
-       {
-       default:
-       case RS2::ActionModifyTrim:
-               action = new QAction(tr("&Trim"), 0);
-//             action = new QAction(tr("Trim"), tr("&Trim"),
-//                                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Trim Entities"));
-               break;
-
-       case RS2::ActionModifyTrim2:
-               action = new QAction(tr("&Trim Two"), 0);
-//             action = new QAction(tr("Trim Two"), tr("&Trim Two"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Trim two Entities"));
-               break;
-       }
-
-       return action;
 }
 
+void RS_ActionModifyTrim::init(int status)
+{
+       RS_ActionInterface::init(status);
 
-void RS_ActionModifyTrim::init(int status) {
-    RS_ActionInterface::init(status);
-
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
-
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
 }
 
+void RS_ActionModifyTrim::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyTrim::trigger()");
 
-
-void RS_ActionModifyTrim::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyTrim::trigger()");
-
-    if (trimEntity!=NULL && trimEntity->isAtomic() &&
-            limitEntity!=NULL /* && limitEntity->isAtomic()*/) {
-
-        RS_Modification m(*container, graphicView);
-        m.trim(trimCoord, (RS_AtomicEntity*)trimEntity,
-               limitCoord, /*(RS_AtomicEntity*)*/limitEntity,
-               both);
-
-        trimEntity = NULL;
-        if (both) {
-            limitEntity->setHighlighted(false);
-            graphicView->drawEntity(limitEntity);
-            setStatus(ChooseLimitEntity);
-        } else {
-            setStatus(ChooseTrimEntity);
-        }
-
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    }
+       if (trimEntity != NULL && trimEntity->isAtomic()
+           && limitEntity != NULL /* && limitEntity->isAtomic()*/)
+       {
+               RS_Modification m(*container, graphicView);
+               m.trim(trimCoord, (RS_AtomicEntity *)trimEntity,
+                       limitCoord, /*(RS_AtomicEntity*)*/ limitEntity,
+                       both);
+
+               trimEntity = NULL;
+
+               if (both)
+               {
+                       limitEntity->setHighlighted(false);
+                       graphicView->drawEntity(limitEntity);
+                       setStatus(ChooseLimitEntity);
+               }
+               else
+                       setStatus(ChooseTrimEntity);
+
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
 }
 
+void RS_ActionModifyTrim::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionModifyTrim::mouseMoveEvent begin");
 
+       Vector mouse = graphicView->toGraph(e->x(), e->y());
+       RS_Entity * se = catchEntity(e);
 
-void RS_ActionModifyTrim::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionModifyTrim::mouseMoveEvent begin");
-
-    Vector mouse = graphicView->toGraph(e->x(), e->y());
-    RS_Entity* se = catchEntity(e);
-
-    switch (getStatus()) {
-    case ChooseLimitEntity:
-        limitCoord = mouse;
-        limitEntity = se;
-        break;
+       switch (getStatus())
+       {
+       case ChooseLimitEntity:
+               limitCoord = mouse;
+               limitEntity = se;
+               break;
 
-    case ChooseTrimEntity:
-        trimCoord = mouse;
-        trimEntity = se;
-        break;
+       case ChooseTrimEntity:
+               trimCoord = mouse;
+               trimEntity = se;
+               break;
 
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    RS_DEBUG->print("RS_ActionModifyTrim::mouseMoveEvent end");
+       RS_DEBUG->print("RS_ActionModifyTrim::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionModifyTrim::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-
-        Vector mouse = graphicView->toGraph(e->x(), e->y());
-        RS_Entity* se = catchEntity(e);
-
-        switch (getStatus()) {
-        case ChooseLimitEntity:
-            limitCoord = mouse;
-            limitEntity = se;
-            if (limitEntity!=NULL /*&& limitEntity->isAtomic()*/) {
-                limitEntity->setHighlighted(true);
-                graphicView->drawEntity(limitEntity);
-                setStatus(ChooseTrimEntity);
-            }
-            break;
-
-        case ChooseTrimEntity:
-            trimCoord = mouse;
-            trimEntity = se;
-            if (trimEntity!=NULL && trimEntity->isAtomic()) {
-                trigger();
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        if (limitEntity!=NULL) {
-            limitEntity->setHighlighted(false);
-            graphicView->drawEntity(limitEntity);
-        }
-        init(getStatus()-1);
-    }
+void RS_ActionModifyTrim::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector mouse = graphicView->toGraph(e->x(), e->y());
+               RS_Entity * se = catchEntity(e);
+
+               switch (getStatus())
+               {
+               case ChooseLimitEntity:
+                       limitCoord = mouse;
+                       limitEntity = se;
+
+                       if (limitEntity != NULL /*&& limitEntity->isAtomic()*/)
+                       {
+                               limitEntity->setHighlighted(true);
+                               graphicView->drawEntity(limitEntity);
+                               setStatus(ChooseTrimEntity);
+                       }
+                       break;
+
+               case ChooseTrimEntity:
+                       trimCoord = mouse;
+                       trimEntity = se;
+
+                       if (trimEntity != NULL && trimEntity->isAtomic())
+                               trigger();
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+
+               if (limitEntity != NULL)
+               {
+                       limitEntity->setHighlighted(false);
+                       graphicView->drawEntity(limitEntity);
+               }
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionModifyTrim::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case ChooseLimitEntity:
+
+               if (both)
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select first trim entity"),
+                               tr("Cancel"));
+               else
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select limiting entity"),
+                               tr("Back"));
+               break;
 
+       case ChooseTrimEntity:
 
-void RS_ActionModifyTrim::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case ChooseLimitEntity:
-        if (both) {
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select first trim entity"),
-                                                tr("Cancel"));
-        } else {
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select limiting entity"),
-                                                tr("Back"));
-        }
-        break;
-    case ChooseTrimEntity:
-        if (both) {
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select second trim entity"),
-                                                tr("Cancel"));
-        } else {
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Select entity to trim"),
-                                                tr("Back"));
-        }
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
-}
-
-
+               if (both)
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select second trim entity"),
+                               tr("Cancel"));
+               else
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Select entity to trim"),
+                               tr("Back"));
+               break;
 
-void RS_ActionModifyTrim::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyTrim::updateToolBar() {
-    RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+void RS_ActionModifyTrim::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
+void RS_ActionModifyTrim::updateToolBar()
+{
+       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+}
 
index b66b8b417637ec99118b420df032eb0165e8f1ee..5c374069b51e0f40260f0895039c48c6252b6a0e 100644 (file)
@@ -2,47 +2,44 @@
 #define RS_ACTIONMODIFYTRIM_H
 
 #include "rs_previewactioninterface.h"
-#include "rs_modification.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to trim entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyTrim : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        ChooseLimitEntity,     /**< Choosing the limiting entity. */
-        ChooseTrimEntity       /**< Choosing the entity to trim. */
-    };
-
-public:
-    RS_ActionModifyTrim(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView,
-                                               bool both=false);
-    ~RS_ActionModifyTrim() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_Entity* limitEntity;
-       Vector limitCoord;
-    RS_Entity* trimEntity;
-       Vector trimCoord;
-       bool both;
+class RS_ActionModifyTrim: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       ChooseLimitEntity, /**< Choosing the limiting entity. */
+                       ChooseTrimEntity /**< Choosing the entity to trim. */
+               };
+
+       public:
+               RS_ActionModifyTrim(RS_EntityContainer & container, RS_GraphicView & graphicView, bool both = false);
+               ~RS_ActionModifyTrim();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_Entity * limitEntity;
+               Vector limitCoord;
+               RS_Entity * trimEntity;
+               Vector trimCoord;
+               bool both;
 };
 
 #endif
index 9513135e0572c8f0698a15690e6c0bdb92b5a884..65666c82c203f99af5ff0395ef42a0602e69920b 100644 (file)
-/****************************************************************************
-** $Id: rs_actionmodifytrimamount.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionmodifytrimamount.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionmodifytrimamount.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
+#include "rs_modification.h"
 
 RS_ActionModifyTrimAmount::RS_ActionModifyTrimAmount(
-    RS_EntityContainer& container,
-    RS_GraphicView& graphicView)
-        :RS_ActionInterface("Trim Entity by a given amount",
-                    container, graphicView) {
-
-    trimEntity = NULL;
-    trimCoord = Vector(false);
-    distance = 0.0;
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Trim Entity by a given amount",
+               container, graphicView)
+{
+       trimEntity = NULL;
+       trimCoord = Vector(false);
+       distance = 0.0;
 }
 
-QAction* RS_ActionModifyTrimAmount::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionModifyTrimAmount::~RS_ActionModifyTrimAmount()
 {
-       QAction * action = new QAction(tr("&Lengthen"), 0);
-//     QAction* action = new QAction(tr("Lengthen"), tr("&Lengthen"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Lengthen by a given amount"));
-       return action;
 }
 
-void RS_ActionModifyTrimAmount::init(int status)
+/*virtual*/ RS2::ActionType RS_ActionModifyTrimAmount::rtti()
 {
-    RS_ActionInterface::init(status);
-
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
+       return RS2::ActionModifyTrimAmount;
 }
 
+void RS_ActionModifyTrimAmount::init(int status)
+{
+       RS_ActionInterface::init(status);
 
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
+}
 
-void RS_ActionModifyTrimAmount::trigger() {
-
-    RS_DEBUG->print("RS_ActionModifyTrimAmount::trigger()");
-
-    if (trimEntity!=NULL && trimEntity->isAtomic()) {
+void RS_ActionModifyTrimAmount::trigger()
+{
+       RS_DEBUG->print("RS_ActionModifyTrimAmount::trigger()");
 
-        RS_Modification m(*container, graphicView);
-        m.trimAmount(trimCoord, (RS_AtomicEntity*)trimEntity, distance);
+       if (trimEntity != NULL && trimEntity->isAtomic())
+       {
+               RS_Modification m(*container, graphicView);
+               m.trimAmount(trimCoord, (RS_AtomicEntity *)trimEntity, distance);
 
-        trimEntity = NULL;
-        setStatus(ChooseTrimEntity);
+               trimEntity = NULL;
+               setStatus(ChooseTrimEntity);
 
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    }
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
 }
 
-
-
-void RS_ActionModifyTrimAmount::mouseReleaseEvent(QMouseEvent* e) {
-
-    trimCoord = graphicView->toGraph(e->x(), e->y());
-    trimEntity = catchEntity(e);
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case ChooseTrimEntity:
-            if (trimEntity!=NULL && trimEntity->isAtomic()) {
-                trigger();
-            } else {
-                if (trimEntity==NULL) {
-                    RS_DIALOGFACTORY->commandMessage(
-                        tr("No entity found. "));
-                } else if (trimEntity->rtti()==RS2::EntityInsert) {
-                    RS_DIALOGFACTORY->commandMessage(
-                        tr("The chosen Entity is in a block. "
-                           "Please edit the block."));
-                } else {
-                    RS_DIALOGFACTORY->commandMessage(
-                        tr("The chosen Entity is not an atomic entity "
-                           "or cannot be trimmed."));
-                }
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionModifyTrimAmount::mouseReleaseEvent(QMouseEvent * e)
+{
+       trimCoord = graphicView->toGraph(e->x(), e->y());
+       trimEntity = catchEntity(e);
+
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case ChooseTrimEntity:
+
+                       if (trimEntity != NULL && trimEntity->isAtomic())
+                               trigger();
+                       else
+                       {
+                               if (trimEntity == NULL)
+                                       RS_DIALOGFACTORY->commandMessage(
+                                               tr("No entity found. "));
+                               else if (trimEntity->rtti() == RS2::EntityInsert)
+                                       RS_DIALOGFACTORY->commandMessage(
+                                               tr("The chosen Entity is in a block. "
+                                                       "Please edit the block."));
+                               else
+                                       RS_DIALOGFACTORY->commandMessage(
+                                               tr("The chosen Entity is not an atomic entity "
+                                                       "or cannot be trimmed."));
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionModifyTrimAmount::commandEvent(RS_CommandEvent* e) {
-    QString c = e->getCommand().toLower();
-
-    if (checkCommand("help", c)) {
-        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
-                                         + getAvailableCommands().join(", "));
-        return;
-    }
-
-    switch (getStatus()) {
-    case ChooseTrimEntity: {
-            bool ok;
-            double d = RS_Math::eval(c, &ok);
-            if (ok==true) {
-                distance = d;
-            } else {
-                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
-            }
-            RS_DIALOGFACTORY->requestOptions(this, true, true);
-            setStatus(ChooseTrimEntity);
-        }
-        break;
-
-    default:
-        break;
-    }
+void RS_ActionModifyTrimAmount::commandEvent(RS_CommandEvent * e)
+{
+       QString c = e->getCommand().toLower();
+
+       if (checkCommand("help", c))
+       {
+               RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+                       + getAvailableCommands().join(", "));
+               return;
+       }
+
+       switch (getStatus())
+       {
+       case ChooseTrimEntity: {
+               bool ok;
+               double d = RS_Math::eval(c, &ok);
+
+               if (ok == true)
+                       distance = d;
+               else
+                       RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+               RS_DIALOGFACTORY->requestOptions(this, true, true);
+               setStatus(ChooseTrimEntity);
+       }
+       break;
+
+       default:
+               break;
+       }
 }
 
+QStringList RS_ActionModifyTrimAmount::getAvailableCommands()
+{
+       QStringList cmd;
 
+       switch (getStatus())
+       {
+       case ChooseTrimEntity:
+               break;
 
-QStringList RS_ActionModifyTrimAmount::getAvailableCommands() {
-    QStringList cmd;
-
-    switch (getStatus()) {
-    case ChooseTrimEntity:
-        break;
-    default:
-        break;
-    }
+       default:
+               break;
+       }
 
-    return cmd;
+       return cmd;
 }
 
+void RS_ActionModifyTrimAmount::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-void RS_ActionModifyTrimAmount::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionModifyTrimAmount::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
-
-void RS_ActionModifyTrimAmount::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+       RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
-
-void RS_ActionModifyTrimAmount::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case ChooseTrimEntity:
-        RS_DIALOGFACTORY->updateMouseWidget(
-            tr("Select entity to trim or enter distance:"),
-            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionModifyTrimAmount::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case ChooseTrimEntity:
+               RS_DIALOGFACTORY->updateMouseWidget(
+                       tr("Select entity to trim or enter distance:"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionModifyTrimAmount::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionModifyTrimAmount::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionModifyTrimAmount::updateToolBar() {
-    RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
+void RS_ActionModifyTrimAmount::updateToolBar()
+{
+       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
 }
 
+double RS_ActionModifyTrimAmount::getDistance()
+{
+       return distance;
+}
 
-// EOF
+void RS_ActionModifyTrimAmount::setDistance(double d)
+{
+       distance = d;
+}
index a26e33f97a6e0d7812046e81d2a7475b9d4660ed..3cb02c0be9d8b5360be1f3a2349c51b97b23f53a 100644 (file)
@@ -1,35 +1,10 @@
-/****************************************************************************
-** $Id: rs_actionmodifytrimamount.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONMODIFYTRIMAMOUNT_H
 #define RS_ACTIONMODIFYTRIMAMOUNT_H
 
 #include "rs_previewactioninterface.h"
-#include "rs_modification.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to trim entities by a given
  *
  * @author Andrew Mustun
  */
-class RS_ActionModifyTrimAmount : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        ChooseTrimEntity      /**< Choosing the entity to trim. */
-    };
-
-public:
-    RS_ActionModifyTrimAmount(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionModifyTrimAmount() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionModifyTrimAmount;
-       }
-
-    virtual void init(int status=0);
-       
-    virtual void trigger();
-
-    //virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-    virtual void hideOptions();
-    virtual void showOptions();
-       
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-       
-       double getDistance() {
-               return distance;
-       }
-
-       void setDistance(double d) {
-               distance = d;
-       }
-
-private:
-    RS_Entity* trimEntity;
-       Vector trimCoord;
-       double distance;
-       /**
-        * Commands
-        */
-       /*
-       QString cmdDistance;
-       QString cmdDistance2;
-       QString cmdDistance3;
-       */
+class RS_ActionModifyTrimAmount: public RS_ActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       ChooseTrimEntity /**< Choosing the entity to trim. */
+               };
+
+       public:
+               RS_ActionModifyTrimAmount(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionModifyTrimAmount();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               //virtual void mouseMoveEvent(QMouseEvent* e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void hideOptions();
+               virtual void showOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               double getDistance();
+               void setDistance(double d);
+
+       private:
+               RS_Entity * trimEntity;
+               Vector trimCoord;
+               double distance;
 };
 
 #endif
index 4b220d97fe202f974c6b4531c0aa1ee291aedb1f..54c866fa702752d32e9819fea938fdd2006d2e8b 100644 (file)
@@ -1,69 +1,55 @@
-/****************************************************************************
-** $Id: rs_actionoptionsdrawing.cpp 1090 2004-03-16 10:02:59Z js $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionoptionsdrawing.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionoptionsdrawing.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 #include "rs_graphicview.h"
 
-RS_ActionOptionsDrawing::RS_ActionOptionsDrawing(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionOptionsDrawing::RS_ActionOptionsDrawing(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Drawing Options", container, graphicView)
 {
 }
 
-QAction* RS_ActionOptionsDrawing::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionOptionsDrawing::~RS_ActionOptionsDrawing()
 {
-       QAction * action = new QAction(tr("Current &Drawing Preferences..."), 0);
-//     QAction* action = new QAction(tr("Drawing"), tr("Current &Drawing Preferences")+"...",
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Settings for the current Drawing"));
-       return action;
 }
 
-void RS_ActionOptionsDrawing::init(int status)
+/*virtual*/ RS2::ActionType RS_ActionOptionsDrawing::rtti()
 {
-    RS_ActionInterface::init(status);
-
-    trigger();
+       return RS2::ActionOptionsDrawing;
 }
 
+void RS_ActionOptionsDrawing::init(int status)
+{
+       RS_ActionInterface::init(status);
 
-
-void RS_ActionOptionsDrawing::trigger() {
-    if (graphic!=NULL) {
-        RS_DIALOGFACTORY->requestOptionsDrawingDialog(*graphic);
-        RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0,0.0),
-                Vector(0.0,0.0),
-                true);
-        graphicView->updateGrid();
-        graphicView->redraw();
-    }
-    finish();
+       trigger();
 }
 
+void RS_ActionOptionsDrawing::trigger()
+{
+       if (graphic != NULL)
+       {
+               RS_DIALOGFACTORY->requestOptionsDrawingDialog(*graphic);
+               RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0),
+                       Vector(0.0, 0.0),
+                       true);
+               graphicView->updateGrid();
+               graphicView->redraw();
+       }
+       finish();
+}
 
 // EOF
index 0fcf43499f62d70e726f1c346055ad2736147af9..d9bfc58594be54b5d528606a1c097b02e09b3e22 100644 (file)
@@ -1,57 +1,23 @@
-/****************************************************************************
-** $Id: rs_actionoptionsdrawing.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONOPTIONSDRAWING_H
 #define RS_ACTIONOPTIONSDRAWING_H
 
 #include "rs_actioninterface.h"
 
-
 /**
- * This action class can handle user events to change general 
+ * This action class can handle user events to change general
  * application options.
  *
  * @author Andrew Mustun
  */
-class RS_ActionOptionsDrawing : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionOptionsDrawing(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView);
-    ~RS_ActionOptionsDrawing() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionOptionsDrawing;
-       }
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
+class RS_ActionOptionsDrawing: public RS_ActionInterface
+{
+       public:
+               RS_ActionOptionsDrawing(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionOptionsDrawing();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index 22dc058e34ed4903e50476a324636861fb47aa86..e280e57116d2d5ad68b7f9c293b6e33ca1b03da4 100644 (file)
@@ -1,81 +1,66 @@
-/****************************************************************************
-** $Id: rs_actionprintpreview.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionprintpreview.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionprintpreview.h"
-//Added by qt3to4:
-#include <QPixmap>
+
+#include "rs_dialogfactory.h"
+#include "drawing.h"
+#include "rs_graphicview.h"
 
 /**
  * Constructor.
  */
-RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Print Preview",
-                    container, graphicView) {
-    showOptions();
+RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Print Preview",
+               container, graphicView)
+{
+       showOptions();
 }
 
-
-
-RS_ActionPrintPreview::~RS_ActionPrintPreview() {
+RS_ActionPrintPreview::~RS_ActionPrintPreview()
+{
 }
 
-
-QAction* RS_ActionPrintPreview::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionPrintPreview::rtti()
 {
-       QAction * action = new QAction(QIcon(":/res/fileprintpreview.png"), tr("Print Pre&view"), 0);
-//     QAction* action = new QAction(tr("Print Preview"), QPixmap::fromMimeSource("fileprintpreview.png"), tr("Print Pre&view"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Shows a preview of a print"));
-       return action;
+       return RS2::ActionPrintPreview;
 }
 
-
-void RS_ActionPrintPreview::init(int status) {
-    RS_ActionInterface::init(status);
-    showOptions();
+void RS_ActionPrintPreview::init(int status)
+{
+       RS_ActionInterface::init(status);
+       showOptions();
 }
 
+void RS_ActionPrintPreview::trigger()
+{
+}
 
-
-
-void RS_ActionPrintPreview::trigger() {}
-
-
-
-void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent* e) {
-       switch (getStatus()) {
+void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
        case Moving:
                v2 = graphicView->toGraph(e->x(), e->y());
-               if (graphic!=NULL) {
+
+               if (graphic != NULL)
+               {
                        Vector pinsbase = graphic->getPaperInsertionBase();
 
                        double scale = graphic->getPaperScale();
 
-                       graphic->setPaperInsertionBase(pinsbase-v2*scale+v1*scale);
+                       graphic->setPaperInsertionBase(pinsbase - v2 * scale + v1 * scale);
                }
                v1 = v2;
                graphicView->redraw();
@@ -86,137 +71,133 @@ void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent* e) {
        }
 }
 
-
-
-void RS_ActionPrintPreview::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case Neutral:
-            v1 = graphicView->toGraph(e->x(), e->y());
-            setStatus(Moving);
-            break;
-
-        default:
-            break;
-        }
-    }
+void RS_ActionPrintPreview::mousePressEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case Neutral:
+                       v1 = graphicView->toGraph(e->x(), e->y());
+                       setStatus(Moving);
+                       break;
+
+               default:
+                       break;
+               }
+       }
 }
 
-
-void RS_ActionPrintPreview::mouseReleaseEvent(QMouseEvent* e) {
-       switch (getStatus()) {
+void RS_ActionPrintPreview::mouseReleaseEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
        case Moving:
                setStatus(Neutral);
                break;
 
-    default:
-        //deleteSnapper();
-        RS_DIALOGFACTORY->requestPreviousMenu();
-#if QT_VERSION>=0x030000
-        e->accept();
+       default:
+               //deleteSnapper();
+               RS_DIALOGFACTORY->requestPreviousMenu();
+#if QT_VERSION >= 0x030000
+               e->accept();
 #endif
-        break;
+               break;
        }
 }
 
-
-
-void RS_ActionPrintPreview::coordinateEvent(RS_CoordinateEvent* ) {}
-
-
-
-void RS_ActionPrintPreview::commandEvent(RS_CommandEvent* ) {}
-
-
-
-QStringList RS_ActionPrintPreview::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+void RS_ActionPrintPreview::coordinateEvent(Vector *)
+{
 }
 
-
-void RS_ActionPrintPreview::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+void RS_ActionPrintPreview::commandEvent(RS_CommandEvent *)
+{
 }
 
-
-
-void RS_ActionPrintPreview::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+QStringList RS_ActionPrintPreview::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
+void RS_ActionPrintPreview::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-void RS_ActionPrintPreview::updateMouseButtonHints() {}
-
-
-
-void RS_ActionPrintPreview::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::MovingHandCursor);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionPrintPreview::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
+       RS_DIALOGFACTORY->requestOptions(this, false);
+}
 
-void RS_ActionPrintPreview::updateToolBar() {}
-
+void RS_ActionPrintPreview::updateMouseButtonHints()
+{
+}
 
-void RS_ActionPrintPreview::center() {
-    if (graphic!=NULL) {
-        graphic->centerToPage();
-        graphicView->redraw();
-    }
+void RS_ActionPrintPreview::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::MovingHandCursor);
 }
 
+void RS_ActionPrintPreview::updateToolBar()
+{
+}
 
-void RS_ActionPrintPreview::fit() {
-    if (graphic!=NULL) {
-        graphic->fitToPage();
-        graphicView->redraw();
-    }
+void RS_ActionPrintPreview::center()
+{
+       if (graphic != NULL)
+       {
+               graphic->centerToPage();
+               graphicView->redraw();
+       }
 }
 
+void RS_ActionPrintPreview::fit()
+{
+       if (graphic != NULL)
+       {
+               graphic->fitToPage();
+               graphicView->redraw();
+       }
+}
 
-void RS_ActionPrintPreview::setScale(double f) {
-    if (graphic!=NULL) {
+void RS_ActionPrintPreview::setScale(double f)
+{
+       if (graphic != NULL)
+       {
                graphic->setPaperScale(f);
-       graphicView->redraw();
+               graphicView->redraw();
        }
 }
 
-
-
-double RS_ActionPrintPreview::getScale() {
+double RS_ActionPrintPreview::getScale()
+{
        double ret = 1.0;
-    if (graphic!=NULL) {
+
+       if (graphic != NULL)
                ret = graphic->getPaperScale();
-       }
        return ret;
 }
 
-
-
-void RS_ActionPrintPreview::setBlackWhite(bool bw) {
-    if (bw) {
-        graphicView->setDrawingMode(RS2::ModeBW);
-    }
-       else {
-        graphicView->setDrawingMode(RS2::ModeFull);
-       }
+void RS_ActionPrintPreview::setBlackWhite(bool bw)
+{
+       if (bw)
+               graphicView->setDrawingMode(RS2::ModeBW);
+       else
+               graphicView->setDrawingMode(RS2::ModeFull);
        graphicView->redraw();
 }
 
-
-RS2::Unit RS_ActionPrintPreview::getUnit() {
-    if (graphic!=NULL) {
+RS2::Unit RS_ActionPrintPreview::getUnit()
+{
+       if (graphic != NULL)
                return graphic->getUnit();
-       }
-       else {
+       else
                return RS2::None;
-       }
 }
 
-
 // EOF
index c6970f902f51adf95a2eb390f53e3e4565282270..3e94eacf699bafb27330c169576a461ef2403c1c 100644 (file)
@@ -1,95 +1,54 @@
-/****************************************************************************
-** $Id: rs_actionprintpreview.h 1117 2004-04-09 19:57:47Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONPRINTPREVIEW_H
 #define RS_ACTIONPRINTPREVIEW_H
 
+#include "rs.h"
 #include "rs_actioninterface.h"
+#include "vector.h"
 
 /**
  * Default action for print preview.
  *
  * @author Andrew Mustun
  */
-class RS_ActionPrintPreview : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-               Neutral,
-               Moving
-    };
-
-public:
-    RS_ActionPrintPreview(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionPrintPreview();
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionPrintPreview;
-       }
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void coordinateEvent(RS_CoordinateEvent* e);
-    virtual void commandEvent(RS_CommandEvent* e);
-       virtual QStringList getAvailableCommands();
-
-       virtual void showOptions();
-       virtual void hideOptions();
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-       void center();
-       void fit();
-       void setScale(double f);
-       double getScale();
-
-       void setBlackWhite(bool bw);
-       //bool isBlackWhite() {
-       //      return blackWhite;
-       //}
-       RS2::Unit getUnit();
-
-protected:
-       //bool blackWhite;
-       Vector v1;
-       Vector v2;
+class RS_ActionPrintPreview: public RS_ActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       Neutral,
+                       Moving
+               };
+
+       public:
+               RS_ActionPrintPreview(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionPrintPreview();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void commandEvent(RS_CommandEvent * e);
+               virtual QStringList getAvailableCommands();
+               virtual void showOptions();
+               virtual void hideOptions();
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+               void center();
+               void fit();
+               void setScale(double f);
+               double getScale();
+               void setBlackWhite(bool bw);
+               RS2::Unit getUnit();
+
+       protected:
+               Vector v1;
+               Vector v2;
 };
 
 #endif
index 9f9f04f714803d9ab970b545981ac31bc2c36074..88d73b7ec6cc6e2e4b0e126c09aa9ece73b67a4f 100644 (file)
@@ -1,41 +1,33 @@
-/****************************************************************************
-** $Id: rs_actionselect.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionselect.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionselect.h"
 
-#include "rs_snapper.h"
 #include "rs_actionselectsingle.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 
-RS_ActionSelect::RS_ActionSelect(RS_EntityContainer & container,
-       RS_GraphicView & graphicView, RS2::ActionType nextAction):
+RS_ActionSelect::RS_ActionSelect(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ActionType nextAction):
        RS_ActionInterface("Select Entities", container, graphicView)
 {
        this->nextAction = nextAction;
 }
 
+RS_ActionSelect::~RS_ActionSelect()
+{
+}
+
 void RS_ActionSelect::init(int status)
 {
        RS_ActionInterface::init(status);
@@ -58,5 +50,3 @@ void RS_ActionSelect::updateToolBar()
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
        }
 }
-
-// EOF
index cf642987002e3553830c97efd0d940bc69c4de7e..eb400a493eda5076e097ba83a4b5e7b37ad2c982 100644 (file)
@@ -1,55 +1,25 @@
-/****************************************************************************
-** $Id: rs_actionselect.h 1047 2003-11-26 18:14:32Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECT_H
 #define RS_ACTIONSELECT_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to select entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelect : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelect(RS_EntityContainer& container,
-                    RS_GraphicView& graphicView,
-                    RS2::ActionType nextAction);
-    ~RS_ActionSelect() {}
+class RS_ActionSelect: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelect(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ActionType nextAction);
+               ~RS_ActionSelect();
 
-    void init(int status);
-    //virtual void keyPressEvent(QKeyEvent* e);
-    void mouseReleaseEvent(QMouseEvent* e);
-    void updateToolBar();
+               void init(int status);
+               void mouseReleaseEvent(QMouseEvent * e);
+               void updateToolBar();
 
-private:
-    RS2::ActionType nextAction;
+       private:
+               RS2::ActionType nextAction;
 };
 
 #endif
index b3a0e220b6462a4b9436af1a62a285e3469aa614..9a58bfe2571f406e4c4f02cd9a584ce9c54cf8aa 100644 (file)
@@ -9,43 +9,29 @@
 //
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
-// JLH  05/22/2010  Added this text. :-)
+// JLH  06/22/2010  Added this text. :-)
 //
 
 #include "rs_actionselectall.h"
+
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
 
-RS_ActionSelectAll::RS_ActionSelectAll(RS_EntityContainer& container,
-       RS_GraphicView& graphicView, bool select):
+RS_ActionSelectAll::RS_ActionSelectAll(RS_EntityContainer & container,
+       RS_GraphicView & graphicView, bool select):
        RS_ActionInterface("Select All Entities", container, graphicView)
 {
-    this->select = select;
+       this->select = select;
 }
 
-QAction * RS_ActionSelectAll::createGUIAction(RS2::ActionType type, QObject * parent)
+RS_ActionSelectAll::~RS_ActionSelectAll()
 {
-       QAction * action;
-
-       if (type == RS2::ActionSelectAll)
-       {
-               action = new QAction(tr("Select &All"), parent);
-               action->setShortcut(Qt::CTRL + Qt::Key_A);
-//             action = new QAction(tr("Select All"), tr("Select &All"),
-//                                                             CTRL+Key_A, parent);
-               action->setStatusTip(tr("Selects all Entities"));
-       }
-       else
-       {
-               action = new QAction(tr("Deselect &all"), parent);
-               action->setShortcut(Qt::CTRL + Qt::Key_K);
-//             action = new QAction(tr("Deselect all"), tr("Deselect &all"),
-//                                                             CTRL+Key_K, parent);
-               action->setStatusTip(tr("Deselects all Entities"));
-       }
-
-       return action;
 }
 
+/*virtual*/ RS2::ActionType RS_ActionSelectAll::rtti()
+{
+       return RS2::ActionSelectAll;
+}
 
 void RS_ActionSelectAll::init(int status)
 {
@@ -61,5 +47,3 @@ void RS_ActionSelectAll::trigger()
 
        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
-
-// EOF
index d032c438a80c90c7a7bba6132bc6f8929746c4a1..c12d0289f8da73b98f7d85a193102886c34e4f9e 100644 (file)
@@ -3,31 +3,23 @@
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to select all entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectAll : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelectAll(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView,
-                       bool select);
-    ~RS_ActionSelectAll() {}
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* parent);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectAll;
-       }
-
-    void init(int status);
-    virtual void trigger();
-
-protected:
-    bool select;
+class RS_ActionSelectAll: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelectAll(RS_EntityContainer & container, RS_GraphicView & graphicView, bool select);
+               ~RS_ActionSelectAll();
+
+               virtual RS2::ActionType rtti();
+               void init(int status);
+               virtual void trigger();
+
+       protected:
+               bool select;
 };
 
 #endif
index d8a3d49483f1532644fb8b5c420898773be85455..c065235ba9e885998bbfb95f8bec7557dfb556a2 100644 (file)
@@ -1,56 +1,42 @@
-/****************************************************************************
-** $Id: rs_actionselectbase.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionselectbase.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionselectbase.h"
 
+#include "rs_graphicview.h"
 
+RS_ActionSelectBase::RS_ActionSelectBase(const char * name,
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface(name, container, graphicView)
+{
+}
 
-RS_ActionSelectBase::RS_ActionSelectBase(const char* name,
-        RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface(name,
-                    container, graphicView) {}
-
-
+RS_ActionSelectBase::~RS_ActionSelectBase()
+{
+}
 
 /**
  * Default behaviour of this method is triggering the predecesing
  * action and finishing this one when the enter key is pressed.
  */
-void RS_ActionSelectBase::keyReleaseEvent(QKeyEvent* e) {
-    if (e->key()==Qt::Key_Return && predecessor!=NULL) {
-        finish();
-    }
+void RS_ActionSelectBase::keyReleaseEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Return && predecessor != NULL)
+               finish();
 }
 
-
-
-void RS_ActionSelectBase::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionSelectBase::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
-
-
-// EOF
index 9cf25efe9e9386e2c5fb392b10f0c78b2e087adf..0908ffc7f8effc7a4d68c5cfda6c1e063d0e8c1e 100644 (file)
@@ -1,50 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionselectbase.h 973 2003-08-09 22:39:50Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECTBASE_H
 #define RS_ACTIONSELECTBASE_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This class is the base class to all select actions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectBase : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelectBase(const char* name,
-                        RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionSelectBase() {}
+class RS_ActionSelectBase: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelectBase(const char * name, RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSelectBase();
 
-    virtual void keyReleaseEvent(QKeyEvent* e);
-    virtual void updateMouseCursor();
+               virtual void keyReleaseEvent(QKeyEvent * e);
+               virtual void updateMouseCursor();
 };
 
 #endif
index ccad43a4f8eef1c1b793a444671461a089f0bc84..378a905c2ce138d1adab73d59021bb1331c2c42d 100644 (file)
@@ -1,88 +1,73 @@
-/****************************************************************************
-** $Id: rs_actionselectcontour.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionselectcontour.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionselectcontour.h"
 
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
-#include "rs_snapper.h"
 
-
-
-RS_ActionSelectContour::RS_ActionSelectContour(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Select Contours", container, graphicView) {
-
-    en = NULL;
+RS_ActionSelectContour::RS_ActionSelectContour(RS_EntityContainer & container,
+       RS_GraphicView & graphicView):
+       RS_ActionInterface("Select Contours", container, graphicView)
+{
+       en = NULL;
 }
 
-QAction* RS_ActionSelectContour::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionSelectContour::~RS_ActionSelectContour()
 {
-       QAction * action = new QAction(tr("(De-)Select &Contour"), 0);
-//     QAction* action = new QAction(tr("(De-)Select Contour"), tr("(De-)Select &Contour"),
-//                                                             QKeySequence(), NULL);
-       action->setStatusTip(tr("(De-)Selects connected entities"));
-       return action;
 }
 
-
-void RS_ActionSelectContour::trigger() {
-    if (en!=NULL) {
-        if (en->isAtomic()) {
-            RS_Selection s(*container, graphicView);
-            s.selectContour(en);
-
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-            }
-        } else {
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->commandMessage(
-                    tr("Entity must be an Atomic Entity."));
-            }
-        }
-    } else {
-        RS_DEBUG->print("RS_ActionSelectContour::trigger: Entity is NULL\n");
-    }
+/*virtual*/ RS2::ActionType RS_ActionSelectContour::rtti()
+{
+       return RS2::ActionSelectContour;
 }
 
-
-
-void RS_ActionSelectContour::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-        en = catchEntity(e);
-        trigger();
-    }
+void RS_ActionSelectContour::trigger()
+{
+       if (en != NULL)
+       {
+               if (en->isAtomic())
+               {
+                       RS_Selection s(*container, graphicView);
+                       s.selectContour(en);
+
+                       if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+               }
+               else if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->commandMessage(
+                               tr("Entity must be an Atomic Entity."));
+
+       }
+       else
+               RS_DEBUG->print("RS_ActionSelectContour::trigger: Entity is NULL\n");
 }
 
+void RS_ActionSelectContour::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else
+       {
+               en = catchEntity(e);
+               trigger();
+       }
+}
 
-
-void RS_ActionSelectContour::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionSelectContour::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
 
 // EOF
index 63947a00bb874da8beaed3df2e65d4b5baf24e3d..7e32c54852b21f79781a7a1d5a49f47db06e0c9e 100644 (file)
@@ -1,59 +1,28 @@
-/****************************************************************************
-** $Id: rs_actionselectcontour.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECTCONTOURS_H
 #define RS_ACTIONSELECTCONTOURS_H
 
 #include "rs_actioninterface.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to select contours.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectContour : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelectContour(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionSelectContour() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectContour;
-       }
-
-    virtual void trigger();
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseCursor();
-
-private:
-    RS_Entity* en;
+class RS_ActionSelectContour: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelectContour(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSelectContour();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseCursor();
+
+       private:
+               RS_Entity * en;
 };
 
 #endif
index 7d6e25c2288f97269aab33b9d9dfdf4a238a8603..dc158d5c4cee3596d11023ac9adee1531d050e86 100644 (file)
@@ -14,9 +14,9 @@
 
 #include "rs_actionselectintersected.h"
 
-#include "rs.h"
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
+#include "rs_preview.h"
 
 /**
  * Constructor.
  * @param select true: select window. false: deselect window
  */
 RS_ActionSelectIntersected::RS_ActionSelectIntersected(
-       RS_EntityContainer& container, RS_GraphicView& graphicView, bool select):
+       RS_EntityContainer & container, RS_GraphicView & graphicView, bool select):
        RS_PreviewActionInterface("Select Intersected", container, graphicView)
 {
        this->select = select;
 }
 
-QAction * RS_ActionSelectIntersected::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionSelectIntersected::~RS_ActionSelectIntersected()
 {
-       QAction * action;
-
-       if (type == RS2::ActionSelectIntersected)
-       {
-               action = new QAction(tr("In&tersected Entities"), 0);
-//             action = new QAction(tr("Select Intersected Entities"), tr("In&tersected Entities"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Selects all entities intersected by a line"));
-       }
-       else
-       {
-               action = new QAction(tr("Deselect Inte&rsected Entities"), 0);
-//             action = new QAction(tr("Deselect Intersected Entities"),
-//                                                             tr("Deselect Inte&rsected Entities"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Deselects all entities intersected by a line"));
-       }
+}
 
-       return action;
+/*virtual*/ RS2::ActionType RS_ActionSelectIntersected::rtti()
+{
+       return RS2::ActionSelectIntersected;
 }
 
 void RS_ActionSelectIntersected::init(int status)
 {
-    RS_PreviewActionInterface::init(status);
+       RS_PreviewActionInterface::init(status);
 
-    v1 = v2 = Vector(false);
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
+       v1 = v2 = Vector(false);
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
 }
 
 void RS_ActionSelectIntersected::trigger()
 {
-    RS_PreviewActionInterface::trigger();
+       RS_PreviewActionInterface::trigger();
 
-    if (v1.valid && v2.valid) {
-        if (graphicView->toGuiDX(v1.distanceTo(v2))>10) {
-            deleteSnapper();
+       if (v1.valid && v2.valid)
+               if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
+               {
+                       deleteSnapper();
 
-            RS_Selection s(*container, graphicView);
-            s.selectIntersected(v1, v2, select);
+                       RS_Selection s(*container, graphicView);
+                       s.selectIntersected(v1, v2, select);
 
-            if (RS_DIALOGFACTORY!=NULL) {
-                RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-            }
+                       if (RS_DIALOGFACTORY != NULL)
+                               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 
-            init();
-        }
-    }
+                       init();
+               }
 }
 
-void RS_ActionSelectIntersected::mouseMoveEvent(QMouseEvent* e)
+void RS_ActionSelectIntersected::mouseMoveEvent(QMouseEvent * e)
 {
-    if (getStatus()==SetPoint2 && v1.valid) {
-        v2 = snapPoint(e);
-        deletePreview();
-        clearPreview();
-        preview->addEntity(new RS_Line(preview,
-                                       RS_LineData(Vector(v1.x, v1.y),
-                                                   Vector(v2.x, v2.y))));
-        drawPreview();
-    }
+       if (getStatus() == SetPoint2 && v1.valid)
+       {
+               v2 = snapPoint(e);
+               deletePreview();
+               clearPreview();
+               preview->addEntity(new RS_Line(preview,
+                               RS_LineData(Vector(v1.x, v1.y),
+                                       Vector(v2.x, v2.y))));
+               drawPreview();
+       }
 }
 
+void RS_ActionSelectIntersected::mousePressEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetPoint1:
+                       v1 = snapPoint(e);
+                       setStatus(SetPoint2);
+                       break;
+
+               default:
+                       break;
+               }
+       }
 
-
-void RS_ActionSelectIntersected::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetPoint1:
-            v1 = snapPoint(e);
-            setStatus(SetPoint2);
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    RS_DEBUG->print("RS_ActionSelectIntersected::mousePressEvent(): %f %f",
-                    v1.x, v1.y);
+       RS_DEBUG->print("RS_ActionSelectIntersected::mousePressEvent(): %f %f",
+               v1.x, v1.y);
 }
 
+void RS_ActionSelectIntersected::mouseReleaseEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionSelectIntersected::mouseReleaseEvent()");
 
-
-void RS_ActionSelectIntersected::mouseReleaseEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionSelectIntersected::mouseReleaseEvent()");
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        if (getStatus()==SetPoint2) {
-            deletePreview();
-        }
-        deleteSnapper();
-        init(getStatus()-1);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        if (getStatus()==SetPoint2) {
-            v2 = snapPoint(e);
-            trigger();
-        }
-    }
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               if (getStatus() == SetPoint2)
+                       deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+               if (getStatus() == SetPoint2)
+               {
+                       v2 = snapPoint(e);
+                       trigger();
+               }
 }
 
-
-
-void RS_ActionSelectIntersected::updateMouseButtonHints() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        switch (getStatus()) {
-        case SetPoint1:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first point of intersection line"), tr("Cancel"));
-            break;
-        case SetPoint2:
-            RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second point of intersection line"), tr("Back"));
-            break;
-        default:
-            RS_DIALOGFACTORY->updateMouseWidget("", "");
-            break;
-        }
-    }
+void RS_ActionSelectIntersected::updateMouseButtonHints()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               switch (getStatus())
+               {
+               case SetPoint1:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first point of intersection line"), tr("Cancel"));
+                       break;
+
+               case SetPoint2:
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second point of intersection line"), tr("Back"));
+                       break;
+
+               default:
+                       RS_DIALOGFACTORY->updateMouseWidget("", "");
+                       break;
+               }
+       }
 }
 
-
-
-void RS_ActionSelectIntersected::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionSelectIntersected::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
 
-
-
-void RS_ActionSelectIntersected::updateToolBar() {
-    if (RS_DIALOGFACTORY!=NULL) {
-        if (!isFinished()) {
-            //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
-        } else {
-            RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
-        }
-    }
+void RS_ActionSelectIntersected::updateToolBar()
+{
+       if (RS_DIALOGFACTORY != NULL)
+       {
+               if (!isFinished())
+                       //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
+               else
+                       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
+       }
 }
 
 // EOF
index 4217c8560daf7c5945c71ee472fa0ca0f9900f91..9697d1e5d6cca2559ebf79a9cda43fec6761a6e2 100644 (file)
@@ -4,52 +4,41 @@
 #include "rs_previewactioninterface.h"
 #include "vector.h"
 
-
 /**
  * This action class can handle user events to select all entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectIntersected : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetPoint1,     /**< Setting the 1st corner of the window.  */
-        SetPoint2      /**< Setting the 2nd corner of the window. */
-    };
-
-public:
-    RS_ActionSelectIntersected(RS_EntityContainer& container,
-                         RS_GraphicView& graphicView,
-                         bool select);
-    ~RS_ActionSelectIntersected() {}
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectIntersected;
-       }
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    Vector v1;
-    Vector v2;
-
-    bool select;
+class RS_ActionSelectIntersected: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetPoint1, /**< Setting the 1st corner of the window.  */
+                       SetPoint2 /**< Setting the 2nd corner of the window. */
+               };
+
+       public:
+               RS_ActionSelectIntersected(RS_EntityContainer & container, RS_GraphicView & graphicView, bool select);
+               ~RS_ActionSelectIntersected();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               Vector v1;
+               Vector v2;
+
+               bool select;
 };
 
 #endif
index ff31d274af8e8c372a9c51a332812ba91718bbb9..8451e146aa63a9f54f01c147664e8375542faf85 100644 (file)
@@ -1,60 +1,48 @@
-/****************************************************************************
-** $Id: rs_actionselectinvert.cpp 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionselectinvert.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionselectinvert.h"
+
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
 
-RS_ActionSelectInvert::RS_ActionSelectInvert(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Invert Selection",
-                    container, graphicView) {
+RS_ActionSelectInvert::RS_ActionSelectInvert(RS_EntityContainer & container,
+       RS_GraphicView & graphicView): RS_ActionInterface("Invert Selection",
+               container, graphicView)
+{
 }
 
-
-QAction* RS_ActionSelectInvert::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionSelectInvert::~RS_ActionSelectInvert()
 {
-       QAction * action = new QAction(tr("&Invert Selection"), 0);
-//     QAction* action = new QAction(tr("Invert Selection"), tr("&Invert Selection"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Inverts the current selection"));
-       return action;
 }
 
+/*virtual*/ RS2::ActionType RS_ActionSelectInvert::rtti()
+{
+       return RS2::ActionSelectInvert;
+}
 
-void RS_ActionSelectInvert::init(int status) {
-    RS_ActionInterface::init(status);
-    trigger();
-    finish();
+void RS_ActionSelectInvert::init(int status)
+{
+       RS_ActionInterface::init(status);
+       trigger();
+       finish();
 }
 
-void RS_ActionSelectInvert::trigger() {
-    RS_Selection s(*container, graphicView);
-    s.invertSelection();
+void RS_ActionSelectInvert::trigger()
+{
+       RS_Selection s(*container, graphicView);
+       s.invertSelection();
 
-    RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 }
-
-// EOF
index a55ba95d74ced0bbda02998e299abb20f81ad51c..5a4a2bbdbf6177bae2db8dd42494b75b978dbb39 100644 (file)
@@ -1,55 +1,22 @@
-/****************************************************************************
-** $Id: rs_actionselectinvert.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECTINVERT_H
 #define RS_ACTIONSELECTINVERT_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to select all entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectInvert : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelectInvert(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionSelectInvert() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectInvert;
-       }
-
-    void init(int status);
-    virtual void trigger();
+class RS_ActionSelectInvert: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelectInvert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSelectInvert();
+
+               virtual RS2::ActionType rtti();
+               void init(int status);
+               virtual void trigger();
 };
 
 #endif
index 883241611ac976b4568ab031569337852d7e1c54..933d01206704ddd8855c76fc2b10b4b93ad53d5e 100644 (file)
@@ -1,79 +1,65 @@
-/****************************************************************************
-** $Id: rs_actionselectlayer.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionselectlayer.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionselectlayer.h"
 
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
 
-RS_ActionSelectLayer::RS_ActionSelectLayer(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Select Layers", container, graphicView) {
+RS_ActionSelectLayer::RS_ActionSelectLayer(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Select Layers", container, graphicView)
+{
+       en = NULL;
+}
 
-    en = NULL;
+RS_ActionSelectLayer::~RS_ActionSelectLayer()
+{
 }
 
-QAction* RS_ActionSelectLayer::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionSelectLayer::rtti()
 {
-       QAction * action = new QAction(tr("(De-)Select Layer"), 0);
-//     QAction* action = new QAction(tr("(De-)Select Layer"), tr("(De-)Select Layer"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("(De-)Selects layers"));
-       return action;
+       return RS2::ActionSelectLayer;
 }
 
 void RS_ActionSelectLayer::trigger()
 {
-    if (en != NULL)
+       if (en != NULL)
        {
-        RS_Selection s(*container, graphicView);
-        s.selectLayer(en);
-        if (RS_DIALOGFACTORY!=NULL)
-               {
-            RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-        }
-    } else {
-        RS_DEBUG->print("RS_ActionSelectLayer::trigger: Entity is NULL\n");
-    }
-}
-
-
+               RS_Selection s(*container, graphicView);
+               s.selectLayer(en);
 
-void RS_ActionSelectLayer::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-        en = catchEntity(e);
-        trigger();
-    }
+               if (RS_DIALOGFACTORY != NULL)
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
+       else
+               RS_DEBUG->print("RS_ActionSelectLayer::trigger: Entity is NULL\n");
 }
 
+void RS_ActionSelectLayer::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else
+       {
+               en = catchEntity(e);
+               trigger();
+       }
+}
 
-
-void RS_ActionSelectLayer::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionSelectLayer::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
 
 // EOF
index 049ca792e692736608bb981bbd3c83df74458d05..6c6e714e519aed7e06e3670450fb710b07c3eb1d 100644 (file)
@@ -1,59 +1,28 @@
-/****************************************************************************
-** $Id: rs_actionselectlayer.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECTLAYER_H
 #define RS_ACTIONSELECTLAYER_H
 
 #include "rs_actioninterface.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to select contours.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectLayer : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelectLayer(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionSelectLayer() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectLayer;
-       }
-
-    virtual void trigger();
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseCursor();
-
-private:
-    RS_Entity* en;
+class RS_ActionSelectLayer: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelectLayer(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSelectLayer();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseCursor();
+
+       private:
+               RS_Entity * en;
 };
 
 #endif
index 7f1fac0ebad6ed64289e2b882f9872b98770e386..507b11cae4037d8a3e4f0c0040954fb602d29153 100644 (file)
@@ -1,86 +1,70 @@
-/****************************************************************************
-** $Id: rs_actionselectsingle.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionselectsingle.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionselectsingle.h"
 
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
 
-
-
-RS_ActionSelectSingle::RS_ActionSelectSingle(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Select Entities", container, graphicView) {
-
-    en = NULL;
+RS_ActionSelectSingle::RS_ActionSelectSingle(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Select Entities", container, graphicView)
+{
+       en = NULL;
 }
 
-
-QAction* RS_ActionSelectSingle::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+RS_ActionSelectSingle::~RS_ActionSelectSingle()
 {
-       QAction * action = new QAction(tr("(De-)&Select Entity"), 0);
-//     QAction* action = new QAction(tr("Select Entity"), tr("(De-)&Select Entity"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Selects single Entities"));
-       return action;
 }
 
-
-void RS_ActionSelectSingle::trigger() {
-    if (en!=NULL) {
-        RS_Selection s(*container, graphicView);
-        s.selectSingle(en);
-
-        RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-    } else {
-        RS_DEBUG->print("RS_ActionSelectSingle::trigger: Entity is NULL\n");
-    }
+/*virtual*/ RS2::ActionType RS_ActionSelectSingle::rtti()
+{
+       return RS2::ActionSelectSingle;
 }
 
-
-void RS_ActionSelectSingle::keyPressEvent(QKeyEvent* e) {
-    if (e->key()==Qt::Key_Enter) {
-        finish();
-    }
+void RS_ActionSelectSingle::trigger()
+{
+       if (en != NULL)
+       {
+               RS_Selection s(*container, graphicView);
+               s.selectSingle(en);
+
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       }
+       else
+               RS_DEBUG->print("RS_ActionSelectSingle::trigger: Entity is NULL\n");
 }
 
-
-void RS_ActionSelectSingle::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else {
-        en = catchEntity(e);
-        trigger();
-    }
+void RS_ActionSelectSingle::keyPressEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Enter)
+               finish();
 }
 
+void RS_ActionSelectSingle::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else
+       {
+               en = catchEntity(e);
+               trigger();
+       }
+}
 
-
-void RS_ActionSelectSingle::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionSelectSingle::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
 
 // EOF
index e822374116684fe545e142644475eb7b64a104f7..17e9547e71262be0f35fd651c35fd90e2640788d 100644 (file)
@@ -1,60 +1,29 @@
-/****************************************************************************
-** $Id: rs_actionselectsingle.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSELECTSINGLE_H
 #define RS_ACTIONSELECTSINGLE_H
 
 #include "rs_actioninterface.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to select entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectSingle : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSelectSingle(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionSelectSingle() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectSingle;
-       }
-
-    virtual void trigger();
-    virtual void keyPressEvent(QKeyEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseCursor();
-
-private:
-    RS_Entity* en;
+class RS_ActionSelectSingle: public RS_ActionInterface
+{
+       public:
+               RS_ActionSelectSingle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSelectSingle();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void keyPressEvent(QKeyEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseCursor();
+
+       private:
+               RS_Entity * en;
 };
 
 #endif
index 8351f8567457b983c7a25b4b3362dbe7e1068498..f0da9bfe60dfa1d84daab99fa90033b94f1b9136 100644 (file)
 
 #include "rs_actionselectwindow.h"
 
-#include "rs.h"
-#include "rs_snapper.h"
+#include "rs_dialogfactory.h"
 #include "rs_selection.h"
+#include "rs_preview.h"
 
 /**
  * Constructor.
  *
  * @param select true: select window. false: deselect window
  */
-RS_ActionSelectWindow::RS_ActionSelectWindow(RS_EntityContainer& container,
-        RS_GraphicView& graphicView,
-        bool select)
-        : RS_PreviewActionInterface("Select Window",
-                            container, graphicView) {
-
-    this->select = select;
+RS_ActionSelectWindow::RS_ActionSelectWindow(RS_EntityContainer & container,
+       RS_GraphicView & graphicView, bool select):
+       RS_PreviewActionInterface("Select Window", container, graphicView)
+{
+       this->select = select;
 }
 
-QAction * RS_ActionSelectWindow::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionSelectWindow::~RS_ActionSelectWindow()
 {
-       QAction * action;
-
-       if (type == RS2::ActionSelectWindow)
-       {
-               action = new QAction(tr("Select &Window"), 0);
-//             action = new QAction(tr("Select Window"), tr("Select &Window"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Selects all Entities in a given Window"));
-       }
-       else
-       {
-               action = new QAction(tr("Deselect &Window"), 0);
-//             action = new QAction(tr("Deselect Window"), tr("Deselect &Window"),
-//                                                             QKeySequence(), NULL);
-               action->setStatusTip(tr("Deselects all Entities in a given Window"));
-       }
+}
 
-       return action;
+/*virtual*/ RS2::ActionType RS_ActionSelectWindow::rtti()
+{
+       return RS2::ActionSelectWindow;
 }
 
 void RS_ActionSelectWindow::init(int status)
 {
-    RS_PreviewActionInterface::init(status);
-    v1 = v2 = Vector(false);
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
+       RS_PreviewActionInterface::init(status);
+       v1 = v2 = Vector(false);
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
 }
 
+void RS_ActionSelectWindow::trigger()
+{
+       RS_PreviewActionInterface::trigger();
 
+       if (v1.valid && v2.valid)
+       {
+               if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
+               {
+                       deleteSnapper();
 
-void RS_ActionSelectWindow::trigger() {
-    RS_PreviewActionInterface::trigger();
-
-    if (v1.valid && v2.valid) {
-        if (graphicView->toGuiDX(v1.distanceTo(v2))>10) {
-            deleteSnapper();
-
-            bool cross = (v2.y>v1.y);
+                       bool cross = (v2.y > v1.y);
 
-            RS_Selection s(*container, graphicView);
-            s.selectWindow(v1, v2, select, cross);
+                       RS_Selection s(*container, graphicView);
+                       s.selectWindow(v1, v2, select, cross);
 
-            RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
 
-            init();
-        }
-    }
+                       init();
+               }
+       }
 }
 
-
-
-void RS_ActionSelectWindow::mouseMoveEvent(QMouseEvent* e) {
-    if (getStatus()==SetCorner2 && v1.valid) {
-        v2 = snapPoint(e);
-        deletePreview();
-        clearPreview();
-        preview->addEntity(new RS_Line(preview,
-                                       RS_LineData(Vector(v1.x, v1.y),
-                                                   Vector(v2.x, v1.y))));
-        preview->addEntity(new RS_Line(preview,
-                                       RS_LineData(Vector(v2.x, v1.y),
-                                                   Vector(v2.x, v2.y))));
-        preview->addEntity(new RS_Line(preview,
-                                       RS_LineData(Vector(v2.x, v2.y),
-                                                   Vector(v1.x, v2.y))));
-        preview->addEntity(new RS_Line(preview,
-                                       RS_LineData(Vector(v1.x, v2.y),
-                                                   Vector(v1.x, v1.y))));
-        drawPreview();
-    }
+void RS_ActionSelectWindow::mouseMoveEvent(QMouseEvent * e)
+{
+       if (getStatus() == SetCorner2 && v1.valid)
+       {
+               v2 = snapPoint(e);
+               deletePreview();
+               clearPreview();
+               preview->addEntity(new RS_Line(preview,
+                               RS_LineData(Vector(v1.x, v1.y),
+                                       Vector(v2.x, v1.y))));
+               preview->addEntity(new RS_Line(preview,
+                               RS_LineData(Vector(v2.x, v1.y),
+                                       Vector(v2.x, v2.y))));
+               preview->addEntity(new RS_Line(preview,
+                               RS_LineData(Vector(v2.x, v2.y),
+                                       Vector(v1.x, v2.y))));
+               preview->addEntity(new RS_Line(preview,
+                               RS_LineData(Vector(v1.x, v2.y),
+                                       Vector(v1.x, v1.y))));
+               drawPreview();
+       }
 }
 
+void RS_ActionSelectWindow::mousePressEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case SetCorner1:
+                       v1 = snapPoint(e);
+                       setStatus(SetCorner2);
+                       break;
+
+               default:
+                       break;
+               }
+       }
 
-
-void RS_ActionSelectWindow::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case SetCorner1:
-            v1 = snapPoint(e);
-            setStatus(SetCorner2);
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    RS_DEBUG->print("RS_ActionSelectWindow::mousePressEvent(): %f %f",
-                    v1.x, v1.y);
+       RS_DEBUG->print("RS_ActionSelectWindow::mousePressEvent(): %f %f",
+               v1.x, v1.y);
 }
 
+void RS_ActionSelectWindow::mouseReleaseEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionSelectWindow::mouseReleaseEvent()");
 
-
-void RS_ActionSelectWindow::mouseReleaseEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionSelectWindow::mouseReleaseEvent()");
-
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        if (getStatus()==SetCorner2) {
-            v2 = snapPoint(e);
-            trigger();
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        if (getStatus()==SetCorner2) {
-            deletePreview();
-        }
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               if (getStatus() == SetCorner2)
+               {
+                       v2 = snapPoint(e);
+                       trigger();
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               if (getStatus() == SetCorner2)
+                       deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
+void RS_ActionSelectWindow::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case SetCorner1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first edge"), tr("Cancel"));
+               break;
 
+       case SetCorner2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"), tr("Back"));
+               break;
 
-void RS_ActionSelectWindow::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case SetCorner1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first edge"), tr("Cancel"));
-        break;
-    case SetCorner2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"), tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionSelectWindow::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::SelectCursor);
+void RS_ActionSelectWindow::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::SelectCursor);
 }
 
-
-
-void RS_ActionSelectWindow::updateToolBar() {
-    if (!isFinished()) {
-        //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
-    }
+void RS_ActionSelectWindow::updateToolBar()
+{
+       if (!isFinished())
+               //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
 }
 
 // EOF
index 7a38550f1873f87545db97aaf3160e56fca7371a..856281de08f4128326a3517ea260513ae97f58e1 100644 (file)
@@ -4,52 +4,41 @@
 #include "rs_previewactioninterface.h"
 #include "vector.h"
 
-
 /**
  * This action class can handle user events to select all entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSelectWindow : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        SetCorner1,     /**< Setting the 1st corner of the window.  */
-        SetCorner2      /**< Setting the 2nd corner of the window. */
-    };
-
-public:
-    RS_ActionSelectWindow(RS_EntityContainer& container,
-                         RS_GraphicView& graphicView,
-                         bool select);
-    ~RS_ActionSelectWindow() {}
-
-       static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSelectWindow;
-       }
-
-    virtual void init(int status=0);
-
-    virtual void trigger();
-
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-protected:
-    Vector v1;
-    Vector v2;
-
-    bool select;
+class RS_ActionSelectWindow: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       SetCorner1, /**< Setting the 1st corner of the window.  */
+                       SetCorner2 /**< Setting the 2nd corner of the window. */
+               };
+
+       public:
+               RS_ActionSelectWindow(RS_EntityContainer & container, RS_GraphicView & graphicView, bool select);
+               ~RS_ActionSelectWindow();
+
+               virtual RS2::ActionType rtti();
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       protected:
+               Vector v1;
+               Vector v2;
+
+               bool select;
 };
 
 #endif
index f1b2cc4f43dfbe13ab396c3600114cfe74c4fd21..14c6ff73adc5b8c1718e75f25587ab635db3d0c9 100644 (file)
-/****************************************************************************
-** $Id: rs_actionsetrelativezero.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionsetrelativezero.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionsetrelativezero.h"
 
-#include "rs_snapper.h"
-#include "rs_point.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 
-
-
-RS_ActionSetRelativeZero::RS_ActionSetRelativeZero(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_PreviewActionInterface("Set the relative Zero",
-                           container, graphicView) {}
-
-
-QAction * RS_ActionSetRelativeZero::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionSetRelativeZero::RS_ActionSetRelativeZero(RS_EntityContainer & container,
+       RS_GraphicView & graphicView): RS_PreviewActionInterface("Set the relative Zero",
+               container, graphicView)
 {
-       QAction * action = new QAction(tr("&Set Relative Zero"), 0);
-//     QAction* action = new QAction(tr("Set Relative Zero"), tr("&Set Relative Zero"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Set position of the Relative Zero point"));
-       return action;
 }
 
-
-void RS_ActionSetRelativeZero::trigger() {
-    bool wasLocked = graphicView->isRelativeZeroLocked();
-    if (pt.valid) {
-        graphicView->lockRelativeZero(false);
-        graphicView->moveRelativeZero(pt);
-        graphicView->lockRelativeZero(wasLocked);
-    }
-    finish();
+RS_ActionSetRelativeZero::~RS_ActionSetRelativeZero()
+{
 }
 
-
-
-void RS_ActionSetRelativeZero::mouseMoveEvent(QMouseEvent* e) {
-    snapPoint(e);
+/*virtual*/ RS2::ActionType RS_ActionSetRelativeZero::rtti()
+{
+       return RS2::ActionSetRelativeZero;
 }
 
-
-
-void RS_ActionSetRelativeZero::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deleteSnapper();
-        init(getStatus()-1);
-    } else {
-        RS_CoordinateEvent ce(snapPoint(e));
-        coordinateEvent(&ce);
-    }
+void RS_ActionSetRelativeZero::trigger()
+{
+       bool wasLocked = graphicView->isRelativeZeroLocked();
+
+       if (pt.valid)
+       {
+               graphicView->lockRelativeZero(false);
+               graphicView->moveRelativeZero(pt);
+               graphicView->lockRelativeZero(wasLocked);
+       }
+       finish();
 }
 
-
-
-void RS_ActionSetRelativeZero::coordinateEvent(RS_CoordinateEvent* e) {
-    if (e==NULL) {
-        return;
-    }
-
-    pt = e->getCoordinate();
-    trigger();
+void RS_ActionSetRelativeZero::mouseMoveEvent(QMouseEvent * e)
+{
+       snapPoint(e);
 }
 
-
-
-void RS_ActionSetRelativeZero::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case 0:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Set relative Zero"), tr("Cancel"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionSetRelativeZero::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
+       else
+       {
+               Vector ce(snapPoint(e));
+               coordinateEvent(&ce);
+       }
 }
 
+void RS_ActionSetRelativeZero::coordinateEvent(Vector * e)
+{
+       if (e == NULL)
+               return;
 
-
-void RS_ActionSetRelativeZero::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       pt = *e;
+       trigger();
 }
 
+void RS_ActionSetRelativeZero::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case 0:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Set relative Zero"), tr("Cancel"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
+}
 
+void RS_ActionSetRelativeZero::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
+}
 
-void RS_ActionSetRelativeZero::updateToolBar() {
-    if (!isFinished()) {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    } else {
-        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
-    }
+void RS_ActionSetRelativeZero::updateToolBar()
+{
+       if (!isFinished())
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+       else
+               RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
 }
 
 // EOF
index ddbaf12a51b40c7303e7c655baeb13c467d83ff2..d79978e6891576f1ca878a8185111ec1e7c26566 100644 (file)
@@ -1,34 +1,8 @@
-/****************************************************************************
-** $Id: rs_actionsetrelativezero.h 1114 2004-04-04 22:49:45Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSETRELATIVEZERO_H
 #define RS_ACTIONSETRELATIVEZERO_H
 
 #include "rs_previewactioninterface.h"
-
+#include "vector.h"
 
 /**
  * This action class can handle user events to set
  *
  * @author Ulf Lehnert
  */
-class RS_ActionSetRelativeZero : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSetRelativeZero(RS_EntityContainer& container,
-                             RS_GraphicView& graphicView);
-    ~RS_ActionSetRelativeZero() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-       virtual RS2::ActionType rtti() {
-               return RS2::ActionSetRelativeZero;
-       }
-
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-       
-       virtual void coordinateEvent(RS_CoordinateEvent* e);
-
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    Vector pt;
+class RS_ActionSetRelativeZero: public RS_PreviewActionInterface
+{
+       public:
+               RS_ActionSetRelativeZero(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSetRelativeZero();
+
+               virtual RS2::ActionType rtti();
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void coordinateEvent(Vector * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               Vector pt;
 };
 
 #endif
index 089d4a87dafe9565ed82e84403422f2dde7825f0..3819e441de9cf9906489c7a0f465bdb4d9843a6e 100644 (file)
@@ -1,53 +1,44 @@
-/****************************************************************************
-** $Id: rs_actionsetsnapmode.cpp 945 2003-06-11 06:56:54Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionsetsnapmode.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionsetsnapmode.h"
 
+#include "rs_graphicview.h"
+
 /**
  * Constructor.
  *
  * @param snapMode The new snap mode used from now on.
  */
-RS_ActionSetSnapMode::RS_ActionSetSnapMode(RS_EntityContainer & container,
-       RS_GraphicView & graphicView, RS2::SnapMode snapMode):
+RS_ActionSetSnapMode::RS_ActionSetSnapMode(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapMode snapMode):
        RS_ActionInterface("Set Snap Mode", container, graphicView)
 {
-    this->snapMode = snapMode;
+       this->snapMode = snapMode;
+}
+
+RS_ActionSetSnapMode::~RS_ActionSetSnapMode()
+{
 }
 
 void RS_ActionSetSnapMode::trigger()
 {
-    graphicView->setDefaultSnapMode(snapMode);
-    finish();
+       graphicView->setDefaultSnapMode(snapMode);
+       finish();
 }
 
 void RS_ActionSetSnapMode::init(int status)
 {
-    RS_ActionInterface::init(status);
-    trigger();
+       RS_ActionInterface::init(status);
+       trigger();
 }
-
-// EOF
index a78e2cd07d4d90ae1507fc53f63518c0d4750bc6..ebe0c2cd14d3f43544866599729dcd706c2ece09 100644 (file)
@@ -1,53 +1,25 @@
-/****************************************************************************
-** $Id: rs_actionsetsnapmode.h 973 2003-08-09 22:39:50Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSETSNAPMODE_H
 #define RS_ACTIONSETSNAPMODE_H
 
+#include "rs.h"
 #include "rs_actioninterface.h"
 
-
 /**
  * This action changes the current snap mode.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSetSnapMode : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSetSnapMode(RS_EntityContainer& container,
-                         RS_GraphicView& graphicView,
-                         RS2::SnapMode snapMode);
-    ~RS_ActionSetSnapMode() {}
+class RS_ActionSetSnapMode: public RS_ActionInterface
+{
+       public:
+               RS_ActionSetSnapMode(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapMode snapMode);
+               ~RS_ActionSetSnapMode();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-protected:
-    RS2::SnapMode snapMode;
+       protected:
+               RS2::SnapMode snapMode;
 };
 
 #endif
index 3f8428cdafeb85913106b7672fdd3911d4ca5aae..8da558dfa241ed9d3c1870ea53545101481f37c8 100644 (file)
@@ -1,42 +1,36 @@
-/****************************************************************************
-** $Id: rs_actionsetsnaprestriction.cpp 945 2003-06-11 06:56:54Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionsetsnaprestriction.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionsetsnaprestriction.h"
 
+#include "rs_graphicview.h"
+
 /**
  * Constructor.
  *
  * @param snapRes The new snap mode used from now on.
  * @param set true: set additional snap mode / false: unset
  */
-RS_ActionSetSnapRestriction::RS_ActionSetSnapRestriction(RS_EntityContainer& container,
-       RS_GraphicView& graphicView, RS2::SnapRestriction snapRes):
+RS_ActionSetSnapRestriction::RS_ActionSetSnapRestriction(
+       RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapRestriction snapRes):
        RS_ActionInterface("Set Additional Snap Mode", container, graphicView)
 {
-    this->snapRes = snapRes;
+       this->snapRes = snapRes;
+}
+
+RS_ActionSetSnapRestriction::~RS_ActionSetSnapRestriction()
+{
 }
 
 void RS_ActionSetSnapRestriction::trigger()
@@ -50,5 +44,3 @@ void RS_ActionSetSnapRestriction::init(int status)
        RS_ActionInterface::init(status);
        trigger();
 }
-
-// EOF
index ccc4a5075049a938e53805760ad9d525539241ce..4d3f67d2af1eee76db1add6863ec33c1f1a5b77e 100644 (file)
@@ -1,53 +1,25 @@
-/****************************************************************************
-** $Id: rs_actionsetsnaprestriction.h 973 2003-08-09 22:39:50Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSETSNAPRESTRICTION_H
 #define RS_ACTIONSETSNAPRESTRICTION_H
 
+#include "rs.h"
 #include "rs_actioninterface.h"
 
-
 /**
  * This action changes the current additional snap mode.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSetSnapRestriction : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionSetSnapRestriction(RS_EntityContainer& container,
-                         RS_GraphicView& graphicView,
-                         RS2::SnapRestriction snapRes);
-    ~RS_ActionSetSnapRestriction() {}
+class RS_ActionSetSnapRestriction: public RS_ActionInterface
+{
+       public:
+               RS_ActionSetSnapRestriction(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapRestriction snapRes);
+               ~RS_ActionSetSnapRestriction();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-protected:
-    RS2::SnapRestriction snapRes;
+       protected:
+               RS2::SnapRestriction snapRes;
 };
 
 #endif
index 85b16f97a98e5183e6d9d0ceab2f83903ef09f79..78330b5addc55dff8d9d67625c55c08f292d5de6 100644 (file)
@@ -1,39 +1,29 @@
-/****************************************************************************
-** $Id: rs_actionsnapintersectionmanual.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionsetsnapintersectionmanual.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionsnapintersectionmanual.h"
 
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
 #include "rs_information.h"
-#include "rs_snapper.h"
+#include "rs_preview.h"
 
 /**
  * @param both Trim both entities.
  */
 RS_ActionSnapIntersectionManual::RS_ActionSnapIntersectionManual(
-       RS_EntityContainer& container, RS_GraphicView& graphicView):
+       RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_PreviewActionInterface("Trim Entity", container, graphicView)
 {
        entity2 = NULL;
@@ -41,14 +31,8 @@ RS_ActionSnapIntersectionManual::RS_ActionSnapIntersectionManual(
        coord = Vector(false);
 }
 
-QAction * RS_ActionSnapIntersectionManual::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionSnapIntersectionManual::~RS_ActionSnapIntersectionManual()
 {
-       QAction * action = new QAction(tr("I&ntersection Manually"), 0);
-       action->setCheckable(true);
-//     QAction* action = new QAction(tr("Intersection Manually"), tr("I&ntersection Manually"),
-//                                                                     QKeySequence(), NULL, 0, true);
-       action->setStatusTip(tr("Snap to intersection points manually"));
-       return action;
 }
 
 void RS_ActionSnapIntersectionManual::init(int status)
@@ -61,142 +45,145 @@ void RS_ActionSnapIntersectionManual::init(int status)
 
 void RS_ActionSnapIntersectionManual::trigger()
 {
-    RS_DEBUG->print("RS_ActionSnapIntersectionManual::trigger()");
+       RS_DEBUG->print("RS_ActionSnapIntersectionManual::trigger()");
 
-    if (entity2!=NULL && entity2->isAtomic() &&
-            entity1!=NULL && entity1->isAtomic())
+       if (entity2 != NULL && entity2->isAtomic()
+           && entity1 != NULL && entity1->isAtomic())
        {
-        VectorSolutions sol =
-            RS_Information::getIntersection(entity1, entity2, false);
-
-        entity2 = NULL;
-        entity1 = NULL;
-        if (predecessor!=NULL) {
-            Vector ip = sol.getClosest(coord);
-
-            if (ip.valid) {
-                RS_CoordinateEvent e(ip);
-                predecessor->coordinateEvent(&e);
-            }
-        }
-        finish();
-    }
+               VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
+
+               entity2 = NULL;
+               entity1 = NULL;
+
+               if (predecessor != NULL)
+               {
+                       Vector ip = sol.getClosest(coord);
+
+                       if (ip.valid)
+                       {
+                               Vector e(ip);
+                               predecessor->coordinateEvent(&e);
+                       }
+               }
+               finish();
+       }
 }
 
+void RS_ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent * e)
+{
+       RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent begin");
 
+       RS_Entity * se = catchEntity(e);
+       Vector mouse = graphicView->toGraph(e->x(), e->y());
 
-void RS_ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent* e) {
-    RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent begin");
-
-    RS_Entity* se = catchEntity(e);
-    Vector mouse = graphicView->toGraph(e->x(), e->y());
-
-    switch (getStatus()) {
-    case ChooseEntity1:
-        entity1 = se;
-        break;
-
-    case ChooseEntity2: {
-            entity2 = se;
-            coord = mouse;
-
-            VectorSolutions sol =
-                RS_Information::getIntersection(entity1, entity2, false);
-
-            //for (int i=0; i<sol.getNumber(); i++) {
-            //    ip = sol.get(i);
-            //    break;
-            //}
-
-            Vector ip = sol.getClosest(coord);
-
-            if (ip.valid) {
-                deletePreview();
-                clearPreview();
-                preview->addEntity(
-                    new RS_Circle(preview,
-                                  RS_CircleData(
-                                      ip,
-                                      graphicView->toGraphDX(4))));
-                drawPreview();
-
-                RS_DIALOGFACTORY->updateCoordinateWidget(ip,
-                        ip - graphicView->getRelativeZero());
-
-            }
-        }
-        break;
-
-    default:
-        break;
-    }
-
-    RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent end");
+       switch (getStatus())
+       {
+       case ChooseEntity1:
+               entity1 = se;
+               break;
+
+       case ChooseEntity2: {
+               entity2 = se;
+               coord = mouse;
+
+               VectorSolutions sol =
+                       RS_Information::getIntersection(entity1, entity2, false);
+
+               //for (int i=0; i<sol.getNumber(); i++) {
+               //    ip = sol.get(i);
+               //    break;
+               //}
+
+               Vector ip = sol.getClosest(coord);
+
+               if (ip.valid)
+               {
+                       deletePreview();
+                       clearPreview();
+                       preview->addEntity(
+                               new RS_Circle(preview,
+                                       RS_CircleData(
+                                               ip,
+                                               graphicView->toGraphDX(4))));
+                       drawPreview();
+
+                       RS_DIALOGFACTORY->updateCoordinateWidget(ip,
+                               ip - graphicView->getRelativeZero());
+               }
+       }
+       break;
+
+       default:
+               break;
+       }
+
+       RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent end");
 }
 
-
-
-void RS_ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-
-        Vector mouse = graphicView->toGraph(e->x(), e->y());
-        RS_Entity* se = catchEntity(e);
-
-        switch (getStatus()) {
-        case ChooseEntity1:
-            entity1 = se;
-            if (entity1!=NULL && entity1->isAtomic()) {
-                setStatus(ChooseEntity2);
-            }
-            break;
-
-        case ChooseEntity2:
-            entity2 = se;
-            coord = mouse;
-            if (entity2!=NULL && entity2->isAtomic() && coord.valid) {
-                trigger();
-            }
-            break;
-
-        default:
-            break;
-        }
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        deletePreview();
-        deleteSnapper();
-        init(getStatus()-1);
-    }
+void RS_ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               Vector mouse = graphicView->toGraph(e->x(), e->y());
+               RS_Entity * se = catchEntity(e);
+
+               switch (getStatus())
+               {
+               case ChooseEntity1:
+                       entity1 = se;
+
+                       if (entity1 != NULL && entity1->isAtomic())
+                               setStatus(ChooseEntity2);
+                       break;
+
+               case ChooseEntity2:
+                       entity2 = se;
+                       coord = mouse;
+
+                       if (entity2 != NULL && entity2->isAtomic() && coord.valid)
+                               trigger();
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+       {
+               deletePreview();
+               deleteSnapper();
+               init(getStatus() - 1);
+       }
 }
 
-
-
-void RS_ActionSnapIntersectionManual::updateMouseButtonHints() {
-    switch (getStatus()) {
-    case ChooseEntity1:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
-                                            tr("Back"));
-        break;
-    case ChooseEntity2:
-        RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
-                                            tr("Back"));
-        break;
-    default:
-        RS_DIALOGFACTORY->updateMouseWidget("", "");
-        break;
-    }
+void RS_ActionSnapIntersectionManual::updateMouseButtonHints()
+{
+       switch (getStatus())
+       {
+       case ChooseEntity1:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
+                       tr("Back"));
+               break;
+
+       case ChooseEntity2:
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
+                       tr("Back"));
+               break;
+
+       default:
+               RS_DIALOGFACTORY->updateMouseWidget("", "");
+               break;
+       }
 }
 
-
-
-void RS_ActionSnapIntersectionManual::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionSnapIntersectionManual::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
-
-
-void RS_ActionSnapIntersectionManual::updateToolBar() {
-    RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+void RS_ActionSnapIntersectionManual::updateToolBar()
+{
+       RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
 }
 
-
 // EOF
index 467ed32a56b2da2849e99a18ff134c089bdd4321..fca9b2576dfbd8b796df2f2498d1039b131917cd 100644 (file)
@@ -1,70 +1,43 @@
-/****************************************************************************
-** $Id: rs_actionsnapintersectionmanual.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONSNAPINTERSECTIONMANUAL_H
 #define RS_ACTIONSNAPINTERSECTIONMANUAL_H
 
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
+class RS_Entity;
 
 /**
  * This action class can handle user events to trim entities.
  *
  * @author Andrew Mustun
  */
-class RS_ActionSnapIntersectionManual : public RS_PreviewActionInterface {
-       //Q_OBJECT
-public:
-    /**
-     * Action States.
-     */
-    enum Status {
-        ChooseEntity1,      /**< Choosing the 1st entity. */
-        ChooseEntity2       /**< Choosing the 2nd entity. */
-    };
-
-public:
-    RS_ActionSnapIntersectionManual(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionSnapIntersectionManual() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-    virtual void updateToolBar();
-
-private:
-    RS_Entity* entity1;
-    RS_Entity* entity2;
-       Vector coord;
+class RS_ActionSnapIntersectionManual: public RS_PreviewActionInterface
+{
+       public:
+               /**
+                * Action States.
+                */
+               enum Status {
+                       ChooseEntity1, /**< Choosing the 1st entity. */
+                       ChooseEntity2 /**< Choosing the 2nd entity. */
+               };
+
+       public:
+               RS_ActionSnapIntersectionManual(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionSnapIntersectionManual();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+               virtual void updateToolBar();
+
+       private:
+               RS_Entity * entity1;
+               RS_Entity * entity2;
+               Vector coord;
 };
 
 #endif
index d59f7ee60dacd5a48b813dc7b1e4446fd37d4e62..2ad2048b12a85cc0dad1893dad7c9b172f6b7fca 100644 (file)
@@ -1,55 +1,36 @@
-/****************************************************************************
-** $Id: rs_actiontoolregeneratedimensions.cpp 1074 2004-02-29 00:30:50Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actiontoolregeneratedimensions.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actiontoolregeneratedimensions.h"
 
-#include "rs_information.h"
+#include "rs_dialogfactory.h"
 #include "rs_dimension.h"
+#include "rs_graphicview.h"
+#include "rs_information.h"
 
-RS_ActionToolRegenerateDimensions::RS_ActionToolRegenerateDimensions(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionToolRegenerateDimensions::RS_ActionToolRegenerateDimensions(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Tool Regen Dim", container, graphicView)
 {
 }
 
-QAction * RS_ActionToolRegenerateDimensions::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionToolRegenerateDimensions::~RS_ActionToolRegenerateDimensions()
 {
-       QAction * action = new QAction(tr("&Regenerate Dimension Entities"), 0);
-//     QAction* action = new QAction(tr("Regenerate Dimension Entities"),
-//                                                                     tr("&Regenerate Dimension Entities"),
-//                                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Regenerates all Dimension Entities"));
-
-       return action;
 }
 
 void RS_ActionToolRegenerateDimensions::init(int status)
 {
        RS_ActionInterface::init(status);
-
        trigger();
 }
 
@@ -58,19 +39,18 @@ void RS_ActionToolRegenerateDimensions::trigger()
        RS_DEBUG->print("RS_ActionToolRegenerateDimensions::trigger()");
 
        int num = 0;
-       for (RS_Entity* e = container->firstEntity(RS2::ResolveNone);
-                       e != NULL;
-                       e = container->nextEntity(RS2::ResolveNone))
+
+       for(RS_Entity * e = container->firstEntity(RS2::ResolveNone);
+            e != NULL; e = container->nextEntity(RS2::ResolveNone))
        {
                if (RS_Information::isDimension(e->rtti()) && e->isVisible())
                {
                        num++;
-                       if (((RS_Dimension*)e)->getLabel()==";;")
-                       {
-                               ((RS_Dimension*)e)->setLabel("");
-                       }
 
-                       ((RS_Dimension*)e)->update(true);
+                       if (((RS_Dimension *)e)->getLabel() == ";;")
+                               ((RS_Dimension *)e)->setLabel("");
+
+                       ((RS_Dimension *)e)->update(true);
                }
        }
 
@@ -80,12 +60,9 @@ void RS_ActionToolRegenerateDimensions::trigger()
                RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num));
        }
        else
-       {
                RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found"));
-       }
 
        finish();
 }
 
-
 // EOF
index 5289e1fcd9b11eea42b43501fb58bfb0223d73a2..92dd955224485f4c9936f60de73001aad3e32fe7 100644 (file)
@@ -1,51 +1,21 @@
-/****************************************************************************
-** $Id: rs_actiontoolregeneratedimensions.h 1063 2004-01-18 10:59:32Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONTOOLREGENERATEDIMENSIONS_H
 #define RS_ACTIONTOOLREGENERATEDIMENSIONS_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to regenerate dimensions.
  *
  * @author Andrew Mustun
  */
-class RS_ActionToolRegenerateDimensions : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionToolRegenerateDimensions(RS_EntityContainer& container,
-                          RS_GraphicView& graphicView);
-    ~RS_ActionToolRegenerateDimensions() {}
-       
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionToolRegenerateDimensions: public RS_ActionInterface
+{
+       public:
+               RS_ActionToolRegenerateDimensions(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionToolRegenerateDimensions();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index b75503a579a796162a1443705edacd51bad14215..6d1942b6bc5725be14211947c336ba4a38516f61 100644 (file)
@@ -1,32 +1,20 @@
-/****************************************************************************
-** $Id: rs_actionzoomauto.cpp 1090 2004-03-16 10:02:59Z js $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomauto.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomauto.h"
-//Added by qt3to4:
-//#include <QPixmap>
+
+#include "rs_graphicview.h"
 
 /**
  * Constructor.
  * @param keepAspectRatio true: keep same zoom value for x/y.
  *                        false: adjust both x and y individually
  */
-RS_ActionZoomAuto::RS_ActionZoomAuto(RS_EntityContainer& container,
-       RS_GraphicView& graphicView, bool keepAspectRatio):
+RS_ActionZoomAuto::RS_ActionZoomAuto(RS_EntityContainer & container,
+       RS_GraphicView & graphicView, bool keepAspectRatio):
        RS_ActionInterface("Auto zoom", container, graphicView)
 {
-    this->keepAspectRatio = keepAspectRatio;
+       this->keepAspectRatio = keepAspectRatio;
 }
 
-QAction * RS_ActionZoomAuto::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionZoomAuto::~RS_ActionZoomAuto()
 {
-       QAction * action = new QAction(QIcon(":/res/zoomauto.png"), tr("&Auto Zoom"), 0);
-//     QAction* action = new QAction(tr("Auto Zoom"), QPixmap::fromMimeSource("zoomauto.png"),
-//                                                     tr("&Auto Zoom"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Zooms automatic"));
-       return action;
 }
 
 void RS_ActionZoomAuto::init(int status)
@@ -61,5 +44,3 @@ void RS_ActionZoomAuto::trigger()
        graphicView->zoomAuto(false, keepAspectRatio);
        finish();
 }
-
-// EOF
index 35a4c9484fd4211c642f8d7b90273cdac93f32c6..73d5437a378f907ac01dc0cb7452464c7199992a 100644 (file)
@@ -1,55 +1,24 @@
-/****************************************************************************
-** $Id: rs_actionzoomauto.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMAUTO_H
 #define RS_ACTIONZOOMAUTO_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action triggers an auto zoom.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomAuto : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionZoomAuto(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView,
-                      bool keepAspectRatio=true);
-    ~RS_ActionZoomAuto() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionZoomAuto: public RS_ActionInterface
+{
+       public:
+               RS_ActionZoomAuto(RS_EntityContainer & container, RS_GraphicView & graphicView, bool keepAspectRatio = true);
+               ~RS_ActionZoomAuto();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-protected:
-    bool keepAspectRatio;
+       protected:
+               bool keepAspectRatio;
 };
 
 #endif
index 75017938c3daff2032ceb5844563334fcc879954..01868f6b2c66854fecaaf649d9e62b982e511440 100644 (file)
@@ -1,39 +1,29 @@
-/****************************************************************************
-** $Id: rs_actionzoomautoy.cpp 945 2003-06-11 06:56:54Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomautoy.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomautoy.h"
 
+#include "rs_graphicview.h"
 
-
-RS_ActionZoomAutoY::RS_ActionZoomAutoY(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionZoomAutoY::RS_ActionZoomAutoY(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Auto zoom Y", container, graphicView)
 {
 }
 
+RS_ActionZoomAutoY::~RS_ActionZoomAutoY()
+{
+}
 
 void RS_ActionZoomAutoY::trigger()
 {
@@ -41,12 +31,8 @@ void RS_ActionZoomAutoY::trigger()
        finish();
 }
 
-
-
 void RS_ActionZoomAutoY::init(int status)
 {
        RS_ActionInterface::init(status);
        trigger();
 }
-
-// EOF
index c6c62c9547faa1a3b3e998a637ca46df759425c7..c0a32e38028c638a2a91fcb91d39bd193e2b0180 100644 (file)
@@ -1,49 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionzoomautoy.h 973 2003-08-09 22:39:50Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMAUTOY_H
 #define RS_ACTIONZOOMAUTOY_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action triggers an auto zoom in Y only.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomAutoY : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionZoomAutoY(RS_EntityContainer& container,
-                       RS_GraphicView& graphicView);
-    ~RS_ActionZoomAutoY() {}
+class RS_ActionZoomAutoY: public RS_ActionInterface
+{
+       public:
+               RS_ActionZoomAutoY(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionZoomAutoY();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index d0db01f1650b6f6ad131acfcd380aaf1426434ed..56cb9efee47574c26d07fcd917f66e3b5471b2cc 100644 (file)
 
 #include "rs_actionzoomin.h"
 
+#include "rs_graphicview.h"
+
 /**
  * Default constructor.
  *
  * @param direction In for zooming in, Out for zooming out.
  * @param axis Axis that are affected by the zoom (OnlyX, OnlyY or Both)
  */
-RS_ActionZoomIn::RS_ActionZoomIn(RS_EntityContainer& container,
-       RS_GraphicView& graphicView, RS2::ZoomDirection direction,
-       RS2::Axis axis, const Vector& center):
+RS_ActionZoomIn::RS_ActionZoomIn(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ZoomDirection direction, RS2::Axis axis, const Vector & center):
        RS_ActionInterface("Zoom in", container, graphicView)
 {
        this->direction = direction;
@@ -30,26 +30,8 @@ RS_ActionZoomIn::RS_ActionZoomIn(RS_EntityContainer& container,
        this->center = center;
 }
 
-QAction * RS_ActionZoomIn::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
+RS_ActionZoomIn::~RS_ActionZoomIn()
 {
-       QAction * action;
-
-       if (type == RS2::ActionZoomIn)
-       {
-               action = new QAction(QIcon(":/res/zoomin.png"), tr("Zoom &In"), 0);
-//             action = new QAction(tr("Zoom in"), QPixmap::fromMimeSource("zoomin.png"),
-//                                                             tr("Zoom &In"), QKeySequence(), NULL);
-               action->setStatusTip(tr("Zooms in"));
-       }
-       else
-       {
-               action = new QAction(QIcon(":/res/zoomout.png"), tr("Zoom &Out"), 0);
-//             action = new QAction(tr("Zoom out"), QPixmap::fromMimeSource("zoomout.png"),
-//                                                             tr("Zoom &Out"), QKeySequence(), NULL);
-               action->setStatusTip(tr("Zooms out"));
-       }
-
-       return action;
 }
 
 void RS_ActionZoomIn::init(int status)
@@ -63,36 +45,27 @@ void RS_ActionZoomIn::trigger()
        switch (axis)
        {
        case RS2::OnlyX:
+
                if (direction == RS2::In)
-               {
                        graphicView->zoomInX();
-               }
                else
-               {
                        graphicView->zoomOutX();
-               }
                break;
 
        case RS2::OnlyY:
+
                if (direction == RS2::In)
-               {
                        graphicView->zoomInY();
-               }
                else
-               {
                        graphicView->zoomOutY();
-               }
                break;
 
        case RS2::Both:
+
                if (direction == RS2::In)
-               {
                        graphicView->zoomIn(1.25, center);
-               }
                else
-               {
                        graphicView->zoomOut(1.25, center);
-               }
                break;
        }
 
index 64e1bab59660b30412fe64716ac7356ed2281072..68abaebb44640e5a55854ef71923db18c4f1dabc 100644 (file)
@@ -1,23 +1,20 @@
 #ifndef RS_ACTIONZOOMIN_H
 #define RS_ACTIONZOOMIN_H
 
+#include "rs.h"
 #include "rs_actioninterface.h"
+#include "vector.h"
 
 /**
  * This action triggers zoom increase.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomIn : public RS_ActionInterface
+class RS_ActionZoomIn: public RS_ActionInterface
 {
-       //Q_OBJECT
        public:
-               RS_ActionZoomIn(RS_EntityContainer& container, RS_GraphicView& graphicView,
-                       RS2::ZoomDirection direction = RS2::In, RS2::Axis axis = RS2::Both,
-                       const Vector& center = Vector(false));
-               ~RS_ActionZoomIn() {}
-
-               static QAction * createGUIAction(RS2::ActionType type, QObject * /*parent*/);
+               RS_ActionZoomIn(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ZoomDirection direction = RS2::In, RS2::Axis axis = RS2::Both, const Vector & center = Vector(false));
+               ~RS_ActionZoomIn();
 
                virtual void init(int status = 0);
                virtual void trigger();
index 6f700e43f8c53e8d3ae9600ac5adb1b81c270dd8..0795666a671f4f59d09513a133a221f700fa6160 100644 (file)
-/****************************************************************************
-** $Id: rs_actionzoompan.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoompan.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoompan.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
-//Added by qt3to4:
-//#include <QPixmap>
 
-RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+#include "rs_graphicview.h"
+
+RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Zoom Pan", container, graphicView)
 {
 }
 
-QAction * RS_ActionZoomPan::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionZoomPan::~RS_ActionZoomPan()
 {
-       QAction * action = new QAction(QIcon(":/res/zoompan.png"), tr("&Pan Zoom"), 0);
-//     QAction* action = new QAction(tr("Pan Zoom"), QPixmap::fromMimeSource("zoompan.png"),
-//                                                                     tr("&Pan Zoom"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Realtime Panning"));
-       return action;
 }
 
 void RS_ActionZoomPan::init(int status)
 {
-    RS_ActionInterface::init(status);
-    snapMode = RS2::SnapFree;
-    snapRes = RS2::RestrictNothing;
-    //v1 = v2 = Vector(false);
-    x1 = y1 = x2 = y2 = -1;
-    //graphicView->saveView();
+       RS_ActionInterface::init(status);
+       snapMode = RS2::SnapFree;
+       snapRes = RS2::RestrictNothing;
+       //v1 = v2 = Vector(false);
+       x1 = y1 = x2 = y2 = -1;
+       //graphicView->saveView();
 }
 
-
-
-void RS_ActionZoomPan::trigger() {
-    /*if (v1.valid && v2.valid) {
-        graphicView->zoomPan(v2-v1);
-        v1 = v2;
-}*/
-    if (x1>=0) {
-        graphicView->zoomPan(x2-x1, y2-y1);
-        x1 = x2;
-        y1 = y2;
-    }
+void RS_ActionZoomPan::trigger()
+{
+       /*if (v1.valid && v2.valid) {
+           graphicView->zoomPan(v2-v1);
+           v1 = v2;
+          }*/
+       if (x1 >= 0)
+       {
+               graphicView->zoomPan(x2 - x1, y2 - y1);
+               x1 = x2;
+               y1 = y2;
+       }
 }
 
+void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent * e)
+{
+       //v2 = snapPoint(e);
+       x2 = e->x();
+       y2 = e->y();
 
-
-void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent* e) {
-    //v2 = snapPoint(e);
-    x2 = e->x();
-    y2 = e->y();
-    //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) {
-    if (getStatus()==1 && (abs(x2-x1)>7 || abs(y2-y1)>7)) {
-        trigger();
-    }
+       //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) {
+       if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7))
+               trigger();
 }
 
-
-
-void RS_ActionZoomPan::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::MidButton ||
-            RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        //v1 = snapPoint(e);
-        x1 = e->x();
-        y1 = e->y();
-        setStatus(1);
-    }
+void RS_ActionZoomPan::mousePressEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::MidButton
+           || RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               //v1 = snapPoint(e);
+               x1 = e->x();
+               y1 = e->y();
+               setStatus(1);
+       }
 }
 
-
-
-void RS_ActionZoomPan::mouseReleaseEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
-        init(getStatus()-1);
-    } else if (RS2::qtToRsButtonState(e->button())==RS2::MidButton) {
-        init(-1);
-    } else {
-        setStatus(0);
-    }
-
-    //RS_DEBUG->print("RS_ActionZoomPan::mousePressEvent(): %f %f", v1.x, v1.y);
+void RS_ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+               init(getStatus() - 1);
+       else if (RS2::qtToRsButtonState(e->button()) == RS2::MidButton)
+               init(-1);
+       else
+               setStatus(0);
+
+       //RS_DEBUG->print("RS_ActionZoomPan::mousePressEvent(): %f %f", v1.x, v1.y);
 }
 
-
-
-void RS_ActionZoomPan::updateMouseCursor() {
+void RS_ActionZoomPan::updateMouseCursor()
+{
 #ifndef __APPLE__
-    graphicView->setMouseCursor(RS2::SizeAllCursor);
+       graphicView->setMouseCursor(RS2::SizeAllCursor);
 #endif
 }
 
-
 // EOF
index f0c002b299833c971389370002630920c00704c3..d9019e9e143354355c571d85733f3a84cfc6e112 100644 (file)
@@ -1,63 +1,31 @@
-/****************************************************************************
-** $Id: rs_actionzoompan.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMPAN_H
 #define RS_ACTIONZOOMPAN_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action class can handle user events to zoom in a window.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomPan : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionZoomPan(RS_EntityContainer& container,
-                     RS_GraphicView& graphicView);
-    ~RS_ActionZoomPan() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseCursor();
-
-protected:
-    //Vector v1;
-    //Vector v2;
-       int x1;
-       int y1;
-       int x2;
-       int y2;
+class RS_ActionZoomPan: public RS_ActionInterface
+{
+       public:
+               RS_ActionZoomPan(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionZoomPan();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseCursor();
+
+       protected:
+               int x1;
+               int y1;
+               int x2;
+               int y2;
 };
 
 #endif
index 2cf3e673b4a91cbbe4119e7c9483b7139a985733..3b6ee3bb87eee4f1c92ecfa799a7052f14e1e61c 100644 (file)
@@ -1,61 +1,41 @@
-/****************************************************************************
-** $Id: rs_actionzoomprevious.cpp 1115 2004-04-05 16:47:51Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomprevious.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomprevious.h"
-//Added by qt3to4:
-//#include <QPixmap>
+
+#include "rs_graphicview.h"
 
 /**
  * Constructor.
  */
-RS_ActionZoomPrevious::RS_ActionZoomPrevious(RS_EntityContainer& container,
-       RS_GraphicView& graphicView):
+RS_ActionZoomPrevious::RS_ActionZoomPrevious(RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Previous zoom", container, graphicView)
 {
 }
 
-QAction * RS_ActionZoomPrevious::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionZoomPrevious::~RS_ActionZoomPrevious()
 {
-       QAction * action = new QAction(QIcon(":/res/zoomprevious.png"), tr("&Previous View"), 0);
-//     QAction* action = new QAction(tr("Previous View"), QPixmap::fromMimeSource("zoomprevious.png"),
-//                                                     tr("&Previous View"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Shows previous view"));
-       return action;
 }
 
 void RS_ActionZoomPrevious::init(int status)
 {
-    RS_ActionInterface::init(status);
-    trigger();
+       RS_ActionInterface::init(status);
+       trigger();
 }
 
 void RS_ActionZoomPrevious::trigger()
 {
-    graphicView->zoomPrevious();
-    finish();
+       graphicView->zoomPrevious();
+       finish();
 }
-
-// EOF
index ac63b71a651dc970630a69898b2318d1737b968e..bc6b8ce1e118410e7789d1464a180045c5dcef02 100644 (file)
@@ -1,53 +1,23 @@
-/****************************************************************************
-** $Id: rs_actionzoomprevious.h 1115 2004-04-05 16:47:51Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMPREVIOUS_H
 #define RS_ACTIONZOOMPREVIOUS_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action switches back to the previously used view..
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomPrevious : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionZoomPrevious(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView);
-    ~RS_ActionZoomPrevious() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionZoomPrevious: public RS_ActionInterface
+{
+       public:
+               RS_ActionZoomPrevious(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionZoomPrevious();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-protected:
+       protected:
 };
 
 #endif
index 9ef3961609e3949e5d1c7cca6802529879fa9190..f8845392b89f78f36c6ef9fe7837c496438921c0 100644 (file)
@@ -1,32 +1,20 @@
-/****************************************************************************
-** $Id: rs_actionzoomredraw.cpp 1090 2004-03-16 10:02:59Z js $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomredraw.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomredraw.h"
-//Added by qt3to4:
-//#include <QPixmap>
+
+#include "rs_graphicview.h"
 
 /**
  * Constructor.
  * @param keepAspectRatio true: keep same zoom value for x/y.
  *                        false: adjust both x and y individually
  */
-RS_ActionZoomRedraw::RS_ActionZoomRedraw(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Redraw", container, graphicView)
+RS_ActionZoomRedraw::RS_ActionZoomRedraw(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Redraw", container, graphicView)
 {
 }
 
-QAction * RS_ActionZoomRedraw::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionZoomRedraw::~RS_ActionZoomRedraw()
 {
-       QAction * action = new QAction(QIcon(":/res/zoomredraw.png"), tr("&Redraw"), 0);
-//     QAction* action = new QAction(tr("Redraw"), QPixmap::fromMimeSource("zoomredraw.png"),
-//                                                                     tr("&Redraw"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Redraw"));
-       return action;
 }
 
 void RS_ActionZoomRedraw::init(int status)
@@ -60,5 +42,3 @@ void RS_ActionZoomRedraw::trigger()
        graphicView->redraw();
        finish();
 }
-
-// EOF
index 071f7c9f22dc092ac7600b372f1a5b713633a402..712c900fcdb01b089eac70a3eb0e05fff87ca09b 100644 (file)
@@ -1,51 +1,21 @@
-/****************************************************************************
-** $Id: rs_actionzoomredraw.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMREDRAW_H
 #define RS_ACTIONZOOMREDRAW_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action triggers an auto zoom.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomRedraw : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionZoomRedraw(RS_EntityContainer& container,
-                      RS_GraphicView& graphicView);
-    ~RS_ActionZoomRedraw() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
+class RS_ActionZoomRedraw: public RS_ActionInterface
+{
+       public:
+               RS_ActionZoomRedraw(RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionZoomRedraw();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 };
 
 #endif
index ce2840091a5d4cb4bcf9b78c7b23c11910b50267..621e91613dcbf5ad742b728d044425e286f1f438 100644 (file)
@@ -1,38 +1,31 @@
-/****************************************************************************
-** $Id: rs_actionzoomscroll.cpp 945 2003-06-11 06:56:54Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomscroll.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomscroll.h"
 
-RS_ActionZoomScroll::RS_ActionZoomScroll(RS2::Direction direction,
-       RS_EntityContainer& container, RS_GraphicView& graphicView):
+#include "rs_graphicview.h"
+
+RS_ActionZoomScroll::RS_ActionZoomScroll(RS2::Direction direction, RS_EntityContainer & container, RS_GraphicView & graphicView):
        RS_ActionInterface("Zoom scroll", container, graphicView)
 {
        this->direction = direction;
 }
 
+RS_ActionZoomScroll::~RS_ActionZoomScroll()
+{
+}
+
 void RS_ActionZoomScroll::trigger()
 {
        graphicView->zoomScroll(direction);
@@ -44,5 +37,3 @@ void RS_ActionZoomScroll::init(int status)
        RS_ActionInterface::init(status);
        trigger();
 }
-
-// EOF
index bb8b5ddd1118b91a10391f4e312b1b0572e25a72..f461d5f4e24cfe480e1b6bc465a21849b89dc56f 100644 (file)
@@ -1,53 +1,24 @@
-/****************************************************************************
-** $Id: rs_actionzoomscroll.h 973 2003-08-09 22:39:50Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMSCROLL_H
 #define RS_ACTIONZOOMSCROLL_H
 
 #include "rs_actioninterface.h"
 
-
 /**
  * This action triggers a scrolling.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomScroll : public RS_ActionInterface {
-       //Q_OBJECT
-public:
-    RS_ActionZoomScroll(RS2::Direction direction,
-                        RS_EntityContainer& container,
-                        RS_GraphicView& graphicView);
-    ~RS_ActionZoomScroll() {}
+class RS_ActionZoomScroll: public RS_ActionInterface
+{
+       public:
+               RS_ActionZoomScroll(RS2::Direction direction, RS_EntityContainer & container, RS_GraphicView & graphicView);
+               ~RS_ActionZoomScroll();
 
-    virtual void init(int status=0);
-    virtual void trigger();
+               virtual void init(int status = 0);
+               virtual void trigger();
 
-protected:
-    RS2::Direction direction;
+       protected:
+               RS2::Direction direction;
 };
 
 #endif
index 65c09ffb3fae7f73dcc8b0228bd19eeb12576191..5ef6118ba966f32972152a8139696d6ea98d964c 100644 (file)
@@ -1,36 +1,22 @@
-/****************************************************************************
-** $Id: rs_actionzoomwindow.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomwindow.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomwindow.h"
 
-#include "rs.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
-//Added by qt3to4:
-//#include <QIcon>
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 /**
  * Default constructor.
  *          area will be fit to the viewport.
  */
 RS_ActionZoomWindow::RS_ActionZoomWindow(RS_EntityContainer & container,
-       RS_GraphicView& graphicView, bool keepAspectRatio):
+       RS_GraphicView & graphicView, bool keepAspectRatio):
        RS_PreviewActionInterface("Zoom Window", container, graphicView)
 {
        this->keepAspectRatio = keepAspectRatio;
 }
 
-QAction* RS_ActionZoomWindow::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionZoomWindow::~RS_ActionZoomWindow()
 {
-       QAction * action = new QAction(QIcon(":/res/zoomwindow.png"), tr("&Window Zoom"), 0);
-//     QAction* action = new QAction(tr("Window Zoom"), QPixmap::fromMimeSource("zoomwindow.png"),
-//                                                                     tr("&Window Zoom"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Zooms in a window"));
-       return action;
 }
 
 void RS_ActionZoomWindow::init(int status)
@@ -92,13 +73,13 @@ void RS_ActionZoomWindow::mouseMoveEvent(QMouseEvent * e)
                deletePreview();
                clearPreview();
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
+                               RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
+                               RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
+                               RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
+                               RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
                drawPreview();
        }
 }
@@ -129,20 +110,16 @@ void RS_ActionZoomWindow::mouseReleaseEvent(QMouseEvent * e)
        if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
        {
                if (getStatus() == 1)
-               {
                        deletePreview();
-               }
 
                init(getStatus() - 1);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
-       {
                if (getStatus() == 1)
                {
                        v2 = snapPoint(e);
                        trigger();
                }
-       }
 }
 
 void RS_ActionZoomWindow::updateMouseButtonHints()
@@ -154,9 +131,11 @@ void RS_ActionZoomWindow::updateMouseButtonHints()
        case 0:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first edge"), tr("Cancel"));
                break;
+
        case 1:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second edge"), tr("Back"));
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
index b51d310c72b9ea1e66b5e1f94e60cc676122410e..aca5cd6b1f83532b7c36984a28dbfe93ab1c5854 100644 (file)
@@ -1,63 +1,33 @@
-/****************************************************************************
-** $Id: rs_actionzoomwindow.h 1062 2004-01-16 21:51:20Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use 
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
 #ifndef RS_ACTIONZOOMWINDOW_H
 #define RS_ACTIONZOOMWINDOW_H
 
 #include "rs_previewactioninterface.h"
+#include "vector.h"
 
 /**
  * This action class can handle user events to zoom in a window.
  *
  * @author Andrew Mustun
  */
-class RS_ActionZoomWindow : public RS_PreviewActionInterface {
-    //Q_OBJECT
-public:
-    RS_ActionZoomWindow(RS_EntityContainer& container,
-                        RS_GraphicView& graphicView,
-                        bool keepAspectRatio=true);
-
-    ~RS_ActionZoomWindow() {}
-
-       static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
-
-    virtual void init(int status=0);
-    virtual void trigger();
-    virtual void mouseMoveEvent(QMouseEvent* e);
-    virtual void mousePressEvent(QMouseEvent* e);
-    virtual void mouseReleaseEvent(QMouseEvent* e);
-    virtual void updateMouseButtonHints();
-    virtual void updateMouseCursor();
-
-protected:
-    Vector v1;
-    Vector v2;
-
-    bool keepAspectRatio;
+class RS_ActionZoomWindow: public RS_PreviewActionInterface
+{
+       public:
+               RS_ActionZoomWindow(RS_EntityContainer & container, RS_GraphicView & graphicView, bool keepAspectRatio = true);
+               ~RS_ActionZoomWindow();
+
+               virtual void init(int status = 0);
+               virtual void trigger();
+               virtual void mouseMoveEvent(QMouseEvent * e);
+               virtual void mousePressEvent(QMouseEvent * e);
+               virtual void mouseReleaseEvent(QMouseEvent * e);
+               virtual void updateMouseButtonHints();
+               virtual void updateMouseCursor();
+
+       protected:
+               Vector v1;
+               Vector v2;
+
+               bool keepAspectRatio;
 };
 
 #endif
index 60a8f057c0883da34d307ac33ec3a5141a2ae224..a17cad6c7faae283680d201299ef8300ac833a8f 100644 (file)
@@ -586,6 +586,7 @@ Qt::KeyButtonMask   Qt::KeyboardModifierMask
                Keypad          = Qt::KeypadModifier
        };
 
+#if 1
     /**
      * Wrapper for Qt
      */
@@ -601,6 +602,7 @@ Qt::KeyButtonMask   Qt::KeyboardModifierMask
 //        return (RS2::ButtonState)t;
 //    }
     static RS2::ButtonState qtToRsButtonState(int t) { return (RS2::ButtonState)t; }
+#endif
 
     /**
      * Enum of line styles:
index 9d4f4e55ef90afae8b304dfe2aab0147b21b9155..9557d315219a61341a42f49a46cfdd1722f16b89 100644 (file)
 
 #include "rs_actioninterface.h"
 
+#include "commands.h"
+#include "rs_debug.h"
+#include "rs_entitycontainer.h"
+#include "rs_graphicview.h"
+
 /**
  * Constructor.
  *
@@ -60,9 +65,9 @@ RS_ActionInterface::RS_ActionInterface(const char * name,
  */
 RS_ActionInterface::~RS_ActionInterface()
 {
-//JLH: Only it isn't pure virtual...
        // would be pure virtual now:
        // hideOptions();
+//JLH: Only it isn't pure virtual...
 }
 
 /**
@@ -158,7 +163,8 @@ void RS_ActionInterface::keyReleaseEvent(QKeyEvent * e)
  * This function can be overwritten by the implementing action.
  * The default implementation does nothing.
  */
-void RS_ActionInterface::coordinateEvent(RS_CoordinateEvent *)
+//void RS_ActionInterface::coordinateEvent(RS_CoordinateEvent *)
+void RS_ActionInterface::coordinateEvent(Vector *)
 {
 }
 
index ed76836ee94700b1f8ab85ef959443f4cf22e073..8b16095d98e57255722a06c4c6a6a7d0ab15d4ec 100644 (file)
@@ -1,26 +1,15 @@
 #ifndef RS_ACTIONINTERFACE_H
 #define RS_ACTIONINTERFACE_H
 
-#include <QtCore>
-
-#include "rs_entitycontainer.h"
-#include "rs_commandevent.h"
-//#include "rs_event.h"
-#include "drawing.h"
-#include "rs_graphicview.h"
+#include <QtGui>
 #include "rs_snapper.h"
-#include "rs_preview.h"
-#include "rs_dialogfactory.h"
-
-#ifndef RS_NO_QCADCMD
-#include "commands.h"
-#endif
 
-//template<class T> T* instantiate(RS_EntityContainer& container, RS_GraphicView& graphicView) {
-//     return new T(container, graphicView);
-       //void (*function)() = T::instantiate;
-       //return (*function)();
-//}
+class RS_CommandEvent;
+class RS_Document;
+class Drawing;
+class RS_EntityContainer;
+class RS_GraphicView;
+class Vector;
 
 /**
  * This is the interface that must be implemented for all
 class RS_ActionInterface: public QObject, public RS_Snapper
 {
 //huh? no slots/signals here...    Q_OBJECT
-
+//WHY derive from QObject???
+//for the TR macro???
        public:
                RS_ActionInterface(const char * name, RS_EntityContainer & container,
                        RS_GraphicView & graphicView);
                virtual ~RS_ActionInterface();
 
                virtual RS2::ActionType rtti();
-
                QString getName();
-
                virtual void init(int status = 0);
                virtual void mouseMoveEvent(QMouseEvent *);
                virtual void mousePressEvent(QMouseEvent *);
-
                virtual void mouseReleaseEvent(QMouseEvent *);
                virtual void keyPressEvent(QKeyEvent * e);
                virtual void keyReleaseEvent(QKeyEvent * e);
-               virtual void coordinateEvent(RS_CoordinateEvent *);
+//             virtual void coordinateEvent(RS_CoordinateEvent *);
+               virtual void coordinateEvent(Vector *);
                virtual void commandEvent(RS_CommandEvent *);
                virtual QStringList getAvailableCommands();
                virtual void setStatus(int status);
@@ -75,14 +63,14 @@ class RS_ActionInterface: public QObject, public RS_Snapper
 
        private:
                /**
-               * Current status of the action. After an action has
-               * been created the action status is set to 0. Actions
-               * that are terminated have a status of -1. Other status
-               * numbers can be used to describe the stage this action
-               * is in. E.g. a window zoom consists of selecting the
-               * first corner (status 0), and selecting the second
-               * corner (status 1).
-               */
+                * Current status of the action. After an action has
+                * been created the action status is set to 0. Actions
+                * that are terminated have a status of -1. Other status
+                * numbers can be used to describe the stage this action
+                * is in. E.g. a window zoom consists of selecting the
+                * first corner (status 0), and selecting the second
+                * corner (status 1).
+                */
                int status;
 
        protected:
@@ -90,53 +78,26 @@ class RS_ActionInterface: public QObject, public RS_Snapper
                QString name;
 
                /**
-               * This flag is set when the action has terminated and
-               * can be deleted.
-               */
+                * This flag is set when the action has terminated and
+                * can be deleted.
+                */
                bool finished;
 
                /**
-               * Pointer to the graphic is this container is a graphic.
-               * NULL otherwise
-               */
+                * Pointer to the graphic is this container is a graphic.
+                * NULL otherwise
+                */
                Drawing * graphic;
 
                /**
-               * Pointer to the document (graphic or block) or NULL.
-               */
+                * Pointer to the document (graphic or block) or NULL.
+                */
                RS_Document * document;
 
                /**
-               * Pointer to the default mouse cursor for this action or NULL.
-               */
-               //RS2::CursorType cursor;
-
-               /**
-               * Predecessor of this action or NULL.
-               */
+                * Predecessor of this action or NULL.
+                */
                RS_ActionInterface * predecessor;
-
-               /**
-               * String prepended to the help text for currently available commands.
-               */
-               //static QString msgAvailableCommands;
-
-               /**
-               * Command used for showing help for every action.
-               */
-               //static QString cmdHelp;
-
-               /**
-               * Command for answering yes to a question.
-               */
-               //static QString cmdYes;
-               //static QString cmdYes2;
-
-               /**
-               * Command for answering no to a question.
-               */
-               //static QString cmdNo;
-               //static QString cmdNo2;
 };
 
 #endif
diff --git a/src/base/rs_commandevent.cpp b/src/base/rs_commandevent.cpp
new file mode 100644 (file)
index 0000000..519f7ec
--- /dev/null
@@ -0,0 +1,52 @@
+// rs_commandevent.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/02/2010  Added this text. :-)
+// JLH  06/02/2010  Moved implementation from header to here WHERE IT BELONGS.
+//
+
+#include "rs_commandevent.h"
+
+/**
+ * Creates a new command event that is not yet accepted.
+ *
+ * @param cmd the command that was triggered.
+ */
+RS_CommandEvent::RS_CommandEvent(const QString & cmd)
+{
+       this->cmd = cmd;
+       accepted = false;
+}
+
+/**
+ * @return the command that was triggered, usually by
+ * the user.
+ */
+QString RS_CommandEvent::getCommand()
+{
+       return cmd;
+}
+
+/**
+ * Sets the event state to accepted.
+ */
+void RS_CommandEvent::accept()
+{
+       accepted = true;
+}
+
+/**
+ * @return Whether the event was already accepted or not.
+ */
+bool RS_CommandEvent::isAccepted()
+{
+       return accepted;
+}
index 6d6ca7c0c861dd3a3d1f035b7c57c4641e21d9d4..d766588ade3b861f29428f8684fef4cf49bd96e1 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef RS_COMMANDEVENT_H
 #define RS_COMMANDEVENT_H
 
+#include <QtCore>
+
 /**
  * Command Events.
  */
index fb99b2f25e215529f007e0f334f823d462d950e6..a8a14e078afab4cc2a9b81f35a14e195547a88e4 100644 (file)
 
 #include "rs_creation.h"
 
-#include <QtCore>
 #include "rs_constructionline.h"
 #include "drawing.h"
 #include "rs_graphicview.h"
+#include "rs_image.h"
 #include "rs_information.h"
+#include "rs_insert.h"
 #include "rs_modification.h"
 #include "rs_units.h"
 
@@ -1056,43 +1057,39 @@ RS_Line* RS_Creation::createPolygon2(const Vector& corner1,
     return ret;
 }
 
-
-
 /**
  * Creates an insert with the given data.
  *
  * @param data Insert data (position, block name, ..)
  */
-RS_Insert* RS_Creation::createInsert(RS_InsertData& data) {
-
-    RS_DEBUG->print("RS_Creation::createInsert");
+RS_Insert* RS_Creation::createInsert(RS_InsertData & data)
+{
+       RS_DEBUG->print("RS_Creation::createInsert");
 
-    if (document!=NULL && handleUndo) {
-        document->startUndoCycle();
-    }
+       if (document != NULL && handleUndo)
+               document->startUndoCycle();
 
-    RS_Insert* ins = new RS_Insert(container, data);
-    // inserts are also on layers
-    ins->setLayerToActive();
-    ins->setPenToActive();
+       RS_Insert * ins = new RS_Insert(container, data);
+       // inserts are also on layers
+       ins->setLayerToActive();
+       ins->setPenToActive();
 
-    if (container!=NULL) {
-        container->addEntity(ins);
-    }
-    if (document!=NULL && handleUndo) {
-        document->addUndoable(ins);
-        document->endUndoCycle();
-    }
-    if (graphicView!=NULL) {
-        graphicView->drawEntity(ins);
-    }
+       if (container != NULL)
+               container->addEntity(ins);
 
-    RS_DEBUG->print("RS_Creation::createInsert: OK");
+       if (document != NULL && handleUndo)
+       {
+               document->addUndoable(ins);
+               document->endUndoCycle();
+       }
 
-    return ins;
-}
+       if (graphicView != NULL)
+               graphicView->drawEntity(ins);
 
+       RS_DEBUG->print("RS_Creation::createInsert: OK");
 
+       return ins;
+}
 
 /**
  * Creates an image with the given data.
index e2a6c887e05e60fd7c833839fbadd4c13eda30f4..64b4a899fe3ccaec303277a77fa516ac13623be6 100644 (file)
@@ -1,11 +1,23 @@
 #ifndef RS_CREATION_H
 #define RS_CREATION_H
 
-#include "rs_entitycontainer.h"
-#include "rs_line.h"
-#include "rs_polyline.h"
-#include "rs_insert.h"
-#include "rs_image.h"
+#include <QtCore>
+#include "vector.h"
+
+class RS_EntityContainer;
+class RS_GraphicView;
+class RS_Entity;
+class RS_Line;
+class RS_Circle;
+class RS_Arc;
+class RS_Image;
+class RS_Block;
+class RS_Insert;
+class Drawing;
+class RS_Document;
+class RS_ImageData;
+class RS_InsertData;
+class RS_BlockData;
 
 /**
  * Data needed to insert library items.
index 29e03186f83c9ae02efed0a8c8679a5dcd31c053..2961ff733d4e2e8b4e902e62462d67c8cc1ab732 100644 (file)
 
 #include <QtGui>
 #include "rs_actioninterface.h"
-#include "rs_coordinateevent.h"
+#include "rs_commandevent.h"
+#include "rs_debug.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_math.h"
 
 /**
  * Constructor.
@@ -218,23 +222,20 @@ void RS_EventHandler::keyPressEvent(QKeyEvent * e)
 /**
  * Called by RS_GraphicView
  */
-void RS_EventHandler::keyReleaseEvent(QKeyEvent* e)
+void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
 {
-       if (actionIndex >= 0 && currentActions[actionIndex] != NULL &&
-               !currentActions[actionIndex]->isFinished())
+       if (actionIndex >= 0 && currentActions[actionIndex] != NULL
+               && !currentActions[actionIndex]->isFinished())
        {
                currentActions[actionIndex]->keyReleaseEvent(e);
        }
        else
        {
                if (defaultAction != NULL)
-               {
                        defaultAction->keyReleaseEvent(e);
-               }
                else
-               {
                        e->ignore();
-               }
+
                //RS_DEBUG->print("currently no action defined");
        }
 }
@@ -268,9 +269,11 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
 
                                        if (ok1 && ok2)
                                        {
-                                               RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
-                                               RS_CoordinateEvent ce(Vector(x, y));
+//                                             RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
+//                                             RS_CoordinateEvent ce(Vector(x, y));
                                                RS_DEBUG->print("RS_EventHandler::commandEvent: 006");
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               Vector ce(x, y);
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
@@ -292,7 +295,6 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                if (actionIndex >= 0 && currentActions[actionIndex] != NULL
                                        && !currentActions[actionIndex]->isFinished())
                                {
-//                                     int commaPos = cmd.find(',');
                                        int commaPos = cmd.indexOf(',');
                                        bool ok1, ok2;
                                        double x = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
@@ -300,8 +302,9 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
 
                                        if (ok1 && ok2)
                                        {
-                                               RS_CoordinateEvent ce(Vector(x,y) +
-                                                       graphicView->getRelativeZero());
+//                                             RS_CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               Vector ce(Vector(x,y) + graphicView->getRelativeZero());
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
@@ -333,8 +336,9 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                        {
                                                Vector pos;
                                                pos.setPolar(r,RS_Math::deg2rad(a));
-                                               RS_CoordinateEvent ce(pos);
-                                               currentActions[actionIndex]->coordinateEvent(&ce);
+//                                             RS_CoordinateEvent ce(pos);
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               currentActions[actionIndex]->coordinateEvent(&pos);
                                        }
                                        else
                                        {
@@ -365,8 +369,9 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                        {
                                                Vector pos;
                                                pos.setPolar(r,RS_Math::deg2rad(a));
-                                               RS_CoordinateEvent ce(pos +
-                                                       graphicView->getRelativeZero());
+//                                             RS_CoordinateEvent ce(pos + graphicView->getRelativeZero());
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               Vector ce(pos + graphicView->getRelativeZero());
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
@@ -393,10 +398,7 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                else
                {
                        if (defaultAction != NULL)
-                       {
                                defaultAction->commandEvent(e);
-                               //e->accept();
-                       }
                }
        }
 
index 28d86c9852815bd877e6121e38328b51cb2509bc..4dd3e13cc5b14c81a59565d92e404540e0d44288 100644 (file)
 
 #include <stdio.h>
 #include "rs_actioninterface.h"
-#include "rs_application.h"
 #include "rs_block.h"
-#include "rs_eventhandler.h"
+#include "rs_dialogfactory.h"
 #include "drawing.h"
+#include "rs_eventhandler.h"
 #include "rs_grid.h"
 #include "rs_insert.h"
 #include "rs_layer.h"
index d4bcdf0bbfa7ad6d067a7f5af9b70783837dee89..9ba6a1ea76a09b3bd0b7e45fcc3346acd953418e 100644 (file)
@@ -26,296 +26,296 @@ class PaintInterface;
  */
 class RS_GraphicView
 {
-public:
-    RS_GraphicView();
-    virtual ~RS_GraphicView();
-
-       void cleanUp();
-
-    Drawing * getGraphic();
-    void setDrawingMode(RS2::DrawingMode m);
-    RS2::DrawingMode getDrawingMode();
-    void setDeleteMode(bool m);
-    bool getDeleteMode();
-
-    /** This virtual method must be overwritten to return
-      the width of the widget the graphic is shown in */
-    virtual int getWidth() = 0;
-    /** This virtual method must be overwritten to return
-      the height of the widget the graphic is shown in */
-    virtual int getHeight() = 0;
-    /** This virtual method must be overwritten to redraw
-      the widget. */
-    virtual void redraw() = 0;
-    /** This virtual method must be overwritten and is then
-      called whenever the view changed */
-    virtual void adjustOffsetControls();
-    /** This virtual method must be overwritten and is then
-      called whenever the view changed */
-    virtual void adjustZoomControls();
-       /**
-        * Sets an external painter device.
-        */
-    virtual void setPainter(PaintInterface * p);
-//    virtual void setPainter(RS_Painter * p);
-    /** This virtual method must be overwritten and must return
-      the painter device for the buffer of this widget */
-    virtual PaintInterface * createPainter() = 0;
-//    virtual RS_Painter * createPainter() = 0;
-    /**
-     * This virtual method must be overwritten and must return
-     *  the direct painter device for this widget
-     */
-    virtual PaintInterface * createDirectPainter() = 0;
-//    virtual RS_Painter * createDirectPainter() = 0;
-    /**
-     * This virtual method must be overwritten and must destroy
-     * the painter device and point 'painter' to NULL. If the painter
-     * is static during the whole life of the application, it might
-     * just do nothing.
-     */
-    virtual void destroyPainter() = 0;
-
-       virtual void setBackground(const RS_Color & bg);
-       RS_Color getBackground();
-       RS_Color getForeground();
-       void setGridColor(const RS_Color & c);
-       void setMetaGridColor(const RS_Color & c);
-       void setSelectedColor(const RS_Color & c);
-       void setHighlightedColor(const RS_Color & c);
-    virtual void setMouseCursor(RS2::CursorType /*c*/);
-    void setContainer(RS_EntityContainer * container);
-       RS_EntityContainer* getContainer();
-    void setFactor(double f);
-    void setFactorX(double f);
-    void setFactorY(double f);
-    Vector getFactor();
-    void setOffset(int ox, int oy);
-    void setOffsetX(int ox);
-    void setOffsetY(int oy);
-    int getOffsetX();
-    int getOffsetY();
-    void centerOffsetX();
-    void centerOffsetY();
-    void centerX(double x);
-    void centerY(double y);
-    virtual void updateView();
-    void setBorders(int left, int top, int right, int bottom);
-    int getBorderLeft();
-    int getBorderTop();
-    int getBorderRight();
-    int getBorderBottom();
-    void disableUpdate();
-    void enableUpdate();
-    bool isUpdateEnabled();
-    void freezeZoom(bool freeze);
-    bool isZoomFrozen();
-
-    void setDefaultAction(RS_ActionInterface * action);
-    RS_ActionInterface *  getDefaultAction();
-    void setCurrentAction(RS_ActionInterface * action);
-    RS_ActionInterface * getCurrentAction();
-
-    void killSelectActions();
-    void killAllActions();
-
-    /**
-     * Must be overwritten to emulate a mouse move event with
-     * the last known mouse position.
-     *
-     * @see mx, my
-     */
-    virtual void emulateMouseMoveEvent() = 0;
-
-    void back();
-    void enter();
-
-    void mousePressEvent(QMouseEvent * e);
-    void mouseReleaseEvent(QMouseEvent * e);
-    void mouseMoveEvent(QMouseEvent * e);
-    void mouseLeaveEvent();
-    void mouseEnterEvent();
-    void keyPressEvent(QKeyEvent * e);
-    void keyReleaseEvent(QKeyEvent * e);
-       void commandEvent(RS_CommandEvent * e);
-       void enableCoordinateInput();
-       void disableCoordinateInput();
-
-    virtual void zoomIn(double f = 1.5, const Vector & center = Vector(false));
-    virtual void zoomInX(double f = 1.5);
-    virtual void zoomInY(double f = 1.5);
-    virtual void zoomOut(double f = 1.5, const Vector & center = Vector(false));
-    virtual void zoomOutX(double f = 1.5);
-    virtual void zoomOutY(double f = 1.5);
-    virtual void zoomAuto(bool axis = true, bool keepAspectRatio = true);
-    virtual void zoomAutoY(bool axis = true);
-    virtual void zoomPrevious();
-       virtual void saveView();
-       virtual void restoreView();
-    virtual void zoomWindow(Vector v1, Vector v2, bool keepAspectRatio = true);
-    //virtual void zoomPan(Vector v1);
-    virtual void zoomPan(int dx, int dy);
-    virtual void zoomScroll(RS2::Direction direction);
-    virtual void zoomPage();
-
-    virtual void drawWindow(Vector v1, Vector v2);
-    virtual void drawIt();
-    virtual void deleteEntity(RS_Entity * e);
-    virtual void drawEntity(RS_Entity * e, double patternOffset = 0.0, bool db = false);
-    virtual void drawEntityPlain(RS_Entity * e, double patternOffset = 0.0);
-    virtual void setPenForEntity(RS_Entity * e);
-
-    void simulateIt();
-    void simulateEntity(RS_Entity * e, const RS_Pen & pen);
-       void drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen);
-       void drawArcSmooth(const Vector & center, double radius,
-               double a1, double a2, bool rev, const RS_Pen & pen);
-       void simulationDelay(bool step = false);
-
-    virtual RS_LineTypePattern * getPattern(RS2::LineType t);
-
-    virtual void drawAbsoluteZero();
-    virtual void drawRelativeZero();
-    virtual void drawPaper();
-    virtual void drawGrid();
-    virtual void drawMetaGrid();
-    virtual void updateGrid();
-    RS_Grid * getGrid();
-       virtual void updateGridStatusWidget(const QString & /*text*/);
-
-    void setDefaultSnapMode(RS2::SnapMode sm);
-    RS2::SnapMode getDefaultSnapMode();
-    void setSnapRestriction(RS2::SnapRestriction sr);
-    RS2::SnapRestriction getSnapRestriction();
-    bool isGridOn();
-
-    Vector toGui(Vector v);
-    double toGuiX(double x, bool * visible = NULL);
-    double toGuiY(double y);
-    double toGuiDX(double d);
-    double toGuiDY(double d);
-
-    Vector toGraph(Vector v);
-    Vector toGraph(int x, int y);
-    double toGraphX(int x);
-    double toGraphY(int y);
-    double toGraphDX(int d);
-    double toGraphDY(int d);
-
-       void lockRelativeZero(bool lock);
-       bool isRelativeZeroLocked();
-       Vector getRelativeZero();
-       void setRelativeZero(const Vector & pos);
-       void moveRelativeZero(const Vector & pos);
-
-       RS_EventHandler * getEventHandler();
-       void setPrintPreview(bool pv);
-       bool isPrintPreview();
-       void setPrinting(bool p);
-       bool isPrinting();
-       bool isDraftMode();
-       void setSimulationSpeed(int s);
-       int getSimulationSpeed();
-       void setSimulationSmooth(bool s);
-       void setSimulationRapid(bool r);
-       bool getSimulationRapid();
-
-       //this is here because of crappy braindead infrastructure
-       void SetPreviewMode(bool mode = true);
-       void SetPreviewEntity(RS_Preview *);
-       void SetPreviewOffset(Vector);
-       void SetSnapperDraw(bool);
-       void SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs);
-
-protected:
-    RS_EntityContainer * container;
-    RS_EventHandler * eventHandler;
-
-    int mx;   //!< Last known mouse cursor position
-    int my;   //!< Last known mouse cursor position
-
-//    RS_Painter * painter;
-       PaintInterface * painter;
-    /** background color (any color) */
-    RS_Color background;
-    /** foreground color (black or white) */
-    RS_Color foreground;
-       /** grid color */
-    RS_Color gridColor;
-       /** meta grid color */
-       RS_Color metaGridColor;
-    /** selected color */
-    RS_Color selectedColor;
-    /** highlighted color */
-    RS_Color highlightedColor;
-    /** Grid */
-    RS_Grid * grid;
-    /**
-        * Current default snap mode for this graphic view. Used for new
-        * actions.
-        */
-    RS2::SnapMode defaultSnapMode;
-    /**
-        * Current default snap restriction for this graphic view. Used for new
-        * actions.
-        */
-    RS2::SnapRestriction defaultSnapRes;
-
-    RS2::DrawingMode drawingMode;
-
-       /**
-        * Delete mode. If true, all drawing actions will delete in background color
-        * instead.
-        */
-       bool deleteMode;
-       //! If true, the simulation is currectly running
-       bool simulationRunning;
-
-private:
-    int updateEnabled;
-    bool zoomFrozen;
-    //bool gridVisible;
-       bool draftMode;
-
-    Vector factor;
-       int offsetX;
-    int offsetY;
-
-       Vector previousFactor;
-       int previousOffsetX;
-    int previousOffsetY;
-
-    int borderLeft;
-    int borderTop;
-    int borderRight;
-    int borderBottom;
-
-       Vector relativeZero;
-       bool relativeZeroLocked;
-       //! Print preview flag
-       bool printPreview;
-       //! Active when printing only:
-       bool printing;
-       //int drawRecursion;
-
-       //! Simulation speed in percentage
-       int simulationSpeed;
-       //! If true, the entity is drawn slowly (pixel by pixel).
-       bool simulationSmooth;
-       //! If true, the way between entities is also shown.
-       bool simulationRapid;
-       //! Last position (for rapid move)
-       Vector simulationLast;
-
-protected:
-       // crap to make painting with update() possible
-       RS_Preview * previewEntity;
-       bool previewMode;
-       Vector previewOffset;
-       bool snapperDraw;
-       Vector snapSpot1;
-       Vector snapCoord1;
-       bool showCrosshairs1;
+       public:
+               RS_GraphicView();
+               virtual ~RS_GraphicView();
+
+               void cleanUp();
+
+               Drawing * getGraphic();
+               void setDrawingMode(RS2::DrawingMode m);
+               RS2::DrawingMode getDrawingMode();
+               void setDeleteMode(bool m);
+               bool getDeleteMode();
+
+               /** This virtual method must be overwritten to return
+               the width of the widget the graphic is shown in */
+               virtual int getWidth() = 0;
+               /** This virtual method must be overwritten to return
+               the height of the widget the graphic is shown in */
+               virtual int getHeight() = 0;
+               /** This virtual method must be overwritten to redraw
+               the widget. */
+               virtual void redraw() = 0;
+               /** This virtual method must be overwritten and is then
+               called whenever the view changed */
+               virtual void adjustOffsetControls();
+               /** This virtual method must be overwritten and is then
+               called whenever the view changed */
+               virtual void adjustZoomControls();
+               /**
+                * Sets an external painter device.
+                */
+               virtual void setPainter(PaintInterface * p);
+       //    virtual void setPainter(RS_Painter * p);
+               /** This virtual method must be overwritten and must return
+               the painter device for the buffer of this widget */
+               virtual PaintInterface * createPainter() = 0;
+       //    virtual RS_Painter * createPainter() = 0;
+               /**
+                * This virtual method must be overwritten and must return
+                *  the direct painter device for this widget
+                */
+               virtual PaintInterface * createDirectPainter() = 0;
+       //    virtual RS_Painter * createDirectPainter() = 0;
+               /**
+                * This virtual method must be overwritten and must destroy
+                * the painter device and point 'painter' to NULL. If the painter
+                * is static during the whole life of the application, it might
+                * just do nothing.
+                */
+               virtual void destroyPainter() = 0;
+
+               virtual void setBackground(const RS_Color & bg);
+               RS_Color getBackground();
+               RS_Color getForeground();
+               void setGridColor(const RS_Color & c);
+               void setMetaGridColor(const RS_Color & c);
+               void setSelectedColor(const RS_Color & c);
+               void setHighlightedColor(const RS_Color & c);
+               virtual void setMouseCursor(RS2::CursorType /*c*/);
+               void setContainer(RS_EntityContainer * container);
+               RS_EntityContainer * getContainer();
+               void setFactor(double f);
+               void setFactorX(double f);
+               void setFactorY(double f);
+               Vector getFactor();
+               void setOffset(int ox, int oy);
+               void setOffsetX(int ox);
+               void setOffsetY(int oy);
+               int getOffsetX();
+               int getOffsetY();
+               void centerOffsetX();
+               void centerOffsetY();
+               void centerX(double x);
+               void centerY(double y);
+               virtual void updateView();
+               void setBorders(int left, int top, int right, int bottom);
+               int getBorderLeft();
+               int getBorderTop();
+               int getBorderRight();
+               int getBorderBottom();
+               void disableUpdate();
+               void enableUpdate();
+               bool isUpdateEnabled();
+               void freezeZoom(bool freeze);
+               bool isZoomFrozen();
+
+               void setDefaultAction(RS_ActionInterface * action);
+               RS_ActionInterface *  getDefaultAction();
+               void setCurrentAction(RS_ActionInterface * action);
+               RS_ActionInterface * getCurrentAction();
+
+               void killSelectActions();
+               void killAllActions();
+
+               /**
+                * Must be overwritten to emulate a mouse move event with
+                * the last known mouse position.
+                *
+                * @see mx, my
+                */
+               virtual void emulateMouseMoveEvent() = 0;
+
+               void back();
+               void enter();
+
+               void mousePressEvent(QMouseEvent * e);
+               void mouseReleaseEvent(QMouseEvent * e);
+               void mouseMoveEvent(QMouseEvent * e);
+               void mouseLeaveEvent();
+               void mouseEnterEvent();
+               void keyPressEvent(QKeyEvent * e);
+               void keyReleaseEvent(QKeyEvent * e);
+               void commandEvent(RS_CommandEvent * e);
+               void enableCoordinateInput();
+               void disableCoordinateInput();
+
+               virtual void zoomIn(double f = 1.5, const Vector & center = Vector(false));
+               virtual void zoomInX(double f = 1.5);
+               virtual void zoomInY(double f = 1.5);
+               virtual void zoomOut(double f = 1.5, const Vector & center = Vector(false));
+               virtual void zoomOutX(double f = 1.5);
+               virtual void zoomOutY(double f = 1.5);
+               virtual void zoomAuto(bool axis = true, bool keepAspectRatio = true);
+               virtual void zoomAutoY(bool axis = true);
+               virtual void zoomPrevious();
+               virtual void saveView();
+               virtual void restoreView();
+               virtual void zoomWindow(Vector v1, Vector v2, bool keepAspectRatio = true);
+               //virtual void zoomPan(Vector v1);
+               virtual void zoomPan(int dx, int dy);
+               virtual void zoomScroll(RS2::Direction direction);
+               virtual void zoomPage();
+
+               virtual void drawWindow(Vector v1, Vector v2);
+               virtual void drawIt();
+               virtual void deleteEntity(RS_Entity * e);
+               virtual void drawEntity(RS_Entity * e, double patternOffset = 0.0, bool db = false);
+               virtual void drawEntityPlain(RS_Entity * e, double patternOffset = 0.0);
+               virtual void setPenForEntity(RS_Entity * e);
+
+               void simulateIt();
+               void simulateEntity(RS_Entity * e, const RS_Pen & pen);
+               void drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen);
+               void drawArcSmooth(const Vector & center, double radius,
+                       double a1, double a2, bool rev, const RS_Pen & pen);
+               void simulationDelay(bool step = false);
+
+               virtual RS_LineTypePattern * getPattern(RS2::LineType t);
+
+               virtual void drawAbsoluteZero();
+               virtual void drawRelativeZero();
+               virtual void drawPaper();
+               virtual void drawGrid();
+               virtual void drawMetaGrid();
+               virtual void updateGrid();
+               RS_Grid * getGrid();
+               virtual void updateGridStatusWidget(const QString & /*text*/);
+
+               void setDefaultSnapMode(RS2::SnapMode sm);
+               RS2::SnapMode getDefaultSnapMode();
+               void setSnapRestriction(RS2::SnapRestriction sr);
+               RS2::SnapRestriction getSnapRestriction();
+               bool isGridOn();
+
+               Vector toGui(Vector v);
+               double toGuiX(double x, bool * visible = NULL);
+               double toGuiY(double y);
+               double toGuiDX(double d);
+               double toGuiDY(double d);
+
+               Vector toGraph(Vector v);
+               Vector toGraph(int x, int y);
+               double toGraphX(int x);
+               double toGraphY(int y);
+               double toGraphDX(int d);
+               double toGraphDY(int d);
+
+               void lockRelativeZero(bool lock);
+               bool isRelativeZeroLocked();
+               Vector getRelativeZero();
+               void setRelativeZero(const Vector & pos);
+               void moveRelativeZero(const Vector & pos);
+
+               RS_EventHandler * getEventHandler();
+               void setPrintPreview(bool pv);
+               bool isPrintPreview();
+               void setPrinting(bool p);
+               bool isPrinting();
+               bool isDraftMode();
+               void setSimulationSpeed(int s);
+               int getSimulationSpeed();
+               void setSimulationSmooth(bool s);
+               void setSimulationRapid(bool r);
+               bool getSimulationRapid();
+
+               //this is here because of crappy braindead infrastructure
+               void SetPreviewMode(bool mode = true);
+               void SetPreviewEntity(RS_Preview *);
+               void SetPreviewOffset(Vector);
+               void SetSnapperDraw(bool);
+               void SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs);
+
+       protected:
+               RS_EntityContainer * container;
+               RS_EventHandler * eventHandler;
+
+               int mx;   //!< Last known mouse cursor position
+               int my;   //!< Last known mouse cursor position
+
+       //    RS_Painter * painter;
+               PaintInterface * painter;
+               /** background color (any color) */
+               RS_Color background;
+               /** foreground color (black or white) */
+               RS_Color foreground;
+               /** grid color */
+               RS_Color gridColor;
+               /** meta grid color */
+               RS_Color metaGridColor;
+               /** selected color */
+               RS_Color selectedColor;
+               /** highlighted color */
+               RS_Color highlightedColor;
+               /** Grid */
+               RS_Grid * grid;
+               /**
+               * Current default snap mode for this graphic view. Used for new
+               * actions.
+               */
+               RS2::SnapMode defaultSnapMode;
+               /**
+               * Current default snap restriction for this graphic view. Used for new
+               * actions.
+               */
+               RS2::SnapRestriction defaultSnapRes;
+
+               RS2::DrawingMode drawingMode;
+
+               /**
+               * Delete mode. If true, all drawing actions will delete in background color
+               * instead.
+               */
+               bool deleteMode;
+               //! If true, the simulation is currectly running
+               bool simulationRunning;
+
+       private:
+               int updateEnabled;
+               bool zoomFrozen;
+               //bool gridVisible;
+               bool draftMode;
+
+               Vector factor;
+               int offsetX;
+               int offsetY;
+
+               Vector previousFactor;
+               int previousOffsetX;
+               int previousOffsetY;
+
+               int borderLeft;
+               int borderTop;
+               int borderRight;
+               int borderBottom;
+
+               Vector relativeZero;
+               bool relativeZeroLocked;
+               //! Print preview flag
+               bool printPreview;
+               //! Active when printing only:
+               bool printing;
+               //int drawRecursion;
+
+               //! Simulation speed in percentage
+               int simulationSpeed;
+               //! If true, the entity is drawn slowly (pixel by pixel).
+               bool simulationSmooth;
+               //! If true, the way between entities is also shown.
+               bool simulationRapid;
+               //! Last position (for rapid move)
+               Vector simulationLast;
+
+       protected:
+               // crap to make painting with update() possible
+               RS_Preview * previewEntity;
+               bool previewMode;
+               Vector previewOffset;
+               bool snapperDraw;
+               Vector snapSpot1;
+               Vector snapCoord1;
+               bool showCrosshairs1;
 };
 
 #endif
index eb6a5c2cca09e97f253ae0a523870c2fcfe3ed31..b35fed1b1dcf1fc09fde3b185360e404a899a5f2 100644 (file)
 
 #include "rs_previewactioninterface.h"
 
+#include "rs_debug.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
+
 /**
  * Constructor.
  *
index 61424a8037653e3f17625cae8238997894441590..f29c3a957a630b3c497a28b9852906deec6645a9 100644 (file)
@@ -2,6 +2,7 @@
 #define RS_PREVIEWACTIONINTERFACE_H
 
 #include "rs_actioninterface.h"
+#include "vector.h"
 
 class RS_Preview;
 
index 1ee3007862032c1f1700345fec5ffe7a819ef85a..cc58b1ae161cca1ca755457041280d9975d450ca 100644 (file)
@@ -15,8 +15,8 @@
 #include "rs_snapper.h"
 
 #include "rs_dialogfactory.h"
-#include "rs_entitycontainer.h"
 #include "drawing.h"
+#include "rs_entitycontainer.h"
 #include "rs_graphicview.h"
 #include "rs_grid.h"
 #include "rs_information.h"
@@ -212,8 +212,8 @@ Vector RS_Snapper::snapFree(Vector coord)
 Vector RS_Snapper::snapEndpoint(Vector coord)
 {
        Vector vec(false);
-
        vec = container->getNearestEndpoint(coord, NULL/*, &keyEntity*/);
+
        return vec;
 }
 
@@ -279,6 +279,7 @@ Vector RS_Snapper::snapOnEntity(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestPointOnEntity(coord, true, NULL, &keyEntity);
+
        return vec;
 }
 
@@ -291,8 +292,8 @@ Vector RS_Snapper::snapOnEntity(Vector coord)
 Vector RS_Snapper::snapCenter(Vector coord)
 {
        Vector vec(false);
-
        vec = container->getNearestCenter(coord, NULL);
+
        return vec;
 }
 
@@ -305,8 +306,8 @@ Vector RS_Snapper::snapCenter(Vector coord)
 Vector RS_Snapper::snapMiddle(Vector coord)
 {
        Vector vec(false);
-
        vec = container->getNearestMiddle(coord, NULL);
+
        return vec;
 }
 
@@ -319,8 +320,8 @@ Vector RS_Snapper::snapMiddle(Vector coord)
 Vector RS_Snapper::snapDist(Vector coord)
 {
        Vector vec(false);
-
        vec = container->getNearestDist(distance, coord, NULL);
+
        return vec;
 }
 
@@ -333,8 +334,8 @@ Vector RS_Snapper::snapDist(Vector coord)
 Vector RS_Snapper::snapIntersection(Vector coord)
 {
        Vector vec(false);
-
        vec = container->getNearestIntersection(coord, NULL);
+
        return vec;
 }
 
index baceae4dd893aba95259034c76de263c2b179379..89351d6ad3f6d5b7ce0e21e5c75d3dcb075dcde0 100644 (file)
@@ -2,14 +2,12 @@
 #define RS_SNAPPER_H
 
 #include <QtCore>
-
 #include "rs.h"
-#include "rs_entitycontainer.h"
-#include "rs_coordinateevent.h"
+#include "vector.h"
 
 class RS_Entity;
+class RS_EntityContainer;
 class RS_GraphicView;
-class Vector;
 
 /**
  * This class is used for snapping functions in a graphic view.