1 /****************************************************************************
2 ** $Id: rs_actionblockscreate.cpp 1134 2004-07-13 23:26:13Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #include "rs_actionblockscreate.h"
29 #include "rs_creation.h"
30 #include "rs_insert.h"
31 #include "rs_modification.h"
36 RS_ActionBlocksCreate::RS_ActionBlocksCreate(RS_EntityContainer& container,
37 RS_GraphicView& graphicView)
38 :RS_PreviewActionInterface("Blocks Create",
39 container, graphicView)
41 referencePoint = Vector(false);
46 RS_ActionBlocksCreate::~RS_ActionBlocksCreate() {}
50 QAction* RS_ActionBlocksCreate::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
52 QAction * action = new QAction(tr("&Create Block"), 0);
53 // QAction* action = new QAction(tr("Create Block"),
54 // tr("&Create Block"),
55 // QKeySequence(), NULL);
56 action->setStatusTip(tr("Create Block"));
63 void RS_ActionBlocksCreate::init(int status) {
64 RS_PreviewActionInterface::init(status);
70 void RS_ActionBlocksCreate::trigger() {
75 //RS_Modification m(*container, graphicView);
76 //m.paste(data.insertionPoint);
77 //std::cout << *RS_Clipboard::instance();
80 RS_BlockList* blockList = graphic->getBlockList();
81 if (blockList!=NULL) {
83 RS_DIALOGFACTORY->requestNewBlockDialog(blockList);
85 if (!d.name.isEmpty()) {
86 RS_Creation creation(container, graphicView);
87 creation.createBlock(d, referencePoint, true);
96 creation.createInsert(id);
101 graphicView->redraw();
103 graphicView->killSelectActions();
107 void RS_ActionBlocksCreate::mouseMoveEvent(QMouseEvent* e) {
110 switch (getStatus()) {
111 case SetReferencePoint:
112 //data.insertionPoint = snapPoint(e);
117 //preview->addAllFrom(*block);
118 //preview->move(data.insertionPoint);
119 RS_Creation creation(preview, NULL, false);
120 creation.createInsert(data);
132 void RS_ActionBlocksCreate::mouseReleaseEvent(QMouseEvent* e) {
133 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
134 RS_CoordinateEvent ce(snapPoint(e));
135 coordinateEvent(&ce);
136 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
144 void RS_ActionBlocksCreate::coordinateEvent(RS_CoordinateEvent* e) {
149 switch (getStatus()) {
150 case SetReferencePoint:
151 referencePoint = e->getCoordinate();
163 void RS_ActionBlocksCreate::updateMouseButtonHints() {
164 switch (getStatus()) {
165 case SetReferencePoint:
166 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
170 RS_DIALOGFACTORY->updateMouseWidget("", "");
177 void RS_ActionBlocksCreate::updateMouseCursor() {
178 graphicView->setMouseCursor(RS2::CadCursor);
183 void RS_ActionBlocksCreate::updateToolBar() {
185 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
187 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);