1 // actionselectwindow.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. :-)
17 #include "actionselectwindow.h"
19 #include "rs_dialogfactory.h"
20 #include "rs_selection.h"
21 #include "rs_preview.h"
26 * @param select true: select window. false: deselect window
28 ActionSelectWindow::ActionSelectWindow(RS_EntityContainer & container,
29 GraphicView & graphicView, bool select):
30 ActionInterface("Select Window", container, graphicView)
32 this->select = select;
35 ActionSelectWindow::~ActionSelectWindow()
39 /*virtual*/ RS2::ActionType ActionSelectWindow::rtti()
41 return RS2::ActionSelectWindow;
44 void ActionSelectWindow::init(int status)
46 ActionInterface::init(status);
47 v1 = v2 = Vector(false);
48 /* snapMode = RS2::SnapFree;
49 snapRes = RS2::RestrictNothing;*/
52 void ActionSelectWindow::trigger()
54 ActionInterface::trigger();
56 if (v1.valid && v2.valid)
58 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
61 bool cross = (v2.y > v1.y);
62 RS_Selection s(*container, graphicView);
63 s.selectWindow(v1, v2, select, cross);
64 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
70 void ActionSelectWindow::mouseMoveEvent(QMouseEvent * e)
72 if (getStatus() == SetCorner2 && v1.valid)
77 /* preview->addEntity(new RS_Line(preview,
78 RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
79 preview->addEntity(new RS_Line(preview,
80 RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
81 preview->addEntity(new RS_Line(preview,
82 RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
83 preview->addEntity(new RS_Line(preview,
84 RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));*/
89 void ActionSelectWindow::mousePressEvent(QMouseEvent * e)
91 if (e->button() == Qt::LeftButton)
97 setStatus(SetCorner2);
105 RS_DEBUG->print("ActionSelectWindow::mousePressEvent(): %f %f",
109 void ActionSelectWindow::mouseReleaseEvent(QMouseEvent * e)
111 RS_DEBUG->print("ActionSelectWindow::mouseReleaseEvent()");
113 if (e->button() == Qt::LeftButton)
115 if (getStatus() == SetCorner2)
121 else if (e->button() == Qt::RightButton)
123 if (getStatus() == SetCorner2)
127 init(getStatus() - 1);
131 void ActionSelectWindow::updateMouseButtonHints()
136 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first edge"), tr("Cancel"));
140 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"), tr("Back"));
144 RS_DIALOGFACTORY->updateMouseWidget("", "");
149 void ActionSelectWindow::updateMouseCursor()
151 graphicView->setMouseCursor(RS2::SelectCursor);
154 void ActionSelectWindow::updateToolBar()
157 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
159 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);