X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Frs_actionselectintersected.cpp;h=240c4da4faa04faa944d76884d3cafd02c0396e2;hb=be33e866f2121c48db93e06d743c5ae3826c1948;hp=7d6e25c2288f97269aab33b9d9dfdf4a238a8603;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/actions/rs_actionselectintersected.cpp b/src/actions/rs_actionselectintersected.cpp index 7d6e25c..240c4da 100644 --- a/src/actions/rs_actionselectintersected.cpp +++ b/src/actions/rs_actionselectintersected.cpp @@ -14,9 +14,9 @@ #include "rs_actionselectintersected.h" -#include "rs.h" -#include "rs_snapper.h" +#include "rs_dialogfactory.h" #include "rs_selection.h" +#include "rs_preview.h" /** * Constructor. @@ -24,149 +24,138 @@ * @param select true: select window. false: deselect window */ RS_ActionSelectIntersected::RS_ActionSelectIntersected( - RS_EntityContainer& container, RS_GraphicView& graphicView, bool select): + RS_EntityContainer & container, 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 (e->button() == Qt::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 (e->button() == Qt::RightButton) + { + if (getStatus() == SetPoint2) + deletePreview(); + deleteSnapper(); + init(getStatus() - 1); + } + else if (e->button() == Qt::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