1 // actionmodifydeletefree.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 06/04/2010 Added this text. :-)
17 #include "actionmodifydeletefree.h"
19 #include "dialogfactory.h"
20 #include "graphicview.h"
21 #include "modification.h"
25 ActionModifyDeleteFree::ActionModifyDeleteFree(EntityContainer & container,
26 GraphicView & graphicView):
27 ActionInterface("Delete Entities Freehand", container, graphicView)
31 ActionModifyDeleteFree::~ActionModifyDeleteFree()
35 void ActionModifyDeleteFree::init(int status)
37 ActionInterface::init(status);
40 v1 = v2 = Vector(false);
41 // setSnapMode(RS2::SnapOnEntity);
44 void ActionModifyDeleteFree::trigger()
48 EntityContainer * parent = e2->getParent();
52 if (parent->rtti() == RS2::EntityPolyline)
54 if (parent->getId() == polyline->getId())
56 #warning "!!! Old rendering path need upgrade !!!"
58 // deletes whole polyline on screen:
59 graphicView->deleteEntity((Entity *)polyline);
62 // splits up the polyline in the container:
65 Modification m(*container);
66 m.splitPolyline(*polyline, *e1, v1, *e2, v2, &pl1, &pl2);
70 document->startUndoCycle();
71 document->addUndoable(polyline);
72 document->addUndoable(pl1);
73 document->addUndoable(pl2);
74 document->endUndoCycle();
77 // draws the new polylines on the screen:
78 graphicView->drawEntity((Entity *)pl1);
79 graphicView->drawEntity((Entity *)pl2);
83 DIALOGFACTORY->updateSelectionWidget(
84 container->countSelected());
87 DIALOGFACTORY->commandMessage(tr("Entities not in the same polyline."));
90 DIALOGFACTORY->commandMessage(tr("Parent of second entity is not a polyline"));
93 DIALOGFACTORY->commandMessage(tr("Parent of second entity is NULL"));
96 DIALOGFACTORY->commandMessage(tr("One of the chosen entities is NULL"));
99 void ActionModifyDeleteFree::mouseReleaseEvent(QMouseEvent * e)
101 if (e->button() == Qt::RightButton)
102 init(getStatus() - 1);
109 // e1 = getKeyEntity();
110 e1 = graphicView->GetSnapperEntity();
114 EntityContainer * parent = e1->getParent();
118 if (parent->rtti() == RS2::EntityPolyline)
120 polyline = (Polyline *)parent;
124 DIALOGFACTORY->commandMessage(
125 tr("Parent of first entity is not a polyline"));
128 DIALOGFACTORY->commandMessage(
129 tr("Parent of first entity is NULL"));
132 DIALOGFACTORY->commandMessage(
133 tr("First entity is NULL"));
139 // e2 = getKeyEntity();
140 e2 = graphicView->GetSnapperEntity();
145 DIALOGFACTORY->commandMessage(tr("Second entity is NULL"));
152 void ActionModifyDeleteFree::updateMouseButtonHints()
157 DIALOGFACTORY->updateMouseWidget(tr("Specify first break point "
158 "on a polyline"), tr("Cancel"));
162 DIALOGFACTORY->updateMouseWidget(tr("Specify second break point "
163 "on the same polyline"), tr("Back"));
167 DIALOGFACTORY->updateMouseWidget("", "");