1 // actionmodifytrim.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/22/2010 Added this text. :-)
15 #include "actionmodifytrim.h"
17 #include "rs_dialogfactory.h"
18 #include "rs_modification.h"
21 * @param both Trim both entities.
23 ActionModifyTrim::ActionModifyTrim(RS_EntityContainer & container,
24 GraphicView & graphicView, bool both): ActionInterface("Trim Entity",
25 container, graphicView)
28 trimCoord = Vector(false);
30 limitCoord = Vector(false);
34 ActionModifyTrim::~ActionModifyTrim()
38 void ActionModifyTrim::init(int status)
40 ActionInterface::init(status);
42 /* snapMode = RS2::SnapFree;
43 snapRes = RS2::RestrictNothing;*/
46 void ActionModifyTrim::trigger()
48 RS_DEBUG->print("ActionModifyTrim::trigger()");
50 if (trimEntity && trimEntity->isAtomic() && limitEntity)
52 RS_Modification m(*container, graphicView);
53 m.trim(trimCoord, (RS_AtomicEntity *)trimEntity,
54 limitCoord, limitEntity, both);
60 limitEntity->setHighlighted(false);
61 graphicView->drawEntity(limitEntity);
62 setStatus(ChooseLimitEntity);
65 setStatus(ChooseTrimEntity);
67 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
71 void ActionModifyTrim::mouseMoveEvent(QMouseEvent * e)
73 RS_DEBUG->print("ActionModifyTrim::mouseMoveEvent begin");
75 Vector mouse = graphicView->toGraph(e->x(), e->y());
76 RS_Entity * se = catchEntity(e);
80 case ChooseLimitEntity:
85 case ChooseTrimEntity:
94 RS_DEBUG->print("ActionModifyTrim::mouseMoveEvent end");
97 void ActionModifyTrim::mouseReleaseEvent(QMouseEvent * e)
99 if (e->button() == Qt::LeftButton)
101 Vector mouse = graphicView->toGraph(e->x(), e->y());
102 RS_Entity * se = catchEntity(e);
106 case ChooseLimitEntity:
112 limitEntity->setHighlighted(true);
113 graphicView->drawEntity(limitEntity);
114 setStatus(ChooseTrimEntity);
118 case ChooseTrimEntity:
122 if (trimEntity != NULL && trimEntity->isAtomic())
130 else if (e->button() == Qt::RightButton)
135 if (limitEntity != NULL)
137 limitEntity->setHighlighted(false);
138 graphicView->drawEntity(limitEntity);
140 init(getStatus() - 1);
144 void ActionModifyTrim::updateMouseButtonHints()
148 case ChooseLimitEntity:
151 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first trim entity"),
154 RS_DIALOGFACTORY->updateMouseWidget(tr("Select limiting entity"),
158 case ChooseTrimEntity:
161 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second trim entity"),
164 RS_DIALOGFACTORY->updateMouseWidget(tr("Select entity to trim"),
169 RS_DIALOGFACTORY->updateMouseWidget("", "");
174 void ActionModifyTrim::updateMouseCursor()
176 graphicView->setMouseCursor(RS2::CadCursor);
179 void ActionModifyTrim::updateToolBar()
181 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);