X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Frs_actiondrawlinefree.cpp;h=f2d18e7c32cd7323f453f2fca294333b0ea4b3cf;hb=3f46c180da0806c9c263e6d87d0f1404632402da;hp=05aeb833eef8db17e2475e236264b11bd8d0a447;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/actions/rs_actiondrawlinefree.cpp b/src/actions/rs_actiondrawlinefree.cpp index 05aeb83..f2d18e7 100644 --- a/src/actions/rs_actiondrawlinefree.cpp +++ b/src/actions/rs_actiondrawlinefree.cpp @@ -1,153 +1,136 @@ -/**************************************************************************** -** $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 +// +// 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