From: Shamus Hammons Date: Fri, 18 Jun 2010 02:55:11 +0000 (+0000) Subject: Removed a bunch of cruft... X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be33e866f2121c48db93e06d743c5ae3826c1948;p=architektonas Removed a bunch of cruft... --- diff --git a/src/actions/rs_actionparisdebugcreatecontainer.cpp.old b/src/actions/rs_actionparisdebugcreatecontainer.cpp.old deleted file mode 100644 index d7e9e15..0000000 --- a/src/actions/rs_actionparisdebugcreatecontainer.cpp.old +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** $Id: rs_actionparisdebugcreatecontainer.cpp 1040 2003-11-12 09:58:41Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef NO_COMPLEX_ENTITIES - -#include "rs_actionparisdebugcreatecontainer.h" - -#include - -/** - * Constructor. - */ -RS_ActionPARISDebugCreateContainer::RS_ActionPARISDebugCreateContainer( - RS_EntityContainer & container, RS_GraphicView & graphicView): - RS_ActionInterface("rs_actionparischeckcont", container, graphicView) -{ - //QMessageBox::about(NULL, "info", "check container"); - RS_Document * theDoc = (RS_Document *)&container; - - if (theDoc->countSelected() < 2) - return; - - RS_EntityContainer * con = new RS_EntityContainer(theDoc, true); - Q3PtrListIterator it = theDoc->createIterator(); - RS_Entity * e; - - while ((e = it.current()) != 0) - { - ++it; - if (e->isSelected()) - { - con->addEntity(e); - e->setParent(con); - } - } - - theDoc->addEntity(con); -} - -RS_ActionPARISDebugCreateContainer::~RS_ActionPARISDebugCreateContainer() -{ -} - -#endif diff --git a/src/actions/rs_actionparisdebugcreatecontainer.h.old b/src/actions/rs_actionparisdebugcreatecontainer.h.old deleted file mode 100644 index ad16695..0000000 --- a/src/actions/rs_actionparisdebugcreatecontainer.h.old +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** $Id: rs_actionparisdebugcreatecontainer.h 1040 2003-11-12 09:58:41Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef NO_COMPLEX_ENTITIES - -#ifndef RS_ACTIONPARISDEBUGCREATECONTAINER_H -#define RS_ACTIONPARISDEBUGCREATECONTAINER_H - -#include "rs_actioninterface.h" - -/** - * Creates an entity group without using blocks. - * - * @author Tobias Schulze, shhinfo.de - */ -class RS_ActionPARISDebugCreateContainer: public RS_ActionInterface -{ - Q_OBJECT -public: - RS_ActionPARISDebugCreateContainer(RS_EntityContainer & container, - RS_GraphicView & graphicView); - virtual ~RS_ActionPARISDebugCreateContainer(); - - virtual RS2::ActionType rtti() - { - return RS2::ActionPARISDebugCreateContainer; - } -}; - -#endif -#endif diff --git a/src/base/rs_application.h.old b/src/base/rs_application.h.old deleted file mode 100644 index f6a010a..0000000 --- a/src/base/rs_application.h.old +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef RS_APPLICATION_H -#define RS_APPLICATION_H - -#include - -#define RS_Application QApplication -#define RS_APP qApp - -#endif diff --git a/src/base/rs_coordinateevent.h.old b/src/base/rs_coordinateevent.h.old deleted file mode 100644 index 53907a0..0000000 --- a/src/base/rs_coordinateevent.h.old +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef RS_COORDINATEEVENT_H -#define RS_COORDINATEEVENT_H - -/** - * Coordinate Events. - */ -class RS_CoordinateEvent -{ - public: - /** - * @param pos coordinate - * @param abs true: absolute coordinate, false: relative coordinate - */ - RS_CoordinateEvent(const Vector & pos) - { - this->pos = pos; - } - - /** - * @return the position of the event in real graphic measures. - */ - Vector getCoordinate() - { - return pos; - } - - protected: - Vector pos; -}; - -#endif diff --git a/src/base/rs_datetime.h.old b/src/base/rs_datetime.h.old deleted file mode 100644 index 94960b5..0000000 --- a/src/base/rs_datetime.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_datetime.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_DATETIME_H -#define RS_DATETIME_H - -//#include -#include - -#define RS_DateTime QDateTime - -#endif diff --git a/src/base/rs_dict.h.old b/src/base/rs_dict.h.old deleted file mode 100644 index 1e0c499..0000000 --- a/src/base/rs_dict.h.old +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** $Id: rs_dict.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_DICT_H -#define RS_DICT_H - -//#include -#include - -#define RS_Dict Q3Dict -#define RS_DictIterator Q3DictIterator - -#endif diff --git a/src/base/rs_dir.h.old b/src/base/rs_dir.h.old deleted file mode 100644 index 66e2ca1..0000000 --- a/src/base/rs_dir.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_dir.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_DIR_H -#define RS_DIR_H - -//#include -#include - -#define RS_Dir QDir - -#endif diff --git a/src/base/rs_event.h.old b/src/base/rs_event.h.old deleted file mode 100644 index 14453b0..0000000 --- a/src/base/rs_event.h.old +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** $Id: rs_event.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_EVENT_H -#define RS_EVENT_H - -#warning "!!! RS_Event is an empty class !!!" -/** - * Events base class. - */ -class RS_Event -{ -}; - -#endif diff --git a/src/base/rs_file.h.old b/src/base/rs_file.h.old deleted file mode 100644 index d50f9cf..0000000 --- a/src/base/rs_file.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_file.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_FILE_H -#define RS_FILE_H - -//#include -#include - -#define RS_File QFile - -#endif diff --git a/src/base/rs_fileinfo.h.old b/src/base/rs_fileinfo.h.old deleted file mode 100644 index aac733f..0000000 --- a/src/base/rs_fileinfo.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_fileinfo.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_FILEINFO_H -#define RS_FILEINFO_H - -//#include -#include - -#define RS_FileInfo QFileInfo - -#endif diff --git a/src/base/rs_img.h.old b/src/base/rs_img.h.old deleted file mode 100644 index 0da2a0e..0000000 --- a/src/base/rs_img.h.old +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** $Id: rs_img.h 1688 2003-08-30 21:47:12Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_IMG_H -#define RS_IMG_H - -//#include -//#include -#include - -#define RS_Img QImage -#define RS_Pixmap QPixmap - -#endif diff --git a/src/base/rs_infoarea.cpp.bak b/src/base/rs_infoarea.cpp.bak deleted file mode 100644 index 9fe8978..0000000 --- a/src/base/rs_infoarea.cpp.bak +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** $Id: rs_infoarea.cpp 1892 2004-07-09 23:54:59Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_infoarea.h" - - -#include "rs_infoarea.h" -#include "rs_math.h" -#include "rs_debug.h" - - -/** - * Constructor. - */ -RS_InfoArea::RS_InfoArea() { -} - - - -/** - * Destructor. - */ -RS_InfoArea::~RS_InfoArea() {} - - - -/** - * Adds a point to the internal list - * - * @param p co-ordinate of the point - */ -void RS_InfoArea::addPoint(const Vector& p) { - if (thePoints.empty()) { - baseY = p.y; - } - - thePoints.append(p); -} - - - -/** - * Resets the points. - */ -void RS_InfoArea::reset() { - thePoints.clear(); - area = 0.0; - circumference = 0.0; -} - - - -/** - * Closes the polygon if it is not closed already. - */ -void RS_InfoArea::close() { - if (isValid() && isClosed()==false) { - - thePoints.append(thePoints.first()); - - RS_DEBUG->print("RS_InfoArea::close: closed"); - } -} - - - -/** - * @retval true If the area is closed (i.e. start point and end point are - * identical) - * @retval false Otherwise. - */ -bool RS_InfoArea::isClosed() { - return (thePoints.first().distanceTo(thePoints.last())<1.0e-4); -} - - - -/** - * @retval true If the area is defined (i.e. there are at least 3 points) - * @retval false If there are only two or less points. - */ -bool RS_InfoArea::isValid() { - RS_DEBUG->print("RS_InfoArea::isValid: count: %d", thePoints.count()); - return (thePoints.count()>2); -} - - - -/** - * Calculates the area and the circumference of the area. - */ -void RS_InfoArea::calculate() { - area = 0.0; - circumference = 0.0; - Vector ptFirst; - Vector p1; - Vector p2; - - // at least 3 points needed for an area - if (isValid()) { - ptFirst = thePoints.last(); - thePoints.pop_back(); - - p1 = ptFirst; - while (!thePoints.empty()) { - p2 = thePoints.last(); - thePoints.pop_back(); - - area += calcSubArea(p1, p2); - circumference += p1.distanceTo(p2); - //if (p1 != ptFirst) { - // delete p1; - //} - p1 = p2; - } - area += calcSubArea(p1, ptFirst); - circumference += p1.distanceTo(ptFirst); - //delete p1; - //delete ptFirst; - } - - //thePoints.clear(); - area = fabs(area); -} - - - -/** - * Calculates a sub area. - * - * @param p1 first point - * @param p2 second point - */ -double RS_InfoArea::calcSubArea(const Vector& p1, const Vector& p2) { - double width = p2.x - p1.x; - double height = (p1.y - baseY) + (p2.y - baseY); - - return width * height / 2.0; -} - - - -/*! Calculates a distance - \param _p1 first point - \param _p2 second point -*/ -/*double -RS_InfoArea::calcDistance(Vector *_p1, Vector *_p2) -{ - return mtGetDistance(_p1->getX(), _p1->getY(), _p2->getX(), _p2->getY()); -}*/ - - -// EOF diff --git a/src/base/rs_infoarea.h.bak b/src/base/rs_infoarea.h.bak deleted file mode 100644 index 5c9e518..0000000 --- a/src/base/rs_infoarea.h.bak +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** $Id: rs_infoarea.h 1892 2004-07-09 23:54:59Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_INFOAREA_H -#define RS_INFOAREA_H - -#include "vector.h" -#include "rs_valuevector.h" - -/** - * Class for getting information about an area. - * - * @author Andrew Mustun - */ -class RS_InfoArea -{ -public: - RS_InfoArea(); - ~RS_InfoArea(); - - void reset(); - void addPoint(const Vector& p); - void calculate(); - void close(); - bool isValid(); - bool isClosed(); - double getArea() - { - return area; - } - double getCircumference() - { - return circumference; - } - int count() - { - return thePoints.count(); - } - -private: - double calcSubArea(const Vector& p1, const Vector& p2); - - RS_ValueVector thePoints; - double baseY; - double area; - double circumference; -}; - -#endif - diff --git a/src/base/rs_information.cpp.bak b/src/base/rs_information.cpp.bak deleted file mode 100644 index 13dd47e..0000000 --- a/src/base/rs_information.cpp.bak +++ /dev/null @@ -1,833 +0,0 @@ -/**************************************************************************** -** $Id: rs_information.cpp 2378 2005-05-16 17:05:15Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_information.h" - -#include "rs_constructionline.h" - - -/** - * Default constructor. - * - * @param container The container to which we will add - * entities. Usually that's an RS_Graphic entity but - * it can also be a polyline, text, ... - */ -RS_Information::RS_Information(RS_EntityContainer& container) { - this->container = &container; -} - - - -/** - * @return true: if the entity is a dimensioning enity. - * false: otherwise - */ -bool RS_Information::isDimension(RS2::EntityType type) { - if (type==RS2::EntityDimAligned || - type==RS2::EntityDimLinear || - type==RS2::EntityDimRadial || - type==RS2::EntityDimDiametric || - type==RS2::EntityDimAngular) { - return true; - } else { - return false; - } -} - - - -/** - * @retval true the entity can be trimmed. - * i.e. it is in a graphic or in a polyline. - */ -bool RS_Information::isTrimmable(RS_Entity* e) { - if (e!=NULL) { - if (e->getParent()!=NULL) { - if (e->getParent()->rtti()==RS2::EntityPolyline) { - return true; - } - else if (e->getParent()->rtti()==RS2::EntityContainer || - e->getParent()->rtti()==RS2::EntityGraphic || - e->getParent()->rtti()==RS2::EntityBlock) { - - // normal entity: - return true; - } - } - } - - return false; -} - - -/** - * @retval true the two entities can be trimmed to each other; - * i.e. they are in a graphic or in the same polyline. - */ -bool RS_Information::isTrimmable(RS_Entity* e1, RS_Entity* e2) { - if (e1!=NULL && e2!=NULL) { - if (e1->getParent()!=NULL && e2->getParent()!=NULL) { - if (e1->getParent()->rtti()==RS2::EntityPolyline && - e2->getParent()->rtti()==RS2::EntityPolyline && - e1->getParent()==e2->getParent()) { - - // in the same polyline - RS_EntityContainer* pl = e1->getParent(); - int idx1 = pl->findEntity(e1); - int idx2 = pl->findEntity(e2); - RS_DEBUG->print("RS_Information::isTrimmable: " - "idx1: %d, idx2: %d", idx1, idx2); - if (abs(idx1-idx2)==1 || abs(idx1-idx2)==pl->count()-1) { - // directly following entities - return true; - } - else { - // not directly following entities - return false; - } - } - else if ((e1->getParent()->rtti()==RS2::EntityContainer || - e1->getParent()->rtti()==RS2::EntityGraphic || - e1->getParent()->rtti()==RS2::EntityBlock) && - (e2->getParent()->rtti()==RS2::EntityContainer || - e2->getParent()->rtti()==RS2::EntityGraphic || - e2->getParent()->rtti()==RS2::EntityBlock)) { - - // normal entities: - return true; - } - } - else { - // independent entities with the same parent: - return (e1->getParent()==e2->getParent()); - } - } - - return false; -} - - -/** - * Gets the nearest end point to the given coordinate. - * - * @param coord Coordinate (typically a mouse coordinate) - * - * @return the coordinate found or an invalid vector - * if there are no elements at all in this graphics - * container. - */ -Vector RS_Information::getNearestEndpoint(const Vector& coord, - double* dist) const { - return container->getNearestEndpoint(coord, dist); -} - - -/** - * Gets the nearest point to the given coordinate which is on an entity. - * - * @param coord Coordinate (typically a mouse coordinate) - * @param dist Pointer to a double which will contain the - * measured distance after return or NULL - * @param entity Pointer to a pointer which will point to the - * entity on which the point is or NULL - * - * @return the coordinate found or an invalid vector - * if there are no elements at all in this graphics - * container. - */ -Vector RS_Information::getNearestPointOnEntity(const Vector& coord, - bool onEntity, - double* dist, - RS_Entity** entity) const { - - return container->getNearestPointOnEntity(coord, onEntity, dist, entity); -} - - -/** - * Gets the nearest entity to the given coordinate. - * - * @param coord Coordinate (typically a mouse coordinate) - * @param dist Pointer to a double which will contain the - * masured distance after return - * @param level Level of resolving entities. - * - * @return the entity found or NULL if there are no elements - * at all in this graphics container. - */ -RS_Entity* RS_Information::getNearestEntity(const Vector& coord, - double* dist, - RS2::ResolveLevel level) const { - - return container->getNearestEntity(coord, dist, level); -} - - - -/** - * Calculates the intersection point(s) between two entities. - * - * @param onEntities true: only return intersection points which are - * on both entities. - * false: return all intersection points. - * - * @todo support more entities - * - * @return All intersections of the two entities. The tangent flag in - * VectorSolutions is set if one intersection is a tangent point. - */ -VectorSolutions RS_Information::getIntersection(RS_Entity* e1, - RS_Entity* e2, bool onEntities) { - - VectorSolutions ret; - double tol = 1.0e-4; - - if (e1==NULL || e2==NULL) { - return ret; - } - - // unsupported entities / entity combinations: - if ((e1->rtti()==RS2::EntityEllipse && e2->rtti()==RS2::EntityEllipse) || - e1->rtti()==RS2::EntityText || e2->rtti()==RS2::EntityText || - isDimension(e1->rtti()) || isDimension(e2->rtti())) { - - return ret; - } - - // (only) one entity is an ellipse: - if (e1->rtti()==RS2::EntityEllipse || e2->rtti()==RS2::EntityEllipse) { - if (e2->rtti()==RS2::EntityEllipse) { - RS_Entity* tmp = e1; - e1 = e2; - e2 = tmp; - } - if (e2->rtti()==RS2::EntityLine) { - RS_Ellipse* ellipse = (RS_Ellipse*)e1; - ret = getIntersectionLineEllipse((RS_Line*)e2, ellipse); - tol = 1.0e-1; - } - - // ellipse / arc, ellipse / ellipse: not supported: - else { - return ret; - } - } else { - - RS_Entity* te1 = e1; - RS_Entity* te2 = e2; - - // entity copies - so we only have to deal with lines and arcs - RS_Line l1(NULL, - RS_LineData(Vector(0.0, 0.0), Vector(0.0,0.0))); - RS_Line l2(NULL, - RS_LineData(Vector(0.0, 0.0), Vector(0.0,0.0))); - - RS_Arc a1(NULL, - RS_ArcData(Vector(0.0,0.0), 1.0, 0.0, 2*M_PI, false)); - RS_Arc a2(NULL, - RS_ArcData(Vector(0.0,0.0), 1.0, 0.0, 2*M_PI, false)); - - // convert construction lines to lines: - if (e1->rtti()==RS2::EntityConstructionLine) { - RS_ConstructionLine* cl = (RS_ConstructionLine*)e1; - - l1.setStartpoint(cl->getPoint1()); - l1.setEndpoint(cl->getPoint2()); - - te1 = &l1; - } - if (e2->rtti()==RS2::EntityConstructionLine) { - RS_ConstructionLine* cl = (RS_ConstructionLine*)e2; - - l2.setStartpoint(cl->getPoint1()); - l2.setEndpoint(cl->getPoint2()); - - te2 = &l2; - } - - - // convert circles to arcs: - if (e1->rtti()==RS2::EntityCircle) { - RS_Circle* c = (RS_Circle*)e1; - - RS_ArcData data(c->getCenter(), c->getRadius(), 0.0, 2*M_PI, false); - a1.setData(data); - - te1 = &a1; - } - if (e2->rtti()==RS2::EntityCircle) { - RS_Circle* c = (RS_Circle*)e2; - - RS_ArcData data(c->getCenter(), c->getRadius(), 0.0, 2*M_PI, false); - a2.setData(data); - - te2 = &a2; - } - - - // line / line: - // - //else - if (te1->rtti()==RS2::EntityLine && - te2->rtti()==RS2::EntityLine) { - - RS_Line* line1 = (RS_Line*)te1; - RS_Line* line2 = (RS_Line*)te2; - - ret = getIntersectionLineLine(line1, line2); - } - - // line / arc: - // - else if (te1->rtti()==RS2::EntityLine && - te2->rtti()==RS2::EntityArc) { - - RS_Line* line = (RS_Line*)te1; - RS_Arc* arc = (RS_Arc*)te2; - - ret = getIntersectionLineArc(line, arc); - } - - // arc / line: - // - else if (te1->rtti()==RS2::EntityArc && - te2->rtti()==RS2::EntityLine) { - - RS_Arc* arc = (RS_Arc*)te1; - RS_Line* line = (RS_Line*)te2; - - ret = getIntersectionLineArc(line, arc); - } - - // arc / arc: - // - else if (te1->rtti()==RS2::EntityArc && - te2->rtti()==RS2::EntityArc) { - - RS_Arc* arc1 = (RS_Arc*)te1; - RS_Arc* arc2 = (RS_Arc*)te2; - - ret = getIntersectionArcArc(arc1, arc2); - } else { - RS_DEBUG->print("RS_Information::getIntersection:: Unsupported entity type."); - } - } - - - // Check all intersection points for being on entities: - // - if (onEntities==true) { - if (!e1->isPointOnEntity(ret.get(0), tol) || - !e2->isPointOnEntity(ret.get(0), tol)) { - ret.set(0, Vector(false)); - } - if (!e1->isPointOnEntity(ret.get(1), tol) || - !e2->isPointOnEntity(ret.get(1), tol)) { - ret.set(1, Vector(false)); - } - if (!e1->isPointOnEntity(ret.get(2), tol) || - !e2->isPointOnEntity(ret.get(2), tol)) { - ret.set(2, Vector(false)); - } - if (!e1->isPointOnEntity(ret.get(3), tol) || - !e2->isPointOnEntity(ret.get(3), tol)) { - ret.set(3, Vector(false)); - } - } - - int k=0; - for (int i=0; i<4; ++i) { - if (ret.get(i).valid) { - ret.set(k, ret.get(i)); - k++; - } - } - for (int i=k; i<4; ++i) { - ret.set(i, Vector(false)); - } - - return ret; -} - - - -/** - * @return Intersection between two lines. - */ -VectorSolutions RS_Information::getIntersectionLineLine(RS_Line* e1, - RS_Line* e2) { - - VectorSolutions ret; - - if (e1==NULL || e2==NULL) { - return ret; - } - - Vector p1 = e1->getStartpoint(); - Vector p2 = e1->getEndpoint(); - Vector p3 = e2->getStartpoint(); - Vector p4 = e2->getEndpoint(); - - double num = ((p4.x-p3.x)*(p1.y-p3.y) - (p4.y-p3.y)*(p1.x-p3.x)); - double div = ((p4.y-p3.y)*(p2.x-p1.x) - (p4.x-p3.x)*(p2.y-p1.y)); - - if (fabs(div)>RS_TOLERANCE) { - double u = num / div; - - double xs = p1.x + u * (p2.x-p1.x); - double ys = p1.y + u * (p2.y-p1.y); - ret = VectorSolutions(Vector(xs, ys)); - } - - // lines are parallel - else { - ret = VectorSolutions(); - } - - return ret; -} - - - -/** - * @return One or two intersection points between given entities. - */ -VectorSolutions RS_Information::getIntersectionLineArc(RS_Line* line, - RS_Arc* arc) { - - VectorSolutions ret; - - if (line==NULL || arc==NULL) { - return ret; - } - - double dist=0.0; - Vector nearest; - nearest = line->getNearestPointOnEntity(arc->getCenter(), false, &dist); - - // special case: arc touches line (tangent): - if (fabs(dist - arc->getRadius()) < 1.0e-4) { - ret = VectorSolutions(nearest); - ret.setTangent(true); - return ret; - } - - Vector p = line->getStartpoint(); - Vector d = line->getEndpoint() - line->getStartpoint(); - if (d.magnitude()<1.0e-6) { - return ret; - } - - Vector c = arc->getCenter(); - double r = arc->getRadius(); - Vector delta = p - c; - - // root term: - double term = RS_Math::pow(Vector::dotP(d, delta), 2.0) - - RS_Math::pow(d.magnitude(), 2.0) - * (RS_Math::pow(delta.magnitude(), 2.0) - RS_Math::pow(r, 2.0)); - - // no intersection: - if (term<0.0) { - VectorSolutions s; - ret = s; - } - - // one or two intersections: - else { - double t1 = (- Vector::dotP(d, delta) + sqrt(term)) - / RS_Math::pow(d.magnitude(), 2.0); - double t2; - bool tangent = false; - - // only one intersection: - if (fabs(term)getCenter(); - Vector c2 = e2->getCenter(); - - double r1 = e1->getRadius(); - double r2 = e2->getRadius(); - - Vector u = c2 - c1; - - // concentric - if (u.magnitude()<1.0e-6) { - return ret; - } - - Vector v = Vector(u.y, -u.x); - - double s, t1, t2, term; - - s = 1.0/2.0 * ((r1*r1 - r2*r2)/(RS_Math::pow(u.magnitude(), 2.0)) + 1.0); - - term = (r1*r1)/(RS_Math::pow(u.magnitude(), 2.0)) - s*s; - - // no intersection: - if (term<0.0) { - ret = VectorSolutions(); - } - - // one or two intersections: - else { - t1 = sqrt(term); - t2 = -sqrt(term); - bool tangent = false; - - Vector sol1 = c1 + u*s + v*t1; - Vector sol2 = c1 + u*s + v*t2; - - if (sol1.distanceTo(sol2)<1.0e-4) { - sol2 = Vector(false); - ret = VectorSolutions(sol1); - tangent = true; - } else { - ret = VectorSolutions(sol1, sol2); - } - - ret.setTangent(tangent); - } - - return ret; -} - - - -/** - * @return One or two intersection points between given entities. - */ -VectorSolutions RS_Information::getIntersectionLineEllipse(RS_Line* line, - RS_Ellipse* ellipse) { - - VectorSolutions ret; - - if (line==NULL || ellipse==NULL) { - return ret; - } - - // rotate into normal position: - double ang = ellipse->getAngle(); - - double rx = ellipse->getMajorRadius(); - double ry = ellipse->getMinorRadius(); - Vector center = ellipse->getCenter(); - Vector a1 = line->getStartpoint().rotate(center, -ang); - Vector a2 = line->getEndpoint().rotate(center, -ang); - Vector origin = a1; - Vector dir = a2-a1; - Vector diff = origin - center; - Vector mDir = Vector(dir.x/(rx*rx), dir.y/(ry*ry)); - Vector mDiff = Vector(diff.x/(rx*rx), diff.y/(ry*ry)); - - double a = Vector::dotP(dir, mDir); - double b = Vector::dotP(dir, mDiff); - double c = Vector::dotP(diff, mDiff) - 1.0; - double d = b*b - a*c; - - if (d < 0) { - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 0"); - } else if ( d > 0 ) { - double root = sqrt(d); - double t_a = (-b - root) / a; - double t_b = (-b + root) / a; - - /*if ( (t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b) ) { - if ( (t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1) ) { - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 1"); - } - else { - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: inside 1"); - } - } else {*/ - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: intersection 1"); - Vector ret1(false); - Vector ret2(false); - //if ( 0 <= t_a && t_a <= 1 ) { - //RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t_a<=1"); - ret1 = a1.lerp(a2, t_a); - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret1: %f/%f", ret1.x, ret1.y); - //} - //if ( 0 <= t_b && t_b <= 1 ) { - //RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t_b<=1"); - ret2 = a1.lerp(a2, t_b); - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret2: %f/%f", ret2.x, ret2.y); - //} - if (ret1.valid && ret2.valid) { - ret = VectorSolutions(ret1, ret2); - } - else { - if (ret1.valid) { - ret = VectorSolutions(ret1); - } - if (ret2.valid) { - ret = VectorSolutions(ret2); - } - } - //} - } else { - double t = -b/a; - if ( 0 <= t && t <= 1 ) { - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t<=1"); - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: intersection 2"); - ret = VectorSolutions(a1.lerp(a2, t)); - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret1: %f/%f", ret.get(0).x, ret.get(0).y); - } else { - RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 2"); - } - } - - ret.rotate(center, ang); - return ret; - - - - /* - RS_Arc* arc = new RS_Arc(NULL, - RS_ArcData(ellipse->getCenter(), - ellipse->getMajorRadius(), - ellipse->getAngle1(), - ellipse->getAngle2(), - false)); - RS_Line* other = (RS_Line*)line->clone(); - double angle = ellipse->getAngle(); - //double ratio = ellipse->getRatio(); - - // rotate entities: - other->rotate(ellipse->getCenter(), -angle); - other->scale(ellipse->getCenter(), Vector(1.0, 1.0/ellipse->getRatio())); - - ret = getIntersectionLineArc(other, arc); - - ret.scale(ellipse->getCenter(), Vector(1.0, ellipse->getRatio())); - ret.rotate(ellipse->getCenter(), angle); - - delete arc; - delete other; - - return ret; - */ -} - - -/** - * Checks if the given coordinate is inside the given contour. - * - * @param point Coordinate to check. - * @param contour One or more entities which shape a contour. - * If the given contour is not closed, the result is undefined. - * The entities don't need to be in a specific order. - * @param onContour Will be set to true if the given point it exactly - * on the contour. - */ -bool RS_Information::isPointInsideContour(const Vector& point, - RS_EntityContainer* contour, bool* onContour) { - - if (contour==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Information::isPointInsideContour: contour is NULL"); - return false; - } - - if (point.x < contour->getMin().x || point.x > contour->getMax().x || - point.y < contour->getMin().y || point.y > contour->getMax().y) { - return false; - } - - double width = contour->getSize().x+1.0; - - bool sure; - int counter; - int tries = 0; - double rayAngle = 0.0; - do { - sure = true; - - // create ray: - Vector v; - v.setPolar(width*10.0, rayAngle); - RS_Line ray(NULL, RS_LineData(point, point+v)); - counter = 0; - VectorSolutions sol; - - if (onContour!=NULL) { - *onContour = false; - } - - for (RS_Entity* e = contour->firstEntity(RS2::ResolveAll); - e!=NULL; - e = contour->nextEntity(RS2::ResolveAll)) { - - // intersection(s) from ray with contour entity: - sol = RS_Information::getIntersection(&ray, e, true); - - for (int i=0; i<=1; ++i) { - Vector p = sol.get(i); - - if (p.valid) { - // point is on the contour itself - if (p.distanceTo(point)<1.0e-5) { - if (onContour!=NULL) { - *onContour = true; - } - } else { - if (e->rtti()==RS2::EntityLine) { - RS_Line* line = (RS_Line*)e; - - // ray goes through startpoint of line: - if (p.distanceTo(line->getStartpoint())<1.0e-4) { - if (RS_Math::correctAngle(line->getAngle1())getEndpoint())<1.0e-4) { - if (RS_Math::correctAngle(line->getAngle2())rtti()==RS2::EntityArc) { - RS_Arc* arc = (RS_Arc*)e; - - if (p.distanceTo(arc->getStartpoint())<1.0e-4) { - double dir = arc->getDirection1(); - if ((dir=1.0e-5) || - ((dir>2*M_PI-1.0e-5 || dir<1.0e-5) && - arc->getCenter().y>p.y)) { - counter++; - sure = false; - } - } - else if (p.distanceTo(arc->getEndpoint())<1.0e-4) { - double dir = arc->getDirection2(); - if ((dir=1.0e-5) || - ((dir>2*M_PI-1.0e-5 || dir<1.0e-5) && - arc->getCenter().y>p.y)) { - counter++; - sure = false; - } - } else { - counter++; - } - } else if (e->rtti()==RS2::EntityCircle) { - // tangent: - if (i==0 && sol.get(1).valid==false) { - if (!sol.isTangent()) { - counter++; - } else { - sure = false; - } - } else if (i==1 || sol.get(1).valid==true) { - counter++; - } - } - } - } - } - } - - rayAngle+=0.02; - tries++; - } - while (!sure && rayAngle<2*M_PI && tries<6); - - // remove double intersections: - /* - RS_PtrList is2; - bool done; - Vector* av; - do { - done = true; - double minDist = RS_MAXDOUBLE; - double dist; - av = NULL; - for (Vector* v = is.first(); v!=NULL; v = is.next()) { - dist = point.distanceTo(*v); - if (dist -#include - -#define RS_KeyEvent QKeyEvent - -#endif diff --git a/src/base/rs_math.cpp.bak b/src/base/rs_math.cpp.bak deleted file mode 100644 index 1a8ae47..0000000 --- a/src/base/rs_math.cpp.bak +++ /dev/null @@ -1,430 +0,0 @@ -/**************************************************************************** -** $Id: rs_math.cpp 1938 2004-12-09 23:09:53Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_math.h" - -#include "rs_debug.h" - -/** - * Rounds the given double to the next int. - */ -int RS_Math::round(double v) -{ - return (v - floor(v) < 0.5 ? (int)floor(v) : (int)ceil(v)); -} - -/** - * Save pow function - */ -double RS_Math::pow(double x, double y) -{ - errno = 0; - double ret = ::pow(x, y); - - if (errno == EDOM) - { - RS_DEBUG->print(RS_Debug::D_ERROR, "RS_Math::pow: EDOM in pow"); - ret = 0.0; - } - else if (errno == ERANGE) - { - RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Math::pow: ERANGE in pow"); - ret = 0.0; - } - - return ret; -} - -/** - * Converts radians to degrees. - */ -double RS_Math::rad2deg(double a) -{ - return (a / (2.0 * M_PI) * 360.0); -} - -/** - * Converts degrees to radians. - */ -double RS_Math::deg2rad(double a) -{ - return ((a / 360.0) * (2.0 * M_PI)); -} - -/** - * Converts radians to gradians. - */ -double RS_Math::rad2gra(double a) -{ - return (a / (2.0 * M_PI) * 400.0); -} - -/** - * Finds greatest common divider using Euclid's algorithm. - */ -int RS_Math::findGCD(int a, int b) -{ - while (b != 0) - { - int rem = a % b; - a = b; - b = rem; - } - - return a; -} - -/** - * Tests if angle a is between a1 and a2. a, a1 and a2 must be in the - * range between 0 and 2*PI. - * All angles in rad. - * - * @param reversed true for clockwise testing. false for ccw testing. - * @return true if the angle a is between a1 and a2. - */ -bool RS_Math::isAngleBetween(double a, double a1, double a2, bool reversed) -{ - bool ret = false; - - if (reversed) - { - double tmp = a1; - a1 = a2; - a2 = tmp; - } - - if (a1 >= a2 - 1.0e-12) - { - if (a >= a1 - 1.0e-12 || a <= a2 + 1.0e-12) - { - ret = true; - } - } - else - { - if (a >= a1 - 1.0e-12 && a <= a2 + 1.0e-12) - { - ret = true; - } - } - - //RS_DEBUG->print("angle %f is %sbetween %f and %f", - // a, ret ? "" : "not ", a1, a2); - return ret; -} - -/** - * Corrects the given angle to the range of 0-2*Pi. - */ -double RS_Math::correctAngle(double a) -{ - while (a > 2 * M_PI) - a -= 2 * M_PI; - - while (a < 0) - a += 2 * M_PI; - - return a; -} - -/** - * @return The angle that needs to be added to a1 to reach a2. - * Always positive and less than 2*pi. - */ -double RS_Math::getAngleDifference(double a1, double a2) -{ - double ret; - - if (a1 >= a2) - a2 += 2 * M_PI; - - ret = a2 - a1; - - if (ret >= 2 * M_PI) - ret = 0.0; - - return ret; -} - -/** - * Makes a text constructed with the given angle readable. Used - * for dimension texts and for mirroring texts. - * - * @param readable true: make angle readable, false: unreadable - * @param corrected Will point to true if the given angle was - * corrected, false otherwise. - * - * @return The given angle or the given angle+PI, depending which on - * is readable from the bottom or right. - */ -double RS_Math::makeAngleReadable(double angle, bool readable, bool * corrected) -{ - double ret; - bool cor = isAngleReadable(angle) ^ readable; - - // quadrant 1 & 4 - if (!cor) - ret = angle; - // quadrant 2 & 3 - else - ret = angle + M_PI; - - if (corrected != NULL) - *corrected = cor; - - return ret; -} - -/** - * @return true: if the given angle is in a range that is readable - * for texts created with that angle. - */ -bool RS_Math::isAngleReadable(double angle) -{ - if (angle > M_PI /2.0 * 3.0 + 0.001 || angle < M_PI / 2.0 + 0.001) - return true; - - return false; -} - -/** - * @param tol Tolerance in rad. - * @retval true The two angles point in the same direction. - */ -bool RS_Math::isSameDirection(double dir1, double dir2, double tol) -{ - double diff = fabs(dir1 - dir2); - - if (diff < tol || diff > 2 * M_PI - tol) - { - //std::cout << "RS_Math::isSameDirection: " << dir1 << " and " << dir2 - // << " point in the same direction" << "\n"; - return true; - } - - //std::cout << "RS_Math::isSameDirection: " << dir1 << " and " << dir2 - // << " don't point in the same direction" << "\n"; - return false; -} - -/** - * Compares two double values with a tolerance. - */ -bool RS_Math::cmpDouble(double v1, double v2, double tol) -{ - return (fabs(v2 - v1) < tol); -} - -/** - * Evaluates a mathematical expression and returns the result. - * If an error occured, the given default value 'def' will be returned. - */ -double RS_Math::eval(const QString & expr, double def) -{ - bool ok; - double res = RS_Math::eval(expr, &ok); - - if (!ok) - { - //std::cerr << "RS_Math::evaluate: Parse error at col " - //<< ret << ": " << fp.ErrorMsg() << "\n"; - return def; - } - - return res; -} - -/** - * Evaluates a mathematical expression and returns the result. - * If an error occured, ok will be set to false (if ok isn't NULL). - */ -//double RS_Math::eval(const RS_String& expr, bool* ok); -/** - * Evaluates a mathematical expression and returns the result. - * If an error occured, ok will be set to false (if ok isn't NULL). - */ -// Keep that in the header file for dynamic inclusion/exclusion. -double RS_Math::eval(const QString & expr, bool * ok) -{ -#ifndef RS_NO_FPARSER - if (expr.isEmpty()) - { - if (ok != NULL) - { - *ok = false; - } - - return 0.0; - } - - FunctionParser fp; - fp.AddConstant("pi", M_PI); - - // replace '14 3/4' with '14+3/4' - QString s = expr; - bool done; - - do - { - done = true; - int i = s.find(RS_RegExp("[0-9]* [0-9]*/[0-9]*")); - if (i!=-1) - { - int i2 = s.find(' ', i); - - if (i2 != -1) - { - s.replace(i2, 1, "+"); - done = false; - } - } - } - while (!done); - - int ret = fp.Parse(s.latin1(), "", true); - - if (ret >= 0) - { - if (ok != NULL) - { - *ok = false; - } - - return 0.0; - } - - if (ok != NULL) - { - *ok = true; - } - - return fp.Eval(NULL); -#else - //std::cerr << "RS_Math::eval: No FParser support compiled in.\n"; - return expr.toDouble(); -#endif -} - -/** - * Converts a double into a string which is as short as possible - * - * @param value The double value - * @param prec Precision e.g. a precision of 1 would mean that a - * value of 2.12030 will be converted to "2.1". 2.000 is always just "2"). - */ -RS_String RS_Math::doubleToString(double value, double prec) -{ - if (prec < 1.0e-12) - { - std::cerr << "RS_Math::doubleToString: invalid precision\n"; - return ""; - } - - RS_String ret; - RS_String exaStr; - int dotPos; - int num = RS_Math::round(value / prec); - - exaStr = RS_Math::doubleToString(prec, 10); - dotPos = exaStr.find('.'); - - if (dotPos == -1) - { - ret.sprintf("%d", RS_Math::round(num * prec)); - } - else - { - int digits = exaStr.length() - dotPos - 1; - ret = RS_Math::doubleToString(num * prec, digits); - } - - return ret; -} - -/** - * Converts a double into a string which is as short as possible. - * - * @param value The double value - * @param prec Precision - */ -QString RS_Math::doubleToString(double value, int prec) -{ - QString valStr; - - valStr.setNum(value, 'f', prec); - - if (valStr.contains('.')) - { - // Remove zeros at the end: - while (valStr.at(valStr.length() - 1) == '0') - { - valStr.truncate(valStr.length() - 1); - } - - if (valStr.at(valStr.length() - 1) == '.') - { - valStr.truncate(valStr.length() - 1); - } - } - - return valStr; -} - -/** - * Performs some testing for the math class. - */ -void RS_Math::test() -{ - std::cout << "RS_Math::test: doubleToString:\n"; - - double v = 0.1; - QString s = RS_Math::doubleToString(v, 0.1); - assert(s == "0.1"); - s = RS_Math::doubleToString(v, 0.01); - assert(s == "0.1"); - s = RS_Math::doubleToString(v, 0.0); - assert(s == "0"); - - v = 0.01; - s = RS_Math::doubleToString(v, 0.1); - assert(s == "0"); - s = RS_Math::doubleToString(v, 0.01); - assert(s == "0.01"); - s = RS_Math::doubleToString(v, 0.0); - assert(s == "0"); - - v = 0.001; - s = RS_Math::doubleToString(v, 0.1); - assert(s == "0"); - s = RS_Math::doubleToString(v, 0.01); - assert(s == "0"); - s = RS_Math::doubleToString(v, 0.001); - assert(s == "0.001"); - s = RS_Math::doubleToString(v, 0.0); - assert(s == "0"); - - std::cout << "RS_Math::test: complete\n"; -} diff --git a/src/base/rs_math.h.bak b/src/base/rs_math.h.bak deleted file mode 100644 index 1daeb92..0000000 --- a/src/base/rs_math.h.bak +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** $Id: rs_math.h 2392 2005-05-17 13:52:38Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_MATH_H -#define RS_MATH_H - -// no idea why, but doesn't link without that under win32 / bcc55: -//who cares if it doesn't -//#ifndef _MT -//#define _MT -//#endif - -#include -#include -#include - -#ifndef RS_NO_FPARSER -#include "fparser.h" -#endif - -#include "rs.h" -//#include "rs_string.h" -#include "rs_regexp.h" -//#include "rs_vector.h" - -#define ARAD 57.29577951308232 -#define RS_TOLERANCE 1.0e-10 -#define RS_TOLERANCE_ANGLE 1.0e-8 - -typedef unsigned int uint; - -/** - * Math functions. - */ -class RS_Math -{ -public: - static int round(double v); - static double pow(double x, double y); - - //static double abs(double v); - //static int abs(int v); - static double rad2deg(double a); - static double deg2rad(double a); - static double rad2gra(double a); - static int findGCD(int a, int b); - static bool isAngleBetween(double a, double a1, double a2, bool reversed); - static double correctAngle(double a); - static double getAngleDifference(double a1, double a2); - static double makeAngleReadable(double angle, bool readable = true, bool * corrected = NULL); - static bool isAngleReadable(double angle); - static bool isSameDirection(double dir1, double dir2, double tol); - static double eval(const QString & expr, double def = 0.0); - static bool cmpDouble(double v1, double v2, double tol = 0.001); - - // Keep that in the header file for dynamic inclusion/exclusion. - // (JLH: What kind of boneheaded crappy justification is that??!!??!!?) - static double eval(const QString & expr, bool * ok); - - static QString doubleToString(double value, double prec); - static QString doubleToString(double value, int prec); - - static void test(); -}; - -#endif diff --git a/src/base/rs_modification.cpp.bak b/src/base/rs_modification.cpp.bak deleted file mode 100644 index 413eefe..0000000 --- a/src/base/rs_modification.cpp.bak +++ /dev/null @@ -1,2985 +0,0 @@ -/**************************************************************************** -** $Id: rs_modification.cpp 2419 2005-07-01 16:47:27Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_modification.h" - -#include "rs_clipboard.h" -#include "rs_creation.h" -#include "rs_entity.h" -#include "rs_graphic.h" -#include "rs_information.h" -#include "rs_insert.h" -#include "rs_polyline.h" -#include "rs_text.h" - - - -/** - * Default constructor. - * - * @param container The container to which we will add - * entities. Usually that's an RS_Graphic entity but - * it can also be a polyline, text, ... - * @param graphicView Pointer to graphic view or NULL if you don't want the - * any views to be updated. - * @param handleUndo true: Handle undo functionalitiy. - */ -RS_Modification::RS_Modification(RS_EntityContainer& container, - RS_GraphicView* graphicView, - bool handleUndo) { - this->container = &container; - this->graphicView = graphicView; - this->handleUndo = handleUndo; - graphic = container.getGraphic(); - document = container.getDocument(); -} - - - -/** - * Deletes all selected entities. - */ -void RS_Modification::remove -() { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::remove: no valid container", - RS_Debug::D_WARNING); - return; - } - - if (document!=NULL) { - document->startUndoCycle(); - } - - // not safe (?) - for (RS_Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - - if (e!=NULL && e->isSelected()) { - e->setSelected(false); - e->changeUndoState(); - if (document!=NULL) { - document->addUndoable(e); - } - } - } - - if (document!=NULL) { - document->endUndoCycle(); - } - - graphicView->redraw(); -} - - - -/** - * Changes the attributes of all selected - */ -bool RS_Modification::changeAttributes(RS_AttributesData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::changeAttributes: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL) { - document->startUndoCycle(); - } - - for (RS_Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - ec->setSelected(false); - - RS_Pen pen = ec->getPen(false); - - if (data.changeLayer==true) { - ec->setLayer(data.layer); - } - - if (data.changeColor==true) { - pen.setColor(data.pen.getColor()); - } - if (data.changeLineType==true) { - pen.setLineType(data.pen.getLineType()); - } - if (data.changeWidth==true) { - pen.setWidth(data.pen.getWidth()); - } - - ec->setPen(pen); - - //if (data.useCurrentLayer) { - // ec->setLayerToActive(); - //} - //if (data.useCurrentAttributes) { - // ec->setPenToActive(); - //} - //if (ec->rtti()==RS2::EntityInsert) { - // ((RS_Insert*)ec)->update(); - //} - ec->update(); - addList.append(ec); - } - } - - deselectOriginals(true); - addNewEntities(addList); - - if (document!=NULL) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - - return true; -} - - -/** - * Copies all selected entities from the given container to the clipboard. - * Layers and blocks that are needed are also copied if the container is - * or is part of an RS_Graphic. - * - * @param container The entity container. - * @param ref Reference point. The entities will be moved by -ref. - * @param cut true: cut instead of copying, false: copy - */ -void RS_Modification::copy(const Vector& ref, const bool cut) { - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::copy: no valid container", - RS_Debug::D_WARNING); - return; - } - - RS_CLIPBOARD->clear(); - if (graphic!=NULL) { - RS_CLIPBOARD->getGraphic()->setUnit(graphic->getUnit()); - } else { - RS_CLIPBOARD->getGraphic()->setUnit(RS2::None); - } - - // start undo cycle for the container if we're cutting - if (cut && document!=NULL) { - document->startUndoCycle(); - } - - // copy entities / layers / blocks - for (RS_Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isSelected()) { - copyEntity(e, ref, cut); - } - } - - if (cut && document!=NULL) { - document->endUndoCycle(); - } -} - - - -/** - * Copies the given entity from the given container to the clipboard. - * Layers and blocks that are needed are also copied if the container is - * or is part of an RS_Graphic. - * - * @param e The entity. - * @param ref Reference point. The entities will be moved by -ref. - * @param cut true: cut instead of copying, false: copy - */ -void RS_Modification::copyEntity(RS_Entity* e, const Vector& ref, - const bool cut) { - - if (e!=NULL && e->isSelected()) { - // delete entity in graphic view: - if (cut) { - if (graphicView!=NULL) { - graphicView->deleteEntity(e); - } - e->setSelected(false); - } else { - if (graphicView!=NULL) { - graphicView->deleteEntity(e); - } - e->setSelected(false); - if (graphicView!=NULL) { - graphicView->drawEntity(e); - } - } - - // add entity to clipboard: - RS_Entity* c = e->clone(); - c->move(-ref); - RS_CLIPBOARD->addEntity(c); - - copyLayers(e); - copyBlocks(e); - - // set layer to the layer clone: - RS_Layer* l = e->getLayer(); - if (l!=NULL) { - c->setLayer(l->getName()); - } - - // make sure all sub entities point to layers of the clipboard - if (c->isContainer()) { - RS_EntityContainer* ec = (RS_EntityContainer*)c; - - for (RS_Entity* e2 = ec->firstEntity(RS2::ResolveAll); e2!=NULL; - e2 = ec->nextEntity(RS2::ResolveAll)) { - - //RS_Entity* e2 = ec->entityAt(i); - RS_Layer* l2 = e2->getLayer(); - - if (l2!=NULL) { - e2->setLayer(l2->getName()); - } - } - } - - if (cut) { - e->changeUndoState(); - if (document!=NULL) { - document->addUndoable(e); - } - } - } - -} - - - -/** - * Copies all layers of the given entity to the clipboard. - */ -void RS_Modification::copyLayers(RS_Entity* e) { - - if (e==NULL) { - return; - } - - // add layer(s) of the entity if it's not an insert - // (inserts are on layer '0'): - if (e->rtti()!=RS2::EntityInsert) { - RS_Layer* l = e->getLayer(); - if (l!=NULL) { - if (!RS_CLIPBOARD->hasLayer(l->getName())) { - RS_CLIPBOARD->addLayer(l->clone()); - } - } - } - - // special handling of inserts: - else { - // insert: add layer(s) of subentities: - RS_Block* b = ((RS_Insert*)e)->getBlockForInsert(); - if (b!=NULL) { - for (RS_Entity* e2=b->firstEntity(); e2!=NULL; - e2=b->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e2 = b->entityAt(i); - copyLayers(e2); - } - } - } -} - - - -/** - * Copies all blocks of the given entity to the clipboard. - */ -void RS_Modification::copyBlocks(RS_Entity* e) { - - if (e==NULL) { - return; - } - - // add block of the entity if it's an insert - if (e->rtti()==RS2::EntityInsert) { - RS_Block* b = ((RS_Insert*)e)->getBlockForInsert(); - if (b!=NULL) { - // add block of an insert: - if (!RS_CLIPBOARD->hasBlock(b->getName())) { - RS_CLIPBOARD->addBlock((RS_Block*)b->clone()); - } - - for (RS_Entity* e2=b->firstEntity(); e2!=NULL; - e2=b->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e2 = b->entityAt(i); - copyBlocks(e2); - } - } - } -} - - - -/** - * Pastes all entities from the clipboard into the container. - * Layers and blocks that are needed are also copied if the container is - * or is part of an RS_Graphic. - * - * @param data Paste data. - * @param source The source from where to paste. NULL means the source - * is the clipboard. - */ -void RS_Modification::paste(const RS_PasteData& data, RS_Graphic* source) { - - if (graphic==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::paste: Graphic is NULL"); - return; - } - - double factor = 1.0; - - if (source==NULL) { - source = RS_CLIPBOARD->getGraphic(); - - // graphics from the clipboard need to be scaled. from the part lib not: - RS2::Unit sourceUnit = source->getUnit(); - RS2::Unit targetUnit = graphic->getUnit(); - factor = RS_Units::convert(1.0, sourceUnit, targetUnit); - } - - if (document!=NULL) { - document->startUndoCycle(); - } - - - // insert layers: - if (graphic!=NULL) { - RS_Layer* layer = graphic->getActiveLayer(); - for(uint i=0; icountLayers(); ++i) { - RS_Layer* l = source->layerAt(i); - if (l!=NULL) { - if (graphic->findLayer(l->getName())==NULL) { - graphic->addLayer(l->clone()); - } - } - } - graphic->activateLayer(layer); - } - - // insert blocks: - if (graphic!=NULL) { - for(uint i=0; icountBlocks(); ++i) { - RS_Block* b = source->blockAt(i); - if (b!=NULL) { - if (graphic->findBlock(b->getName())==NULL) { - RS_Block* bc = (RS_Block*)b->clone(); - bc->reparent(container); - //bc->scale(bc->getBasePoint(), Vector(factor, factor)); - // scale block but don't scale inserts in block - // (they already scale with their block) - for(uint i2=0; i2count(); ++i2) { - RS_Entity* e = bc->entityAt(i2); - if (e!=NULL && e->rtti()!=RS2::EntityInsert) { - e->scale(bc->getBasePoint(), - Vector(factor, factor)); - } else { - Vector ip = ((RS_Insert*)e)->getInsertionPoint(); - ip.scale(bc->getBasePoint(), - Vector(factor, factor)); - ((RS_Insert*)e)->setInsertionPoint(ip); - e->update(); - } - } - - graphic->addBlock(bc); - } - } - } - } - - // add entities to this host (graphic or a new block) - RS_EntityContainer* host = container; - RS_String blockName; - - // create new block: - if (graphic!=NULL) { - if (data.asInsert==true) { - RS_BlockList* blkList = graphic->getBlockList(); - if (blkList!=NULL) { - blockName = blkList->newName(data.blockName); - - RS_Block* blk = - new RS_Block(graphic, - RS_BlockData(blockName, - Vector(0.0,0.0), false)); - graphic->addBlock(blk); - - host = blk; - } - } - } - - // insert entities: - //for (uint i=0; i<((RS_EntityContainer*)source)->count(); ++i) { - //RS_Entity* e = source->entityAt(i); - for (RS_Entity* e=((RS_EntityContainer*)source)->firstEntity(); - e!=NULL; - e=((RS_EntityContainer*)source)->nextEntity()) { - - if (e!=NULL) { - - RS_String layerName = "0"; - RS_Layer* layer = e->getLayer(); - if (layer!=NULL) { - layerName = layer->getName(); - } - RS_Entity* e2 = e->clone(); - e2->reparent(host); - if (data.asInsert==false) { - e2->move(data.insertionPoint); - } - // don't adjust insert factor - block was already adjusted to unit - if (e2->rtti()==RS2::EntityInsert) { - Vector ip = ((RS_Insert*)e2)->getInsertionPoint(); - ip.scale(data.insertionPoint, Vector(factor, factor)); - ((RS_Insert*)e2)->setInsertionPoint(ip); - e2->update(); - } else { - e2->scale(data.insertionPoint, Vector(factor, factor)); - } - host->addEntity(e2); - e2->setLayer(layerName); - - // make sure all sub entities point to layers of the container - if (e2->isContainer()) { - RS_EntityContainer* ec = (RS_EntityContainer*)e2; - - for (RS_Entity* e3 = ec->firstEntity(RS2::ResolveAll); e3!=NULL; - e3 = ec->nextEntity(RS2::ResolveAll)) { - - //RS_Entity* e3 = ec->entityAt(i); - RS_Layer* l2 = e3->getLayer(); - if (l2!=NULL) { - e3->setLayer(l2->getName()); - } - } - } - - if (document!=NULL && data.asInsert==false) { - document->addUndoable(e2); - } - } - } - - if (data.asInsert==true) { - RS_Insert* ins = - new RS_Insert(container, - RS_InsertData( - blockName, - data.insertionPoint, - Vector(data.factor, data.factor), - data.angle, - 1,1,Vector(0.0,0.0))); - container->addEntity(ins); - ins->setLayerToActive(); - ins->setPenToActive(); - - if (document!=NULL) { - document->addUndoable(ins); - } - } - - if (document!=NULL) { - document->endUndoCycle(); - } -} - - -/** - * Splits a polyline into two leaving out a gap. - * - * @param polyline The original polyline - * @param e1 1st entity on which the first cutting point is. - * @param v1 1st cutting point. - * @param e2 2nd entity on which the first cutting point is. - * @param v2 2nd cutting point. - * @param polyline1 Pointer to a polyline pointer which will hold the - * 1st resulting new polyline. Pass NULL if you don't - * need those pointers. - * @param polyline2 Pointer to a polyline pointer which will hold the - * 2nd resulting new polyline. Pass NULL if you don't - * need those pointers. - * - * @todo Support arcs in polylines, check for wrong parameters - * - * @return true - */ -bool RS_Modification::splitPolyline(RS_Polyline& polyline, - RS_Entity& e1, Vector v1, - RS_Entity& e2, Vector v2, - RS_Polyline** polyline1, - RS_Polyline** polyline2) const { - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::splitPolyline: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_Entity* firstEntity = polyline.firstEntity(); - Vector firstPoint(false); - if (firstEntity->rtti()==RS2::EntityLine) { - firstPoint = ((RS_Line*)firstEntity)->getStartpoint(); - } - RS_Polyline* pl1 = - new RS_Polyline(container, - RS_PolylineData(firstPoint, Vector(0.0,0.0), 0)); - RS_Polyline* pl2 = new RS_Polyline(container); - RS_Polyline* pl = pl1; // Current polyline - RS_Line* line = NULL; - RS_Arc* arc = NULL; - - if (polyline1!=NULL) { - *polyline1 = pl1; - } - if (polyline2!=NULL) { - *polyline2 = pl2; - } - - for (RS_Entity* e = polyline.firstEntity(); - e != NULL; - e = polyline.nextEntity()) { - - if (e->rtti()==RS2::EntityLine) { - line = (RS_Line*)e; - arc = NULL; - } else if (e->rtti()==RS2::EntityArc) { - arc = (RS_Arc*)e; - line = NULL; - } else { - line = NULL; - arc = NULL; - } - - if (line!=NULL /*|| arc!=NULL*/) { - - if (e==&e1 && e==&e2) { - // Trim within a single entity: - Vector sp = line->getStartpoint(); - double dist1 = (v1-sp).magnitude(); - double dist2 = (v2-sp).magnitude(); - pl->addVertex(dist1setStartpoint(dist1addVertex(line->getEndpoint(), 0.0); - } else if (e==&e1 || e==&e2) { - // Trim entities: - Vector v = (e==&e1 ? v1 : v2); - if (pl==pl1) { - // Trim endpoint of entity to first vector - pl->addVertex(v, 0.0); - pl = NULL; - } else { - // Trim startpoint of entity to second vector - pl = pl2; - pl->setStartpoint(v); - pl->addVertex(line->getEndpoint(), 0.0); - } - } else { - // Add entities to polylines - if (line!=NULL && pl!=NULL) { - pl->addVertex(line->getEndpoint(), 0.0); - } - } - } - } - - container->addEntity(pl1); - container->addEntity(pl2); - //container->removeEntity(&polyline); - polyline.changeUndoState(); - - return true; -} - - - -/** - * Adds a node to the given polyline. The new node is placed between - * the start and end point of the given segment. - * - * @param node The position of the new node. - * - * @return Pointer to the new polyline or NULL. - */ -/* -RS_Polyline* RS_Modification::addPolylineNode(RS_Polyline& polyline, - const RS_AtomicEntity& segment, - const Vector& node) { - RS_DEBUG->print("RS_Modification::addPolylineNode"); - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::addPolylineNode: no valid container", - RS_Debug::D_WARNING); - return NULL; - } - - if (segment.getParent()!=&polyline) { - RS_DEBUG->print("RS_Modification::addPolylineNode: " - "segment not part of the polyline", - RS_Debug::D_WARNING); - return NULL; - } - - RS_Polyline* newPolyline = new RS_Polyline(container); - newPolyline->setClosed(polyline.isClosed()); - newPolyline->setSelected(polyline.isSelected()); - newPolyline->setLayer(polyline.getLayer()); - newPolyline->setPen(polyline.getPen()); - - // copy polyline and add new node: - bool first = true; - RS_Entity* lastEntity = polyline.lastEntity(); - for (RS_Entity* e=polyline.firstEntity(); e!=NULL; - e=polyline.nextEntity()) { - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - double bulge = 0.0; - if (ae->rtti()==RS2::EntityArc) { - RS_DEBUG->print("RS_Modification::addPolylineNode: arc segment"); - bulge = ((RS_Arc*)ae)->getBulge(); - } else { - RS_DEBUG->print("RS_Modification::addPolylineNode: line segment"); - bulge = 0.0; - } - - if (first) { - RS_DEBUG->print("RS_Modification::addPolylineNode: first segment: %f/%f", - ae->getStartpoint().x, ae->getStartpoint().y); - - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getStartpoint()); - first = false; - } - - // segment to split: - if (ae==&segment) { - RS_DEBUG->print("RS_Modification::addPolylineNode: split segment found"); - - RS_DEBUG->print("RS_Modification::addPolylineNode: node: %f/%f", - node.x, node.y); - - newPolyline->setNextBulge(0.0); - newPolyline->addVertex(node); - - RS_DEBUG->print("RS_Modification::addPolylineNode: after node: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - - if (ae!=lastEntity || polyline.isClosed()==false) { - newPolyline->setNextBulge(0.0); - newPolyline->addVertex(ae->getEndpoint()); - } - } else { - RS_DEBUG->print("RS_Modification::addPolylineNode: normal vertex found: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - - if (ae!=lastEntity || polyline.isClosed()==false) { - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getEndpoint()); - } - } - } else { - RS_DEBUG->print("RS_Modification::addPolylineNode: " - "Polyline contains non-atomic entities", - RS_Debug::D_WARNING); - } - } - - newPolyline->setNextBulge(polyline.getClosingBulge()); - newPolyline->endPolyline(); - - // add new polyline: - container->addEntity(newPolyline); - if (graphicView!=NULL) { - graphicView->deleteEntity(&polyline); - graphicView->drawEntity(newPolyline); - } - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - - polyline.setUndoState(true); - document->addUndoable(&polyline); - document->addUndoable(newPolyline); - - document->endUndoCycle(); - } - - return newPolyline; -} -*/ - - - -/** - * Deletes a node from a polyline. - * - * @param node The node to delete. - * - * @return Pointer to the new polyline or NULL. - */ -/* -RS_Polyline* RS_Modification::deletePolylineNode(RS_Polyline& polyline, - const Vector& node) { - - RS_DEBUG->print("RS_Modification::deletePolylineNode"); - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::addPolylineNode: no valid container", - RS_Debug::D_WARNING); - return NULL; - } - - if (node.valid==false) { - RS_DEBUG->print("RS_Modification::deletePolylineNode: " - "node not valid", - RS_Debug::D_WARNING); - return NULL; - } - - // check if the polyline is no longer there after deleting the node: - if (polyline.count()==1) { - RS_Entity* e = polyline.firstEntity(); - if (e!=NULL && e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - if (node.distanceTo(ae->getStartpoint())<1.0e-6 || - node.distanceTo(ae->getEndpoint())<1.0e-6) { - - if (graphicView!=NULL) { - graphicView->deleteEntity(&polyline); - } - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - polyline.setUndoState(true); - document->addUndoable(&polyline); - document->endUndoCycle(); - } - } - } - return NULL; - } - - RS_Polyline* newPolyline = new RS_Polyline(container); - newPolyline->setClosed(polyline.isClosed()); - newPolyline->setSelected(polyline.isSelected()); - newPolyline->setLayer(polyline.getLayer()); - newPolyline->setPen(polyline.getPen()); - - // copy polyline and drop deleted node: - bool first = true; - bool lastDropped = false; - RS_Entity* lastEntity = polyline.lastEntity(); - for (RS_Entity* e=polyline.firstEntity(); e!=NULL; - e=polyline.nextEntity()) { - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - double bulge = 0.0; - if (ae->rtti()==RS2::EntityArc) { - RS_DEBUG->print("RS_Modification::deletePolylineNode: arc segment"); - bulge = ((RS_Arc*)ae)->getBulge(); - } else { - RS_DEBUG->print("RS_Modification::deletePolylineNode: line segment"); - bulge = 0.0; - } - - // last entity is closing entity and will be added below with endPolyline() - if (e==lastEntity && polyline.isClosed()) { - continue; - } - - // first vertex (startpoint) - if (first && node.distanceTo(ae->getStartpoint())>1.0e-6) { - RS_DEBUG->print("RS_Modification::deletePolylineNode: first node: %f/%f", - ae->getStartpoint().x, ae->getStartpoint().y); - - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getStartpoint()); - first = false; - } - - // normal node (not deleted): - if (first==false && node.distanceTo(ae->getEndpoint())>1.0e-6) { - RS_DEBUG->print("RS_Modification::deletePolylineNode: normal vertex found: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - if (lastDropped) { - //bulge = 0.0; - } - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getEndpoint()); - lastDropped = false; - } - - // drop deleted node: - else { - RS_DEBUG->print("RS_Modification::deletePolylineNode: deleting vertex: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - lastDropped = true; - } - } else { - RS_DEBUG->print("RS_Modification::deletePolylineNode: " - "Polyline contains non-atomic entities", - RS_Debug::D_WARNING); - } - } - - RS_DEBUG->print("RS_Modification::deletePolylineNode: ending polyline"); - newPolyline->setNextBulge(polyline.getClosingBulge()); - newPolyline->endPolyline(); - - //if (newPolyline->count()==1) { - //} - - // add new polyline: - RS_DEBUG->print("RS_Modification::deletePolylineNode: adding new polyline"); - container->addEntity(newPolyline); - if (graphicView!=NULL) { - graphicView->deleteEntity(&polyline); - graphicView->drawEntity(newPolyline); - } - - RS_DEBUG->print("RS_Modification::deletePolylineNode: handling undo"); - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - - polyline.setUndoState(true); - document->addUndoable(&polyline); - document->addUndoable(newPolyline); - - document->endUndoCycle(); - } - - return newPolyline; -} -*/ - - - -/** - * Deletes all nodes between the two given nodes (exclusive). - * - * @param node1 First limiting node. - * @param node2 Second limiting node. - * - * @return Pointer to the new polyline or NULL. - */ -/* -RS_Polyline* RS_Modification::deletePolylineNodesBetween(RS_Polyline& polyline, - RS_AtomicEntity& segment, const Vector& node1, const Vector& node2) { - - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween"); - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::addPolylineNodesBetween: no valid container", - RS_Debug::D_WARNING); - return NULL; - } - - if (node1.valid==false || node2.valid==false) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "node not valid", - RS_Debug::D_WARNING); - return NULL; - } - - if (node1.distanceTo(node2)<1.0e-6) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "nodes are identical", - RS_Debug::D_WARNING); - return NULL; - } - - // check if there's nothing to delete: - for (RS_Entity* e=polyline.firstEntity(); e!=NULL; - e=polyline.nextEntity()) { - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - - if ((node1.distanceTo(ae->getStartpoint())<1.0e-6 && - node2.distanceTo(ae->getEndpoint())<1.0e-6) || - (node2.distanceTo(ae->getStartpoint())<1.0e-6 && - node1.distanceTo(ae->getEndpoint())<1.0e-6)) { - - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "nothing to delete", - RS_Debug::D_WARNING); - return NULL; - } - } - } - - - // check if the start point is involved: - bool startpointInvolved = false; - if (node1.distanceTo(polyline.getStartpoint())<1.0e-6 || - node2.distanceTo(polyline.getStartpoint())<1.0e-6) { - startpointInvolved = true; - } - - - // check which part of the polyline has to be deleted: - bool deleteStart = false; - if (polyline.isClosed()) { - bool found = false; - double length1 = 0.0; - double length2 = 0.0; - RS_Entity* e=polyline.firstEntity(); - - if (startpointInvolved) { - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - length1+=ae->getLength(); - } - e = polyline.nextEntity(); - } - for (; e!=NULL; e=polyline.nextEntity()) { - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - - if (node1.distanceTo(ae->getStartpoint())<1.0e-6 || - node2.distanceTo(ae->getStartpoint())<1.0e-6) { - - found = !found; - } - - if (found) { - length2+=ae->getLength(); - } else { - length1+=ae->getLength(); - } - } - } - if (length1setClosed(polyline.isClosed()); - newPolyline->setSelected(polyline.isSelected()); - newPolyline->setLayer(polyline.getLayer()); - newPolyline->setPen(polyline.getPen()); - - if (startpointInvolved && deleteStart && polyline.isClosed()) { - newPolyline->setNextBulge(0.0); - newPolyline->addVertex(polyline.getStartpoint()); - } - - // copy polyline and drop deleted nodes: - bool first = true; - bool removing = deleteStart; - bool done = false; - bool nextIsStraight = false; - RS_Entity* lastEntity = polyline.lastEntity(); - int i=0; - double bulge = 0.0; - for (RS_Entity* e=polyline.firstEntity(); e!=NULL; - e=polyline.nextEntity()) { - - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: entity: %d", i++); - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: removing: %d", (int)removing); - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - if (ae->rtti()==RS2::EntityArc) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: arc segment"); - bulge = ((RS_Arc*)ae)->getBulge(); - } else { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: line segment"); - bulge = 0.0; - } - - // last entity is closing entity and will be added below with endPolyline() - if (e==lastEntity && polyline.isClosed()) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "dropping last vertex of closed polyline"); - continue; - } - - // first vertex (startpoint) - if (first) { - if (!removing) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: first node: %f/%f", - ae->getStartpoint().x, ae->getStartpoint().y); - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getStartpoint()); - first = false; - } - } - - // stop removing nodes: - if (removing==true && - (node1.distanceTo(ae->getEndpoint())<1.0e-6 || - node2.distanceTo(ae->getEndpoint())<1.0e-6)) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "stop removing at: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - removing = false; - done = true; - if (first==false) { - nextIsStraight = true; - } - } - - // normal node (not deleted): - if (removing==false && (done==false || deleteStart==false)) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "normal vertex found: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - if (nextIsStraight) { - bulge = 0.0; - nextIsStraight = false; - } - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getEndpoint()); - } - - // drop deleted node: - else { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "deleting vertex: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - } - - // start to remove nodes from now on: - if (done==false && removing==false && - (node1.distanceTo(ae->getEndpoint())<1.0e-6 || - node2.distanceTo(ae->getEndpoint())<1.0e-6)) { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "start removing at: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - removing = true; - } - - if (done) { - done=false; - } - } else { - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: " - "Polyline contains non-atomic entities", - RS_Debug::D_WARNING); - } - } - - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: ending polyline"); - newPolyline->setNextBulge(polyline.getClosingBulge()); - newPolyline->endPolyline(); - - // add new polyline: - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: adding new polyline"); - container->addEntity(newPolyline); - if (graphicView!=NULL) { - graphicView->deleteEntity(&polyline); - graphicView->drawEntity(newPolyline); - } - - RS_DEBUG->print("RS_Modification::deletePolylineNodesBetween: handling undo"); - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - - polyline.setUndoState(true); - document->addUndoable(&polyline); - document->addUndoable(newPolyline); - - document->endUndoCycle(); - } - - return newPolyline; -} -*/ - - - -/** - * Trims two segments of a polyline all nodes between the two trim segments - * are removed. - * - * @param polyline The polyline entity. - * @param segment1 First segment to trim. - * @param segment2 Second segment to trim. - * - * @return Pointer to the new polyline or NULL. - */ -/* -RS_Polyline* RS_Modification::polylineTrim(RS_Polyline& polyline, - RS_AtomicEntity& segment1, - RS_AtomicEntity& segment2) { - - RS_DEBUG->print("RS_Modification::polylineTrim"); - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::addPolylineNodesBetween: no valid container", - RS_Debug::D_WARNING); - return NULL; - } - - if (segment1.getParent()!=&polyline || segment2.getParent()!=&polyline) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "segments not in polyline", - RS_Debug::D_WARNING); - return NULL; - } - - if (&segment1==&segment2) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "segments are identical", - RS_Debug::D_WARNING); - return NULL; - } - - VectorSolutions sol; - sol = RS_Information::getIntersection(&segment1, &segment2, false); - - if (sol.getNumber()==0) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "segments cannot be trimmed", - RS_Debug::D_WARNING); - return NULL; - } - - // check which segment comes first in the polyline: - RS_AtomicEntity* firstSegment; - if (polyline.findEntity(&segment1) > polyline.findEntity(&segment2)) { - firstSegment = &segment2; - } else { - firstSegment = &segment1; - } - - // find out if we need to trim towards the open part of the polyline - bool reverseTrim; - reverseTrim = !RS_Math::isSameDirection(firstSegment->getDirection1(), - firstSegment->getStartpoint().angleTo(sol.get(0)), M_PI/2.0); - //reverseTrim = reverseTrim || !RS_Math::isSameDirection(segment2.getDirection1(), - // segment2.getStartpoint().angleTo(sol.get(0)), M_PI/2.0); - - RS_Polyline* newPolyline = new RS_Polyline(container); - newPolyline->setClosed(polyline.isClosed()); - newPolyline->setSelected(polyline.isSelected()); - newPolyline->setLayer(polyline.getLayer()); - newPolyline->setPen(polyline.getPen()); - - // normal trimming: start removing nodes at trim segment. ends stay the same - if (reverseTrim==false) { - // copy polyline, trim segments and drop between nodes: - bool first = true; - bool removing = false; - bool nextIsStraight = false; - RS_Entity* lastEntity = polyline.lastEntity(); - for (RS_Entity* e=polyline.firstEntity(); e!=NULL; - e=polyline.nextEntity()) { - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - double bulge = 0.0; - if (ae->rtti()==RS2::EntityArc) { - RS_DEBUG->print("RS_Modification::polylineTrim: arc segment"); - bulge = ((RS_Arc*)ae)->getBulge(); - } else { - RS_DEBUG->print("RS_Modification::polylineTrim: line segment"); - bulge = 0.0; - } - - // last entity is closing entity and will be added below with endPolyline() - if (e==lastEntity && polyline.isClosed()) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "dropping last vertex of closed polyline"); - continue; - } - - // first vertex (startpoint) - if (first) { - RS_DEBUG->print("RS_Modification::polylineTrim: first node: %f/%f", - ae->getStartpoint().x, ae->getStartpoint().y); - - newPolyline->setNextBulge(bulge); - newPolyline->addVertex(ae->getStartpoint()); - first = false; - } - - // trim and start removing nodes: - if (removing==false && (ae==&segment1 || ae==&segment2)) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "start removing at trim point %f/%f", - sol.get(0).x, sol.get(0).y); - newPolyline->setNextBulge(0.0); - newPolyline->addVertex(sol.get(0)); - removing = true; - nextIsStraight = true; - } - - // stop removing nodes: - else if (removing==true && (ae==&segment1 || ae==&segment2)) { - RS_DEBUG->print("RS_Modification::polylineTrim: stop removing at: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - removing = false; - } - - // normal node (not deleted): - if (removing==false) { - RS_DEBUG->print("RS_Modification::polylineTrim: normal vertex found: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - if (nextIsStraight) { - newPolyline->setNextBulge(0.0); - nextIsStraight = false; - } else { - newPolyline->setNextBulge(bulge); - } - newPolyline->addVertex(ae->getEndpoint()); - } - } else { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "Polyline contains non-atomic entities", - RS_Debug::D_WARNING); - } - } - } - - // reverse trimming: remove nodes at the ends and keep those in between - else { - // copy polyline, trim segments and drop between nodes: - //bool first = true; - bool removing = true; - bool nextIsStraight = false; - RS_Entity* lastEntity = polyline.lastEntity(); - for (RS_Entity* e=polyline.firstEntity(); e!=NULL; - e=polyline.nextEntity()) { - - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - double bulge = 0.0; - if (ae->rtti()==RS2::EntityArc) { - RS_DEBUG->print("RS_Modification::polylineTrim: arc segment"); - bulge = ((RS_Arc*)ae)->getBulge(); - } else { - RS_DEBUG->print("RS_Modification::polylineTrim: line segment"); - bulge = 0.0; - } - - // last entity is closing entity and will be added below with endPolyline() - if (e==lastEntity && polyline.isClosed()) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "dropping last vertex of closed polyline"); - continue; - } - - // trim and stop removing nodes: - if (removing==true && (ae==&segment1 || ae==&segment2)) { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "stop removing at trim point %f/%f", - sol.get(0).x, sol.get(0).y); - newPolyline->setNextBulge(0.0); - // start of new polyline: - newPolyline->addVertex(sol.get(0)); - removing = false; - nextIsStraight = true; - } - - // start removing nodes again: - else if (removing==false && (ae==&segment1 || ae==&segment2)) { - RS_DEBUG->print("RS_Modification::polylineTrim: start removing at: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - newPolyline->setNextBulge(0.0); - // start of new polyline: - newPolyline->addVertex(sol.get(0)); - removing = true; - } - - // normal node (not deleted): - if (removing==false) { - RS_DEBUG->print("RS_Modification::polylineTrim: normal vertex found: %f/%f", - ae->getEndpoint().x, ae->getEndpoint().y); - if (nextIsStraight) { - newPolyline->setNextBulge(0.0); - nextIsStraight = false; - } else { - newPolyline->setNextBulge(bulge); - } - newPolyline->addVertex(ae->getEndpoint()); - } - } else { - RS_DEBUG->print("RS_Modification::polylineTrim: " - "Polyline contains non-atomic entities", - RS_Debug::D_WARNING); - } - } - } - - RS_DEBUG->print("RS_Modification::polylineTrim: ending polyline"); - newPolyline->setNextBulge(polyline.getClosingBulge()); - newPolyline->endPolyline(); - - // add new polyline: - RS_DEBUG->print("RS_Modification::polylineTrim: adding new polyline"); - container->addEntity(newPolyline); - if (graphicView!=NULL) { - graphicView->deleteEntity(&polyline); - graphicView->drawEntity(newPolyline); - } - - RS_DEBUG->print("RS_Modification::polylineTrim: handling undo"); - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - - polyline.setUndoState(true); - document->addUndoable(&polyline); - document->addUndoable(newPolyline); - - document->endUndoCycle(); - } - - return newPolyline; -} -*/ - - - -/** - * Moves all selected entities with the given data for the move - * modification. - */ -bool RS_Modification::move(RS_MoveData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::move: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (int num=1; - num<=data.number || (data.number==0 && num<=1); - num++) { - // too slow: - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - - ec->move(data.offset*num); - if (data.useCurrentLayer) { - ec->setLayerToActive(); - } - if (data.useCurrentAttributes) { - ec->setPenToActive(); - } - if (ec->rtti()==RS2::EntityInsert) { - ((RS_Insert*)ec)->update(); - } - // since 2.0.4.0: keep selection - ec->setSelected(true); - addList.append(ec); - } - } - } - - deselectOriginals(data.number==0); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - return true; -} - - - - -/** - * Rotates all selected entities with the given data for the rotation. - */ -bool RS_Modification::rotate(RS_RotateData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::rotate: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (int num=1; - num<=data.number || (data.number==0 && num<=1); - num++) { - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - ec->setSelected(false); - - ec->rotate(data.center, data.angle*num); - if (data.useCurrentLayer) { - ec->setLayerToActive(); - } - if (data.useCurrentAttributes) { - ec->setPenToActive(); - } - if (ec->rtti()==RS2::EntityInsert) { - ((RS_Insert*)ec)->update(); - } - addList.append(ec); - } - } - } - - deselectOriginals(data.number==0); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - if (graphicView!=NULL) { - graphicView->redraw(); - } - - return true; -} - - - -/** - * Moves all selected entities with the given data for the scale - * modification. - */ -bool RS_Modification::scale(RS_ScaleData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::scale: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (int num=1; - num<=data.number || (data.number==0 && num<=1); - num++) { - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - ec->setSelected(false); - - ec->scale(data.referencePoint, RS_Math::pow(data.factor, num)); - if (data.useCurrentLayer) { - ec->setLayerToActive(); - } - if (data.useCurrentAttributes) { - ec->setPenToActive(); - } - if (ec->rtti()==RS2::EntityInsert) { - ((RS_Insert*)ec)->update(); - } - addList.append(ec); - } - } - } - - deselectOriginals(data.number==0); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - return true; -} - - - -/** - * Mirror all selected entities with the given data for the mirror - * modification. - */ -bool RS_Modification::mirror(RS_MirrorData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::mirror: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (int num=1; - num<=(int)data.copy || (data.copy==false && num<=1); - num++) { - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - ec->setSelected(false); - - ec->mirror(data.axisPoint1, data.axisPoint2); - if (data.useCurrentLayer) { - ec->setLayerToActive(); - } - if (data.useCurrentAttributes) { - ec->setPenToActive(); - } - if (ec->rtti()==RS2::EntityInsert) { - ((RS_Insert*)ec)->update(); - } - addList.append(ec); - } - } - } - - deselectOriginals(data.copy==false); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - return true; -} - - - -/** - * Rotates entities around two centers with the given parameters. - */ -bool RS_Modification::rotate2(RS_Rotate2Data& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::rotate2: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (int num=1; - num<=data.number || (data.number==0 && num<=1); - num++) { - - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - ec->setSelected(false); - - ec->rotate(data.center1, data.angle1*num); - Vector center2 = data.center2; - center2.rotate(data.center1, data.angle1*num); - - ec->rotate(center2, data.angle2*num); - if (data.useCurrentLayer) { - ec->setLayerToActive(); - } - if (data.useCurrentAttributes) { - ec->setPenToActive(); - } - if (ec->rtti()==RS2::EntityInsert) { - ((RS_Insert*)ec)->update(); - } - addList.append(ec); - } - } - } - - deselectOriginals(data.number==0); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - return true; -} - - - -/** - * Moves and rotates entities with the given parameters. - */ -bool RS_Modification::moveRotate(RS_MoveRotateData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::moveRotate: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (int num=1; - num<=data.number || (data.number==0 && num<=1); - num++) { - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - ec->setSelected(false); - - ec->move(data.offset*num); - ec->rotate(data.referencePoint + data.offset*num, - data.angle*num); - if (data.useCurrentLayer) { - ec->setLayerToActive(); - } - if (data.useCurrentAttributes) { - ec->setPenToActive(); - } - if (ec->rtti()==RS2::EntityInsert) { - ((RS_Insert*)ec)->update(); - } - addList.append(ec); - } - } - } - - deselectOriginals(data.number==0); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - if (graphicView!=NULL) { - graphicView->redraw(); - } - - return true; -} - - - -/** - * Deselects all selected entities and removes them if remove is true; - * - * @param remove true: Remove entites. - */ -void RS_Modification::deselectOriginals(bool remove - ) { - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL) { - bool selected = false; - - /* - if (e->isAtomic()) { - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - if (ae->isStartpointSelected() || - ae->isEndpointSelected()) { - - selected = true; - } - } - */ - - if (e->isSelected()) { - selected = true; - } - - if (selected) { - e->setSelected(false); - if (remove - ) { - //if (graphicView!=NULL) { - // graphicView->deleteEntity(e); - //} - e->changeUndoState(); - if (document!=NULL && handleUndo) { - document->addUndoable(e); - } - } else { - //if (graphicView!=NULL) { - // graphicView->drawEntity(e); - //} - } - } - } - } -} - - - -/** - * Adds the given entities to the container and draws the entities if - * there's a graphic view available. - * - * @param addList Entities to add. - */ -void RS_Modification::addNewEntities(RS_PtrList& addList) { - for (RS_Entity* e=addList.first(); - e!=NULL; - e=addList.next()) { - if (e!=NULL) { - container->addEntity(e); - if (document!=NULL && handleUndo) { - document->addUndoable(e); - } - //if (graphicView!=NULL) { - // graphicView->drawEntity(e); - //} - } - } -} - - - -/** - * Trims or extends the given trimEntity to the intersection point of the - * trimEntity and the limitEntity. - * - * @param trimCoord Coordinate which defines which endpoint of the - * trim entity to trim. - * @param trimEntity Entity which will be trimmed. - * @param limitCoord Coordinate which defines the intersection to which the - * trim entity will be trimmed. - * @param limitEntity Entity to which the trim entity will be trimmed. - * @param both true: Trim both entities. false: trim trimEntity only. - */ -bool RS_Modification::trim(const Vector& trimCoord, - RS_AtomicEntity* trimEntity, - const Vector& limitCoord, - RS_Entity* limitEntity, - bool both) { - - if (trimEntity==NULL || limitEntity==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::trim: At least one entity is NULL"); - return false; - } - - if (both && !limitEntity->isAtomic()) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::trim: limitEntity is not atomic"); - } - - VectorSolutions sol; - if (limitEntity->isAtomic()) { - // intersection(s) of the two entities: - sol = RS_Information::getIntersection(trimEntity, limitEntity, false); - } else if (limitEntity->isContainer()) { - RS_EntityContainer* ec = (RS_EntityContainer*)limitEntity; - - sol.alloc(128); - int i=0; - - for (RS_Entity* e=ec->firstEntity(RS2::ResolveAll); e!=NULL; - e=ec->nextEntity(RS2::ResolveAll)) { - //for (int i=0; icount(); ++i) { - // RS_Entity* e = container->entityAt(i); - - if (e!=NULL) { - - VectorSolutions s2 = RS_Information::getIntersection(trimEntity, - e, false); - - if (s2.hasValid()) { - for (int k=0; kisPointOnEntity(s2.get(k), 1.0e-4)) { - sol.set(i++, s2.get(k)); - } - } - } - //break; - } - } - } - } - - if (sol.hasValid()==false) { - return false; - } - - RS_AtomicEntity* trimmed1 = NULL; - RS_AtomicEntity* trimmed2 = NULL; - - // remove trim entity from view: - if (trimEntity->rtti()==RS2::EntityCircle) { - // convert a circle into a trimmable arc - RS_Circle* c = (RS_Circle*)trimEntity; - double am = c->getCenter().angleTo(trimCoord); - RS_ArcData d(c->getCenter(), - c->getRadius(), - RS_Math::correctAngle(am-M_PI/2), - RS_Math::correctAngle(am+M_PI/2), false); - trimmed1 = new RS_Arc(trimEntity->getParent(), d); - } else { - trimmed1 = (RS_AtomicEntity*)trimEntity->clone(); - trimmed1->setHighlighted(false); - } - if (graphicView!=NULL) { - graphicView->deleteEntity(trimEntity); - } - - // remove limit entity from view: - if (both) { - trimmed2 = (RS_AtomicEntity*)limitEntity->clone(); - trimmed2->setHighlighted(false); - if (graphicView!=NULL) { - graphicView->deleteEntity(limitEntity); - } - } - - // trim trim entity - int ind = 0; - Vector is = sol.getClosest(limitCoord, NULL, &ind); - //sol.getClosest(limitCoord, NULL, &ind); - RS_DEBUG->print("RS_Modification::trim: limitCoord: %f/%f", limitCoord.x, limitCoord.y); - RS_DEBUG->print("RS_Modification::trim: sol.get(0): %f/%f", sol.get(0).x, sol.get(0).y); - RS_DEBUG->print("RS_Modification::trim: sol.get(1): %f/%f", sol.get(1).x, sol.get(1).y); - RS_DEBUG->print("RS_Modification::trim: ind: %d", ind); - Vector is2 = sol.get(ind==0 ? 1 : 0); - //Vector is2 = sol.get(ind); - RS_DEBUG->print("RS_Modification::trim: is2: %f/%f", is2.x, is2.y); - - //RS2::Ending ending = trimmed1->getTrimPoint(trimCoord, is); - RS2::Ending ending = trimmed1->getTrimPoint(trimCoord, is); - - switch (ending) { - case RS2::EndingStart: - trimmed1->trimStartpoint(is); - if (trimEntity->rtti()==RS2::EntityCircle) { - trimmed1->trimEndpoint(is2); - } - break; - case RS2::EndingEnd: - trimmed1->trimEndpoint(is); - if (trimEntity->rtti()==RS2::EntityCircle) { - trimmed1->trimStartpoint(is2); - } - break; - default: - break; - } - - // trim limit entity: - if (both) { - Vector is = sol.getClosest(limitCoord); - - RS2::Ending ending = trimmed2->getTrimPoint(limitCoord, is); - - switch (ending) { - case RS2::EndingStart: - trimmed2->trimStartpoint(is); - break; - case RS2::EndingEnd: - trimmed2->trimEndpoint(is); - break; - default: - break; - } - } - - // add new trimmed trim entity: - container->addEntity(trimmed1); - if (graphicView!=NULL) { - graphicView->drawEntity(trimmed1); - } - - // add new trimmed limit entity: - if (both) { - container->addEntity(trimmed2); - if (graphicView!=NULL) { - graphicView->drawEntity(trimmed2); - } - } - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - document->addUndoable(trimmed1); - trimEntity->setUndoState(true); - document->addUndoable(trimEntity); - if (both) { - document->addUndoable(trimmed2); - limitEntity->setUndoState(true); - document->addUndoable(limitEntity); - } - document->endUndoCycle(); - } - - return true; -} - - - -/** - * Trims or extends the given trimEntity by the given amount. - * - * @param trimCoord Coordinate which defines which endpoint of the - * trim entity to trim. - * @param trimEntity Entity which will be trimmed. - * @param dist Amount to trim by. - */ -bool RS_Modification::trimAmount(const Vector& trimCoord, - RS_AtomicEntity* trimEntity, - double dist) { - - if (trimEntity==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::trimAmount: Entity is NULL"); - return false; - } - - RS_AtomicEntity* trimmed = NULL; - - // remove trim entity: - trimmed = (RS_AtomicEntity*)trimEntity->clone(); - if (graphicView!=NULL) { - graphicView->deleteEntity(trimEntity); - } - - // trim trim entity - Vector is = trimmed->getNearestDist(-dist, trimCoord); - if (trimCoord.distanceTo(trimmed->getStartpoint()) < - trimCoord.distanceTo(trimmed->getEndpoint())) { - trimmed->trimStartpoint(is); - } else { - trimmed->trimEndpoint(is); - } - - // add new trimmed trim entity: - container->addEntity(trimmed); - - if (graphicView!=NULL) { - graphicView->drawEntity(trimmed); - } - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - document->addUndoable(trimmed); - trimEntity->setUndoState(true); - document->addUndoable(trimEntity); - document->endUndoCycle(); - } - - return true; -} - - - -/** - * Cuts the given entity at the given point. - */ -bool RS_Modification::cut(const Vector& cutCoord, - RS_AtomicEntity* cutEntity) { - - if (cutEntity==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::cut: Entity is NULL"); - return false; - } - - if (!cutCoord.valid) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::cut: Point invalid."); - return false; - } - - // cut point is at endpoint of entity: - if (cutCoord.distanceTo(cutEntity->getStartpoint())<1.0e-6 || - cutCoord.distanceTo(cutEntity->getEndpoint())<1.0e-6) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::cut: Cutting point on endpoint"); - return false; - } - - // delete cut entity on the screen: - if (graphicView!=NULL) { - graphicView->deleteEntity(cutEntity); - } - - RS_AtomicEntity* cut1 = NULL; - RS_AtomicEntity* cut2 = NULL; - - // create new two halves: - if (cutEntity->rtti()==RS2::EntityCircle) { - RS_Circle* c = (RS_Circle*)cutEntity; - cut1 = new RS_Arc(cutEntity->getParent(), - RS_ArcData(c->getCenter(), - c->getRadius(), - 0.0,0.0, false)); - cut1->setPen(cutEntity->getPen()); - cut1->setLayer(cutEntity->getLayer()); - cut2 = NULL; - - cut1->trimEndpoint(cutCoord); - cut1->trimStartpoint(cutCoord); - } else { - cut1 = (RS_AtomicEntity*)cutEntity->clone(); - cut2 = (RS_AtomicEntity*)cutEntity->clone(); - - cut1->trimEndpoint(cutCoord); - cut2->trimStartpoint(cutCoord); - } - - // add new cut entity: - container->addEntity(cut1); - if (cut2!=NULL) { - container->addEntity(cut2); - } - - if (graphicView!=NULL) { - graphicView->drawEntity(cut1); - if (cut2!=NULL) { - graphicView->drawEntity(cut2); - } - } - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - document->addUndoable(cut1); - if (cut2!=NULL) { - document->addUndoable(cut2); - } - cutEntity->setUndoState(true); - document->addUndoable(cutEntity); - document->endUndoCycle(); - } - - return true; -} - - - -/** - * Stretching. - */ -bool RS_Modification::stretch(const Vector& firstCorner, - const Vector& secondCorner, - const Vector& offset) { - - if (!offset.valid) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::stretch: Offset invalid"); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (int i=0; icount(); ++i) { - // RS_Entity* e = container->entityAt(i); - - if (e!=NULL && - e->isVisible() && - !e->isLocked() && - (e->isInWindow(firstCorner, secondCorner) || - e->hasEndpointsWithinWindow(firstCorner, secondCorner))) { - - RS_Entity* ec = e->clone(); - ec->stretch(firstCorner, secondCorner, offset); - addList.append(ec); - e->setSelected(true); - } - } - - deselectOriginals(true); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - return true; -} - - - -/** - * Bevels a corner. - * - * @param coord1 Mouse coordinate to specify direction from intersection. - * @param entity1 First entity of the corner. - * @param coord2 Mouse coordinate to specify direction from intersection. - * @param entity2 Second entity of the corner. - * @param data Lengths and trim flag. - */ -bool RS_Modification::bevel(const Vector& coord1, RS_AtomicEntity* entity1, - const Vector& coord2, RS_AtomicEntity* entity2, - RS_BevelData& data) { - - RS_DEBUG->print("RS_Modification::bevel"); - - if (entity1==NULL || entity2==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::bevel: At least one entity is NULL"); - return false; - } - - RS_EntityContainer* baseContainer = container; - bool isPolyline = false; - bool isClosedPolyline = false; - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // find out whether we're bevelling within a polyline: - if (entity1->getParent()!=NULL && entity1->getParent()->rtti()==RS2::EntityPolyline) { - RS_DEBUG->print("RS_Modification::bevel: trimming polyline segments"); - if (entity1->getParent()!=entity2->getParent()) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::bevel: entities not in the same polyline"); - return false; - } - // clone polyline for undo - if (document!=NULL && handleUndo) { - RS_EntityContainer* cl = - (RS_EntityContainer*)entity1->getParent()->clone(); - container->addEntity(cl); - //cl->setUndoState(true); - document->addUndoable(cl); - - document->addUndoable(entity1->getParent()); - entity1->getParent()->setUndoState(true); - - baseContainer = cl; - } - - entity1 = (RS_AtomicEntity*)baseContainer->entityAt(entity1->getParent()->findEntity(entity1)); - entity2 = (RS_AtomicEntity*)baseContainer->entityAt(entity2->getParent()->findEntity(entity2)); - - //baseContainer = entity1->getParent(); - isPolyline = true; - isClosedPolyline = ((RS_Polyline*)entity1)->isClosed(); - } - - RS_DEBUG->print("RS_Modification::bevel: getting intersection"); - - VectorSolutions sol = - RS_Information::getIntersection(entity1, entity2, false); - - if (sol.getNumber()==0) { - return false; - } - - RS_AtomicEntity* trimmed1 = NULL; - RS_AtomicEntity* trimmed2 = NULL; - - //if (data.trim || isPolyline) { - if (isPolyline) { - trimmed1 = entity1; - trimmed2 = entity2; - } else { - trimmed1 = (RS_AtomicEntity*)entity1->clone(); - trimmed2 = (RS_AtomicEntity*)entity2->clone(); - } - - // remove trim entity (on screen): - if (data.trim==true || isPolyline) { - if (graphicView!=NULL) { - if (isPolyline) { - graphicView->deleteEntity(baseContainer); - } else { - graphicView->deleteEntity(entity1); - graphicView->deleteEntity(entity2); - } - } - } - - // trim entities to intersection - RS_DEBUG->print("RS_Modification::bevel: trim entities to intersection 01"); - bool start1 = false; - Vector is = sol.getClosest(coord2); - RS2::Ending ending1 = trimmed1->getTrimPoint(coord1, is); - switch (ending1) { - case RS2::EndingStart: - trimmed1->trimStartpoint(is); - start1 = true; - break; - case RS2::EndingEnd: - trimmed1->trimEndpoint(is); - start1 = false; - break; - default: - break; - } - - RS_DEBUG->print("RS_Modification::bevel: trim entities to intersection 02"); - bool start2 = false; - is = sol.getClosest(coord1); - RS2::Ending ending2 = trimmed2->getTrimPoint(coord2, is); - switch (ending2) { - case RS2::EndingStart: - trimmed2->trimStartpoint(is); - start2 = true; - break; - case RS2::EndingEnd: - trimmed2->trimEndpoint(is); - start2 = false; - break; - default: - break; - } - //} - - - // find definitive bevel points - RS_DEBUG->print("RS_Modification::bevel: find definitive bevel points"); - Vector bp1 = trimmed1->getNearestDist(data.length1, start1); - Vector bp2 = trimmed2->getNearestDist(data.length2, start2); - - // final trim: - RS_DEBUG->print("RS_Modification::bevel: final trim"); - if (data.trim==true) { - switch (ending1) { - case RS2::EndingStart: - trimmed1->trimStartpoint(bp1); - break; - case RS2::EndingEnd: - trimmed1->trimEndpoint(bp1); - break; - default: - break; - } - - switch (ending2) { - case RS2::EndingStart: - trimmed2->trimStartpoint(bp2); - break; - case RS2::EndingEnd: - trimmed2->trimEndpoint(bp2); - break; - default: - break; - } - - // add new trimmed entities: - if (isPolyline==false) { - container->addEntity(trimmed1); - container->addEntity(trimmed2); - } - if (graphicView!=NULL) { - if (!isPolyline) { - graphicView->drawEntity(trimmed1); - graphicView->drawEntity(trimmed2); - } - } - } - - - // add bevel line: - RS_DEBUG->print("RS_Modification::bevel: add bevel line"); - RS_Line* bevel = new RS_Line(baseContainer, RS_LineData(bp1, bp2)); - - if (isPolyline==false) { - baseContainer->addEntity(bevel); - } else { - int idx1 = baseContainer->findEntity(trimmed1); - int idx2 = baseContainer->findEntity(trimmed2); - - bevel->setSelected(baseContainer->isSelected()); - bevel->setLayer(baseContainer->getLayer()); - bevel->setPen(baseContainer->getPen()); - - bool insertAfter1 = false; - if (!isClosedPolyline) { - insertAfter1 = (idx1count()-1)); - } - - // insert bevel at the right position: - //if ((idx1count()-1)) { - if (insertAfter1) { - if (trimmed1->getEndpoint().distanceTo(bevel->getStartpoint())>1.0e-4) { - bevel->reverse(); - } - baseContainer->insertEntity(idx1+1, bevel); - } else { - if (trimmed2->getEndpoint().distanceTo(bevel->getStartpoint())>1.0e-4) { - bevel->reverse(); - } - baseContainer->insertEntity(idx2+1, bevel); - } - } - - if (isPolyline) { - ((RS_Polyline*)baseContainer)->updateEndpoints(); - } - - if (graphicView!=NULL) { - if (isPolyline) { - graphicView->drawEntity(baseContainer); - } else { - graphicView->drawEntity(bevel); - } - } - - RS_DEBUG->print("RS_Modification::bevel: handling undo"); - - if (document!=NULL && handleUndo) { - //document->startUndoCycle(); - - if (isPolyline==false && data.trim==true) { - document->addUndoable(trimmed1); - entity1->setUndoState(true); - document->addUndoable(entity1); - - document->addUndoable(trimmed2); - entity2->setUndoState(true); - document->addUndoable(entity2); - } - - if (isPolyline==false) { - document->addUndoable(bevel); - } - - document->endUndoCycle(); - } - - if (data.trim==false) { - RS_DEBUG->print("RS_Modification::bevel: delete trimmed elements"); - delete trimmed1; - delete trimmed2; - RS_DEBUG->print("RS_Modification::bevel: delete trimmed elements: ok"); - } - - return true; - -} - - - -/** - * Rounds a corner. - * - * @param coord Mouse coordinate to specify the rounding. - * @param entity1 First entity of the corner. - * @param entity2 Second entity of the corner. - * @param data Radius and trim flag. - */ -bool RS_Modification::round(const Vector& coord, - const Vector& coord1, - RS_AtomicEntity* entity1, - const Vector& coord2, - RS_AtomicEntity* entity2, - RS_RoundData& data) { - - if (entity1==NULL || entity2==NULL) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::round: At least one entity is NULL"); - return false; - } - - RS_EntityContainer* baseContainer = container; - bool isPolyline = false; - bool isClosedPolyline = false; - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // find out whether we're rounding within a polyline: - if (entity1->getParent()!=NULL && - entity1->getParent()->rtti()==RS2::EntityPolyline) { - - if (entity1->getParent()!=entity2->getParent()) { - RS_DEBUG->print(RS_Debug::D_WARNING, - "RS_Modification::round: entities not in " - "the same polyline"); - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - return false; - } - - // clone polyline for undo - if (document!=NULL && handleUndo) { - RS_EntityContainer* cl = - (RS_EntityContainer*)entity1->getParent()->clone(); - container->addEntity(cl); - document->addUndoable(cl); - - document->addUndoable(entity1->getParent()); - entity1->getParent()->setUndoState(true); - - baseContainer = cl; - } - - entity1 = (RS_AtomicEntity*)baseContainer->entityAt(entity1->getParent()->findEntity(entity1)); - entity2 = (RS_AtomicEntity*)baseContainer->entityAt(entity2->getParent()->findEntity(entity2)); - - isPolyline = true; - isClosedPolyline = ((RS_Polyline*)entity1)->isClosed(); - } - - // create 2 tmp parallels - RS_Creation creation(NULL, NULL); - RS_Entity* par1 = creation.createParallel(coord, data.radius, 1, entity1); - RS_Entity* par2 = creation.createParallel(coord, data.radius, 1, entity2); - - VectorSolutions sol2 = - RS_Information::getIntersection(entity1, entity2, false); - - VectorSolutions sol = - RS_Information::getIntersection(par1, par2, false); - - if (sol.getNumber()==0) { - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - return false; - } - - // there might be two intersections: choose the closest: - Vector is = sol.getClosest(coord); - Vector p1 = entity1->getNearestPointOnEntity(is, false); - Vector p2 = entity2->getNearestPointOnEntity(is, false); - double ang1 = is.angleTo(p1); - double ang2 = is.angleTo(p2); - bool reversed = (RS_Math::getAngleDifference(ang1, ang2)>M_PI); - - RS_Arc* arc = new RS_Arc(baseContainer, - RS_ArcData(is, - data.radius, - ang1, ang2, - reversed)); - - - RS_AtomicEntity* trimmed1 = NULL; - RS_AtomicEntity* trimmed2 = NULL; - - if (data.trim || isPolyline) { - if (isPolyline) { - trimmed1 = entity1; - trimmed2 = entity2; - } else { - trimmed1 = (RS_AtomicEntity*)entity1->clone(); - trimmed2 = (RS_AtomicEntity*)entity2->clone(); - } - - // remove trim entity: - if (graphicView!=NULL) { - if (isPolyline) { - graphicView->deleteEntity(baseContainer); - } else { - graphicView->deleteEntity(entity1); - graphicView->deleteEntity(entity2); - } - } - - // trim entities to intersection - Vector is2 = sol2.getClosest(coord2); - RS2::Ending ending1 = trimmed1->getTrimPoint(coord1, is2); - switch (ending1) { - case RS2::EndingStart: - trimmed1->trimStartpoint(p1); - break; - case RS2::EndingEnd: - trimmed1->trimEndpoint(p1); - break; - default: - break; - } - - is2 = sol2.getClosest(coord1); - RS2::Ending ending2 = trimmed2->getTrimPoint(coord2, is2); - switch (ending2) { - case RS2::EndingStart: - trimmed2->trimStartpoint(p2); - break; - case RS2::EndingEnd: - trimmed2->trimEndpoint(p2); - break; - default: - break; - } - - // add new trimmed entities: - if (isPolyline==false) { - container->addEntity(trimmed1); - container->addEntity(trimmed2); - } - if (graphicView!=NULL) { - if (!isPolyline) { - graphicView->drawEntity(trimmed1); - graphicView->drawEntity(trimmed2); - } - } - } - - // add rounding: - if (isPolyline==false) { - baseContainer->addEntity(arc); - } else { - // find out which base entity is before the rounding: - int idx1 = baseContainer->findEntity(trimmed1); - int idx2 = baseContainer->findEntity(trimmed2); - - arc->setSelected(baseContainer->isSelected()); - arc->setLayer(baseContainer->getLayer()); - arc->setPen(baseContainer->getPen()); - - RS_DEBUG->print("RS_Modification::round: idx1print("RS_Modification::round: idx1!=0: %d", (int)(idx1!=0)); - RS_DEBUG->print("RS_Modification::round: idx2==0: %d", (int)(idx2==0)); - RS_DEBUG->print("RS_Modification::round: idx1==(int)baseContainer->count()-1: %d", - (int)(idx1==(int)baseContainer->count()-1)); - - bool insertAfter1 = false; - if (!isClosedPolyline) { - insertAfter1 = (idx1count()-1)); - } - - // insert rounding at the right position: - //if ((idx1count()-1)) { - //if (idx1getEndpoint().distanceTo(arc->getStartpoint())>1.0e-4) { - arc->reverse(); - } - baseContainer->insertEntity(idx1+1, arc); - } else { - if (trimmed2->getEndpoint().distanceTo(arc->getStartpoint())>1.0e-4) { - arc->reverse(); - } - baseContainer->insertEntity(idx2+1, arc); - } - } - - if (isPolyline) { - ((RS_Polyline*)baseContainer)->updateEndpoints(); - } - - if (graphicView!=NULL) { - if (isPolyline) { - graphicView->drawEntity(baseContainer); - } else { - graphicView->drawEntity(arc); - } - } - - if (document!=NULL && handleUndo) { - if (isPolyline==false && data.trim==true) { - document->addUndoable(trimmed1); - entity1->setUndoState(true); - document->addUndoable(entity1); - - document->addUndoable(trimmed2); - entity2->setUndoState(true); - document->addUndoable(entity2); - } - - if (isPolyline==false) { - document->addUndoable(arc); - } - - document->endUndoCycle(); - } - - delete par1; - delete par2; - - return true; -} - - - -/** - * Removes the selected entity containers and adds the entities in them as - * new single entities. - */ -bool RS_Modification::explode() { - - if (container==NULL) { - RS_DEBUG->print("RS_Modification::explode: no valid container" - " for addinge entities", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isSelected()) { - if (e->isContainer()) { - - // add entities from container: - RS_EntityContainer* ec = (RS_EntityContainer*)e; - //ec->setSelected(false); - - // iterate and explode container: - //for (uint i2=0; i2count(); ++i2) { - // RS_Entity* e2 = ec->entityAt(i2); - RS2::ResolveLevel rl; - bool resolvePen; - bool resolveLayer; - - switch (ec->rtti()) { - case RS2::EntityText: - case RS2::EntityHatch: - case RS2::EntityPolyline: - rl = RS2::ResolveAll; - resolveLayer = true; - resolvePen = false; - break; - - case RS2::EntityInsert: - resolvePen = false; - resolveLayer = false; - rl = RS2::ResolveNone; - break; - - case RS2::EntityDimAligned: - case RS2::EntityDimLinear: - case RS2::EntityDimRadial: - case RS2::EntityDimDiametric: - case RS2::EntityDimAngular: - case RS2::EntityDimLeader: - rl = RS2::ResolveNone; - resolveLayer = true; - resolvePen = false; - break; - - default: - rl = RS2::ResolveAll; - resolveLayer = true; - resolvePen = false; - break; - } - - for (RS_Entity* e2 = ec->firstEntity(rl); e2!=NULL; - e2 = ec->nextEntity(rl)) { - - if (e2!=NULL) { - RS_Entity* clone = e2->clone(); - clone->setSelected(false); - clone->reparent(container); - - if (resolveLayer) { - clone->setLayer(ec->getLayer()); - } else { - clone->setLayer(e2->getLayer()); - } - - clone->setPen(ec->getPen(resolvePen)); - - addList.append(clone); - - clone->update(); - } - } - } else { - e->setSelected(false); - } - } - } - - deselectOriginals(true); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - - return true; -} - - - -bool RS_Modification::explodeTextIntoLetters() { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::explodeTextIntoLetters: no valid container" - " for addinge entities", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - if (e!=NULL && e->isSelected()) { - if (e->rtti()==RS2::EntityText) { - // add letters of text: - RS_Text* text = (RS_Text*)e; - explodeTextIntoLetters(text, addList); - } else { - e->setSelected(false); - } - } - } - - deselectOriginals(true); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - - return true; -} - - - -bool RS_Modification::explodeTextIntoLetters(RS_Text* text, RS_PtrList& addList) { - - if (text==NULL) { - return false; - } - - // iterate though lines: - for (RS_Entity* e2 = text->firstEntity(); e2!=NULL; - e2 = text->nextEntity()) { - - if (e2==NULL) { - break; - } - - - // text lines: - if (e2->rtti()==RS2::EntityContainer) { - - RS_EntityContainer* line = (RS_EntityContainer*)e2; - - // iterate though letters: - for (RS_Entity* e3 = line->firstEntity(); e3!=NULL; - e3 = line->nextEntity()) { - - if (e3==NULL) { - break; - } - - // super / sub texts: - if (e3->rtti()==RS2::EntityText) { - explodeTextIntoLetters((RS_Text*)e3, addList); - } - - // normal letters: - else if (e3->rtti()==RS2::EntityInsert) { - - RS_Insert* letter = (RS_Insert*)e3; - - RS_Text* tl = new RS_Text( - container, - RS_TextData(letter->getInsertionPoint(), - text->getHeight(), - 100.0, - RS2::VAlignBottom, RS2::HAlignLeft, - RS2::LeftToRight, RS2::Exact, - 1.0, - letter->getName(), - text->getStyle(), - letter->getAngle(), - RS2::Update)); - - tl->setLayer(text->getLayer()); - tl->setPen(text->getPen()); - - addList.append(tl); - tl->update(); - } - } - } - } - - return true; -} - - - -/** - * Moves all reference points of selected entities with the given data. - */ -bool RS_Modification::moveRef(RS_MoveRefData& data) { - if (container==NULL) { - RS_DEBUG->print("RS_Modification::moveRef: no valid container", - RS_Debug::D_WARNING); - return false; - } - - RS_PtrList addList; - addList.setAutoDelete(false); - - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } - - // Create new entites - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - if (e!=NULL && e->isSelected()) { - RS_Entity* ec = e->clone(); - - ec->moveRef(data.ref, data.offset); - // since 2.0.4.0: keep it selected - ec->setSelected(true); - addList.append(ec); - } - } - - deselectOriginals(true); - addNewEntities(addList); - - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } - - if (graphicView!=NULL) { - graphicView->redraw(); - } - return true; -} - -// EOF diff --git a/src/base/rs_modification.h.bak b/src/base/rs_modification.h.bak deleted file mode 100644 index ca986bd..0000000 --- a/src/base/rs_modification.h.bak +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** $Id: rs_modification.h 1946 2004-12-24 19:27:43Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_MODIFICATION_H -#define RS_MODIFICATION_H - -#include "rs_entitycontainer.h" -#include "rs_graphicview.h" -#include "rs_line.h" - - - -/** - * Holds the data needed for move modifications. - */ -class RS_MoveData { -public: - int number; - bool useCurrentAttributes; - bool useCurrentLayer; - Vector offset; -}; - - - -/** - * Holds the data needed for rotation modifications. - */ -class RS_RotateData { -public: - int number; - bool useCurrentAttributes; - bool useCurrentLayer; - Vector center; - double angle; -}; - - - -/** - * Holds the data needed for scale modifications. - */ -class RS_ScaleData { -public: - int number; - bool useCurrentAttributes; - bool useCurrentLayer; - Vector referencePoint; - double factor; -}; - - -/** - * Holds the data needed for mirror modifications. - */ -class RS_MirrorData { -public: - bool copy; - bool useCurrentAttributes; - bool useCurrentLayer; - Vector axisPoint1; - Vector axisPoint2; -}; - - -/** - * Holds the data needed for move/rotate modifications. - */ -class RS_MoveRotateData { -public: - int number; - bool useCurrentAttributes; - bool useCurrentLayer; - Vector referencePoint; - Vector offset; - double angle; -}; - - - -/** - * Holds the data needed for rotation around two centers modifications. - */ -class RS_Rotate2Data { -public: - int number; - bool useCurrentAttributes; - bool useCurrentLayer; - Vector center1; - Vector center2; - double angle1; - double angle2; -}; - - - -/** - * Holds the data needed for beveling modifications. - */ -class RS_BevelData { -public: - double length1; - double length2; - bool trim; -}; - - - - -/** - * Holds the data needed for rounding modifications. - */ -class RS_RoundData { -public: - double radius; - bool trim; -}; - - -/** - * Holds the data needed for moving reference points. - */ -class RS_MoveRefData { -public: - Vector ref; - Vector offset; -}; - - - -/** - * Holds the data needed for changing attributes. - */ -class RS_AttributesData { -public: - RS_String layer; - RS_Pen pen; - bool changeLayer; - bool changeColor; - bool changeLineType; - bool changeWidth; -}; - - -/** - * Holds the data needed for pasting. - */ -class RS_PasteData { -public: - RS_PasteData(Vector insertionPoint, - double factor, - double angle, - bool asInsert, - const RS_String& blockName) { - - this->insertionPoint = insertionPoint; - this->factor = factor; - this->angle = angle; - this->asInsert = asInsert; - this->blockName = blockName; - } - - //! Insertion point. - Vector insertionPoint; - //! Scale factor. - double factor; - //! Rotation angle. - double angle; - //! Paste as an insert rather than individual entities. - bool asInsert; - //! Name of the block to create or an empty string to assign a new auto name. - RS_String blockName; -}; - - -/** - * API Class for manipulating entities. - * There's no interaction handled in this class. - * - * All modifications can be undone / redone if the container - * is a RS_Graphic. - * - * This class is connected to an entity container and - * can be connected to a graphic view. - * - * @author Andrew Mustun - */ -class RS_Modification { -public: - RS_Modification(RS_EntityContainer& entityContainer, - RS_GraphicView* graphicView=NULL, - bool handleUndo=true); - - void remove(); - bool changeAttributes(RS_AttributesData& data); - - void copy(const Vector& ref, const bool cut); -private: - void copyEntity(RS_Entity* e, const Vector& ref, const bool cut); -public: - void copyLayers(RS_Entity* e); - void copyBlocks(RS_Entity* e); - void paste(const RS_PasteData& data, RS_Graphic* source=NULL); - - bool move(RS_MoveData& data); - bool rotate(RS_RotateData& data); - bool scale(RS_ScaleData& data); - bool mirror(RS_MirrorData& data); - bool moveRotate(RS_MoveRotateData& data); - bool rotate2(RS_Rotate2Data& data); - - bool trim(const Vector& trimCoord, RS_AtomicEntity* trimEntity, - const Vector& limitCoord, RS_Entity* limitEntity, - bool both); - bool trimAmount(const Vector& trimCoord, RS_AtomicEntity* trimEntity, - double dist); - - bool cut(const Vector& cutCoord, RS_AtomicEntity* cutEntity); - bool stretch(const Vector& firstCorner, - const Vector& secondCorner, - const Vector& offset); - - bool bevel(const Vector& coord1, RS_AtomicEntity* entity1, - const Vector& coord2, RS_AtomicEntity* entity2, - RS_BevelData& data); - bool round(const Vector& coord, - const Vector& coord1, - RS_AtomicEntity* entity1, - const Vector& coord2, - RS_AtomicEntity* entity2, - RS_RoundData& data); - - bool explode(); - bool explodeTextIntoLetters(); - bool explodeTextIntoLetters(RS_Text* text, RS_PtrList& addList); - bool moveRef(RS_MoveRefData& data); - - bool splitPolyline(RS_Polyline& polyline, - RS_Entity& e1, Vector v1, - RS_Entity& e2, Vector v2, - RS_Polyline** polyline1, - RS_Polyline** polyline2) const; - RS_Polyline* addPolylineNode(RS_Polyline& polyline, - const RS_AtomicEntity& segment, - const Vector& node); - RS_Polyline* deletePolylineNode(RS_Polyline& polyline, - const Vector& node); - RS_Polyline* deletePolylineNodesBetween(RS_Polyline& polyline, RS_AtomicEntity& segment, - const Vector& node1, const Vector& node2); - RS_Polyline* polylineTrim(RS_Polyline& polyline, - RS_AtomicEntity& segment1, - RS_AtomicEntity& segment2); - -private: - void deselectOriginals(bool remove); - void addNewEntities(RS_PtrList& addList); - -protected: - RS_EntityContainer* container; - RS_Graphic* graphic; - RS_Document* document; - RS_GraphicView* graphicView; - bool handleUndo; -}; - -#endif diff --git a/src/base/rs_mouseevent.h.old b/src/base/rs_mouseevent.h.old deleted file mode 100644 index 89d0ee0..0000000 --- a/src/base/rs_mouseevent.h.old +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** $Id: rs_mouseevent.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_MOUSEEVENT_H -#define RS_MOUSEEVENT_H - -//#include -#include - -#define RS_MouseEvent QMouseEvent - -/** - * Events which can be triggered for every action. - */ -//enum RS_MouseButton { LEFT, MIDDLE, RIGHT, NONE }; - -/** - * Mouse Events. - */ -/* -class RS_MouseEvent { -public: - RS_MouseEvent(int x, int y, RS_MouseButton button) { - this->x = x; - this->y = y; - this->button = button; - } - - int getX() { - return x; - } - int getY() { - return y; - } - RS_MouseButton getButton() { - return button; - } - -protected: - int x; - int y; - RS_MouseButton button; -}; -*/ - -#endif diff --git a/src/base/rs_painter.cpp.old b/src/base/rs_painter.cpp.old deleted file mode 100644 index f48ea0f..0000000 --- a/src/base/rs_painter.cpp.old +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** $Id: rs_painter.cpp 1938 2004-12-09 23:09:53Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_painter.h" - -RS_Painter::RS_Painter(): drawingMode(RS2::ModeFull), offset(Vector(0.0, 0.0)) -{ -// drawingMode = RS2::ModeFull; -// offset = Vector(0.0, 0.0); -} - -/** -* Sets the drawing mode. -*/ -void RS_Painter::setDrawingMode(RS2::DrawingMode m) -{ - drawingMode = m; -} - -/** -* @return Current drawing mode. -*/ -RS2::DrawingMode RS_Painter::getDrawingMode() -{ - return drawingMode; -} - -void RS_Painter::createArc(Q3PointArray & pa, const Vector& cp, double radius, - double a1, double a2, bool reversed) -{ - if (radius < 1.0e-6) - { - RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Painter::createArc: invalid radius: %f", radius); - return; - } - - int cix; // Next point on circle - int ciy; // - double aStep; // Angle Step (rad) - double a; // Current Angle (rad) - - if (fabs(2.0 / radius) <= 1.0) - aStep = asin(2.0 / radius); - else - aStep = 1.0; - - //if (aStep<0.05) { - // aStep = 0.05; - //} - - // less than a pixel long lines: - //if (radius*aStep<1.0) { - // aStep = - //} - - //QPointArray pa; - int i = 0; - pa.resize(i + 1); - pa.setPoint(i++, toScreenX(cp.x + cos(a1) * radius), toScreenY(cp.y - sin(a1) * radius)); - //moveTo(toScreenX(cp.x+cos(a1)*radius), - // toScreenY(cp.y-sin(a1)*radius)); - - if (!reversed) - { - // Arc Counterclockwise: - if (a1 > a2 - 1.0e-10) - a2 += 2 * M_PI; - - for(a=a1+aStep; a<=a2; a+=aStep) - { - cix = toScreenX(cp.x + cos(a) * radius); - ciy = toScreenY(cp.y - sin(a) * radius); - pa.resize(i + 1); - pa.setPoint(i++, cix, ciy); - } - } - else - { - // Arc Clockwise: - if (a1 < a2 + 1.0e-10) - a2 -= 2 * M_PI; - - for(a=a1-aStep; a>=a2; a-=aStep) - { - cix = toScreenX(cp.x + cos(a) * radius); - ciy = toScreenY(cp.y - sin(a) * radius); - //lineTo(cix, ciy); - pa.resize(i + 1); - pa.setPoint(i++, cix, ciy); - } - } - - pa.resize(i + 1); - pa.setPoint(i++, toScreenX(cp.x + cos(a2) * radius), toScreenY(cp.y - sin(a2) * radius)); - //drawPolyline(pa); -} - -void RS_Painter::drawRect(const Vector & p1, const Vector & p2) -{ - drawLine(Vector(p1.x, p1.y), Vector(p2.x, p1.y)); - drawLine(Vector(p2.x, p1.y), Vector(p2.x, p2.y)); - drawLine(Vector(p2.x, p2.y), Vector(p1.x, p2.y)); - drawLine(Vector(p1.x, p2.y), Vector(p1.x, p1.y)); -} - -void RS_Painter::drawHandle(const Vector & p, const RS_Color & c, int size) -{ - if (size < 0) - size = 2; - - fillRect((int)(p.x - size), (int)(p.y - size), 2 * size, 2 * size, c); -} - -void RS_Painter::setPreviewMode() -{ - drawingMode = RS2::ModeXOR; - setXORMode(); - setPreviewPen(); -} - -bool RS_Painter::isPreviewMode() -{ - return (drawingMode == RS2::ModeXOR); -} - -void RS_Painter::setOffset(const Vector & o) -{ - offset = o; -} - -int RS_Painter::toScreenX(double x) -{ - return RS_Math::round(offset.x + x); -} - -int RS_Painter::toScreenY(double y) -{ - return RS_Math::round(offset.y + y); -} diff --git a/src/base/rs_painter.h.old b/src/base/rs_painter.h.old deleted file mode 100644 index 3826b06..0000000 --- a/src/base/rs_painter.h.old +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** $Id: rs_painter.h 1932 2004-11-30 02:11:33Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_PAINTER_H -#define RS_PAINTER_H - -#include -#include "rs_color.h" -#include "rs_math.h" -#include "rs_pen.h" -#include "vector.h" -//Added by qt3to4: -#include - -/** - * This class is a common interface for a painter class. Such - * a class will in it's implementation be responsible to paint - * lines, arcs, ... in widgets. All angles in rad. - * - * Note that this is just an interface used as a slot to - * communicate with the qcadlib from a GUI level. This - * does not contain any Qt or platform specific code. - * (Oh yeah? Then WTF is that Q3PointArray doing in here???) - */ -class RS_Painter -{ - public: - RS_Painter(); - virtual ~RS_Painter() {} - - void setDrawingMode(RS2::DrawingMode m); - RS2::DrawingMode getDrawingMode(); - -// virtual void moveTo(int x, int y) = 0; -// virtual void lineTo(int x, int y) = 0; - - virtual void drawGridPoint(const Vector & p) = 0; - virtual void drawPoint(const Vector & p) = 0; - virtual void drawLine(const Vector & p1, const Vector & p2) = 0; - virtual void drawRect(const Vector & p1, const Vector & p2); - virtual void drawArc(const Vector & cp, double radius, double a1, double a2, - const Vector & p1, const Vector & p2, bool reversed) = 0; - virtual void drawArc(const Vector & cp, double radius, - double a1, double a2, bool reversed) = 0; - void createArc(Q3PointArray & pa, const Vector & cp, double radius, - double a1, double a2, bool reversed); - virtual void drawCircle(const Vector & cp, double radius) = 0; - virtual void drawEllipse(const Vector & cp, double radius1, double radius2, - double angle, double angle1, double angle2, bool reversed) = 0; - virtual void drawImg(QImage & img, const Vector & pos, - double angle, const Vector & factor, int sx, int sy, int sw, int sh) = 0; - -// virtual void drawTextH(int x1, int y1, int x2, int y2, const QString & text) = 0; -// virtual void drawTextV(int x1, int y1, int x2, int y2, const QString & text) = 0; - - virtual void fillRect(int x1, int y1, int w, int h, const RS_Color & col) = 0; - - virtual void fillTriangle(const Vector & p1, const Vector & p2, const Vector & p3) = 0; - - virtual void drawHandle(const Vector & p, const RS_Color & c, int size=-1); - - virtual void setPreviewPen() = 0; - virtual RS_Pen getPen() = 0; - virtual void setPen(const RS_Pen & pen) = 0; - virtual void setPen(const RS_Color & color) = 0; - virtual void setPen(int r, int g, int b) = 0; - virtual void disablePen() = 0; - virtual void setBrush(const RS_Color & color) = 0; - virtual void drawPolygon(const Q3PointArray & a) = 0; - virtual void erase() = 0; - virtual int getWidth() = 0; - virtual int getHeight() = 0; - - virtual void setXORMode() = 0; - virtual void setNormalMode() = 0; - - virtual void setPreviewMode(); - virtual bool isPreviewMode(); - - virtual void setOffset(const Vector & o); - - virtual void setClipRect(int x, int y, int w, int h) = 0; - virtual void resetClipping() = 0; - int toScreenX(double x); - int toScreenY(double y); - - protected: - /** - * Current drawing mode. - */ - RS2::DrawingMode drawingMode; - /** - * A fixed offset added to all entities drawn (useful for previews). - */ - Vector offset; -}; - -#endif diff --git a/src/base/rs_painteradapter.h.old b/src/base/rs_painteradapter.h.old deleted file mode 100644 index c997fe9..0000000 --- a/src/base/rs_painteradapter.h.old +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** $Id: rs_painteradapter.h 1866 2004-04-04 22:48:00Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_PAINTERADAPTER_H -#define RS_PAINTERADAPTER_H - -#include "rs_painter.h" -//Added by qt3to4: -#include - -/** - * An abstract adapter class for painter object. The methods in this class are empty. - * This class exists as convenience for creating painter objects. - */ -class RS_PainterAdapter: public RS_Painter -{ - public: - RS_PainterAdapter() : RS_Painter() {} - virtual ~RS_PainterAdapter() {} - -// virtual void moveTo(int, int) {} -// virtual void lineTo(int, int) {} - - virtual void drawGridPoint(const Vector&) {} - virtual void drawPoint(const Vector&) {} - virtual void drawLine(const Vector&, const Vector&) {} - virtual void drawRect(const Vector&, const Vector&) {} - virtual void drawArc(const Vector&, double, double, double, - const Vector&, const Vector&, bool ) {} - virtual void drawArc(const Vector&, double, - double, double, bool ) {} - void createArc(Q3PointArray& , const Vector&, double, double, double, bool) {} - virtual void drawCircle(const Vector&, double) {} - virtual void drawEllipse(const Vector&, - double, double, double, double, double, bool) {} - virtual void drawImg(QImage& , const Vector&, - double, const Vector&, int, int, int, int) {} - -// virtual void drawTextH(int, int, int, int, const QString&) {} -// virtual void drawTextV(int, int, int, int, const QString&) {} - - virtual void fillRect(int, int, int, int, const RS_Color&) {} - - virtual void fillTriangle(const Vector&, const Vector&, const Vector&) {} - - virtual void setPreviewPen() {} - virtual RS_Pen getPen() { return RS_Pen(); } - virtual void setPen(const RS_Pen&) {} - virtual void setPen(const RS_Color&) {} - virtual void setPen(int, int, int) {} - virtual void disablePen() {} - virtual void setBrush(const RS_Color&) {} - virtual void drawPolygon(const Q3PointArray& ) {} - virtual void erase() {} - virtual int getWidth() { return 0; } - virtual int getHeight() { return 0; } - - virtual void setXORMode() {} - virtual void setNormalMode() {} - - virtual void setClipRect(int, int, int, int) {} - virtual void resetClipping() {} -}; - -#endif diff --git a/src/base/rs_painterqt.cpp.old b/src/base/rs_painterqt.cpp.old deleted file mode 100644 index 5757ba5..0000000 --- a/src/base/rs_painterqt.cpp.old +++ /dev/null @@ -1,612 +0,0 @@ -/**************************************************************************** -** $Id: rs_painterqt.cpp 2244 2005-03-14 23:00:19Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_painterqt.h" - -#include -//#include -#include "rs_math.h" -#include "rs_application.h" -#include "rs_color.h" - -/** - * Constructor. - */ -//WAS: RS_PainterQt::RS_PainterQt(const QPaintDevice * pd) -RS_PainterQt::RS_PainterQt(QPaintDevice * pd): QPainter(pd), RS_Painter() -{ -} - -/** - * Destructor - */ -RS_PainterQt::~RS_PainterQt() -{ -} - -#if 0 -// These two look like bogus crap to me... -void RS_PainterQt::moveTo(int x, int y) -{ -// QPainter::moveTo(x, y); - cursorX = x, cursorY = y; -} - -void RS_PainterQt::lineTo(int x, int y) -{ -// QPainter::lineTo(x, y); - QPainter::drawLine(cursorX, cursorY, x, y); - cursorX = x, cursorY = y; -} -#endif - -/** - * Draws a grid point at (x1, y1). - */ -void RS_PainterQt::drawGridPoint(const Vector & p) -{ - QPainter::drawPoint(toScreenX(p.x), toScreenY(p.y)); -} - -/** - * Draws a point at (x1, y1). - */ -void RS_PainterQt::drawPoint(const Vector & p) -{ - QPainter::drawLine(toScreenX(p.x - 1), toScreenY(p.y), toScreenX(p.x + 1), toScreenY(p.y)); - QPainter::drawLine(toScreenX(p.x), toScreenY(p.y - 1), toScreenX(p.x), toScreenY(p.y + 1)); -} - -/** - * Draws a line from (x1, y1) to (x2, y2). - */ -void RS_PainterQt::drawLine(const Vector & p1, const Vector & p2) -{ -#ifdef __APPLE__ - int w2 = (int)getPen().getScreenWidth() / 2; - QPainter::drawLine(toScreenX(p1.x - w2), toScreenY(p1.y - w2), - toScreenX(p2.x - w2), toScreenY(p2.y - w2)); -#else - QPainter::drawLine(toScreenX(p1.x), toScreenY(p1.y), toScreenX(p2.x), toScreenY(p2.y)); -#endif -} - -/** - * Draws a rectangle with corners p1, p2. - */ -/*void RS_PainterQt::drawRect(const Vector& p1, const Vector& p2) { - / *QPainter::drawRect(toScreenX(p1.x), toScreenY(p1.y), - abs(toScreenX(p2.x) - toScreenX(p1.x)), - abs(toScreenY(p2.y) - toScreenY(p1.y)));* / - QPainter::drawLine(toScreenX(p1.x), toScreenY(p1.y), - toScreenX(p2.x), toScreenY(p1.y)); - QPainter::drawLine(toScreenX(p2.x), toScreenY(p1.y), - toScreenX(p2.x), toScreenY(p2.y)); - QPainter::drawLine(toScreenX(p2.x), toScreenY(p2.y), - toScreenX(p1.x), toScreenY(p2.y)); - QPainter::drawLine(toScreenX(p1.x), toScreenY(p2.y), - toScreenX(p1.x), toScreenY(p1.y)); -}*/ - -/** - * Draws an arc which starts / ends exactly at the given coordinates. - * - * @param cx center in x - * @param cy center in y - * @param radius Radius - * @param a1 Angle 1 in rad - * @param a2 Angle 2 in rad - * @param x1 startpoint x - * @param y1 startpoint y - * @param x2 endpoint x - * @param y2 endpoint y - * @param reversed true: clockwise, false: counterclockwise - */ -void RS_PainterQt::drawArc(const Vector & cp, double radius, - double a1, double a2, const Vector & p1, const Vector & p2, - bool reversed) -{ - /* - QPainter::drawArc(cx-radius, cy-radius, - 2*radius, 2*radius, - a1*16, (a2-a1)*16); - */ - - if (radius <= 0.5) - drawGridPoint(cp); - else - { -#ifdef __APPLE__ - drawArcMac(cp, radius, a1, a2, reversed); -#else - int cix; // Next point on circle - int ciy; // - double aStep; // Angle Step (rad) - double a; // Current Angle (rad) - double linStep; // linear step (pixels) - - if (drawingMode == RS2::ModePreview) - linStep = 20.0; - else - linStep = 6.0; - - if (fabs(linStep / radius) <= 1.0) - aStep = asin(linStep / radius); - else - aStep = 1.0; - - if (aStep < 0.05) - aStep = 0.05; - - if (!reversed) - { - // Arc Counterclockwise: - if (a1 > a2 - 1.0e-10) - a2 += 2 * M_PI; - -#ifdef __USE_DEPRECATED_QT3__ - //moveTo(toScreenX(p1.x), toScreenY(p1.y)); - Q3PointArray pa; - int i = 0; - pa.resize(i + 1); - pa.setPoint(i++, toScreenX(p1.x), toScreenY(p1.y)); - - for(a=a1+aStep; a<=a2; a+=aStep) - { - cix = toScreenX(cp.x + cos(a) * radius); - ciy = toScreenY(cp.y - sin(a) * radius); - //lineTo(cix, ciy); - pa.resize(i + 1); - pa.setPoint(i++, cix, ciy); - } - - //lineTo(toScreenX(p2.x), toScreenY(p2.y)); - pa.resize(i + 1); - pa.setPoint(i++, toScreenX(p2.x), toScreenY(p2.y)); - drawPolyline(pa); -#else - QPolygon poly; - int i = 0; -// pa.resize(i + 1); - poly.setPoint(i++, toScreenX(p1.x), toScreenY(p1.y)); - - for(a=a1+aStep; a<=a2; a+=aStep) - { - cix = toScreenX(cp.x + cos(a) * radius); - ciy = toScreenY(cp.y - sin(a) * radius); - //lineTo(cix, ciy); -// pa.resize(i + 1); - poly.setPoint(i++, cix, ciy); - } - - //lineTo(toScreenX(p2.x), toScreenY(p2.y)); -// pa.resize(i + 1); - poly.setPoint(i++, toScreenX(p2.x), toScreenY(p2.y)); - drawPolygon(poly); -#endif - } - else - { - // Arc Clockwise: - if (a1 < a2 + 1.0e-10) - a2 -= 2 * M_PI; - -#ifdef __USE_DEPRECATED_QT3__ - Q3PointArray pa; - int i = 0; - pa.resize(i + 1); - pa.setPoint(i++, toScreenX(p1.x), toScreenY(p1.y)); - //moveTo(toScreenX(p1.x), toScreenY(p1.y)); - - for(a=a1-aStep; a>=a2; a-=aStep) - { - cix = toScreenX(cp.x + cos(a) * radius); - ciy = toScreenY(cp.y - sin(a) * radius); - //lineTo(cix, ciy); - pa.resize(i + 1); - pa.setPoint(i++, cix, ciy); - } - - //lineTo(toScreenX(p2.x), toScreenY(p2.y)); - pa.resize(i + 1); - pa.setPoint(i++, toScreenX(p2.x), toScreenY(p2.y)); - drawPolyline(pa); -#else - QPolygon poly; - int i = 0; - poly.setPoint(i++, toScreenX(p1.x), toScreenY(p1.y)); - - for(a=a1-aStep; a>=a2; a-=aStep) - { - cix = toScreenX(cp.x + cos(a) * radius); - ciy = toScreenY(cp.y - sin(a) * radius); - poly.setPoint(i++, cix, ciy); - } - - poly.setPoint(i++, toScreenX(p2.x), toScreenY(p2.y)); - drawPolygon(poly); -#endif - } -#endif - } -} - -/** - * Draws an arc. - * - * @param cx center in x - * @param cy center in y - * @param radius Radius - * @param a1 Angle 1 in rad - * @param a2 Angle 2 in rad - * @param reversed true: clockwise, false: counterclockwise - */ -void RS_PainterQt::drawArc(const Vector & cp, double radius, double a1, double a2, bool reversed) -{ - if (radius <= 0.5) - drawGridPoint(cp); - else - { -#ifdef __APPLE__ - drawArcMac(cp, radius, a1, a2, reversed); -#else - Q3PointArray pa; - createArc(pa, cp, radius, a1, a2, reversed); - drawPolyline(pa); -#endif - } -} - -/** - * Draws an arc on apple. - * - * @param cx center in x - * @param cy center in y - * @param radius Radius - * @param a1 Angle 1 in rad - * @param a2 Angle 2 in rad - * @param reversed true: clockwise, false: counterclockwise - */ -void RS_PainterQt::drawArcMac(const Vector& cp, double radius, double a1, double a2, bool reversed) -{ - RS_DEBUG->print("RS_PainterQt::drawArcMac"); - if (radius <= 0.5) - drawGridPoint(cp); - else - { - double cix; // Next point on circle - double ciy; // - double aStep; // Angle Step (rad) - double a; // Current Angle (rad) - double ox; - double oy; - - if (2.0 / radius <= 1.0) - aStep = asin(2.0 / radius); - else - aStep = 1.0; - - if (aStep < 0.05) - aStep = 0.05; - - ox = cp.x + cos(a1) * radius; - oy = cp.y - sin(a1) * radius; - - if (!reversed) - { - // Arc Counterclockwise: - if (a1 > a2 - 1.0e-10) - a2 += 2 * M_PI; - - for(a=a1+aStep; a<=a2; a+=aStep) - { - cix = cp.x + cos(a) * radius; - ciy = cp.y - sin(a) * radius; - drawLine(Vector(ox, oy), Vector(cix, ciy)); - ox = cix; - oy = ciy; - } - } - else - { - // Arc Clockwise: - if (a1 < a2 + 1.0e-10) - a2 -= 2 * M_PI; - - for(a=a1-aStep; a>=a2; a-=aStep) - { - cix = cp.x + cos(a) * radius; - ciy = cp.y - sin(a) * radius; - drawLine(Vector(ox, oy), Vector(cix, ciy)); - ox = cix; - oy = ciy; - } - } - - drawLine(Vector(ox, oy), Vector(cp.x + cos(a2) * radius, cp.y - sin(a2) * radius)); - } -} - -/** - * Draws a circle. - * @param cx center in x - * @param cy center in y - * @param radius Radius - */ -void RS_PainterQt::drawCircle(const Vector & cp, double radius) -{ - if (drawingMode == RS2::ModeXOR && radius < 500) - { - // This is _very_ slow for large arcs: - QPainter::drawEllipse(toScreenX(cp.x - radius), toScreenY(cp.y - radius), RS_Math::round(2.0 * radius), RS_Math::round(2.0 * radius)); - } - else - { -#ifdef __APPLE__ - drawArcMac(cp, radius, 0.0, 2 * M_PI, false); -#else - drawArc(cp, radius, 0.0, 2 * M_PI, cp + Vector(radius, 0.0), cp + Vector(radius, 0.0), false); -#endif - } -} - -/** - * Draws a rotated ellipse arc. - */ -void RS_PainterQt::drawEllipse(const Vector & cp, double radius1, double radius2, - double angle, double a1, double a2, bool reversed) -{ - double aStep; // Angle Step (rad) - double a; // Current Angle (rad) - - // Angle step in rad - aStep = 0.01; - - Vector vp; - Vector vc(cp.x, cp.y); - vp.set(cp.x + cos(a1) * radius1, cp.y - sin(a1) * radius2); - vp.rotate(vc, -angle); -// moveTo(toScreenX(vp.x), toScreenY(vp.y)); - - if (!reversed) - { - // Arc Counterclockwise: - if (a1 > a2 - RS_TOLERANCE) - a2 += 2 * M_PI; - - for(a=a1+aStep; a<=a2; a+=aStep) - { - Vector last = vp; - vp.set(cp.x + cos(a) * radius1, cp.y - sin(a) * radius2); - vp.rotate(vc, -angle); -// lineTo(toScreenX(vp.x), toScreenY(vp.y)); - drawLine(Vector(toScreenX(last.x), toScreenY(last.y)), - Vector(toScreenX(vp.x), toScreenY(vp.y))); - } - } - else - { - // Arc Clockwise: - if (a1 < a2 + RS_TOLERANCE) - a2 -= 2 * M_PI; - - for(a=a1-aStep; a>=a2; a-=aStep) - { - Vector last = vp; - vp.set(cp.x + cos(a) * radius1, cp.y - sin(a) * radius2); - vp.rotate(vc, -angle); -// lineTo(toScreenX(vp.x), toScreenY(vp.y)); - drawLine(Vector(toScreenX(last.x), toScreenY(last.y)), - Vector(toScreenX(vp.x), toScreenY(vp.y))); - } - } - - Vector last = vp; - vp.set(cp.x + cos(a2) * radius1, cp.y - sin(a2) * radius2); - vp.rotate(vc, -angle); -// lineTo(toScreenX(vp.x), toScreenY(vp.y)); - drawLine(Vector(toScreenX(last.x), toScreenY(last.y)), - Vector(toScreenX(vp.x), toScreenY(vp.y))); - //} -} - -/** - * Draws image. - */ -void RS_PainterQt::drawImg(QImage & img, const Vector & pos, - double angle, const Vector & factor, int sx, int sy, int sw, int sh) -{ - save(); - - QMatrix wm; - wm.translate(pos.x, pos.y); - wm.scale(factor.x, factor.y); - wm.rotate(RS_Math::rad2deg(-angle)); - setWorldMatrix(wm); - - if (fabs(angle) < 1.0e-4) - drawImage(0 + sx, -img.height() + sy, img, sx, sy, sw, sh); - else - drawImage(0, -img.height(), img); - - restore(); -} - -#if 0 -void RS_PainterQt::drawTextH(int x1, int y1, int x2, int y2, const QString & text) -{ - drawText(x1, y1, x2, y2, Qt::AlignRight | Qt::AlignVCenter, text); -} - -void RS_PainterQt::drawTextV(int x1, int y1, int x2, int y2, const QString & text) -{ - save(); - QMatrix wm = worldMatrix(); - wm.rotate(-90.0); - setWorldMatrix(wm); - //rotate(-90.0); - drawText(x1, y1, x2, y2, Qt::AlignRight | Qt::AlignVCenter, text); - restore(); -} -#endif - -void RS_PainterQt::fillRect(int x1, int y1, int w, int h, const RS_Color & col) -{ - QPainter::fillRect(x1, y1, w, h, col); -} - -void RS_PainterQt::fillTriangle(const Vector & p1, const Vector & p2, const Vector & p3) -{ -#if __USE_DEPRECATED_QT3__ - Q3PointArray arr(3); - arr.putPoints(0, 3, toScreenX(p1.x),toScreenY(p1.y), toScreenX(p2.x),toScreenY(p2.y), toScreenX(p3.x),toScreenY(p3.y)); - setBrush(pen().color()); - drawPolygon(arr); -#else - QPolygon poly(3); - poly.putPoints(0, 3, toScreenX(p1.x),toScreenY(p1.y), toScreenX(p2.x),toScreenY(p2.y), toScreenX(p3.x),toScreenY(p3.y)); - setBrush(pen().color()); - drawPolygon(poly); -#endif -} - -void RS_PainterQt::erase() -{ - QPainter::eraseRect(0, 0, getWidth(), getHeight()); -} - -int RS_PainterQt::getWidth() -{ -// Q3PaintDeviceMetrics m(device()); -// return m.width(); - return device()->width(); -} - -int RS_PainterQt::getHeight() -{ -// Q3PaintDeviceMetrics m(device()); -// return m.height(); - return device()->height(); -} - -void RS_PainterQt::setPreviewPen() -{ -// setPen(QColor(0, 255, 255)); - setPen(RS_Color(0, 255, 255)); -} - -RS_Pen RS_PainterQt::getPen() -{ - return lpen; - //RS_Pen p(pen().color(), - // RS2::qw(pen().width()), - // RS2::qw(pen().style())); - //return QPainter::pen(); - //return p; -} - -void RS_PainterQt::setPen(const RS_Pen & pen) -{ - lpen = pen; - -//#warning "!!! Removing B/W restriction in RS_PainterQt::setPen()... !!!" - if (drawingMode == RS2::ModeBW) - lpen.setColor(RS_Color(0, 0, 0)); - - QPen p(lpen.getColor(), RS_Math::round(lpen.getScreenWidth()), RS2::rsToQtLineType(lpen.getLineType())); - p.setJoinStyle(Qt::RoundJoin); - p.setCapStyle(Qt::RoundCap); - QPainter::setPen(p); -} - -void RS_PainterQt::setPen(const RS_Color & color) -{ - if (drawingMode == RS2::ModeBW) - { - lpen.setColor(RS_Color(0, 0, 0)); - QPainter::setPen(RS_Color(0, 0, 0)); - } - else - { - lpen.setColor(color); - QPainter::setPen(color); - } -} - -void RS_PainterQt::setPen(int r, int g, int b) -{ - if (drawingMode == RS2::ModeBW) - setPen(QColor(0, 0, 0)); - else - setPen(QColor(r, g, b)); -} - -void RS_PainterQt::disablePen() -{ - lpen = RS_Pen(RS2::FlagInvalid); - QPainter::setPen(Qt::NoPen); -} - -void RS_PainterQt::setBrush(const RS_Color & color) -{ - if (drawingMode == RS2::ModeBW) - QPainter::setBrush(QColor(0, 0, 0)); - else - QPainter::setBrush(color); -} - -void RS_PainterQt::drawPolygon(const Q3PointArray & a) -{ - QPainter::drawPolygon(a); -} - -//void RS_PainterQt::setColor(const QColor& color) { -// setPen(color); -//} - -void RS_PainterQt::setXORMode() -{ -//WAS: setRasterOp(XorROP); - setCompositionMode(QPainter::CompositionMode_Xor); -} - -void RS_PainterQt::setNormalMode() -{ -//WAS: setRasterOp(CopyROP); - setCompositionMode(QPainter::CompositionMode_SourceOver); -} - -void RS_PainterQt::setClipRect(int x, int y, int w, int h) -{ - QPainter::setClipRect(x, y, w, h); - setClipping(true); -} - -void RS_PainterQt::resetClipping() -{ - setClipping(false); -} - diff --git a/src/base/rs_painterqt.h.old b/src/base/rs_painterqt.h.old deleted file mode 100644 index c8d53cc..0000000 --- a/src/base/rs_painterqt.h.old +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** $Id: rs_painterqt.h 2244 2005-03-14 23:00:19Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_PAINTERQT_H -#define RS_PAINTERQT_H - -#include - -#include "rs_color.h" -#include "rs_graphicview.h" -#include "rs_painter.h" - -/** - * The Qt implementation of a painter. It can draw objects such as - * lines or arcs in a widget. All coordinates are screen coordinates - * and have nothing to do with the graphic view. - */ -class RS_PainterQt: public QPainter, public RS_Painter -{ - public: - //WAS: RS_PainterQt(const QPaintDevice* pd); - RS_PainterQt(QPaintDevice * pd); - virtual ~RS_PainterQt(); - -// virtual void moveTo(int x, int y); -// virtual void lineTo(int x, int y); - virtual void drawGridPoint(const Vector & p); - virtual void drawPoint(const Vector & p); - virtual void drawLine(const Vector & p1, const Vector & p2); - //virtual void drawRect(const Vector& p1, const Vector& p2); - virtual void drawArc(const Vector & cp, double radius, - double a1, double a2, const Vector & p1, const Vector & p2, bool reversed); - - virtual void drawArc(const Vector & cp, double radius, - double a1, double a2, bool reversed); - virtual void drawArcMac(const Vector & cp, double radius, - double a1, double a2, bool reversed); - virtual void drawCircle(const Vector &, double radius); - virtual void drawEllipse(const Vector & cp, double radius1, double radius2, - double angle, double a1, double a2, bool reversed); - virtual void drawImg(QImage & img, const Vector & pos, - double angle, const Vector & factor, int sx, int sy, int sw, int sh); -// virtual void drawTextH(int x1, int y1, int x2, int y2, const QString & text); -// virtual void drawTextV(int x1, int y1, int x2, int y2, const QString & text); - - virtual void fillRect(int x1, int y1, int w, int h, const RS_Color& col); - - virtual void fillTriangle(const Vector & p1, const Vector & p2, const Vector & p3); - - virtual void drawPolygon(const Q3PointArray & a); - virtual void erase(); - virtual int getWidth(); - virtual int getHeight(); - - //virtual void setBackgroundPen(); - //virtual void setDefaultPen(); - virtual void setPreviewPen(); - virtual RS_Pen getPen(); - virtual void setPen(const RS_Pen & pen); - virtual void setPen(const RS_Color & color); - virtual void setPen(int r, int g, int b); - virtual void disablePen(); - //virtual void setColor(const QColor& color); - virtual void setBrush(const RS_Color & color); - - virtual void setXORMode(); - virtual void setNormalMode(); - - virtual void setClipRect(int x, int y, int w, int h); - virtual void resetClipping(); - - protected: - RS_Pen lpen; - -// private: -// int cursorX, cursorY; -}; - -#endif // RS_PAINTERQT_H diff --git a/src/base/rs_pointarray.h.old b/src/base/rs_pointarray.h.old deleted file mode 100644 index 9a3369a..0000000 --- a/src/base/rs_pointarray.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_pointarray.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_POINTARRAY_H -#define RS_POINTARRAY_H - -//#include -#include - -#define RS_PointArray Q3PointArray - -#endif diff --git a/src/base/rs_ptrlist.h.old b/src/base/rs_ptrlist.h.old deleted file mode 100644 index f40e26f..0000000 --- a/src/base/rs_ptrlist.h.old +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** $Id: rs_ptrlist.h 1794 2003-12-02 18:59:02Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_PTRLIST_H -#define RS_PTRLIST_H - -//#include -#include - -#define RS_PtrList Q3PtrList -#define RS_PtrListIterator Q3PtrListIterator - -#endif diff --git a/src/base/rs_ptrqueue.h.old b/src/base/rs_ptrqueue.h.old deleted file mode 100644 index 8d42b27..0000000 --- a/src/base/rs_ptrqueue.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_ptrqueue.h 1877 2004-05-15 09:09:21Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_PTRQUEUE_H -#define RS_PTRQUEUE_H - -//#include -#include - -#define RS_PtrQueue Q3PtrQueue - -#endif diff --git a/src/base/rs_python.cpp.bak b/src/base/rs_python.cpp.bak deleted file mode 100644 index 22efe33..0000000 --- a/src/base/rs_python.cpp.bak +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** $Id: rs_python.cpp 1741 2003-09-30 22:50:17Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_python.h" - -#ifdef RS_OPT_PYTHON - -// -// This is exported from the Boost::Python library declarations -// that are declared inside rs_python_wrappers.cpp. -// -extern "C" void initqcad(); - -/** - * The unique instance of the Python scripting engine - */ -RS_Python* RS_Python::uniqueInstance = NULL; - -/** - * Constructor - */ -RS_Python::RS_Python() -{ - graphic = NULL; - Py_Initialize(); - initqcad(); -} - -/** - * Gets the one and only RS_Python instance - * (creates a new one on first call only) - * - * @return Pointer to the single instance of this - * singleton class - */ -RS_Python* RS_Python::instance() { - if(uniqueInstance==NULL) { - uniqueInstance = new RS_Python; - } - return uniqueInstance; -} - - -/** - * Launches the given script. - */ -int RS_Python::launch(const RS_String& script) { - PyObject *modname, *mod, *mdict, *func, *rslt; - //Py_SetProgramName(argv[0]); - - modname = PyString_FromString(script); - mod = PyImport_Import(modname); - if (mod) { - //printf( "mod\n"); - mdict = PyModule_GetDict(mod); - - // Borrowed reference to start function - func = PyDict_GetItemString(mdict, "start"); - if (func) { - //printf( "func\n"); - if (PyCallable_Check(func)) { - //printf("calling..\n"); - rslt = PyObject_CallFunction(func, "(s)", "noparam"); - //printf("calling ok\n"); - if (rslt) { - // The result value is currently not used - Py_XDECREF(rslt); - } else - { - // Give user some feed back what went wrong - printf("*** PYTHON RUNTIME ERROR ***\n"); - PyErr_Print(); - } - } - } else { - printf("no such function: start\n"); - } - Py_XDECREF(mod); - } else { - printf("*** ERROR LOADING SCRIPT '%s' ***\n", script.latin1()); - PyErr_Print(); - } - Py_XDECREF(modname); - //Py_Finalize(); - return 0; -} - -#endif diff --git a/src/base/rs_python.h.bak b/src/base/rs_python.h.bak deleted file mode 100644 index bf96360..0000000 --- a/src/base/rs_python.h.bak +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** $Id: rs_python.h 1960 2005-03-12 12:22:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_PYTHON_H -#define RS_PYTHON_H - -#ifdef RS_OPT_PYTHON - -#include "Python.h" - -#include "rs_graphic.h" - -#define RS_PYTHON RS_Python::instance() - -/** - * Python scripting support. - * - * OBSOLETE - * - * @author Andrew Mustun - */ -class RS_Python { -private: - RS_Python(); - -public: - static RS_Python* instance(); - - void setGraphic(RS_Graphic* g) { - graphic = g; - } - - RS_Graphic* getGraphic() { - return graphic; - } - - int launch(const RS_String& script); - -private: - static RS_Python* uniqueInstance; - RS_Graphic* graphic; -}; - -#endif - -#endif diff --git a/src/base/rs_python_wrappers.cpp.bak b/src/base/rs_python_wrappers.cpp.bak deleted file mode 100644 index 0b9edbc..0000000 --- a/src/base/rs_python_wrappers.cpp.bak +++ /dev/null @@ -1,602 +0,0 @@ -/*************************************************************************** -** $Id -** -** Python language bindings for QCad II -** -** Copyright (C) 2003 Markus Meyer -** -** Permission to copy, use, modify, sell and distribute this file is granted -** provided this copyright notice is not removed or altered. -** This software is provided "as is" without express or implied -** warranty, and with no claim as to its suitability for any purpose. -** -***************************************************************************/ - -/** - * TODO: - * - Complete block support - * - Support for hatches, dimensions, text, solids - * - Support for user interactions - * - Support for more than one document - */ -#ifdef RS_OPT_PYTHON - -#include -using namespace boost::python; - -#include "rs_python_wrappers.h" -#include "rs_python.h" - -#include "rs.h" -#include "rs_arc.h" -#include "rs_atomicentity.h" -#include "rs_block.h" -#include "rs_blocklist.h" -#include "rs_circle.h" -#include "rs_color.h" -#include "rs_constructionline.h" -#include "rs_document.h" -#include "rs_ellipse.h" -#include "rs_entitycontainer.h" -#include "rs_entity.h" -#include "rs_flags.h" -#include "rs_graphic.h" -#include "rs_image.h" -#include "rs_insert.h" -#include "rs_layer.h" -#include "rs_layerlist.h" -#include "rs_line.h" -#include "rs_pen.h" -#include "rs_point.h" -#include "rs_polyline.h" -#include "rs_vector.h" - -/* Global root functions */ -RS_Graphic* currentGraphic() { return RS_PYTHON->getGraphic(); } - - /* more to be added later (access to global properties, all documents, - creation of new documents, ... */ - -/* To/From Python string conversion logic for string management */ -namespace RS_String_Python_Conversions { - namespace { - struct RS_String_to_python_str - { - static PyObject* convert(RS_String const& s) - { - return boost::python::incref(boost::python::object((const char*)s).ptr()); - } - }; - - struct RS_String_from_python_str - { - RS_String_from_python_str() - { - boost::python::converter::registry::push_back( - &convertible, - &construct, - boost::python::type_id()); - } - - static void* convertible(PyObject* obj_ptr) - { - if (!PyString_Check(obj_ptr)) return 0; - return obj_ptr; - } - - static void construct( - PyObject* obj_ptr, - boost::python::converter::rvalue_from_python_stage1_data* data) - { - const char* value = PyString_AsString(obj_ptr); - if (!value) - boost::python::throw_error_already_set(); - void* storage = ( - (boost::python::converter::rvalue_from_python_storage*) - data)->storage.bytes; - new (storage) RS_String(value); - data->convertible = storage; - } - }; - - void registerConversions() - { - using namespace boost::python; - - boost::python::to_python_converter< - RS_String, RS_String_to_python_str>(); - - RS_String_from_python_str(); - } - } -} - -/* Transfer of ownership is done by using auto pointers */ -/* These are the helper functions needed for this mechanism */ - -#define TRANSFER_OWNERSHIP_FUNCTION(fname, container, addfunc, entity) \ - void fname(container& cont, std::auto_ptr obj) \ - { cont.addfunc(obj.get()); obj.release(); } - -TRANSFER_OWNERSHIP_FUNCTION(RS_Graphic_addLayer, RS_Graphic, addLayer, RS_Layer) -TRANSFER_OWNERSHIP_FUNCTION(RS_LayerList_add, RS_LayerList, add, RS_Layer) - -#define ADDVERTEX_FUNCTION(fname, entity) \ - TRANSFER_OWNERSHIP_FUNCTION(fname, RS_EntityContainer, addEntity, entity) - -ADDVERTEX_FUNCTION(RS_EntityContainer_addArc, RS_Arc) -ADDVERTEX_FUNCTION(RS_EntityContainer_addBlock, RS_Block) -ADDVERTEX_FUNCTION(RS_EntityContainer_addCircle, RS_Circle) -ADDVERTEX_FUNCTION(RS_EntityContainer_addConstructionLine, RS_ConstructionLine) -ADDVERTEX_FUNCTION(RS_EntityContainer_addEllipse, RS_Ellipse) -ADDVERTEX_FUNCTION(RS_EntityContainer_addImage, RS_Image) -ADDVERTEX_FUNCTION(RS_EntityContainer_addLine, RS_Line) -ADDVERTEX_FUNCTION(RS_EntityContainer_addPoint, RS_Point) -ADDVERTEX_FUNCTION(RS_EntityContainer_addPolyline, RS_Polyline) - -/* Overloaded functions helpers */ -void (RS_LayerList::*RS_LayerList_activate_string)(const RS_String&) = &RS_LayerList::activate; -void (RS_LayerList::*RS_LayerList_activate_layer)(RS_Layer*) = &RS_LayerList::activate; -void (RS_LayerList::*RS_LayerList_toggle_string)(const RS_String&) = &RS_LayerList::toggle; -void (RS_LayerList::*RS_LayerList_toggle_layer)(const RS_String&) = &RS_LayerList::toggle; -void (RS_Graphic::*RS_Graphic_toggleLayer_string)(const RS_String&) = &RS_Graphic::toggleLayer; -void (RS_Graphic::*RS_Graphic_toggleLayer_layer)(RS_Layer*) = &RS_Graphic::toggleLayer; -void (RS_Entity::*RS_Entity_setLayer_string)(const RS_String&) = &RS_Entity::setLayer; -void (RS_Entity::*RS_Entity_setLayer_layer)(RS_Layer*) = &RS_Entity::setLayer; - -/** - * The main python module - */ - -BOOST_PYTHON_MODULE(qcad) -{ - /* Initialization code */ - RS_String_Python_Conversions::registerConversions(); - - /* Unbound functions */ - - def("currentGraphic", currentGraphic, return_value_policy()); - - /* Enums */ - enum_("Flag") - .value("Undone", RS2::FlagUndone) - .value("Visible", RS2::FlagVisible) - .value("ByLayer", RS2::FlagByLayer) - .value("ByBlock", RS2::FlagByBlock) - .value("Frozen", RS2::FlagFrozen) - .value("DefFrozen", RS2::FlagDefFrozen) - .value("Locked", RS2::FlagLocked) - .value("Invalid", RS2::FlagInvalid) - .value("Selected", RS2::FlagSelected) - .value("Closed", RS2::FlagClosed) - .value("Temp", RS2::FlagTemp) - .value("Processed", RS2::FlagProcessed) - .value("Selected1", RS2::FlagSelected1) - .value("Selected2", RS2::FlagSelected2) - ; - - enum_("VariableType") - .value("String", RS2::VariableString) - .value("Int", RS2::VariableInt) - .value("Double", RS2::VariableDouble) - .value("Vector", RS2::VariableVector) - .value("Void", RS2::VariableVoid) - ; - - enum_("EntityType") - .value("Unknown", RS2::EntityUnknown) - .value("Container", RS2::EntityContainer) - .value("Block", RS2::EntityBlock) - .value("FontChar", RS2::EntityFontChar) - .value("Insert", RS2::EntityInsert) - .value("Graphic", RS2::EntityGraphic) - .value("Point", RS2::EntityPoint) - .value("Line", RS2::EntityLine) - .value("Polyline", RS2::EntityPolyline) - .value("Vertex", RS2::EntityVertex) - .value("Arc", RS2::EntityArc) - .value("Circle", RS2::EntityCircle) - .value("Ellipse", RS2::EntityEllipse) - .value("Solid", RS2::EntitySolid) - .value("ConstructionLine", RS2::EntityConstructionLine) - .value("Text", RS2::EntityText) - .value("DimAligned", RS2::EntityDimAligned) - .value("DimLinear", RS2::EntityDimLinear) - .value("DimRadial", RS2::EntityDimRadial) - .value("DimDiametric", RS2::EntityDimDiametric) - .value("DimAngular", RS2::EntityDimAngular) - .value("DimLeader", RS2::EntityDimLeader) - .value("Hatch", RS2::EntityHatch) - .value("Image", RS2::EntityImage) - ; - - enum_("LineType") - .value("NoPen", RS2::NoPen) - .value("SolidLine", RS2::SolidLine) - .value("DotLine", RS2::DotLine) - .value("DotLine2", RS2::DotLine2) - .value("DotLineX2", RS2::DotLineX2) - .value("DashLine", RS2::DashLine) - .value("DashLine2", RS2::DashLine2) - .value("DashLineX2", RS2::DashLineX2) - .value("DashDotLine", RS2::DashDotLine) - .value("DashDotLine2", RS2::DashDotLine2) - .value("DashDotLineX2", RS2::DashDotLineX2) - .value("DivideLine", RS2::DivideLine) - .value("DivideLine2", RS2::DivideLine2) - .value("DivideLineX2", RS2::DivideLineX2) - .value("CenterLine", RS2::CenterLine) - .value("CenterLine2", RS2::CenterLine2) - .value("CenterLineX2", RS2::CenterLineX2) - .value("BorderLine", RS2::BorderLine) - .value("BorderLine2", RS2::BorderLine2) - .value("BorderLineX2", RS2::BorderLineX2) - .value("ByLayer", RS2::LineByLayer) - .value("ByBlock", RS2::LineByBlock) - ; - - enum_("LineWidth") - .value("Width00", RS2::Width00) - .value("Width01", RS2::Width01) - .value("Width02", RS2::Width02) - .value("Width03", RS2::Width03) - .value("Width04", RS2::Width04) - .value("Width05", RS2::Width05) - .value("Width06", RS2::Width06) - .value("Width07", RS2::Width07) - .value("Width08", RS2::Width08) - .value("Width09", RS2::Width09) - .value("Width10", RS2::Width10) - .value("Width11", RS2::Width11) - .value("Width12", RS2::Width12) - .value("Width13", RS2::Width13) - .value("Width14", RS2::Width14) - .value("Width15", RS2::Width15) - .value("Width16", RS2::Width16) - .value("Width17", RS2::Width17) - .value("Width18", RS2::Width18) - .value("Width19", RS2::Width19) - .value("Width20", RS2::Width20) - .value("Width21", RS2::Width21) - .value("Width22", RS2::Width22) - .value("Width23", RS2::Width23) - .value("ByLayer", RS2::WidthByLayer) - .value("ByBlock", RS2::WidthByBlock) - .value("Default", RS2::WidthDefault) - ; - - /* "Small" classes */ - - class_("Flags") - .def(init()) - .add_property("flags", &RS_Flags::getFlags, &RS_Flags::setFlags) - .def("resetFlags", &RS_Flags::resetFlags) - .def("setFlag", &RS_Flags::setFlag) - .def("delFlag", &RS_Flags::delFlag) - .def("toggleFlag", &RS_Flags::toggleFlag) - .def("getFlag", &RS_Flags::getFlag) - ; - - class_ >("Color") - .def(init()) - .def(init()) - .def("stripFlags", &RS_Color::stripFlags) - .add_property("byLayer", &RS_Color::isByLayer) - .add_property("byBlock", &RS_Color::isByBlock) - ; - - class_("Vector") - .def(init >()) - .def("set", &RS_Vector::set) - .def("setPolar", &RS_Vector::setPolar) - .def("distanceTo", &RS_Vector::distanceTo) - .def("angle", &RS_Vector::angle) - .def("angleTo", &RS_Vector::angleTo) - .def("magnitude", &RS_Vector::magnitude) - .def("move", &RS_Vector::move) - .def_readwrite("x", &RS_Vector::x) - .def_readwrite("y", &RS_Vector::y) - .def_readwrite("z", &RS_Vector::z) - .def_readwrite("valid", &RS_Vector::valid) - ; - - class_ >("Pen") - .def(init()) - .add_property("lineType", &RS_Pen::getLineType, &RS_Pen::setLineType) - .add_property("width", &RS_Pen::getWidth, &RS_Pen::setWidth) - .add_property("screenWidth", &RS_Pen::getScreenWidth, &RS_Pen::setScreenWidth) - .add_property("color", make_function(&RS_Pen::getColor, return_value_policy()), &RS_Pen::setColor) - .add_property("valid", &RS_Pen::isValid) - ; - - /* Common stuff */ - - class_("EntityContainer", init >()) - /* Wrapper functions for ownership transfer */ - .def("addEntity", RS_EntityContainer_addArc) - .def("addEntity", RS_EntityContainer_addBlock) - .def("addEntity", RS_EntityContainer_addCircle) - .def("addEntity", RS_EntityContainer_addConstructionLine) - .def("addEntity", RS_EntityContainer_addEllipse) - .def("addEntity", RS_EntityContainer_addImage) - .def("addEntity", RS_EntityContainer_addLine) - .def("addEntity", RS_EntityContainer_addPoint) - .def("addEntity", RS_EntityContainer_addPolyline) - - /** Owner-Containers will automatically delete entities upon removing, - * so no problem here. Other containers are not allowed in Python at the moment. - */ - .def("removeEntity", &RS_EntityContainer::removeEntity) - - /* Standard wrappers */ - .def("clear", &RS_EntityContainer::clear) - .add_property("empty", &RS_EntityContainer::isEmpty) - .def("entityAt", &RS_EntityContainer::entityAt, return_value_policy()) - - /* Iterators */ - .def("firstEntity", &RS_EntityContainer::firstEntity, return_value_policy()) - .def("lastEntity", &RS_EntityContainer::lastEntity, return_value_policy()) - .def("nextEntity", &RS_EntityContainer::nextEntity, return_value_policy()) - ; - - class_("LayerData") - .def(init()) - .def_readwrite("name", &RS_LayerData::name) - .def_readwrite("pen", &RS_LayerData::pen) - .def_readwrite("frozen", &RS_LayerData::frozen) - ; - - class_ >("Layer", init()) - .add_property("name", &RS_Layer::getName, &RS_Layer::setName) - .add_property("pen", &RS_Layer::getPen, &RS_Layer::setPen) - .add_property("frozen", &RS_Layer::isFrozen, &RS_Layer::freeze) - .add_property("toggle", &RS_Layer::toggle) - ; - - class_("LayerList") - .def("clear", &RS_LayerList::clear) - .def("count", &RS_LayerList::count) - .def("at", &RS_LayerList::at, return_value_policy()) - .add_property("active", make_function(&RS_LayerList::getActive, return_value_policy()), - RS_LayerList_activate_layer) - .def("activate", RS_LayerList_activate_string) - .def("activate", RS_LayerList_activate_layer) - .def("add", RS_LayerList_add) - .def("remove", &RS_LayerList::remove) - .def("edit", &RS_LayerList::edit) - .def("find", &RS_LayerList::find, return_value_policy()) - .def("toggle", RS_LayerList_toggle_string) - .def("toggle", RS_LayerList_toggle_layer) - .def("freezeAll", &RS_LayerList::freezeAll) - ; - - class_, boost::noncopyable >("Document", no_init) - .add_property("layerList", make_function(&RS_Document::getLayerList, return_value_policy())) - .add_property("blockList", make_function(&RS_Document::getBlockList, return_value_policy())) - .def("newDoc", &RS_Document::newDoc) - .def("save", &RS_Document::save) - .def("saveAs", &RS_Document::saveAs) - .def("open", &RS_Document::open) - .add_property("modified", &RS_Document::isModified) - .add_property("activePen", &RS_Document::getActivePen, &RS_Document::setActivePen) - .add_property("filename", &RS_Document::getFilename) - ; - - class_ >("Graphic", init()) - .def("count", &RS_Graphic::count) - .def("findLayer", &RS_Graphic::findLayer, return_value_policy()) - .def("editLayer", &RS_Graphic::editLayer) - .def("addLayer", RS_Graphic_addLayer) - .def("removeLayer", &RS_Graphic::removeLayer) - .def("toggleLayer", RS_Graphic_toggleLayer_string) - .def("toggleLayer", RS_Graphic_toggleLayer_layer) - .def("clearLayers", &RS_Graphic::clearLayers) - .def("freezeAllLayers", &RS_Graphic::freezeAllLayers) - ; - - /* Entity types */ - - class_("Entity", no_init) - .def("init", &RS_Entity::init) - .def("initId", &RS_Entity::initId) - .def("clone", &RS_Entity::clone, return_value_policy()) - .def("reparent", &RS_Entity::reparent) - .def("resetBorders", &RS_Entity::resetBorders) - .add_property("id", &RS_Entity::getId) - .add_property("count", &RS_Entity::count) - .add_property("parent", make_function(&RS_Entity::getParent, return_value_policy()), &RS_Entity::setParent) - .add_property("graphic", make_function(&RS_Entity::getGraphic, return_value_policy())) - .add_property("block", make_function(&RS_Entity::getBlock, return_value_policy())) - .add_property("insert", make_function(&RS_Entity::getInsert, return_value_policy())) - .add_property("blockOrInsert", make_function(&RS_Entity::getBlockOrInsert, return_value_policy())) - .add_property("document", make_function(&RS_Entity::getDocument, return_value_policy())) - .add_property("layer", make_function(&RS_Entity::getLayer, return_value_policy()), - RS_Entity_setLayer_layer) - .def("setLayer", RS_Entity_setLayer_string) - .def("setLayer", RS_Entity_setLayer_layer) - .def("setLayerToActive", &RS_Entity::setLayerToActive) - .add_property("isContainer", &RS_Entity::isContainer) - .add_property("isAtomic", &RS_Entity::isAtomic) - .add_property("isEdge", &RS_Entity::isEdge) - .add_property("isDocument", &RS_Entity::isDocument) - .add_property("selected", &RS_Entity::isSelected, &RS_Entity::setSelected) - .def("toggleSelected", &RS_Entity::toggleSelected) - .add_property("processed", &RS_Entity::isProcessed, &RS_Entity::setProcessed) - .add_property("visible", &RS_Entity::isVisible, &RS_Entity::setVisible) - .add_property("min", &RS_Entity::getMin) - .add_property("max", &RS_Entity::getMax) - .add_property("size", &RS_Entity::getSize) - .def("move", &RS_Entity::move) - .def("rotate", &RS_Entity::rotate) - .def("calculateBorders", &RS_Entity::calculateBorders) - ; - - class_, boost::noncopyable>("AtomicEntity", no_init) - .add_property("startpointSelected", &RS_AtomicEntity::isStartpointSelected) - .add_property("endpointSelected", &RS_AtomicEntity::isEndpointSelected) - .def("moveStartpoint", &RS_AtomicEntity::moveStartpoint) - .def("moveEndpoint", &RS_AtomicEntity::moveEndpoint) - .add_property("trimPoint", &RS_AtomicEntity::getTrimPoint) - .def("reverse", &RS_AtomicEntity::reverse) - ; - - /* Entities Data */ - - class_("ArcData") - .def(init()) - .def("reset", &RS_ArcData::reset) - .add_property("valid", &RS_ArcData::isValid) - .def_readwrite("center", &RS_ArcData::center) - .def_readwrite("radius", &RS_ArcData::radius) - .def_readwrite("angle1", &RS_ArcData::angle1) - .def_readwrite("angle2", &RS_ArcData::angle2) - .def_readwrite("reversed", &RS_ArcData::reversed) - ; - - class_("BlockData") - .def(init()) - .add_property("valid", &RS_BlockData::isValid) - .def_readwrite("name", &RS_BlockData::name) - .def_readwrite("basePoint", &RS_BlockData::basePoint) - .def_readwrite("frozen", &RS_BlockData::frozen) - ; - - class_("CircleData") - .def(init()) - .def("reset", &RS_CircleData::reset) - .add_property("valid", &RS_CircleData::isValid) - .def_readwrite("center", &RS_CircleData::center) - .def_readwrite("radius", &RS_CircleData::radius) - ; - - class_("ConstructionLineData") - .def(init()) - ; - - class_("EllipseData", init()) - ; - - class_("ImageData") - .def(init()) - .def_readwrite("handle", &RS_ImageData::handle) - .def_readwrite("insertionPoint", &RS_ImageData::insertionPoint) - .def_readwrite("uVector", &RS_ImageData::uVector) - .def_readwrite("vVector", &RS_ImageData::vVector) - .def_readwrite("size", &RS_ImageData::size) - .def_readwrite("file", &RS_ImageData::file) - .def_readwrite("brightness", &RS_ImageData::brightness) - .def_readwrite("contrast", &RS_ImageData::contrast) - .def_readwrite("fade", &RS_ImageData::fade) - ; - - class_("LineData") - .def(init()) - .def_readwrite("startpoint", &RS_LineData::startpoint) - .def_readwrite("endpoint", &RS_LineData::endpoint) - ; - - class_("PointData", init()) - ; - - class_("PolylineData") - .def(init()) - ; - - /* Entities */ - - class_, std::auto_ptr >("Arc", init()) - .add_property("data", &RS_Arc::getData, &RS_Arc::setData) - .add_property("center", &RS_Arc::getCenter, &RS_Arc::setCenter) - .add_property("radius", &RS_Arc::getRadius, &RS_Arc::setRadius) - .add_property("angle1", &RS_Arc::getAngle1, &RS_Arc::setAngle1) - .add_property("angle2", &RS_Arc::getAngle2, &RS_Arc::setAngle2) - .add_property("direction1", &RS_Arc::getDirection1) - .add_property("direction2", &RS_Arc::getDirection2) - .add_property("reversed", &RS_Arc::isReversed, &RS_Arc::setReversed) - .add_property("middlepoint", &RS_Arc::getMiddlepoint) - .add_property("angleLength", &RS_Arc::getAngleLength) - .add_property("length", &RS_Arc::getLength) - .add_property("bulge", &RS_Arc::getBulge) - .def("createFrom3P", &RS_Arc::createFrom3P) - ; - - class_, std::auto_ptr >("Block", init()) - .add_property("name", &RS_Block::getName, &RS_Block::setName) - .add_property("basePoint", &RS_Block::getBasePoint) - .add_property("frozen", &RS_Block::isFrozen, &RS_Block::freeze) - .def("toggle", &RS_Block::toggle) - ; - - class_, std::auto_ptr >("Circle", init()) - .add_property("data", &RS_Circle::getData) - .add_property("center", &RS_Circle::getCenter, &RS_Circle::setCenter) - .add_property("radius", &RS_Circle::getRadius, &RS_Circle::setRadius) - .add_property("angleLength", &RS_Circle::getAngleLength) - .def("createFromCR", &RS_Circle::createFromCR) - .def("createFrom2P", &RS_Circle::createFrom2P) - .def("createFrom3P", &RS_Circle::createFrom3P) - ; - - class_, std::auto_ptr > - ("ConstructionLine", init()) - .add_property("data", &RS_ConstructionLine::getData) - .add_property("point1", &RS_ConstructionLine::getPoint1) - .add_property("point2", &RS_ConstructionLine::getPoint2) - ; - - class_, std::auto_ptr > - ("Ellipse", init()) - .add_property("data", &RS_Ellipse::getData) - .add_property("reversed", &RS_Ellipse::isReversed, &RS_Ellipse::setReversed) - .add_property("angle", &RS_Ellipse::getAngle) - .add_property("angle1", &RS_Ellipse::getAngle1, &RS_Ellipse::setAngle1) - .add_property("angle2", &RS_Ellipse::getAngle2, &RS_Ellipse::setAngle2) - .add_property("center", &RS_Ellipse::getCenter, &RS_Ellipse::setCenter) - .add_property("majorP", &RS_Ellipse::getMajorP, &RS_Ellipse::setMajorP) - .add_property("ratio", &RS_Ellipse::getRatio, &RS_Ellipse::setRatio) - .add_property("majorRadius", &RS_Ellipse::getMajorRadius) - .add_property("minorRadius", &RS_Ellipse::getMinorRadius) - ; - - class_, std::auto_ptr > - ("Image", init()) - .add_property("data", &RS_Image::getData) - .add_property("insertionPoint", &RS_Image::getInsertionPoint, &RS_Image::setInsertionPoint) - .add_property("file", &RS_Image::getFile, &RS_Image::setFile) - .add_property("uVector", &RS_Image::getUVector) - .add_property("vVector", &RS_Image::getVVector) - .add_property("width", &RS_Image::getWidth) - .add_property("height", &RS_Image::getHeight) - .add_property("brightness", &RS_Image::getBrightness) - .add_property("contrast", &RS_Image::getContrast) - .add_property("fade", &RS_Image::getFade) - .add_property("handle", &RS_Image::getHandle, &RS_Image::setHandle) - .add_property("imageWidth", &RS_Image::getImageWidth) - .add_property("imageHeight", &RS_Image::getImageHeight) - ; - - class_, std::auto_ptr > - ("Line", init()) - .add_property("data", &RS_Line::getData) - .add_property("startpoint", &RS_Line::getStartpoint, &RS_Line::setStartpoint) - .add_property("endpoint", &RS_Line::getEndpoint, &RS_Line::setEndpoint) - ; - - class_, std::auto_ptr > - ("Point", init()) - .add_property("pos", &RS_Point::getPos, &RS_Point::setPos) - ; - - class_, std::auto_ptr > - ("Polyline", init()) - .def(init()) - .add_property("startpoint", &RS_Polyline::getStartpoint, &RS_Polyline::setStartpoint) - .add_property("endpoint", &RS_Polyline::getEndpoint) - .add_property("closed", &RS_Polyline::isClosed) - .def("addVertex", &RS_Polyline::addVertex, return_value_policy()) - .def("createVertex", &RS_Polyline::createVertex, return_value_policy()) - .def("endPolyline", &RS_Polyline::endPolyline) - ; -} - -#endif diff --git a/src/base/rs_python_wrappers.h.bak b/src/base/rs_python_wrappers.h.bak deleted file mode 100644 index a07d00a..0000000 --- a/src/base/rs_python_wrappers.h.bak +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This function is automatically exported by the Boost::Python - * libraries. It adds the QCad scripting module to the environment - * - * OBSOLETE - */ -#ifdef RS_OPT_PYTHON -extern "C" void initqcad(); -#endif - diff --git a/src/base/rs_regexp.h.old b/src/base/rs_regexp.h.old deleted file mode 100644 index 576d634..0000000 --- a/src/base/rs_regexp.h.old +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** $Id: rs_regexp.h 1767 2003-10-22 18:17:51Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_REGEXP_H -#define RS_REGEXP_H - -//#include -#include - -#define RS_RegExp QRegExp - -#endif diff --git a/src/base/rs_script.cpp.bak b/src/base/rs_script.cpp.bak deleted file mode 100644 index 1e0ff42..0000000 --- a/src/base/rs_script.cpp.bak +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** $Id: rs_script.cpp 1938 2004-12-09 23:09:53Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_script.h" - -#include -//#include - - - -/** - * Constructor. - */ -RS_Script::RS_Script(const RS_String& name, const RS_String& /*path*/) { - this->name = name; -} - - -// EOF diff --git a/src/base/rs_script.h.bak b/src/base/rs_script.h.bak deleted file mode 100644 index 42ac1e7..0000000 --- a/src/base/rs_script.h.bak +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** $Id: rs_script.h 1960 2005-03-12 12:22:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_SCRIPT_H -#define RS_SCRIPT_H - -#include - -#include "rs_string.h" - - -/** - * Class for representing a script. This is implemented as a RS_String - * containing the script name. - * - * OBSOLETE - * - * @author Andrew Mustun - */ -class RS_Script { -public: - RS_Script(const RS_String& name, const RS_String& path); - //RS_Script(const char* name); - - /** @return the name of this script. */ - RS_String getName() const { - return name; - } - - /** @return the full path and file name of this script. */ - RS_String getPath() const { - return path; - } - -private: - //! Script name - RS_String name; - - //! Full path to script - RS_String path; -}; - -#endif - diff --git a/src/base/rs_scriptlist.cpp.bak b/src/base/rs_scriptlist.cpp.bak deleted file mode 100644 index c6a66b0..0000000 --- a/src/base/rs_scriptlist.cpp.bak +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** $Id: rs_scriptlist.cpp 1960 2005-03-12 12:22:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_scriptlist.h" - -#include "rs_fileinfo.h" -#include "rs_stringlist.h" -#include "rs_system.h" - -RS_ScriptList* RS_ScriptList::uniqueInstance = NULL; - -/** - * Default constructor. - */ -RS_ScriptList::RS_ScriptList() { - scripts.setAutoDelete(true); - //init(); - //scriptListListeners.setAutoDelete(false); - //activeScript = NULL; -} - - -/** - * Initializes the script list by creating RS_Script - * objects, one for each script that could be found. - */ -void RS_ScriptList::init() { - - RS_DEBUG->print("RS_ScriptList::initScripts"); - - scripts.clear(); - RS_StringList list = RS_SYSTEM->getScriptList(); - RS_Script* script; - - for ( RS_StringList::Iterator it = list.begin(); - it != list.end(); ++it ) { - RS_DEBUG->print("script: %s:", (*it).latin1()); - - RS_FileInfo fi(*it); - script = new RS_Script(fi.baseName(), fi.absFilePath()); - scripts.append(script); - - RS_DEBUG->print("base: %s", fi.baseName().latin1()); - RS_DEBUG->print("path: %s", fi.absFilePath().latin1()); - } - - //RS_Script* f = new RS_Script("normal"); - //scripts.append(f); -} - - -/** - * Removes all scripts in the scriptlist. - */ -void RS_ScriptList::clearScripts() { - scripts.clear(); -} - - - -/** - * Removes a script from the list. - * Listeners are notified after the script was removed from - * the list but before it gets deleted. - */ -void RS_ScriptList::removeScript(RS_Script* script) { - RS_DEBUG->print("RS_ScriptList::removeScript()"); - - // here the script is removed from the list but not deleted - scripts.remove(script); - - //for (uint i=0; iscriptRemoved(script); - //} - - // activate an other script if necessary: - //if (activeScript==script) { - // activateScript(scripts.first()); - //} - - // now it's save to delete the script - //delete script; -} - - - -/** - * @return Pointer to the script with the given name or - * \p NULL if no such script was found. The script will be loaded into - * memory if it's not already. - */ -RS_Script* RS_ScriptList::requestScript(const RS_String& name) { - RS_DEBUG->print("RS_ScriptList::requestScript %s", name.latin1()); - - RS_String name2 = name.lower(); - RS_Script* foundScript = NULL; - - RS_DEBUG->print("name2: %s", name2.latin1()); - - // Search our list of available scripts: - for (RS_Script* s=scripts.first(); - s!=NULL; - s=scripts.next()) { - - if (s->getName()==name2) { - foundScript = s; - break; - } - } - - // Script not found: - return foundScript; -} - - - -/** - * @return Pointer to the script with the given name or - * \p NULL if no such script was found. - */ -//RS_Script* RS_ScriptList::loadScript(const RS_String& name) { -//} - - -/** - * Tests the script list and its ability to load scripts. - */ -bool RS_ScriptList::test() { - - //RS_ScriptList* l = RS_ScriptList::instance(); - - //std::cout << "RS_ScriptList: " << *l << std::endl; - - return true; -} - - -// EOF diff --git a/src/base/rs_scriptlist.h.bak b/src/base/rs_scriptlist.h.bak deleted file mode 100644 index 413d701..0000000 --- a/src/base/rs_scriptlist.h.bak +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** $Id: rs_scriptlist.h 1960 2005-03-12 12:22:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_SCRIPTLIST_H -#define RS_SCRIPTLIST_H - - -#include "rs_script.h" -#include "rs_ptrlist.h" - -#define RS_SCRIPTLIST RS_ScriptList::instance() - -/** - * The global list of scripts. This is implemented as a singleton. - * Use RS_ScriptList::instance() to get a pointer to the object. - * - * OBSOLETE - * - * @author Andrew Mustun - */ -class RS_ScriptList { -protected: - RS_ScriptList(); - -public: - /** - * @return Instance to the unique script list. - */ - static RS_ScriptList* instance() { - if (uniqueInstance==NULL) { - uniqueInstance = new RS_ScriptList(); - } - return uniqueInstance; - } - - virtual ~RS_ScriptList() {} - - void init(); - - void clearScripts(); - int countScripts() { - return scripts.count(); - } - //void activateScript(const RS_String& name); - //void activateScript(RS_Script* script); - ////! @return The active script of NULL if no script is activated. - //RS_Script* getActiveScript() { return activeScript; } - //virtual void addScript(RS_Script* script); - virtual void removeScript(RS_Script* script); - //virtual void editScript(RS_Script* script, const RS_Script& source); - RS_Script* requestScript(const RS_String& name); - //RS_Script* loadScript(const RS_String& name); - //void toggleScript(const RS_String& name); - //! @return First script of the list. - RS_Script* firstScript() { - return scripts.first(); - } - /** @return Next script from the list after - * calling firstScript() or nextScript(). - */ - RS_Script* nextScript() { - return scripts.next(); - } - - //void addScriptListListener(RS_ScriptListListener* listener); - - static bool test(); - -protected: - static RS_ScriptList* uniqueInstance; - -private: - //! all scripts available - RS_PtrList scripts; - //! List of registered ScriptListListeners - //RS_PtrList scriptListListeners; - //! Currently active script - //RS_Script* activeScript; -} -; - -#endif diff --git a/src/base/rs_selection.cpp.bak b/src/base/rs_selection.cpp.bak deleted file mode 100644 index e31edeb..0000000 --- a/src/base/rs_selection.cpp.bak +++ /dev/null @@ -1,349 +0,0 @@ -/**************************************************************************** -** $Id: rs_selection.cpp 1888 2004-06-12 23:34:44Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_selection.h" - -#include "rs_information.h" -#include "rs_polyline.h" -#include "rs_entity.h" -#include "rs_graphic.h" - - - -/** - * Default constructor. - * - * @param container The container to which we will add - * entities. Usually that's an RS_Graphic entity but - * it can also be a polyline, text, ... - */ -RS_Selection::RS_Selection(RS_EntityContainer& container, - RS_GraphicView* graphicView) { - this->container = &container; - this->graphicView = graphicView; - graphic = container.getGraphic(); -} - - - -/** - * Selects or deselects the given entitiy. - */ -void RS_Selection::selectSingle(RS_Entity* e) { - if (e!=NULL && (e->getLayer()==NULL || e->getLayer()->isLocked()==false)) { - - if (graphicView!=NULL) { - graphicView->deleteEntity(e); - } - - e->toggleSelected(); - - if (graphicView!=NULL) { - graphicView->drawEntity(e); - } - } -} - - - -/** - * Selects all entities on visible layers. - */ -void RS_Selection::selectAll(bool select) { - if (graphicView!=NULL) { - //graphicView->deleteEntity(container); - } - - //container->setSelected(select); - for (RS_Entity* e=container->firstEntity(); - e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isVisible()) { - e->setSelected(select); - } - } - - if (graphicView!=NULL) { - //graphicView->drawEntity(container); - graphicView->redraw(); - } -} - - - -/** - * Selects all entities on visible layers. - */ -void RS_Selection::invertSelection() { - if (graphicView!=NULL) { - //graphicView->deleteEntity(container); - } - - for (RS_Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isVisible()) { - e->toggleSelected(); - } - } - - if (graphicView!=NULL) { - //graphicView->drawEntity(container); - graphicView->redraw(); - } -} - - - -/** - * Selects all entities that are completely in the given window. - * - * @param v1 First corner of the window to select. - * @param v2 Second corner of the window to select. - * @param select true: select, false: deselect - */ -void RS_Selection::selectWindow(const Vector& v1, const Vector& v2, - bool select, bool cross) { - - //if (graphicView!=NULL) { - // graphicView->drawWindow(v1, v2, true); - //} - - container->selectWindow(v1, v2, select, cross); - - if (graphicView!=NULL) { - //graphicView->drawWindow(v1, v2); - graphicView->redraw(); - } -} - - - -/** - * Selects all entities that are intersected by the given line. - * - * @param v1 Startpoint of line. - * @param v2 Endpoint of line. - * @param select true: select, false: deselect - */ -void RS_Selection::selectIntersected(const Vector& v1, const Vector& v2, - bool select) { - - RS_Line line(NULL, RS_LineData(v1, v2)); - bool inters; - - for (RS_Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isVisible()) { - - inters = false; - - // select containers / groups: - if (e->isContainer()) { - RS_EntityContainer* ec = (RS_EntityContainer*)e; - - for (RS_Entity* e2=ec->firstEntity(RS2::ResolveAll); e2!=NULL; - e2=ec->nextEntity(RS2::ResolveAll)) { - - VectorSolutions sol = - RS_Information::getIntersection(&line, e2, true); - - if (sol.hasValid()) { - inters = true; - } - } - } else { - - VectorSolutions sol = - RS_Information::getIntersection(&line, e, true); - - if (sol.hasValid()) { - inters = true; - } - } - - if (inters) { - if (graphicView!=NULL) { - graphicView->deleteEntity(e); - } - - e->setSelected(select); - - if (graphicView!=NULL) { - graphicView->drawEntity(e); - } - } - } - } - -} - - - -/** - * Selects all entities that are connected to the given entity. - * - * @param e The entity where the algorithm starts. Must be an atomic entity. - */ -void RS_Selection::selectContour(RS_Entity* e) { - - if (e==NULL) { - return; - } - - if (!e->isAtomic()) { - return; - } - - bool select = !e->isSelected(); - RS_AtomicEntity* ae = (RS_AtomicEntity*)e; - Vector p1 = ae->getStartpoint(); - Vector p2 = ae->getEndpoint(); - bool found = false; - - // (de)select 1st entity: - if (graphicView!=NULL) { - graphicView->deleteEntity(e); - } - e->setSelected(select); - if (graphicView!=NULL) { - graphicView->drawEntity(e); - } - - do { - found = false; - - for (RS_Entity* en=container->firstEntity(); en!=NULL; - en=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* en = container->entityAt(i); - - if (en!=NULL && en->isVisible() && - en->isAtomic() && en->isSelected()!=select && - (en->getLayer()==NULL || en->getLayer()->isLocked()==false)) { - - ae = (RS_AtomicEntity*)en; - bool doit = false; - - // startpoint connects to 1st point - if (ae->getStartpoint().distanceTo(p1)<1.0e-4) { - doit = true; - p1 = ae->getEndpoint(); - } - - // endpoint connects to 1st point - else if (ae->getEndpoint().distanceTo(p1)<1.0e-4) { - doit = true; - p1 = ae->getStartpoint(); - } - - // startpoint connects to 2nd point - else if (ae->getStartpoint().distanceTo(p2)<1.0e-4) { - doit = true; - p2 = ae->getEndpoint(); - } - - // endpoint connects to 1st point - else if (ae->getEndpoint().distanceTo(p2)<1.0e-4) { - doit = true; - p2 = ae->getStartpoint(); - } - - if (doit) { - if (graphicView!=NULL) { - graphicView->deleteEntity(ae); - } - ae->setSelected(select); - if (graphicView!=NULL) { - graphicView->drawEntity(ae); - } - found = true; - } - } - } - } while(found); -} - - - -/** - * Selects all entities on the given layer. - */ -void RS_Selection::selectLayer(RS_Entity* e) { - - if (e==NULL) { - return; - } - - bool select = !e->isSelected(); - - RS_Layer* layer = e->getLayer(true); - if (layer==NULL) { - return; - } - - RS_String layerName = layer->getName(); - selectLayer(layerName, select); -} - - - -/** - * Selects all entities on the given layer. - */ -void RS_Selection::selectLayer(const RS_String& layerName, bool select) { - - for (RS_Entity* en=container->firstEntity(); en!=NULL; - en=container->nextEntity()) { - - if (en!=NULL && en->isVisible() && - en->isSelected()!=select && - (en->getLayer()==NULL || en->getLayer()->isLocked()==false)) { - - RS_Layer* l = en->getLayer(true); - - if (l!=NULL && l->getName()==layerName) { - if (graphicView!=NULL) { - graphicView->deleteEntity(en); - } - en->setSelected(select); - if (graphicView!=NULL) { - graphicView->drawEntity(en); - } - } - } - } -} - -// EOF diff --git a/src/base/rs_selection.h.bak b/src/base/rs_selection.h.bak deleted file mode 100644 index 2157c9d..0000000 --- a/src/base/rs_selection.h.bak +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** $Id: rs_selection.h 1868 2004-04-05 23:12:06Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_SELECTION_H -#define RS_SELECTION_H - -#include "rs_entitycontainer.h" -#include "rs_graphicview.h" - - - -/** - * API Class for selecting entities. - * There's no interaction handled in this class. - * This class is connected to an entity container and - * can be connected to a graphic view. - * - * @author Andrew Mustun - */ -class RS_Selection { -public: - RS_Selection(RS_EntityContainer& entityContainer, - RS_GraphicView* graphicView=NULL); - - void selectSingle(RS_Entity* e); - void selectAll(bool select=true); - void deselectAll() { - selectAll(false); - } - void invertSelection(); - void selectWindow(const Vector& v1, const Vector& v2, - bool select=true, bool cross=false); - void deselectWindow(const Vector& v1, const Vector& v2) { - selectWindow(v1, v2, false); - } - void selectIntersected(const Vector& v1, const Vector& v2, - bool select=true); - void deselectIntersected(const Vector& v1, const Vector& v2) { - selectIntersected(v1, v2, false); - } - void selectContour(RS_Entity* e); - - void selectLayer(RS_Entity* e); - void selectLayer(const RS_String& layerName, bool select=true); - void deselectLayer(RS_String& layerName) { - selectLayer(layerName, false); - } - -protected: - RS_EntityContainer* container; - RS_Graphic* graphic; - RS_GraphicView* graphicView; -}; - -#endif diff --git a/src/base/rs_settings.cpp.old b/src/base/rs_settings.cpp.old deleted file mode 100644 index 7d0e04b..0000000 --- a/src/base/rs_settings.cpp.old +++ /dev/null @@ -1,163 +0,0 @@ -// rs_settings.cpp -// -// Originally part of QCad Community Edition by Andrew Mustun -// Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 05/19/2010 Created this file. :-) -// - -#include "rs_settings.h" - -// Class variable -RS_Settings * RS_Settings::uniqueInstance = NULL; - -RS_Settings::RS_Settings(): - initialized(false), companyKey(""), appKey(""), group("") -{ -} - -/** - * Destructor - */ -RS_Settings::~RS_Settings() -{ - // Needed since QList doesn't have AutoDelete... - while (!cache.isEmpty()) - { - QString * value = *cache.begin(); - cache.erase(cache.begin()); - delete value; - } -} - -// Class method -/** - * @return Instance to the unique settings object. - */ -RS_Settings * RS_Settings::instance() -{ - if (uniqueInstance == NULL) - uniqueInstance = new RS_Settings(); - - return uniqueInstance; -} - -/** - * Initialisation. - * - * @param companyKey String that identifies the company. Must start - * with a "/". E.g. "/RibbonSoft" - * @param appKey String that identifies the application. Must start - * with a "/". E.g. "/QCad2" - */ -void RS_Settings::init(const QString & comp, const QString & app) -{ - group = ""; - appKey = app; - companyKey = comp; - -//In Qt4, there is no such thing as a search path anymore... - //insertSearchPath(QSettings::Windows, companyKey + appKey); - //insertSearchPath(QSettings::Unix, "/usr/share/"); - initialized = true; -} - -void RS_Settings::beginGroup(const QString & grp) -{ - group = grp; -} - -void RS_Settings::endGroup() -{ - group = ""; -} - -bool RS_Settings::writeEntry(const QString & key, int value) -{ - QString s = QString("%1").arg(value); - return writeEntry(key, s); -} - -bool RS_Settings::writeEntry(const QString & key, double value) -{ - QString s = QString("%1").arg(value); - return writeEntry(key, s); -} - -bool RS_Settings::writeEntry(const QString & key, const QString & value) -{ -//[DONE, mostly]#warning "!!! Need to revamp outdated settings system !!!" - QSettings settings("Underground Software", "Architektonas"); - -// bool ret = s.writeEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key), value); - settings.setValue(QString("%1%2").arg(group).arg(key), value); - addToCache(key, value); - -// return ret; - // The old system told you if it failed or not, but the new assumes success - return true; -} - -QString RS_Settings::readEntry(const QString & key, const QString & def, bool * ok) -{ - // lookup: - QString entry = readEntryCache(key); - - if (entry != QString::null) - return entry; - - QSettings settings("Underground Software", "Architektonas"); - - QString s = QString("%1%2").arg(group).arg(key); - - if (ok) - *ok = settings.contains(s); - -// ret = s.readEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key), def, ok); - entry = settings.value(s, def).toString(); - addToCache(key, entry); - - return entry; -} - -int RS_Settings::readNumEntry(const QString & key, int def, bool * ok) -{ - // lookup: - QString result = readEntryCache(key); - - if (result != QString::null) - return result.toInt(); - - QSettings settings("Underground Software", "Architektonas"); - -// int ret = s.readNumEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key), def, ok); - QString s = QString("%1%2").arg(group).arg(key); - - if (ok) - *ok = settings.contains(s); - - int entry = settings.value(s, def).toInt(); - addToCache(key, QString("%1").arg(entry)); - - return entry; -} - -QString RS_Settings::readEntryCache(const QString & key) -{ - QString * s = cache.value(key); - - if (s == NULL) - return QString::null; - - return *s; -} - -void RS_Settings::addToCache(const QString & key, const QString & value) -{ - cache.replace(key, new QString(value)); -} diff --git a/src/base/rs_settings.h.old b/src/base/rs_settings.h.old deleted file mode 100644 index 798b814..0000000 --- a/src/base/rs_settings.h.old +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef RS_SETTINGS_H -#define RS_SETTINGS_H - -#include - -#define RS_SETTINGS RS_Settings::instance() - -/** - * This class can store and reload settings from a - * configuration file or the windoze registry. - * Please note that the Qt default implementation doesn't - * work as one would expect. That's why this class overwrites - * most of the default behaviour. - * - */ -class RS_Settings -{ - public: - RS_Settings(); - ~RS_Settings(); - - public: - // Class method - static RS_Settings * instance(); - - /** - * Initialize the system. - * - * @param appName Application name - * @param appDirName Application directory name used for - * subdirectories in /usr, /etc ~/. - */ - void init(const QString & comp, const QString & app); - - void beginGroup(const QString & grp); - void endGroup(); - - bool writeEntry(const QString & key, int value); - bool writeEntry(const QString & key, double value); - bool writeEntry(const QString & key, const QString & value); - QString readEntry(const QString & key, const QString & def = QString::null, bool * ok = 0); - int readNumEntry(const QString & key, int def = 0, bool * ok = 0); - - QString readEntryCache(const QString & key); - void addToCache(const QString & key, const QString & value); - - protected: - // Class variable - static RS_Settings * uniqueInstance; - -// Q3Dict cache; - QMultiHash cache; - bool initialized; - QString companyKey; - QString appKey; - QString group; -}; - -#endif diff --git a/src/base/rs_simplepython.cpp.bak b/src/base/rs_simplepython.cpp.bak deleted file mode 100644 index a26d264..0000000 --- a/src/base/rs_simplepython.cpp.bak +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** $Id: rs_simplepython.cpp 1775 2003-11-02 12:20:46Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifdef RS_OPT_SIMPLEPYTHON -#include "rs_simplepython.h" - - -RS_SimplePython* RS_SimplePython::uniqueInstance = NULL; - - -/** - * Gets the one and only RS_SimplePython instance - * (creates a new one on first call only) - * - * @return Pointer to the single instance of this - * singleton class - */ -RS_SimplePython* RS_SimplePython::instance() { - if(uniqueInstance==NULL) { - uniqueInstance = new RS_SimplePython; - } - return uniqueInstance; -} - - -/** - * Launches the given script. - */ -int RS_SimplePython::launch(const RS_String& script) { - long answer; - PyObject *modname, *mod, *mdict, *func, *rslt; - //Py_SetProgramName(argv[0]); - Py_Initialize(); - init_pyextension(); - modname = PyString_FromString(script); - mod = PyImport_Import(modname); - if (mod) { - //printf( "mod\n"); - mdict = PyModule_GetDict(mod); - - // Borrowed reference to start function - func = PyDict_GetItemString(mdict, "start"); - if (func) { - //printf( "func\n"); - if (PyCallable_Check(func)) { - //printf("calling..\n"); - rslt = PyObject_CallFunction(func, "(s)", "noparam"); - //printf("calling ok\n"); - if (rslt) { - //printf("c: rslt\n"); - answer = PyInt_AsLong(rslt); - //printf("c: answer is: %ld\n", answer); - Py_XDECREF(rslt); - } - } - } else { - printf("no such function: start\n"); - } - Py_XDECREF(mod); - } else { - printf("no such module: %s\n", script.latin1()); - } - Py_XDECREF(modname); - Py_Finalize(); - return 0; -} - - -/** - * A test method exposed to Python - */ -long inc(long i) { - printf("c: inc called\n"); - printf("c: parameter from python: %ld\n", i); - return ++i; -} - -/** - * The magic that exposes inc(). A wrapper function. - */ -static PyObject *py_inc(PyObject* /*self*/, PyObject* args) { - long i; - printf("c: py_inc called\n"); - if (!PyArg_ParseTuple(args, "l", &i)) - return NULL; - return Py_BuildValue("l", inc(i)); -} - -/** - * Adds a line to the current graphic document. - */ -void rsPyAddLine(double x1, double y1, double x2, double y2) { - //printf("c: addLine called\n"); - //printf("c: parameter from python: %f\n", x1); - - RS_Graphic* graphic = RS_SIMPLEPYTHON->getGraphic(); - if (graphic!=NULL) { - graphic->addEntity(new RS_Line(graphic, - RS_LineData(RS_Vector(x1, y1), - RS_Vector(x2, y2)))); - } else { - std::cerr << "rsPyAddLine: No graphic object set.\n"; - } -} - -/** - * Python wrapper. - */ -static PyObject *py_rsPyAddLine(PyObject* /*self*/, PyObject* args) { - double x1, y1, x2, y2; - //printf("c: py_rsPyAddLine called\n"); - if (!PyArg_ParseTuple(args, "dddd", &x1, &y1, &x2, &y2)) { - return NULL; - } - rsPyAddLine(x1, y1, x2, y2); - return Py_BuildValue("d", 1); -} - -/** - * The qcadlib module's function table. - */ -static PyMethodDef rsQCadMethods[] = - { - {"inc", py_inc, 1, - "a silly example method"}, - {"rsPyAddLine", py_rsPyAddLine, 1, - "adds a line to the current document"}, - {NULL, NULL} /* sentinel */ - }; - -/** - * Python will call this when the qcadlib module is imported. - */ -void init_pyextension() { - printf("c: adding module: qcad\n"); - PyImport_AddModule("qcad"); - Py_InitModule("qcad", rsQCadMethods); - printf("c: module qcad: OK\n"); -} - -#endif diff --git a/src/base/rs_simplepython.h.bak b/src/base/rs_simplepython.h.bak deleted file mode 100644 index 4fbd1b2..0000000 --- a/src/base/rs_simplepython.h.bak +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** $Id: rs_simplepython.h 1960 2005-03-12 12:22:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef RS_SIMPLEPYTHON_H -#define RS_SIMPLEPYTHON_H - -#ifdef RS_OPT_SIMPLEPYTHON - -#include "Python.h" - -#include "rs_graphic.h" - -#define RS_SIMPLEPYTHON RS_SimplePython::instance() - -/** - * Python scripting support. - * - * OBSOLETE - * - * @author Andrew Mustun - */ -class RS_SimplePython { -private: - RS_SimplePython() { - graphic = NULL; - } - -public: - static RS_SimplePython* instance(); - - void setGraphic(RS_Graphic* g) { - graphic = g; - } - - RS_Graphic* getGraphic() { - return graphic; - } - - int launch(const RS_String& script); - -private: - static RS_SimplePython* uniqueInstance; - - RS_Graphic* graphic; -}; - - - -/** - * Global method needed by the python lib for initialisation. - */ -void init_pyextension(); - -/** - * Test method. - */ -long inc(long i); - -/** - * Adds a line to the current graphic document. - */ -void rsPyAddLine(double x1, double y1, double x2, double y2); - -#endif - -#endif diff --git a/src/base/rs_string.cpp.old b/src/base/rs_string.cpp.old deleted file mode 100644 index 3189f07..0000000 --- a/src/base/rs_string.cpp.old +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** $Id: rs_string.cpp 1769 2003-10-22 19:46:31Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "rs_string.h" - -#include - -RS_String RS_StringCompat::replace(const RS_String & str, RS_Char c1, RS_Char c2) -{ - RS_String ret = str; - - for(uint i=0; i - -//#include -#include - -#define RS_String QString -#define RS_Char QChar - -class RS_StringCompat -{ - public: - static RS_String replace(const RS_String & str, RS_Char c1, RS_Char c2); - static RS_String replace(const RS_String & str, const RS_String & s1, const RS_String & s2); - static void test(); -}; - -#endif diff --git a/src/base/rs_stringlist.h.old b/src/base/rs_stringlist.h.old deleted file mode 100644 index 20b268c..0000000 --- a/src/base/rs_stringlist.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_stringlist.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_STRINGLIST_H -#define RS_STRINGLIST_H - -//#include -#include - -#define RS_StringList QStringList - -#endif diff --git a/src/base/rs_textstream.h.old b/src/base/rs_textstream.h.old deleted file mode 100644 index 64d3a19..0000000 --- a/src/base/rs_textstream.h.old +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** $Id: rs_textstream.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_TEXTSTREAM_H -#define RS_TEXTSTREAM_H - -//#include -//#include -#include - -#define RS_TextStream Q3TextStream -#define RS_TextCodec QTextCodec - -#endif diff --git a/src/base/rs_translator.h.old b/src/base/rs_translator.h.old deleted file mode 100644 index 8db16aa..0000000 --- a/src/base/rs_translator.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_translator.h 1677 2003-08-08 23:33:46Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_TRANSLATOR_H -#define RS_TRANSLATOR_H - -//#include -#include - -#define RS_Translator QTranslator - -#endif diff --git a/src/base/rs_valuelist.h.old b/src/base/rs_valuelist.h.old deleted file mode 100644 index 248bd08..0000000 --- a/src/base/rs_valuelist.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_valuelist.h 1648 2003-06-11 06:56:01Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_VALUELIST_H -#define RS_VALUELIST_H - -//#include -#include - -#define RS_ValueList Q3ValueList - -#endif diff --git a/src/base/rs_valuevector.h.old b/src/base/rs_valuevector.h.old deleted file mode 100644 index a6b56d0..0000000 --- a/src/base/rs_valuevector.h.old +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** $Id: rs_valuevector.h 1892 2004-07-09 23:54:59Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef RS_VALUEVECTOR_H -#define RS_VALUEVECTOR_H - -//#include -#include - -#define RS_ValueVector Q3ValueVector - -#endif diff --git a/src/widgets/qg_actionfactory.cpp.old b/src/widgets/qg_actionfactory.cpp.old deleted file mode 100644 index 24b238b..0000000 --- a/src/widgets/qg_actionfactory.cpp.old +++ /dev/null @@ -1,1066 +0,0 @@ -// qg_actionfactory.cpp -// -// Part of the Architektonas Project -// Originally part of QCad Community Edition by Andrew Mustun -// Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 05/21/2010 Added this text. :-) -// - -#include "qg_actionfactory.h" - -#include "rs_actionblockscreate.h" -#include "rs_actionblocksfreezeall.h" -#include "rs_actionblocksadd.h" -#include "rs_actionblocksremove.h" -#include "rs_actionblocksattributes.h" -#include "rs_actionblocksedit.h" -#include "rs_actionblocksinsert.h" -#include "rs_actionblockstoggleview.h" -#include "rs_actionblocksexplode.h" -#include "rs_actiondimaligned.h" -#include "rs_actiondimangular.h" -#include "rs_actiondimdiametric.h" -#include "rs_actiondimleader.h" -#include "rs_actiondimlinear.h" -#include "rs_actiondimradial.h" -#include "rs_actiondrawarc.h" -#include "rs_actiondrawarc3p.h" -#include "rs_actiondrawcircle.h" -#include "rs_actiondrawcircle2p.h" -#include "rs_actiondrawcircle3p.h" -#include "rs_actiondrawcirclecr.h" -#include "rs_actiondrawellipseaxis.h" -#include "rs_actiondrawhatch.h" -#include "rs_actiondrawimage.h" -#include "rs_actiondrawline.h" -#include "rs_actiondrawlineangle.h" -#include "rs_actiondrawlinebisector.h" -#include "rs_actiondrawlinefree.h" -#include "rs_actiondrawlinehorvert.h" -#include "rs_actiondrawlineparallel.h" -#include "rs_actiondrawlineparallelthrough.h" -#include "rs_actiondrawlinepolygon.h" -#include "rs_actiondrawlinepolygon2.h" -#include "rs_actiondrawlinerectangle.h" -#include "rs_actiondrawlinerelangle.h" -#include "rs_actiondrawlinetangent1.h" -#include "rs_actiondrawlinetangent2.h" -#include "rs_actiondrawpoint.h" -#include "rs_actiondrawspline.h" -#include "rs_actiondrawtext.h" -#include "rs_actioneditcopy.h" -#include "rs_actioneditpaste.h" -#include "rs_actioneditundo.h" -#include "rs_actionfilenew.h" -#include "rs_actionfileopen.h" -#include "rs_actionfilesave.h" -#include "rs_actionfilesaveas.h" -#include "rs_actioninfoangle.h" -#include "rs_actioninfodist.h" -#include "rs_actioninfodist2.h" -#include "rs_actioninfoinside.h" -#include "rs_actioninfototallength.h" -#include "rs_actionlayersadd.h" -#include "rs_actionlayersedit.h" -#include "rs_actionlayersfreezeall.h" -#include "rs_actionlayersremove.h" -#include "rs_actionlayerstogglelock.h" -#include "rs_actionlayerstoggleview.h" -#include "rs_actionlockrelativezero.h" -#include "rs_actionmodifyattributes.h" -#include "rs_actionmodifybevel.h" -#include "rs_actionmodifymirror.h" -#include "rs_actionmodifycut.h" -#include "rs_actionmodifydelete.h" -#include "rs_actionmodifydeletefree.h" -#include "rs_actionmodifydeletequick.h" -#include "rs_actionmodifyentity.h" -#include "rs_actionmodifymove.h" -#include "rs_actionmodifymoverotate.h" -#include "rs_actionmodifyrotate.h" -#include "rs_actionmodifyround.h" -#include "rs_actionmodifyscale.h" -#include "rs_actionmodifystretch.h" -#include "rs_actionmodifytrim.h" -#include "rs_actionmodifytrimamount.h" -#include "rs_actionmodifyexplodetext.h" -#include "rs_actionoptionsdrawing.h" -#include "rs_actionprintpreview.h" -#include "rs_actionselectall.h" -#include "rs_actionselectintersected.h" -#include "rs_actionselectinvert.h" -#include "rs_actionselectlayer.h" -#include "rs_actionselectsingle.h" -#include "rs_actionselectcontour.h" -#include "rs_actionselectwindow.h" -#include "rs_actionsetrelativezero.h" -#include "rs_actionsnapintersectionmanual.h" -#include "rs_actiontoolregeneratedimensions.h" -#include "rs_actionzoomauto.h" -#include "rs_actionzoomprevious.h" -#include "rs_actionzoomin.h" -#include "rs_actionzoompan.h" -#include "rs_actionzoomredraw.h" -#include "rs_actionzoomwindow.h" - -#ifdef RS_PROF -#include "rs_actiondrawpolyline.h" -#include "rs_actionpolylineadd.h" -#include "rs_actionpolylinedel.h" -#include "rs_actionpolylinedelbetween.h" -#include "rs_actionpolylinetrim.h" -#endif - -#ifdef RS_CAM -#include "rs_actioncamexportauto.h" -#include "rs_actioncamreorder.h" -#endif - -/** - * Constructor. - * - * @param ah Action handler which provides the slots. - * @param w Widget through which the events come in. - */ -QG_ActionFactory::QG_ActionFactory(QG_ActionHandler * ah, QWidget * w) -{ - actionHandler = ah; - widget = w; -} - -/** - * Destructor - */ -QG_ActionFactory::~QG_ActionFactory() -{ -} - -/** - * Creates a new action object and links it to the appropriate slot(s). - * - * @param id ID of the action to create (see rs.h). - * @param obj Object which the action will connect its signal to. - * - * @return Pointer to the action object or NULL if the action is unknown. - */ -QAction * QG_ActionFactory::createAction(RS2::ActionType id, QObject * obj) -{ - // assert that action handler is not invalid: - if (actionHandler == NULL) - { - RS_DEBUG->print(RS_Debug::D_WARNING, "QG_ActionFactory::createAction: " - "No valid action handler available to create action. id: %d", id); - return NULL; - } - - QWidget * mw = widget; - QAction * action = NULL; - QPixmap icon; - - if (mw == NULL) - { - RS_DEBUG->print(RS_Debug::D_WARNING, "QG_ActionFactory::createAction: " - "No valid main window available to create action. id: %d ", id); - return NULL; - } - - // create requested action - switch (id) - { - // File actions: - // - case RS2::ActionFileNew: - action = RS_ActionFileNew::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileNew())); - break; - - case RS2::ActionFileOpen: - action = RS_ActionFileOpen::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileOpen())); - break; - - case RS2::ActionFileSave: - action = RS_ActionFileSave::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileSave())); - break; - - case RS2::ActionFileSaveAs: - action = RS_ActionFileSaveAs::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileSaveAs())); - break; - - case RS2::ActionFileExport: - action = new QAction(tr("&Export..."), mw); -// action = new QAction(tr("Export Drawing"), tr("&Export..."), -// 0, mw); - action->setStatusTip(tr("Exports the current drawing as bitmap")); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileExport())); - break; - - case RS2::ActionFileClose: - action = new QAction(QIcon(":/res/fileclose.png"), tr("&Close"), mw); - action->setShortcut(Qt::CTRL + Qt::Key_W); -// action = new QAction(tr("Close Drawing"), qPixmapFromMimeSource("fileclose.png"), tr("&Close"), -// Qt::CTRL+Qt::Key_W, mw); - action->setStatusTip(tr("Closes the current drawing")); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileClose())); - break; - - case RS2::ActionFilePrint: - action = new QAction(QIcon(":/res/fileprint.png"), tr("&Print..."), mw); - action->setShortcut(Qt::CTRL + Qt::Key_P); -// icon = qPixmapFromMimeSource("fileprint.png"); -// action = new QAction(tr("Print Drawing"), icon, tr("&Print..."), -// Qt::CTRL+Qt::Key_P, mw); - action->setStatusTip(tr("Prints out the current drawing")); - connect(action, SIGNAL(activated()), obj, SLOT(slotFilePrint())); - break; - - case RS2::ActionFilePrintPreview: - action = RS_ActionPrintPreview::createGUIAction(id, mw); -// action->setToggleAction(true); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), obj, SLOT(slotFilePrintPreview(bool))); - break; - - case RS2::ActionFileQuit: - action = new QAction(QIcon(":/res/exit.png"), tr("&Quit"), mw); - action->setShortcut(Qt::CTRL + Qt::Key_Q); -// action = new QAction(tr("Quit"), qPixmapFromMimeSource("exit.png"), -// tr("&Quit"), -// Qt::CTRL+Qt::Key_Q, mw); - action->setStatusTip(tr("Quits the application")); - connect(action, SIGNAL(activated()), obj, SLOT(slotFileQuit())); - break; - - // Viewing actions: - // - case RS2::ActionViewGrid: - action = new QAction(QIcon(":/res/viewgrid.png"), tr("&Grid"), mw); - action->setCheckable(true); -// icon = qPixmapFromMimeSource("viewgrid.png"); -// action = new QAction(tr("Grid"), icon, tr("&Grid"), -// 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the grid")); - connect(action, SIGNAL(toggled(bool)), obj, SLOT(slotViewGrid(bool))); - break; - case RS2::ActionViewDraft: - action = new QAction(QIcon(":/res/viewdraft.png"), tr("&Draft"), mw); - action->setCheckable(true); -// icon = qPixmapFromMimeSource("viewdraft.png"); -// action = new QAction(tr("Draft"), icon, tr("&Draft"), -// 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the draft mode")); - connect(action, SIGNAL(toggled(bool)), obj, SLOT(slotViewDraft(bool))); - break; - case RS2::ActionViewStatusBar: -//NOTE: This works!!! shortcut combo is displayed on the right side!!! - action = new QAction(tr("&Statusbar") + QString("\tsb"), mw); - action->setCheckable(true); -// action = new QAction(tr("Statusbar"), tr("&Statusbar"), -// 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the statusbar")); - connect(action, SIGNAL(toggled(bool)), obj, SLOT(slotViewStatusBar(bool))); - break; - /* - case RS2::ActionViewLayerList: - action = new QAction(tr("Layer List"), tr("&Layer List"), - 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the layerlist")); - connect(action, SIGNAL(toggled(bool)), - obj, SLOT(slotViewLayerList(bool))); - break; - - case RS2::ActionViewBlockList: - action = new QAction(tr("Block List"), tr("&Block List"), - 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the blocklist")); - connect(action, SIGNAL(toggled(bool)), - obj, SLOT(slotViewBlockList(bool))); - break; - - case RS2::ActionViewCommandLine: - action = new QAction(tr("Command Widget"), tr("&Command Widget"), - 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the command widget")); - connect(action, SIGNAL(toggled(bool)), - obj, SLOT(slotViewCommandLine(bool))); - break; - - case RS2::ActionViewOptionToolbar: - action = new QAction(tr("Option Toolbar"), tr("&Option Toolbar"), - 0, mw, 0, true); - action->setStatusTip(tr("Enables/disables the option toolbar")); - connect(action, SIGNAL(toggled(bool)), - obj, SLOT(slotViewOptionToolbar(bool))); - break; - */ - - // Tools: - // - case RS2::ActionToolRegenerateDimensions: - action = RS_ActionToolRegenerateDimensions::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotToolRegenerateDimensions())); - break; - - // Zooming actions: - // - case RS2::ActionZoomIn: - action = RS_ActionZoomIn::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomIn())); - break; - - case RS2::ActionZoomOut: - action = RS_ActionZoomIn::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomOut())); - break; - - case RS2::ActionZoomAuto: - action = RS_ActionZoomAuto::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomAuto())); - break; - - case RS2::ActionZoomWindow: - action = RS_ActionZoomWindow::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomWindow())); - break; - - case RS2::ActionZoomPan: - action = RS_ActionZoomPan::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomPan())); - break; - - case RS2::ActionZoomPrevious: - action = RS_ActionZoomPrevious::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomPrevious())); - break; - - case RS2::ActionZoomRedraw: - action = RS_ActionZoomRedraw::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotZoomRedraw())); - break; - - // Editing actions: - // - case RS2::ActionEditUndo: - action = RS_ActionEditUndo::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotEditUndo())); - break; - - case RS2::ActionEditRedo: - action = RS_ActionEditUndo::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotEditRedo())); - break; - - case RS2::ActionEditCut: - action = RS_ActionEditCopy::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotEditCut())); - break; - - case RS2::ActionEditCopy: - action = RS_ActionEditCopy::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotEditCopy())); - break; - - case RS2::ActionEditPaste: - action = RS_ActionEditPaste::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotEditPaste())); - break; - - // Selecting actions: - // - case RS2::ActionSelectSingle: - action = RS_ActionSelectSingle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectSingle())); - break; - - case RS2::ActionSelectWindow: - action = RS_ActionSelectWindow::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectWindow())); - break; - - case RS2::ActionDeselectWindow: - action = RS_ActionSelectWindow::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDeselectWindow())); - break; - - case RS2::ActionSelectContour: - action = RS_ActionSelectContour::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectContour())); - break; - - case RS2::ActionSelectAll: - action = RS_ActionSelectAll::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectAll())); - break; - - case RS2::ActionDeselectAll: - action = RS_ActionSelectAll::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDeselectAll())); - break; - - case RS2::ActionSelectInvert: - action = RS_ActionSelectInvert::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectInvert())); - break; - - case RS2::ActionSelectIntersected: - action = RS_ActionSelectIntersected::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectIntersected())); - break; - - case RS2::ActionDeselectIntersected: - action = RS_ActionSelectIntersected::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDeselectIntersected())); - break; - - case RS2::ActionSelectLayer: - action = RS_ActionSelectLayer::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSelectLayer())); - break; - - // Drawing actions: - // - case RS2::ActionDrawPoint: - action = RS_ActionDrawPoint::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawPoint())); - break; - - case RS2::ActionDrawLine: - action = RS_ActionDrawLine::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLine())); - break; - - case RS2::ActionDrawLineAngle: - action = RS_ActionDrawLineAngle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineAngle())); - break; - - case RS2::ActionDrawLineHorizontal: - action = RS_ActionDrawLineAngle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineHorizontal())); - break; - - case RS2::ActionDrawLineHorVert: - action = RS_ActionDrawLineHorVert::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineHorVert())); - break; - - case RS2::ActionDrawLineVertical: - action = RS_ActionDrawLineAngle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineVertical())); - break; - - case RS2::ActionDrawLineFree: - action = RS_ActionDrawLineFree::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineFree())); - break; - - case RS2::ActionDrawLineParallel: - action = RS_ActionDrawLineParallel::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineParallel())); - break; - - case RS2::ActionDrawLineParallelThrough: - action = RS_ActionDrawLineParallelThrough::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineParallelThrough())); - break; - - case RS2::ActionDrawLineRectangle: - action = RS_ActionDrawLineRectangle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineRectangle())); - break; - - case RS2::ActionDrawLineBisector: - action = RS_ActionDrawLineBisector::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineBisector())); - break; - - case RS2::ActionDrawLineTangent1: - action = RS_ActionDrawLineTangent1::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineTangent1())); - break; - - case RS2::ActionDrawLineTangent2: - action = RS_ActionDrawLineTangent2::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineTangent2())); - break; - - case RS2::ActionDrawLineOrthogonal: - action = RS_ActionDrawLineRelAngle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineOrthogonal())); - break; - - case RS2::ActionDrawLineRelAngle: - action = RS_ActionDrawLineRelAngle::createGUIAction(id, mw); - /* - action = new QAction(tr("Relative angle"), tr("R&elative angle"), - 0, mw); - action->setStatusTip(tr("Draw line with relative angle")); - */ - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLineRelAngle())); - break; - -#ifdef RS_PROF - case RS2::ActionDrawPolyline: - action = RS_ActionDrawPolyline::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawPolyline())); - break; -#endif - - case RS2::ActionDrawLinePolygon: - action = RS_ActionDrawLinePolygon::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLinePolygon())); - break; - - case RS2::ActionDrawLinePolygon2: - action = RS_ActionDrawLinePolygon::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawLinePolygon2())); - break; - - case RS2::ActionDrawCircle: - action = RS_ActionDrawCircle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawCircle())); - break; - - case RS2::ActionDrawCircleCR: - action = RS_ActionDrawCircleCR::createGUIAction(id, mw); - /* - action = new QAction(tr("Circle: Center, Radius"), - tr("Center, &Radius"), - 0, mw); - action->setStatusTip(tr("Draw circles with center and radius")); - */ - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawCircleCR())); - break; - - case RS2::ActionDrawCircle2P: - action = RS_ActionDrawCircle2P::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawCircle2P())); - break; - - case RS2::ActionDrawCircle3P: - action = RS_ActionDrawCircle3P::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawCircle3P())); - break; - - case RS2::ActionDrawCircleParallel: - action = RS_ActionDrawLineParallel::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawCircleParallel())); - break; - - case RS2::ActionDrawArc: - action = RS_ActionDrawArc::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawArc())); - break; - - case RS2::ActionDrawArc3P: - action = RS_ActionDrawArc3P::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawArc3P())); - break; - - case RS2::ActionDrawArcParallel: - action = RS_ActionDrawLineParallel::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawArcParallel())); - break; - - case RS2::ActionDrawEllipseAxis: - action = RS_ActionDrawEllipseAxis::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawEllipseAxis())); - break; - - case RS2::ActionDrawEllipseArcAxis: - action = RS_ActionDrawEllipseAxis::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawEllipseArcAxis())); - break; - - case RS2::ActionDrawSpline: - action = RS_ActionDrawSpline::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawSpline())); - break; - -#ifdef RS_PROF - case RS2::ActionPolylineAdd: - action = RS_ActionPolylineAdd::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotPolylineAdd())); - break; - - case RS2::ActionPolylineDel: - action = RS_ActionPolylineDel::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotPolylineDel())); - break; - - case RS2::ActionPolylineDelBetween: - action = RS_ActionPolylineDelBetween::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotPolylineDelBetween())); - break; - - case RS2::ActionPolylineTrim: - action = RS_ActionPolylineTrim::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotPolylineTrim())); - break; -#endif - - case RS2::ActionDrawText: - action = RS_ActionDrawText::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawText())); - break; - - case RS2::ActionDrawHatch: - action = RS_ActionDrawHatch::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawHatch())); - break; - - case RS2::ActionDrawImage: - action = RS_ActionDrawImage::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDrawImage())); - break; - - // Dimensioning actions: - // - case RS2::ActionDimAligned: - action = RS_ActionDimAligned::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimAligned())); - break; - - case RS2::ActionDimLinear: - action = RS_ActionDimLinear::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimLinear())); - break; - - case RS2::ActionDimLinearHor: - action = RS_ActionDimLinear::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimLinearHor())); - break; - - case RS2::ActionDimLinearVer: - action = RS_ActionDimLinear::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimLinearVer())); - break; - - case RS2::ActionDimRadial: - action = RS_ActionDimRadial::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimRadial())); - break; - - case RS2::ActionDimDiametric: - action = RS_ActionDimDiametric::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimDiametric())); - break; - - case RS2::ActionDimAngular: - action = RS_ActionDimAngular::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimAngular())); - break; - - case RS2::ActionDimLeader: - action = RS_ActionDimLeader::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotDimLeader())); - break; - - // Modifying actions: - // - case RS2::ActionModifyAttributes: - action = RS_ActionModifyAttributes::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyAttributes())); - break; - case RS2::ActionModifyDelete: - action = RS_ActionModifyDelete::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyDelete())); - break; - - case RS2::ActionModifyDeleteQuick: - action = RS_ActionModifyDeleteQuick::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyDeleteQuick())); - break; - - case RS2::ActionModifyDeleteFree: - action = RS_ActionModifyDeleteFree::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyDeleteFree())); - break; - - case RS2::ActionModifyMove: - action = RS_ActionModifyMove::createGUIAction(id, mw); - /* - action = new QAction(tr("Move"), tr("&Move"), - 0, mw); - action->setStatusTip(tr("Move Entities")); - */ - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyMove())); - break; - - case RS2::ActionModifyRotate: - action = RS_ActionModifyRotate::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyRotate())); - break; - - case RS2::ActionModifyScale: - action = RS_ActionModifyScale::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyScale())); - break; - - case RS2::ActionModifyMirror: - action = RS_ActionModifyMirror::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyMirror())); - break; - - case RS2::ActionModifyMoveRotate: - action = RS_ActionModifyMoveRotate::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyMoveRotate())); - break; - - case RS2::ActionModifyRotate2: - action = RS_ActionModifyRotate::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyRotate2())); - break; - - case RS2::ActionModifyEntity: - action = RS_ActionModifyEntity::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyEntity())); - break; - - case RS2::ActionModifyTrim: - action = RS_ActionModifyTrim::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyTrim())); - break; - - case RS2::ActionModifyTrim2: - action = RS_ActionModifyTrim::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyTrim2())); - break; - - case RS2::ActionModifyTrimAmount: - action = RS_ActionModifyTrimAmount::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyTrimAmount())); - break; - - case RS2::ActionModifyCut: - action = RS_ActionModifyCut::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyCut())); - break; - - case RS2::ActionModifyStretch: - action = RS_ActionModifyStretch::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyStretch())); - break; - - case RS2::ActionModifyBevel: - action = RS_ActionModifyBevel::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyBevel())); - break; - - case RS2::ActionModifyRound: - action = RS_ActionModifyRound::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyRound())); - break; - - case RS2::ActionModifyExplodeText: - action = RS_ActionModifyExplodeText::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotModifyExplodeText())); - break; - - // Snapping actions: - // - case RS2::ActionSnapFree: - action = new QAction(tr("&Free"), mw); - action->setChecked(true); -// action = new QAction(tr("Free"), tr("&Free"), 0, mw, 0, true); - action->setStatusTip(tr("Free positioning")); - actionHandler->setActionSnapFree(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapFree())); - break; - - case RS2::ActionSnapGrid: - action = new QAction(tr("&Grid"), mw); - action->setChecked(true); -// action = new QAction(tr("Grid"), tr("&Grid"), 0, mw, "snapGrid", true); - action->setStatusTip(tr("Grid positioning")); - actionHandler->setActionSnapGrid(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapGrid())); - break; - - case RS2::ActionSnapEndpoint: - action = new QAction(tr("&Endpoints"), mw); - action->setChecked(true); -// action = new QAction(tr("Endpoints"), tr("&Endpoints"), 0, mw, 0, true); - action->setStatusTip(tr("Snap to endpoints")); - actionHandler->setActionSnapEndpoint(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapEndpoint())); - break; - - case RS2::ActionSnapOnEntity: - action = new QAction(tr("&On Entity"), mw); - action->setChecked(true); -// action = new QAction(tr("On Entity"), tr("&On Entity"), 0, mw, 0, true); - action->setStatusTip(tr("Snap to nearest point on entity")); - actionHandler->setActionSnapOnEntity(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapOnEntity())); - break; - - case RS2::ActionSnapCenter: - action = new QAction(tr("&Center"), mw); - action->setChecked(true); -// action = new QAction(tr("Center"), tr("&Center"), 0, mw, 0, true); - action->setStatusTip(tr("Snap to centers")); - actionHandler->setActionSnapCenter(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapCenter())); - break; - - case RS2::ActionSnapMiddle: - action = new QAction(tr("&Middle"), mw); - action->setChecked(true); -// action = new QAction(tr("Middle"), tr("&Middle"), 0, mw, 0, true); - action->setStatusTip(tr("Snap to middle points")); - actionHandler->setActionSnapMiddle(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapMiddle())); - break; - - case RS2::ActionSnapDist: - action = new QAction(tr("&Distance from Endpoint"), mw); - action->setChecked(true); -// action = new QAction(tr("Distance from Endpoint"), tr("&Distance from Endpoint"), 0, mw, 0, true); - action->setStatusTip(tr("Snap to points with a given distance to an endpoint")); - actionHandler->setActionSnapDist(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapDist())); - break; - - case RS2::ActionSnapIntersection: - action = new QAction(tr("&Intersection"), mw); - action->setChecked(true); -// action = new QAction(tr("Intersection"), tr("&Intersection"), 0, mw, 0, true); - action->setStatusTip(tr("Snap to intersection points")); - actionHandler->setActionSnapIntersection(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapIntersection())); - break; - - case RS2::ActionSnapIntersectionManual: - action = RS_ActionSnapIntersectionManual::createGUIAction(id, mw); - actionHandler->setActionSnapIntersectionManual(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotSnapIntersectionManual())); - break; - - // Snap restriction actions: - // - case RS2::ActionRestrictNothing: - action = new QAction(tr("Restrict &Nothing"), mw); - action->setChecked(true); -// action = new QAction(tr("Restrict Nothing"), tr("Restrict &Nothing"), 0, mw, 0, true); - action->setStatusTip(tr("No snap restriction")); - actionHandler->setActionRestrictNothing(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotRestrictNothing())); - break; - - case RS2::ActionRestrictOrthogonal: - action = new QAction(tr("Restrict &Orthogonally"), mw); - action->setChecked(true); -// action = new QAction(tr("Restrict Orthogonally"), tr("Restrict &Orthogonally"), 0, mw, 0, true); - action->setStatusTip(tr("Restrict snapping orthogonally")); - actionHandler->setActionRestrictOrthogonal(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotRestrictOrthogonal())); - break; - - case RS2::ActionRestrictHorizontal: - action = new QAction(tr("Restrict &Horizontally"), mw); - action->setChecked(true); -// action = new QAction(tr("Restrict Horizontally"), tr("Restrict &Horizontally"), 0, mw, 0, true); - action->setStatusTip(tr("Restrict snapping horizontally")); - actionHandler->setActionRestrictHorizontal(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotRestrictHorizontal())); - break; - - case RS2::ActionRestrictVertical: - action = new QAction(tr("Restrict &Vertically"), mw); - action->setChecked(true); -// action = new QAction(tr("Restrict Vertically"), tr("Restrict &Vertically"), 0, mw, 0, true); - action->setStatusTip(tr("Restrict snapping vertically")); - actionHandler->setActionRestrictVertical(action); - connect(action, SIGNAL(activated()), obj, SLOT(slotRestrictVertical())); - break; - - // Relative zero point - // - case RS2::ActionSetRelativeZero: - action = RS_ActionSetRelativeZero::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotSetRelativeZero())); - break; - case RS2::ActionLockRelativeZero: - action = RS_ActionLockRelativeZero::createGUIAction(id, mw); - actionHandler->setActionLockRelativeZero(action); - connect(action, SIGNAL(toggled(bool)), obj, SLOT(slotLockRelativeZero(bool))); - break; - - // Info actions: - // - case RS2::ActionInfoInside: - action = RS_ActionInfoInside::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotInfoInside())); - break; - - case RS2::ActionInfoDist: - action = RS_ActionInfoDist::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotInfoDist())); - break; - - case RS2::ActionInfoDist2: - action = RS_ActionInfoDist2::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotInfoDist2())); - break; - - case RS2::ActionInfoAngle: - action = RS_ActionInfoAngle::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotInfoAngle())); - break; - - case RS2::ActionInfoTotalLength: - action = RS_ActionInfoTotalLength::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotInfoTotalLength())); - break; - - // Layer actions: - // - case RS2::ActionLayersDefreezeAll: - action = RS_ActionLayersFreezeAll::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersDefreezeAll())); - break; - case RS2::ActionLayersFreezeAll: - action = RS_ActionLayersFreezeAll::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersFreezeAll())); - break; - case RS2::ActionLayersAdd: - action = RS_ActionLayersAdd::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersAdd())); - break; - - case RS2::ActionLayersRemove: - action = RS_ActionLayersRemove::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersRemove())); - break; - - case RS2::ActionLayersEdit: - action = RS_ActionLayersEdit::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersEdit())); - break; - - case RS2::ActionLayersToggleLock: - action = RS_ActionLayersToggleLock::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersToggleView())); - break; - - case RS2::ActionLayersToggleView: - action = RS_ActionLayersToggleView::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotLayersToggleView())); - break; - - // Block actions: - // - case RS2::ActionBlocksDefreezeAll: - action = RS_ActionBlocksFreezeAll::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksDefreezeAll())); - break; - case RS2::ActionBlocksFreezeAll: - action = RS_ActionBlocksFreezeAll::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksFreezeAll())); - break; - case RS2::ActionBlocksAdd: - action = RS_ActionBlocksAdd::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksAdd())); - break; - case RS2::ActionBlocksRemove: - action = RS_ActionBlocksRemove::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksRemove())); - break; - case RS2::ActionBlocksAttributes: - action = RS_ActionBlocksAttributes::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksAttributes())); - break; - case RS2::ActionBlocksEdit: - action = RS_ActionBlocksEdit::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksEdit())); - break; - case RS2::ActionBlocksInsert: - action = RS_ActionBlocksInsert::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksInsert())); - break; - case RS2::ActionBlocksToggleView: - action = RS_ActionBlocksToggleView::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksToggleView())); - break; - case RS2::ActionBlocksCreate: - action = RS_ActionBlocksCreate::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksCreate())); - break; - case RS2::ActionBlocksExplode: - action = RS_ActionBlocksExplode::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotBlocksExplode())); - break; - - // Options actions: - // - case RS2::ActionOptionsGeneral: - action = new QAction(QIcon(":/res/configure.png"), -#ifdef __APPLE__ - tr("&Preferences"), -#else - tr("&Application Preferences..."), -#endif - mw); -// action = new QAction(tr("Application"), qPixmapFromMimeSource("configure.png"), -//#ifdef __APPLE__ -// tr("&Preferences"), -//#else -// tr("&Application Preferences..."), -//#endif -// 0, mw); - action->setStatusTip(tr("General Application Preferences")); - connect(action, SIGNAL(activated()), obj, SLOT(slotOptionsGeneral())); - break; - - case RS2::ActionOptionsDrawing: - action = RS_ActionOptionsDrawing::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotOptionsDrawing())); - break; - - // Scripting actions: - // - case RS2::ActionScriptOpenIDE: - action = new QAction(tr("&Open IDE"), mw); -// action = new QAction(tr("Open IDE"), tr("&Open IDE"), 0, mw); - action->setStatusTip(tr("Opens the integrated development environment for scripting")); - connect(action, SIGNAL(activated()), obj, SLOT(slotScriptOpenIDE())); - break; - - case RS2::ActionScriptRun: - action = new QAction(tr("&Run Script..."), mw); -// action = new QAction(tr("Run Script.."), tr("&Run Script.."), 0, mw); - action->setStatusTip(tr("Runs a script")); - connect(action, SIGNAL(activated()), obj, SLOT(slotScriptRun())); - break; - - // CAM actions: - // -#ifdef RS_CAM - case RS2::ActionCamExportAuto: - action = RS_ActionCamExportAuto::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotCamExportAuto())); - break; - - case RS2::ActionCamReorder: - action = RS_ActionCamReorder::createGUIAction(id, mw); - connect(action, SIGNAL(activated()), obj, SLOT(slotCamReorder())); - break; -#endif - - default: - RS_DEBUG->print(RS_Debug::D_WARNING, "No action %d defined", id); - assert(true); - break; - } - - return action; -} diff --git a/src/widgets/qg_actionfactory.h.old b/src/widgets/qg_actionfactory.h.old deleted file mode 100644 index d042de0..0000000 --- a/src/widgets/qg_actionfactory.h.old +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef QG_ACTIONFACTORY_H -#define QG_ACTIONFACTORY_H - -#include - -#include "rs.h" -#include "qg_actionhandler.h" -#include "qg_mainwindowinterface.h" - -/** - * This class can store recent files in a list. (???--JLH) - */ -class QG_ActionFactory: public QObject -{ - Q_OBJECT - - public: - QG_ActionFactory(QG_ActionHandler * ah, QWidget * w); - virtual ~QG_ActionFactory(); - - QAction * createAction(RS2::ActionType id, QObject * obj); - - private: - QG_ActionHandler * actionHandler; - QWidget * widget; -}; - -#endif // QG_ACTIONFACTORY_H