1 // rs_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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/04/2010 Added this text. :-)
15 #include "rs_actionmodifydeletefree.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_modification.h"
20 #include "rs_polyline.h"
23 RS_ActionModifyDeleteFree::RS_ActionModifyDeleteFree(
24 RS_EntityContainer & container, GraphicView & graphicView):
25 RS_ActionInterface("Delete Entities Freehand",
26 container, graphicView)
30 RS_ActionModifyDeleteFree::~RS_ActionModifyDeleteFree()
34 void RS_ActionModifyDeleteFree::init(int status)
36 RS_ActionInterface::init(status);
39 v1 = v2 = Vector(false);
40 setSnapMode(RS2::SnapOnEntity);
43 void RS_ActionModifyDeleteFree::trigger()
45 if (e1 != NULL && e2 != NULL)
47 RS_EntityContainer * parent = e2->getParent();
51 if (parent->rtti() == RS2::EntityPolyline)
53 if (parent->getId() == polyline->getId())
55 // deletes whole polyline on screen:
56 graphicView->deleteEntity((RS_Entity *)polyline);
58 // splits up the polyline in the container:
61 RS_Modification m(*container);
62 m.splitPolyline(*polyline,
69 document->startUndoCycle();
70 document->addUndoable(polyline);
71 document->addUndoable(pl1);
72 document->addUndoable(pl2);
73 document->endUndoCycle();
76 // draws the new polylines on the screen:
77 graphicView->drawEntity((RS_Entity *)pl1);
78 graphicView->drawEntity((RS_Entity *)pl2);
82 RS_DIALOGFACTORY->updateSelectionWidget(
83 container->countSelected());
86 RS_DIALOGFACTORY->commandMessage(tr("Entities not in the same polyline."));
89 RS_DIALOGFACTORY->commandMessage(tr("Parent of second entity is not a polyline"));
92 RS_DIALOGFACTORY->commandMessage(tr("Parent of second entity is NULL"));
95 RS_DIALOGFACTORY->commandMessage(tr("One of the chosen entities is NULL"));
98 void RS_ActionModifyDeleteFree::mouseReleaseEvent(QMouseEvent * e)
100 if (e->button() == Qt::RightButton)
101 init(getStatus() - 1);
112 RS_EntityContainer * parent = e1->getParent();
116 if (parent->rtti() == RS2::EntityPolyline)
118 polyline = (RS_Polyline *)parent;
122 RS_DIALOGFACTORY->commandMessage(
123 tr("Parent of first entity is not a polyline"));
126 RS_DIALOGFACTORY->commandMessage(
127 tr("Parent of first entity is NULL"));
130 RS_DIALOGFACTORY->commandMessage(
131 tr("First entity is NULL"));
142 RS_DIALOGFACTORY->commandMessage(tr("Second entity is NULL"));
149 void RS_ActionModifyDeleteFree::updateMouseButtonHints()
154 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first break point "
155 "on a polyline"), tr("Cancel"));
159 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second break point "
160 "on the same polyline"),
165 RS_DIALOGFACTORY->updateMouseWidget("", "");