1 // actionblockscreate.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/03/2010 Added this text. :-)
15 // JLH 06/03/2010 Scrubbed out all occurances of CoordinateEvent
18 #include "actionblockscreate.h"
21 #include "dialogfactory.h"
22 #include "graphicview.h"
24 #include "modification.h"
29 ActionBlocksCreate::ActionBlocksCreate(EntityContainer & container, GraphicView & graphicView): ActionInterface("Blocks Create", container, graphicView)
31 referencePoint = Vector(false);
34 ActionBlocksCreate::~ActionBlocksCreate()
38 /*virtual*/ RS2::ActionType ActionBlocksCreate::rtti()
40 return RS2::ActionBlocksCreate;
43 void ActionBlocksCreate::init(int status)
45 ActionInterface::init(status);
48 void ActionBlocksCreate::trigger()
52 BlockList * blockList = graphic->getBlockList();
56 BlockData d = DIALOGFACTORY->requestNewBlockDialog(blockList);
58 if (!d.name.isEmpty())
60 Creation creation(container, graphicView);
61 creation.createBlock(d, referencePoint, true);
62 InsertData id(d.name, referencePoint, Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0));
63 creation.createInsert(id);
68 graphicView->redraw();
70 graphicView->killSelectActions();
73 void ActionBlocksCreate::mouseMoveEvent(QMouseEvent * e)
75 // graphicView->snapper.snapPoint(e);
76 graphicView->SnapPoint(e);
80 case SetReferencePoint:
81 //data.insertionPoint = snapPoint(e);
86 //preview->addAllFrom(*block);
87 //preview->move(data.insertionPoint);
88 Creation creation(preview, NULL, false);
89 creation.createInsert(data);
99 void ActionBlocksCreate::mouseReleaseEvent(QMouseEvent * e)
101 if (e->button() == Qt::LeftButton)
103 // Vector ce(graphicView->snapper.snapPoint(e));
104 Vector ce(graphicView->SnapPoint(e));
105 coordinateEvent(&ce);
107 else if (e->button() == Qt::RightButton)
110 init(getStatus() - 1);
114 void ActionBlocksCreate::coordinateEvent(Vector * e)
121 case SetReferencePoint:
131 void ActionBlocksCreate::updateMouseButtonHints()
135 case SetReferencePoint:
136 DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"), tr("Cancel"));
140 DIALOGFACTORY->updateMouseWidget("", "");
145 void ActionBlocksCreate::updateMouseCursor()
147 graphicView->setMouseCursor(RS2::CadCursor);
150 void ActionBlocksCreate::updateToolBar()
153 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
155 DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);