1 /****************************************************************************
2 ** $Id: rs_actiondrawlinetangent2.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_actiondrawlinetangent2.h"
29 #include "rs_creation.h"
30 #include "rs_snapper.h"
34 RS_ActionDrawLineTangent2::RS_ActionDrawLineTangent2(
35 RS_EntityContainer& container,
36 RS_GraphicView& graphicView)
37 :RS_PreviewActionInterface("Draw Tangents 2", container, graphicView) {
44 QAction* RS_ActionDrawLineTangent2::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
46 QAction * action = new QAction(tr("Tan&gent (C,C)"), 0);
47 // QAction* action = new QAction(tr("Tangent (C,C)"), tr("Tan&gent (C,C)"),
48 // QKeySequence(), NULL);
49 action->setStatusTip(tr("Draw tangent (circle, circle)"));
55 void RS_ActionDrawLineTangent2::trigger() {
56 RS_PreviewActionInterface::trigger();
59 RS_Entity* newEntity = NULL;
61 newEntity = new RS_Line(container,
64 if (newEntity!=NULL) {
65 newEntity->setLayerToActive();
66 newEntity->setPenToActive();
67 container->addEntity(newEntity);
71 document->startUndoCycle();
72 document->addUndoable(newEntity);
73 document->endUndoCycle();
75 graphicView->drawEntity(newEntity);
76 setStatus(SetCircle1);
81 RS_DEBUG->print("RS_ActionDrawLineTangent2::trigger:"
88 void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent* e) {
89 RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent begin");
91 Vector mouse(graphicView->toGraphX(e->x()),
92 graphicView->toGraphY(e->y()));
94 switch (getStatus()) {
96 RS_Entity* en = catchEntity(e, RS2::ResolveAll);
97 if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
98 en->rtti()==RS2::EntityArc)) {
105 RS_Entity* en = catchEntity(e, RS2::ResolveAll);
106 if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
107 en->rtti()==RS2::EntityArc)) {
110 RS_Creation creation(NULL, NULL);
111 RS_Line* t = creation.createTangent2(mouse,
119 tangent = (RS_Line*)t->clone();
123 preview->addEntity(t);
134 RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent end");
139 void RS_ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent* e) {
141 if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
146 switch (getStatus()) {
148 setStatus(SetCircle2);
161 void RS_ActionDrawLineTangent2::updateMouseButtonHints() {
162 if (RS_DIALOGFACTORY!=NULL) {
163 switch (getStatus()) {
165 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
169 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
173 RS_DIALOGFACTORY->updateMouseWidget("", "");
181 void RS_ActionDrawLineTangent2::updateMouseCursor() {
182 graphicView->setMouseCursor(RS2::CadCursor);
187 void RS_ActionDrawLineTangent2::updateToolBar() {
188 if (RS_DIALOGFACTORY!=NULL) {
189 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);