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 \
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 \
** 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_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)
{
}
// 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)
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
** 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
** 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
** 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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
** 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();
}
** 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
** 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
** 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
#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();
RS_ActionInterface::init(status);
trigger();
}
+
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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());
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:
{
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;
break;
}
}
- }
}
while (!done);
}
RS_ActionInterface::init(status);
trigger();
}
+
-/****************************************************************************
-** $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();
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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()
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()
RS_ActionInterface::hideOptions();
if (RS_DIALOGFACTORY != NULL)
- {
RS_DIALOGFACTORY->requestOptions(this, false);
- }
}
void RS_ActionDimension::showOptions()
RS_ActionInterface::showOptions();
if (RS_DIALOGFACTORY != NULL)
- {
RS_DIALOGFACTORY->requestOptions(this, true, true);
- }
}
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);
+}
+
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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();
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));
// 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);
Vector mouse = snapPoint(e);
- if (getStatus()==SetEndpoint && points.last()!=NULL)
+ if (getStatus() == SetEndpoint && points.last() != NULL)
{
deletePreview();
clearPreview();
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];
{
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)
}
}
-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())
{
if (checkCommand("help", c))
{
if (RS_DIALOGFACTORY != NULL)
- {
RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
- }
return;
}
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;
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
}
}
+
-/****************************************************************************
-** $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. */
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();
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();
/**
* Points set so far.
*/
- // Q3PtrList<Vector> points;
+ // Q3PtrList<Vector> points;
QList<Vector *> points;
};
#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();
}
{
}
-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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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;
break;
case SetRadius:
+
if (data.center.valid)
{
data.radius = data.center.distanceTo(mouse);
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;
drawPreview();
}
}
- break;
+ break;
default:
break;
-
}
RS_DEBUG->print("RS_ActionDrawArc::mouseMoveEvent end");
{
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)
}
}
-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);
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()
{
data.reversed = r;
}
+
-/****************************************************************************
-** $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. */
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
-/****************************************************************************
-** $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();
reset();
}
else
- {
RS_DIALOGFACTORY->commandMessage(tr("Invalid arc data."));
- }
}
void RS_ActionDrawArc3P::preparePreview()
{
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)
}
}
-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())
{
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;
else
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs);
}
+
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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;
+}
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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;
+}
-/****************************************************************************
-** $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
//
#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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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();
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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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)
{
}
{
}
-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)
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()
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();
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);
}
}
-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();
}
switch (getStatus())
{
case SetTargetPoint:
+
if (checkCommand("angle", c))
{
deleteSnapper();
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;
cmd += command("angle");
cmd += command("factor");
break;
+
default:
break;
}
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;
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);
+}
+
-/****************************************************************************
-** $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
#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");
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");
{
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)
}
}
-void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawLine::coordinateEvent(Vector * e)
{
RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent");
return;
}
- Vector mouse = e->getCoordinate();
+ Vector mouse = *e;
switch (getStatus())
{
switch (getStatus())
{
case SetStartpoint:
+
if (checkCommand("help", c))
{
RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
break;
case SetEndpoint:
+
if (checkCommand("close", c))
{
close();
{
case SetStartpoint:
break;
+
case SetEndpoint:
+
if (history.count() >= 2)
cmd += command("undo");
cmd += command("close");
break;
+
default:
break;
}
case SetStartpoint:
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
break;
+
case SetEndpoint:
{
QString msg = "";
}
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;
graphicView->moveRelativeZero(start);
}
else
- {
RS_DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet."));
- }
}
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)
while (!history.isEmpty())
delete history.takeFirst();
}
+
*/
class RS_ActionDrawLine: public RS_PreviewActionInterface
{
-//No slots/signals... //Q_OBJECT
-
public:
/**
- * Action States.
- */
+ * Action States.
+ */
enum Status
{
SetStartpoint = 0, /**< Setting the startpoint. */
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();
/**
* Point history (for undo)
*/
-// Q3PtrList<Vector> history;
QList<Vector *> history;
};
// 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()
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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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
#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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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
#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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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)
{
}
{
}
-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)
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)
}
}
-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();
case 0:
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify location"), tr("Cancel"));
break;
+
default:
RS_DIALOGFACTORY->updateMouseWidget("", "");
break;
}
}
-void RS_ActionDrawPoint::updateMouseCursor() {
- graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionDrawPoint::updateMouseCursor()
+{
+ graphicView->setMouseCursor(RS2::CadCursor);
}
void RS_ActionDrawPoint::updateToolBar()
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarPoints);
}
}
+
#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();
-/****************************************************************************
-** $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();
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)
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();
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();
//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 {
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;
}
-/****************************************************************************
-** $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. */
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();
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
#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;
graphicView->redraw();
}
- break;
+ break;
case SetPos:
RS_DIALOGFACTORY->requestOptions(this, true, true);
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()
{
if (e->button() == Qt::LeftButton)
{
- RS_CoordinateEvent ce(snapPoint(e));
+ Vector ce(snapPoint(e));
coordinateEvent(&ce);
}
else if (e->button() == Qt::RightButton)
}
}
-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())
{
if (checkCommand("help", c))
{
if (RS_DIALOGFACTORY != NULL)
- {
RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
- }
return;
}
switch (getStatus())
{
case SetPos:
+
if (checkCommand("text", c))
{
deleteSnapper();
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;
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())
case SetPos:
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
break;
+
default:
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
break;
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;
}
+
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();
#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
#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();
-/****************************************************************************
-** $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)
{
}
{
}
-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
-/****************************************************************************
-** $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
//
#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;
}
{
}
-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);
finish();
RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
}
+
#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();
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
+// 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)
{
}
{
}
-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();
}
+
*/
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();
};
-/****************************************************************************
-** $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()
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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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
*/
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();
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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)
{
}
{
}
-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)
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)
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;
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)
{
{
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)
}
}
-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();
}
switch (getStatus())
{
case SetTargetPoint:
+
if (checkCommand("angle", c))
{
deleteSnapper();
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:
{
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;
case SetTargetPoint:
cmd += command("angle");
cmd += command("factor");
- ;
break;
+
default:
break;
}
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;
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;
+}
+
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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;
}
/**
*/
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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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();
+}
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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)
}
}
-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)
case SetReferencePoint:
case SetTargetPoint:
#warning "Bad comparison (in checkCommand -> rs_actioninterface)... !!! FIX !!!"
+
if (!c.isEmpty() && checkCommand("angle", c))
// if (c == checkCommand("angle", c))
{
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;
+}
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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;
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;
+}
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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);
+}
#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
-/****************************************************************************
-** $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;
+}
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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();
}
}
-
-
-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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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);
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
}
}
-
-// EOF
-/****************************************************************************
-** $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
//
// 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)
{
RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
}
-
-// EOF
#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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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
#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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
#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
#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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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()
RS_ActionInterface::init(status);
trigger();
}
-
-// EOF
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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;
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)
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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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();
}
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);
}
}
RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num));
}
else
- {
RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found"));
- }
finish();
}
-
// EOF
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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)
graphicView->zoomAuto(false, keepAspectRatio);
finish();
}
-
-// EOF
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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()
{
finish();
}
-
-
void RS_ActionZoomAutoY::init(int status)
{
RS_ActionInterface::init(status);
trigger();
}
-
-// EOF
-/****************************************************************************
-** $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
#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;
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)
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;
}
#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();
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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)
graphicView->redraw();
finish();
}
-
-// EOF
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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);
RS_ActionInterface::init(status);
trigger();
}
-
-// EOF
-/****************************************************************************
-** $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
-/****************************************************************************
-** $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)
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();
}
}
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()
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;
-/****************************************************************************
-** $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
Keypad = Qt::KeypadModifier
};
+#if 1
/**
* Wrapper for Qt
*/
// return (RS2::ButtonState)t;
// }
static RS2::ButtonState qtToRsButtonState(int t) { return (RS2::ButtonState)t; }
+#endif
/**
* Enum of line styles:
#include "rs_actioninterface.h"
+#include "commands.h"
+#include "rs_debug.h"
+#include "rs_entitycontainer.h"
+#include "rs_graphicview.h"
+
/**
* Constructor.
*
*/
RS_ActionInterface::~RS_ActionInterface()
{
-//JLH: Only it isn't pure virtual...
// would be pure virtual now:
// hideOptions();
+//JLH: Only it isn't pure virtual...
}
/**
* 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 *)
{
}
#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);
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:
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
--- /dev/null
+// 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;
+}
#ifndef RS_COMMANDEVENT_H
#define RS_COMMANDEVENT_H
+#include <QtCore>
+
/**
* Command Events.
*/
#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"
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.
#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.
#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.
/**
* 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");
}
}
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
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);
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
{
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
{
{
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
else
{
if (defaultAction != NULL)
- {
defaultAction->commandEvent(e);
- //e->accept();
- }
}
}
#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"
*/
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
#include "rs_previewactioninterface.h"
+#include "rs_debug.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
+
/**
* Constructor.
*
#define RS_PREVIEWACTIONINTERFACE_H
#include "rs_actioninterface.h"
+#include "vector.h"
class RS_Preview;
#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"
Vector RS_Snapper::snapEndpoint(Vector coord)
{
Vector vec(false);
-
vec = container->getNearestEndpoint(coord, NULL/*, &keyEntity*/);
+
return vec;
}
{
Vector vec(false);
vec = container->getNearestPointOnEntity(coord, true, NULL, &keyEntity);
+
return vec;
}
Vector RS_Snapper::snapCenter(Vector coord)
{
Vector vec(false);
-
vec = container->getNearestCenter(coord, NULL);
+
return vec;
}
Vector RS_Snapper::snapMiddle(Vector coord)
{
Vector vec(false);
-
vec = container->getNearestMiddle(coord, NULL);
+
return vec;
}
Vector RS_Snapper::snapDist(Vector coord)
{
Vector vec(false);
-
vec = container->getNearestDist(distance, coord, NULL);
+
return vec;
}
Vector RS_Snapper::snapIntersection(Vector coord)
{
Vector vec(false);
-
vec = container->getNearestIntersection(coord, NULL);
+
return vec;
}
#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.