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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/22/2010 Added this text. :-)
15 // JLH 09/17/2010 Fixed preview/snapper rendering somewhat. Some bugs remain.
18 #include "actionmodifytrim.h"
21 #include "dialogfactory.h"
22 #include "modification.h"
25 * @param both Trim both entities.
27 ActionModifyTrim::ActionModifyTrim(EntityContainer & container,
28 GraphicView & graphicView, bool b):
29 ActionInterface("Trim Entity", container, graphicView),
30 limitEntity(NULL), limitCoord(false), trimEntity(NULL), trimCoord(false),
34 // trimCoord = Vector(false);
35 // limitEntity = NULL;
36 // limitCoord = Vector(false);
40 ActionModifyTrim::~ActionModifyTrim()
44 void ActionModifyTrim::init(int status)
46 ActionInterface::init(status);
48 /* snapMode = RS2::SnapFree;
49 snapRes = RS2::RestrictNothing;*/
52 void ActionModifyTrim::trigger()
54 DEBUG->print("ActionModifyTrim::trigger()");
56 if (trimEntity && trimEntity->isAtomic() && limitEntity)
58 Modification m(*container, graphicView);
59 m.trim(trimCoord, (AtomicEntity *)trimEntity, limitCoord, limitEntity,
66 limitEntity->setHighlighted(false);
67 // graphicView->drawEntity(limitEntity);
68 setStatus(ChooseLimitEntity);
69 graphicView->redraw(); //hm.
72 setStatus(ChooseTrimEntity);
74 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
78 void ActionModifyTrim::mouseMoveEvent(QMouseEvent * e)
80 DEBUG->print("ActionModifyTrim::mouseMoveEvent begin");
82 Vector mouse = graphicView->toGraph(e->x(), e->y());
83 Entity * se = catchEntity(e);
87 case ChooseLimitEntity:
92 case ChooseTrimEntity:
101 DEBUG->print("ActionModifyTrim::mouseMoveEvent end");
104 void ActionModifyTrim::mouseReleaseEvent(QMouseEvent * e)
106 if (e->button() == Qt::LeftButton)
108 Vector mouse = graphicView->toGraph(e->x(), e->y());
109 Entity * se = catchEntity(e);
113 case ChooseLimitEntity:
119 limitEntity->setHighlighted(true);
120 // graphicView->drawEntity(limitEntity);
121 setStatus(ChooseTrimEntity);
122 graphicView->redraw(); //hm.
126 case ChooseTrimEntity:
130 if (trimEntity && trimEntity->isAtomic())
138 else if (e->button() == Qt::RightButton)
145 limitEntity->setHighlighted(false);
146 // graphicView->drawEntity(limitEntity);
149 init(getStatus() - 1);
150 graphicView->redraw(); //hm.
154 void ActionModifyTrim::updateMouseButtonHints()
158 case ChooseLimitEntity:
161 DIALOGFACTORY->updateMouseWidget(tr("Select first trim entity"),
164 DIALOGFACTORY->updateMouseWidget(tr("Select limiting entity"),
168 case ChooseTrimEntity:
171 DIALOGFACTORY->updateMouseWidget(tr("Select second trim entity"),
174 DIALOGFACTORY->updateMouseWidget(tr("Select entity to trim"),
179 DIALOGFACTORY->updateMouseWidget("", "");
184 void ActionModifyTrim::updateMouseCursor()
186 graphicView->setMouseCursor(RS2::CadCursor);
189 void ActionModifyTrim::updateToolBar()
191 DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);