1 /****************************************************************************
2 ** $Id: rs_actionsnapintersectionmanual.cpp 1161 2004-12-09 23:10:09Z 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_actionsnapintersectionmanual.h"
29 #include "rs_information.h"
30 #include "rs_snapper.h"
33 * @param both Trim both entities.
35 RS_ActionSnapIntersectionManual::RS_ActionSnapIntersectionManual(
36 RS_EntityContainer& container, RS_GraphicView& graphicView):
37 RS_PreviewActionInterface("Trim Entity", container, graphicView)
41 coord = Vector(false);
44 QAction * RS_ActionSnapIntersectionManual::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
46 QAction * action = new QAction(tr("I&ntersection Manually"), 0);
47 action->setCheckable(true);
48 // QAction* action = new QAction(tr("Intersection Manually"), tr("I&ntersection Manually"),
49 // QKeySequence(), NULL, 0, true);
50 action->setStatusTip(tr("Snap to intersection points manually"));
54 void RS_ActionSnapIntersectionManual::init(int status)
56 RS_ActionInterface::init(status);
58 snapMode = RS2::SnapFree;
59 snapRes = RS2::RestrictNothing;
62 void RS_ActionSnapIntersectionManual::trigger()
64 RS_DEBUG->print("RS_ActionSnapIntersectionManual::trigger()");
66 if (entity2!=NULL && entity2->isAtomic() &&
67 entity1!=NULL && entity1->isAtomic())
70 RS_Information::getIntersection(entity1, entity2, false);
74 if (predecessor!=NULL) {
75 Vector ip = sol.getClosest(coord);
78 RS_CoordinateEvent e(ip);
79 predecessor->coordinateEvent(&e);
88 void RS_ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent* e) {
89 RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent begin");
91 RS_Entity* se = catchEntity(e);
92 Vector mouse = graphicView->toGraph(e->x(), e->y());
94 switch (getStatus()) {
103 VectorSolutions sol =
104 RS_Information::getIntersection(entity1, entity2, false);
106 //for (int i=0; i<sol.getNumber(); i++) {
111 Vector ip = sol.getClosest(coord);
117 new RS_Circle(preview,
120 graphicView->toGraphDX(4))));
123 RS_DIALOGFACTORY->updateCoordinateWidget(ip,
124 ip - graphicView->getRelativeZero());
134 RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent end");
139 void RS_ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent* e) {
140 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
142 Vector mouse = graphicView->toGraph(e->x(), e->y());
143 RS_Entity* se = catchEntity(e);
145 switch (getStatus()) {
148 if (entity1!=NULL && entity1->isAtomic()) {
149 setStatus(ChooseEntity2);
156 if (entity2!=NULL && entity2->isAtomic() && coord.valid) {
164 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
173 void RS_ActionSnapIntersectionManual::updateMouseButtonHints() {
174 switch (getStatus()) {
176 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
180 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
184 RS_DIALOGFACTORY->updateMouseWidget("", "");
191 void RS_ActionSnapIntersectionManual::updateMouseCursor() {
192 graphicView->setMouseCursor(RS2::CadCursor);
197 void RS_ActionSnapIntersectionManual::updateToolBar() {
198 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);