src/base/rs_font.h \
src/base/rs_fontchar.h \
src/base/rs_fontlist.h \
- src/base/rs_graphicview.h \
src/base/rs_grid.h \
src/base/rs_hatch.h \
src/base/rs_image.h \
src/base/rs_filterinterface.cpp \
src/base/rs_font.cpp \
src/base/rs_fontlist.cpp \
- src/base/rs_graphicview.cpp \
src/base/rs_grid.cpp \
src/base/rs_hatch.cpp \
src/base/rs_image.cpp \
src/widgets/qg_mainwindowinterface.h \
src/widgets/qg_patternbox.h \
src/widgets/qg_pentoolbar.h \
- src/widgets/qg_qt2rs.h \
- src/widgets/qg_recentfiles.h \
+ src/widgets/recentfiles.h \
src/widgets/qg_scrollbar.h \
src/widgets/qg_widthbox.h
src/widgets/qg_listviewitem.cpp \
src/widgets/qg_patternbox.cpp \
src/widgets/qg_pentoolbar.cpp \
- src/widgets/qg_recentfiles.cpp \
+ src/widgets/recentfiles.cpp \
src/widgets/qg_scrollbar.cpp \
src/widgets/qg_widthbox.cpp
src/mainapp/commands.h \
src/mainapp/createqtactions.h \
src/mainapp/qc_dialogfactory.h \
+ src/mainapp/graphicview.h \
src/mainapp/qc_graphicview.h \
src/mainapp/main.h \
src/mainapp/mdiwindow.h \
src/mainapp/commands.cpp \
src/mainapp/createqtactions.cpp \
src/mainapp/qc_dialogfactory.cpp \
+ src/mainapp/graphicview.cpp \
src/mainapp/qc_graphicview.cpp \
src/mainapp/main.cpp \
src/mainapp/mdiwindow.cpp \
#include "drawing.h"
#include "rs_dialogfactory.h"
-RS_ActionBlocksAdd::RS_ActionBlocksAdd(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionBlocksAdd::RS_ActionBlocksAdd(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Add Block", container, graphicView)
{
}
{
//Q_OBJECT
public:
- RS_ActionBlocksAdd(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksAdd(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksAdd()
{
}
#include "rs_dialogfactory.h"
RS_ActionBlocksAttributes::RS_ActionBlocksAttributes(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Edit Block Attributes", container, graphicView)
{
}
{
//Q_OBJECT
public:
- RS_ActionBlocksAttributes(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksAttributes(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksAttributes()
{
}
#include "rs_creation.h"
#include "rs_dialogfactory.h"
+#include "graphicview.h"
#include "rs_insert.h"
#include "rs_modification.h"
/**
* Constructor.
*/
-RS_ActionBlocksCreate::RS_ActionBlocksCreate(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Blocks Create", container, graphicView)
+RS_ActionBlocksCreate::RS_ActionBlocksCreate(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Blocks Create", container, graphicView)
{
referencePoint = Vector(false);
}
#define RS_ACTIONBLOCKSCREATE_H
#include "rs_previewactioninterface.h"
-//#include "rs_insert.h"
/**
* This action class can handle user events for creating blocks from
*/
class RS_ActionBlocksCreate: public RS_PreviewActionInterface
{
- //Q_OBJECT
public:
/**
* Action States.
};
public:
- RS_ActionBlocksCreate(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksCreate(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksCreate();
virtual RS2::ActionType rtti();
virtual void trigger();
virtual void mouseMoveEvent(QMouseEvent * e);
virtual void mouseReleaseEvent(QMouseEvent * e);
-// virtual void coordinateEvent(Vector * e);
virtual void coordinateEvent(Vector * e);
//virtual void commandEvent(RS_CommandEvent * e);
//virtual QStringList getAvailableCommands();
#include "drawing.h"
#include "rs_dialogfactory.h"
-RS_ActionBlocksEdit::RS_ActionBlocksEdit(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionBlocksEdit::RS_ActionBlocksEdit(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Edit Block", container, graphicView)
{
}
{
//Q_OBJECT
public:
- RS_ActionBlocksEdit(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksEdit(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksEdit()
{
}
/**
* Constructor.
*/
-RS_ActionBlocksExplode::RS_ActionBlocksExplode(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionBlocksExplode::RS_ActionBlocksExplode(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Blocks Explode",
container, graphicView)
{
{
//Q_OBJECT
public:
- RS_ActionBlocksExplode(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksExplode(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksExplode();
static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
#include "rs_actionblocksfreezeall.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionBlocksFreezeAll::RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Freeze all Blocks",
+RS_ActionBlocksFreezeAll::RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Freeze all Blocks",
container, graphicView)
{
this->freeze = freeze;
*/
class RS_ActionBlocksFreezeAll: public RS_ActionInterface
{
- //Q_OBJECT
public:
- RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksFreezeAll(bool freeze, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksFreezeAll();
virtual void init(int status = 0);
#include "rs_actionblocksinsert.h"
#include "commands.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
#include "rs_modification.h"
/**
* Constructor.
*/
-RS_ActionBlocksInsert::RS_ActionBlocksInsert(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Blocks Insert",
+RS_ActionBlocksInsert::RS_ActionBlocksInsert(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Blocks Insert",
container, graphicView)
{
}
};
public:
- RS_ActionBlocksInsert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksInsert(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksInsert();
virtual RS2::ActionType rtti();
#include "rs_block.h"
#include "rs_dialogfactory.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_insert.h"
-RS_ActionBlocksRemove::RS_ActionBlocksRemove(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionBlocksRemove::RS_ActionBlocksRemove(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Remove Block", container, graphicView)
{
}
class RS_ActionBlocksRemove: public RS_ActionInterface
{
public:
- RS_ActionBlocksRemove(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksRemove(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksRemove();
virtual void init(int status = 0);
#include "rs_actionblockstoggleview.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionBlocksToggleView::RS_ActionBlocksToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Toggle Block Visibility",
+RS_ActionBlocksToggleView::RS_ActionBlocksToggleView(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Toggle Block Visibility",
container, graphicView)
{
}
class RS_ActionBlocksToggleView: public RS_ActionInterface
{
public:
- RS_ActionBlocksToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionBlocksToggleView(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionBlocksToggleView();
virtual void init(int status = 0);
#include "rs_actiondefault.h"
#include "rs.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
#include "rs_line.h"
#include "rs_modification.h"
/**
* Constructor.
*/
-RS_ActionDefault::RS_ActionDefault(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Default",
+RS_ActionDefault::RS_ActionDefault(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Default",
container, graphicView)
{
RS_DEBUG->print("RS_ActionDefault::RS_ActionDefault");
};
public:
- RS_ActionDefault(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDefault(RS_EntityContainer & container, GraphicView & graphicView);
virtual ~RS_ActionDefault();
static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
#include "rs_actiondimaligned.h"
+#include "rs_commandevent.h"
#include "rs_constructionline.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
#include "rs_snapper.h"
-RS_ActionDimAligned::RS_ActionDimAligned(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw aligned dimensions",
+RS_ActionDimAligned::RS_ActionDimAligned(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionDimension("Draw aligned dimensions",
container, graphicView)
{
reset();
};
public:
- RS_ActionDimAligned(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDimAligned(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDimAligned();
virtual RS2::ActionType rtti();
#include "rs_actiondimangular.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
#include "rs_preview.h"
-RS_ActionDimAngular::RS_ActionDimAngular(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw Angular Dimensions",
+RS_ActionDimAngular::RS_ActionDimAngular(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionDimension("Draw Angular Dimensions",
container, graphicView)
{
reset();
};
public:
- RS_ActionDimAngular(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDimAngular(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDimAngular();
virtual RS2::ActionType rtti();
#include "rs_actiondimdiametric.h"
-#include "rs_graphicview.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDimDiametric::RS_ActionDimDiametric(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw Diametric Dimensions",
+RS_ActionDimDiametric::RS_ActionDimDiametric(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionDimension("Draw Diametric Dimensions",
container, graphicView)
{
reset();
};
public:
- RS_ActionDimDiametric(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDimDiametric(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDimDiametric();
virtual RS2::ActionType rtti();
#include "rs_actiondimension.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionDimension::RS_ActionDimension(const char * name, RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDimension::RS_ActionDimension(const char * name, RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface(name, container, graphicView)
{
reset();
class RS_ActionDimension: public RS_PreviewActionInterface
{
public:
- RS_ActionDimension(const char * name, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDimension(const char * name, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDimension();
virtual void reset();
#include "rs_actiondimleader.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDimLeader::RS_ActionDimLeader(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDimLeader::RS_ActionDimLeader(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw leaders", container, graphicView)
{
reset();
};
public:
- RS_ActionDimLeader(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDimLeader(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDimLeader();
//static QAction * createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/);
#include "rs_actiondimlinear.h"
+#include "rs_commandevent.h"
#include "rs_constructionline.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
/**
* @param fixedAngle true: The user can't change the angle.
* false: The user can change the angle in a option widget.
*/
-RS_ActionDimLinear::RS_ActionDimLinear(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle, bool fixedAngle):
+RS_ActionDimLinear::RS_ActionDimLinear(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
RS_ActionDimension("Draw linear dimensions", container, graphicView)
{
edata.angle = angle;
};
public:
- RS_ActionDimLinear(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+ RS_ActionDimLinear(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
~RS_ActionDimLinear();
virtual RS2::ActionType rtti();
#include "rs_actiondimradial.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDimRadial::RS_ActionDimRadial(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionDimension("Draw Radial Dimensions",
+RS_ActionDimRadial::RS_ActionDimRadial(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionDimension("Draw Radial Dimensions",
container, graphicView)
{
reset();
};
public:
- RS_ActionDimRadial(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDimRadial(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDimRadial();
virtual RS2::ActionType rtti();
#include "rs_actiondrawarc.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawArc::RS_ActionDrawArc(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawArc::RS_ActionDrawArc(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw arcs", container, graphicView)
{
reset();
};
public:
- RS_ActionDrawArc(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawArc(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawArc();
virtual RS2::ActionType rtti();
#include "rs_actiondrawarc3p.h"
#include "rs_actiondrawarc.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawArc3P::RS_ActionDrawArc3P(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawArc3P::RS_ActionDrawArc3P(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw arcs 3P", container, graphicView)
{
reset();
};
public:
- RS_ActionDrawArc3P(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawArc3P(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawArc3P();
void reset();
#include "rs_actiondrawarctangential.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawArcTangential::RS_ActionDrawArcTangential(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw arcs tangential",
+RS_ActionDrawArcTangential::RS_ActionDrawArcTangential(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw arcs tangential",
container, graphicView)
{
reset();
};
public:
- RS_ActionDrawArcTangential(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawArcTangential(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawArcTangential();
virtual RS2::ActionType rtti();
#include "rs_actiondrawcircle.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawCircle::RS_ActionDrawCircle(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawCircle::RS_ActionDrawCircle(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw circles", container, graphicView)
{
reset();
};
public:
- RS_ActionDrawCircle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawCircle(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawCircle();
virtual RS2::ActionType rtti();
#include "rs_actiondrawcircle2p.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawCircle2P::RS_ActionDrawCircle2P(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw circles",
+RS_ActionDrawCircle2P::RS_ActionDrawCircle2P(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw circles",
container, graphicView)
{
reset();
};
public:
- RS_ActionDrawCircle2P(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawCircle2P(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawCircle2P();
void reset();
#include "rs_actiondrawcircle3p.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawCircle3P::RS_ActionDrawCircle3P(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw circles",
+RS_ActionDrawCircle3P::RS_ActionDrawCircle3P(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw circles",
container, graphicView)
{
reset();
};
public:
- RS_ActionDrawCircle3P(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawCircle3P(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawCircle3P();
void reset();
#include "rs_actiondrawcirclecr.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
/**
* Constructor.
*/
-RS_ActionDrawCircleCR::RS_ActionDrawCircleCR(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw circles CR",
+RS_ActionDrawCircleCR::RS_ActionDrawCircleCR(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw circles CR",
container, graphicView)
{
reset();
};
public:
- RS_ActionDrawCircleCR(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawCircleCR(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawCircleCR();
virtual RS2::ActionType rtti();
#include "rs_actiondrawellipseaxis.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
/**
* @param isArc true if this action will produce an ellipse arc.
* false if it will produce a full ellipse.
*/
-RS_ActionDrawEllipseAxis::RS_ActionDrawEllipseAxis(RS_EntityContainer & container, RS_GraphicView & graphicView, bool isArc): RS_PreviewActionInterface("Draw ellipse with axis",
+RS_ActionDrawEllipseAxis::RS_ActionDrawEllipseAxis(RS_EntityContainer & container, GraphicView & graphicView, bool isArc): RS_PreviewActionInterface("Draw ellipse with axis",
container, graphicView)
{
this->isArc = isArc;
};
public:
- RS_ActionDrawEllipseAxis(RS_EntityContainer & container, RS_GraphicView & graphicView, bool isArc);
+ RS_ActionDrawEllipseAxis(RS_EntityContainer & container, GraphicView & graphicView, bool isArc);
~RS_ActionDrawEllipseAxis();
virtual void init(int status = 0);
#include "rs_actiondrawhatch.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
-RS_ActionDrawHatch::RS_ActionDrawHatch(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawHatch::RS_ActionDrawHatch(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw Hatch", container, graphicView)
{
hatch = NULL;
};
public:
- RS_ActionDrawHatch(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawHatch(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawHatch();
virtual void init(int status = 0);
#include "rs_actiondrawimage.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
/**
* Constructor.
*/
-RS_ActionDrawImage::RS_ActionDrawImage(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawImage::RS_ActionDrawImage(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Image", container, graphicView)
{
}
};
public:
- RS_ActionDrawImage(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawImage(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawImage();
virtual RS2::ActionType rtti();
#include "rs_actiondrawline.h"
#include "rs_actioneditundo.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw lines", container, graphicView)
{
RS_DEBUG->print("RS_ActionDrawLine::RS_ActionDrawLine");
};
public:
- RS_ActionDrawLine(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLine(RS_EntityContainer & container, GraphicView & graphicView);
virtual ~RS_ActionDrawLine();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlineangle.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineAngle::RS_ActionDrawLineAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle, bool fixedAngle):
+RS_ActionDrawLineAngle::RS_ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
RS_PreviewActionInterface("Draw lines with given angle",
container, graphicView)
{
SetLength /**< Setting length in the command line. */
};
- RS_ActionDrawLineAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+ RS_ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
~RS_ActionDrawLineAngle();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlinebisector.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineBisector::RS_ActionDrawLineBisector(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawLineBisector::RS_ActionDrawLineBisector(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw Bisectors", container, graphicView)
{
bisector = NULL;
};
public:
- RS_ActionDrawLineBisector(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineBisector(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineBisector();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlinefree.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_polyline.h"
-RS_ActionDrawLineFree::RS_ActionDrawLineFree(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Draw freehand lines",
+RS_ActionDrawLineFree::RS_ActionDrawLineFree(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Draw freehand lines",
container, graphicView)
{
vertex = Vector(false);
class RS_ActionDrawLineFree: public RS_ActionInterface
{
public:
- RS_ActionDrawLineFree(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineFree(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineFree();
virtual void trigger();
#include "rs_actiondrawlinehorvert.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineHorVert::RS_ActionDrawLineHorVert(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw horizontal/vertical lines",
+RS_ActionDrawLineHorVert::RS_ActionDrawLineHorVert(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw horizontal/vertical lines",
container, graphicView)
{
reset();
};
public:
- RS_ActionDrawLineHorVert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineHorVert(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineHorVert();
void reset();
#include "rs_actiondrawlineparallel.h"
#include "rs_actiondrawlineparallelthrough.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineParallel::RS_ActionDrawLineParallel(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Parallels",
+RS_ActionDrawLineParallel::RS_ActionDrawLineParallel(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Parallels",
container, graphicView)
{
parallel = NULL;
};
public:
- RS_ActionDrawLineParallel(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineParallel(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineParallel();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlineparallelthrough.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
RS_ActionDrawLineParallelThrough::RS_ActionDrawLineParallelThrough(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw Parallels", container, graphicView)
{
parallel = NULL;
};
public:
- RS_ActionDrawLineParallelThrough(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineParallelThrough(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineParallelThrough();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlinepolygon.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLinePolygon::RS_ActionDrawLinePolygon(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Polygons",
+RS_ActionDrawLinePolygon::RS_ActionDrawLinePolygon(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Polygons",
container, graphicView)
{
center = Vector(false);
};
public:
- RS_ActionDrawLinePolygon(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLinePolygon(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLinePolygon();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlinepolygon2.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLinePolygon2::RS_ActionDrawLinePolygon2(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Polygons",
+RS_ActionDrawLinePolygon2::RS_ActionDrawLinePolygon2(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Polygons",
container, graphicView)
{
corner1 = Vector(false);
};
public:
- RS_ActionDrawLinePolygon2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLinePolygon2(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLinePolygon2();
virtual RS2::ActionType rtti();
#include "rs_actiondrawlinerectangle.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
RS_ActionDrawLineRectangle::RS_ActionDrawLineRectangle(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw rectangles", container, graphicView)
{
reset();
};
public:
- RS_ActionDrawLineRectangle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineRectangle(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineRectangle();
void reset();
#include "rs_actiondrawlinerelangle.h"
+#include "rs_commandevent.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineRelAngle::RS_ActionDrawLineRelAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle, bool fixedAngle):
+RS_ActionDrawLineRelAngle::RS_ActionDrawLineRelAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
RS_PreviewActionInterface("Draw Lines with relative angles",
container, graphicView)
{
};
public:
- RS_ActionDrawLineRelAngle(RS_EntityContainer & container, RS_GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+ RS_ActionDrawLineRelAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
~RS_ActionDrawLineRelAngle();
virtual RS2::ActionType rtti();
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineTangent1::RS_ActionDrawLineTangent1(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Tangents 1",
+RS_ActionDrawLineTangent1::RS_ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Tangents 1",
container, graphicView)
{
tangent = NULL;
};
public:
- RS_ActionDrawLineTangent1(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineTangent1();
virtual void trigger();
#include "rs_creation.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
RS_ActionDrawLineTangent2::RS_ActionDrawLineTangent2(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw Tangents 2", container, graphicView)
{
tangent = NULL;
};
public:
- RS_ActionDrawLineTangent2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawLineTangent2(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawLineTangent2();
virtual void trigger();
#include "rs_actiondrawpoint.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawPoint::RS_ActionDrawPoint(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawPoint::RS_ActionDrawPoint(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw Points", container, graphicView)
{
}
class RS_ActionDrawPoint: public RS_PreviewActionInterface
{
public:
- RS_ActionDrawPoint(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawPoint(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawPoint();
virtual void trigger();
#include "rs_actiondrawspline.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawSpline::RS_ActionDrawSpline(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionDrawSpline::RS_ActionDrawSpline(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw splines", container, graphicView)
{
reset();
};
public:
- RS_ActionDrawSpline(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawSpline(RS_EntityContainer & container, GraphicView & graphicView);
virtual ~RS_ActionDrawSpline();
virtual RS2::ActionType rtti();
#include "rs_actiondrawtext.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawText::RS_ActionDrawText(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Text", container, graphicView)
+RS_ActionDrawText::RS_ActionDrawText(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Text", container, graphicView)
{
pos = Vector(false);
textChanged = true;
};
public:
- RS_ActionDrawText(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionDrawText(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionDrawText();
virtual RS2::ActionType rtti();
*
* @param undo true for undo and false for redo.
*/
-RS_ActionEditCopy::RS_ActionEditCopy(bool copy, RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionEditCopy::RS_ActionEditCopy(bool copy, RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Edit Copy", container, graphicView)
{
this->copy = copy;
};
public:
- RS_ActionEditCopy(bool copy, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionEditCopy(bool copy, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionEditCopy();
virtual void init(int status = 0);
*
* @param undo true for undo and false for redo.
*/
-RS_ActionEditPaste::RS_ActionEditPaste(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Edit Paste",
+RS_ActionEditPaste::RS_ActionEditPaste(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Edit Paste",
container, graphicView)
{
}
};
public:
- RS_ActionEditPaste(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionEditPaste(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionEditPaste();
virtual void init(int status = 0);
#include "rs_actioneditundo.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
*
* @param undo true for undo and false for redo.
*/
-RS_ActionEditUndo::RS_ActionEditUndo(bool undo, RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Edit Undo", container, graphicView)
+RS_ActionEditUndo::RS_ActionEditUndo(bool undo, RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Edit Undo", container, graphicView)
{
this->undo = undo;
}
class RS_ActionEditUndo: public RS_ActionInterface
{
public:
- RS_ActionEditUndo(bool undo, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionEditUndo(bool undo, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionEditUndo();
virtual void init(int status = 0);
//#include "drawing.h"
-RS_ActionFileNew::RS_ActionFileNew(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionFileNew::RS_ActionFileNew(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("File New", container, graphicView)
{
}
class RS_ActionFileNew: public RS_ActionInterface
{
public:
- RS_ActionFileNew(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionFileNew(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionFileNew();
virtual void init(int status = 0);
//#include "drawing.h"
-RS_ActionFileOpen::RS_ActionFileOpen(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionFileOpen::RS_ActionFileOpen(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("File Open", container, graphicView)
{
}
class RS_ActionFileOpen: public RS_ActionInterface
{
public:
- RS_ActionFileOpen(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionFileOpen(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionFileOpen();
virtual void init(int status = 0);
#include "drawing.h"
-RS_ActionFileSave::RS_ActionFileSave(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionFileSave::RS_ActionFileSave(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("File Save", container, graphicView)
{
}
class RS_ActionFileSave: public RS_ActionInterface
{
public:
- RS_ActionFileSave(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionFileSave(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionFileSave();
virtual void init(int status = 0);
#include "drawing.h"
-RS_ActionFileSaveAs::RS_ActionFileSaveAs(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionFileSaveAs::RS_ActionFileSaveAs(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Add Layer", container, graphicView)
{
}
class RS_ActionFileSaveAs: public RS_ActionInterface
{
public:
- RS_ActionFileSaveAs(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionFileSaveAs(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionFileSaveAs();
virtual void init(int status = 0);
#include "rs_actioninfoangle.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
-RS_ActionInfoAngle::RS_ActionInfoAngle(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Info Angle",
+RS_ActionInfoAngle::RS_ActionInfoAngle(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Info Angle",
container, graphicView)
{
}
};
public:
- RS_ActionInfoAngle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionInfoAngle(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionInfoAngle();
virtual void init(int status = 0);
#include "rs_actioninfoarea.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionInfoArea::RS_ActionInfoArea(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Info Area",
+RS_ActionInfoArea::RS_ActionInfoArea(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Info Area",
container, graphicView)
{
}
};
public:
- RS_ActionInfoArea(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionInfoArea(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionInfoArea();
virtual void init(int status = 0);
#include "rs_actioninfodist.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionInfoDist::RS_ActionInfoDist(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Info Dist",
+RS_ActionInfoDist::RS_ActionInfoDist(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Info Dist",
container, graphicView)
{
}
};
public:
- RS_ActionInfoDist(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionInfoDist(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionInfoDist();
virtual void init(int status = 0);
#include "rs_actioninfodist2.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionInfoDist2::RS_ActionInfoDist2(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionInfoDist2::RS_ActionInfoDist2(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Info Dist2", container, graphicView)
{
}
};
public:
- RS_ActionInfoDist2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionInfoDist2(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionInfoDist2();
virtual void init(int status = 0);
#include "rs_actioninfoinside.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
-RS_ActionInfoInside::RS_ActionInfoInside(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionInfoInside::RS_ActionInfoInside(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Info Inside", container, graphicView)
{
contour = new RS_EntityContainer(NULL, false);
class RS_ActionInfoInside: public RS_ActionInterface
{
public:
- RS_ActionInfoInside(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionInfoInside(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionInfoInside();
virtual void trigger();
#include "rs_dialogfactory.h"
-RS_ActionInfoTotalLength::RS_ActionInfoTotalLength(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Info Total Length",
+RS_ActionInfoTotalLength::RS_ActionInfoTotalLength(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Info Total Length",
container, graphicView)
{
}
};
public:
- RS_ActionInfoTotalLength(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionInfoTotalLength(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionInfoTotalLength();
virtual void init(int status = 0);
#include "rs_dialogfactory.h"
#include "drawing.h"
-RS_ActionLayersAdd::RS_ActionLayersAdd(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionLayersAdd::RS_ActionLayersAdd(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Add Layer", container, graphicView)
{
}
class RS_ActionLayersAdd: public RS_ActionInterface
{
public:
- RS_ActionLayersAdd(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLayersAdd(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionLayersAdd();
virtual void init(int status = 0);
#include "rs_actionlayersedit.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "drawing.h"
-RS_ActionLayersEdit::RS_ActionLayersEdit(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionLayersEdit::RS_ActionLayersEdit(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Edit Layer", container, graphicView)
{
}
class RS_ActionLayersEdit: public RS_ActionInterface
{
public:
- RS_ActionLayersEdit(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLayersEdit(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionLayersEdit();
virtual void init(int status = 0);
#include "drawing.h"
-RS_ActionLayersFreezeAll::RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionLayersFreezeAll::RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Freeze all Layers", container, graphicView)
{
this->freeze = freeze;
class RS_ActionLayersFreezeAll: public RS_ActionInterface
{
public:
- RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLayersFreezeAll(bool freeze, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionLayersFreezeAll();
virtual void init(int status = 0);
#include "rs_dialogfactory.h"
#include "drawing.h"
-RS_ActionLayersRemove::RS_ActionLayersRemove(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionLayersRemove::RS_ActionLayersRemove(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Remove Layer", container, graphicView)
{
}
class RS_ActionLayersRemove: public RS_ActionInterface
{
public:
- RS_ActionLayersRemove(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLayersRemove(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionLayersRemove();
virtual void init(int status = 0);
#include "rs_actionlayerstogglelock.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "drawing.h"
-RS_ActionLayersToggleLock::RS_ActionLayersToggleLock(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Toggle Layer Visibility",
+RS_ActionLayersToggleLock::RS_ActionLayersToggleLock(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Toggle Layer Visibility",
container, graphicView)
{
}
class RS_ActionLayersToggleLock: public RS_ActionInterface
{
public:
- RS_ActionLayersToggleLock(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLayersToggleLock(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionLayersToggleLock();
virtual void init(int status = 0);
#include "drawing.h"
-RS_ActionLayersToggleView::RS_ActionLayersToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Toggle Layer Visibility",
+RS_ActionLayersToggleView::RS_ActionLayersToggleView(RS_EntityContainer & container, GraphicView & graphicView): RS_ActionInterface("Toggle Layer Visibility",
container, graphicView)
{
}
class RS_ActionLayersToggleView: public RS_ActionInterface
{
public:
- RS_ActionLayersToggleView(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLayersToggleView(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionLayersToggleView();
virtual void init(int status = 0);
#include "rs_actionlibraryinsert.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
#include "rs_units.h"
/**
* Constructor.
*/
-RS_ActionLibraryInsert::RS_ActionLibraryInsert(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionLibraryInsert::RS_ActionLibraryInsert(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Library Insert", container, graphicView)
{
}
};
public:
- RS_ActionLibraryInsert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionLibraryInsert(RS_EntityContainer & container, GraphicView & graphicView);
virtual ~RS_ActionLibraryInsert();
virtual RS2::ActionType rtti();
#include "rs_actionlockrelativezero.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
RS_ActionLockRelativeZero::RS_ActionLockRelativeZero(
- RS_EntityContainer & container, RS_GraphicView & graphicView, bool on):
+ RS_EntityContainer & container, GraphicView & graphicView, bool on):
RS_ActionInterface("(Un-)lock the relative Zero", container, graphicView)
{
this->on = on;
class RS_ActionLockRelativeZero: public RS_ActionInterface
{
public:
- RS_ActionLockRelativeZero(RS_EntityContainer & container, RS_GraphicView & graphicView, bool on);
+ RS_ActionLockRelativeZero(RS_EntityContainer & container, GraphicView & graphicView, bool on);
~RS_ActionLockRelativeZero();
virtual void init(int status = 0);
#include "rs_dialogfactory.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_modification.h"
RS_ActionModifyAttributes::RS_ActionModifyAttributes(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Change Attributes", container, graphicView)
{
}
};
public:
- RS_ActionModifyAttributes(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyAttributes(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyAttributes();
virtual void init(int status = 0);
#include "rs_actionmodifybevel.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
#include "rs_information.h"
-RS_ActionModifyBevel::RS_ActionModifyBevel(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Bevel Entities",
+RS_ActionModifyBevel::RS_ActionModifyBevel(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Bevel Entities",
container, graphicView)
{
entity1 = NULL;
};
public:
- RS_ActionModifyBevel(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyBevel(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyBevel();
virtual RS2::ActionType rtti();
#include "rs_actionmodifycut.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_modification.h"
RS_ActionModifyCut::RS_ActionModifyCut(RS_EntityContainer & container,
- RS_GraphicView & graphicView): RS_ActionInterface("Cut Entity",
+ GraphicView & graphicView): RS_ActionInterface("Cut Entity",
container, graphicView)
{
cutEntity = NULL;
};
public:
- RS_ActionModifyCut(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyCut(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyCut();
virtual void init(int status = 0);
#include "rs_actionmodifydelete.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_modification.h"
RS_ActionModifyDelete::RS_ActionModifyDelete(RS_EntityContainer & container,
- RS_GraphicView & graphicView): RS_ActionInterface("Delete Entities",
+ GraphicView & graphicView): RS_ActionInterface("Delete Entities",
container, graphicView)
{
}
};
public:
- RS_ActionModifyDelete(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyDelete(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyDelete();
virtual void init(int status = 0);
#include "rs_actionmodifydeletefree.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_modification.h"
#include "rs_polyline.h"
#include "rs_undo.h"
RS_ActionModifyDeleteFree::RS_ActionModifyDeleteFree(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Delete Entities Freehand",
container, graphicView)
{
class RS_ActionModifyDeleteFree: public RS_ActionInterface
{
public:
- RS_ActionModifyDeleteFree(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyDeleteFree(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyDeleteFree();
virtual void init(int status = 0);
#include "rs_actionmodifydeletequick.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
RS_ActionModifyDeleteQuick::RS_ActionModifyDeleteQuick(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Quick Delete Entities", container, graphicView)
{
en = NULL;
class RS_ActionModifyDeleteQuick: public RS_ActionInterface
{
public:
- RS_ActionModifyDeleteQuick(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyDeleteQuick(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyDeleteQuick();
virtual void trigger();
#include "rs_actionmodifyentity.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
RS_ActionModifyEntity::RS_ActionModifyEntity(RS_EntityContainer & container,
- RS_GraphicView & graphicView):
+ GraphicView & graphicView):
RS_ActionInterface("Modify Entity", container, graphicView)
{
en = NULL;
{
//Q_OBJECT
public:
- RS_ActionModifyEntity(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyEntity(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyEntity();
virtual void trigger();
* Constructor.
*/
RS_ActionModifyExplodeText::RS_ActionModifyExplodeText(RS_EntityContainer & container,
- RS_GraphicView & graphicView): RS_PreviewActionInterface("Blocks Explode",
+ GraphicView & graphicView): RS_PreviewActionInterface("Blocks Explode",
container, graphicView)
{
}
class RS_ActionModifyExplodeText: public RS_PreviewActionInterface
{
public:
- RS_ActionModifyExplodeText(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyExplodeText(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyExplodeText();
virtual RS2::ActionType rtti();
#include "rs_dialogfactory.h"
#include "rs_preview.h"
-RS_ActionModifyMirror::RS_ActionModifyMirror(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionModifyMirror::RS_ActionModifyMirror(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Mirror Entities", container, graphicView)
{
}
};
public:
- RS_ActionModifyMirror(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyMirror(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyMirror();
virtual void init(int status = 0);
#include "rs_preview.h"
RS_ActionModifyMove::RS_ActionModifyMove(RS_EntityContainer & container,
- RS_GraphicView & graphicView):
+ GraphicView & graphicView):
RS_PreviewActionInterface("Move Entities", container, graphicView)
{
}
};
public:
- RS_ActionModifyMove(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyMove(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyMove();
virtual void init(int status = 0);
#include "rs_actionmodifymoverotate.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
#include "rs_preview.h"
RS_ActionModifyMoveRotate::RS_ActionModifyMoveRotate(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Move and Rotate Entities", container, graphicView)
{
}
};
public:
- RS_ActionModifyMoveRotate(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyMoveRotate(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyMoveRotate();
virtual RS2::ActionType rtti();
#include "rs_dialogfactory.h"
-RS_ActionModifyRotate::RS_ActionModifyRotate(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionModifyRotate::RS_ActionModifyRotate(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Rotate Entities",
container, graphicView)
{
};
public:
- RS_ActionModifyRotate(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyRotate(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyRotate();
virtual void init(int status = 0);
#include "rs_dialogfactory.h"
RS_ActionModifyRotate2::RS_ActionModifyRotate2(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Rotate Entities around two centers", container, graphicView)
{
}
};
public:
- RS_ActionModifyRotate2(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyRotate2(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyRotate2();
virtual void init(int status = 0);
#include "rs_actionmodifyround.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
#include "rs_information.h"
#include "rs_preview.h"
-RS_ActionModifyRound::RS_ActionModifyRound(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionModifyRound::RS_ActionModifyRound(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Round Entities", container, graphicView)
{
entity1 = NULL;
};
public:
- RS_ActionModifyRound(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyRound(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyRound();
virtual RS2::ActionType rtti();
#include "rs_dialogfactory.h"
-RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Scale Entities",
container, graphicView)
{
};
public:
- RS_ActionModifyScale(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyScale(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyScale();
virtual void init(int status = 0);
#include "rs_preview.h"
RS_ActionModifyStretch::RS_ActionModifyStretch(RS_EntityContainer & container,
- RS_GraphicView & graphicView): RS_PreviewActionInterface("Stretch Entities",
+ GraphicView & graphicView): RS_PreviewActionInterface("Stretch Entities",
container, graphicView)
{
firstCorner = Vector(false);
};
public:
- RS_ActionModifyStretch(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyStretch(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyStretch();
virtual void init(int status = 0);
* @param both Trim both entities.
*/
RS_ActionModifyTrim::RS_ActionModifyTrim(RS_EntityContainer & container,
- RS_GraphicView & graphicView, bool both): RS_PreviewActionInterface("Trim Entity",
+ GraphicView & graphicView, bool both): RS_PreviewActionInterface("Trim Entity",
container, graphicView)
{
trimEntity = NULL;
};
public:
- RS_ActionModifyTrim(RS_EntityContainer & container, RS_GraphicView & graphicView, bool both = false);
+ RS_ActionModifyTrim(RS_EntityContainer & container, GraphicView & graphicView, bool both = false);
~RS_ActionModifyTrim();
virtual void init(int status = 0);
#include "rs_actionmodifytrimamount.h"
+#include "rs_commandevent.h"
#include "rs_dialogfactory.h"
#include "rs_modification.h"
RS_ActionModifyTrimAmount::RS_ActionModifyTrimAmount(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Trim Entity by a given amount",
container, graphicView)
{
};
public:
- RS_ActionModifyTrimAmount(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionModifyTrimAmount(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionModifyTrimAmount();
virtual RS2::ActionType rtti();
#include "rs_actionoptionsdrawing.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionOptionsDrawing::RS_ActionOptionsDrawing(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionOptionsDrawing::RS_ActionOptionsDrawing(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Drawing Options", container, graphicView)
{
}
class RS_ActionOptionsDrawing: public RS_ActionInterface
{
public:
- RS_ActionOptionsDrawing(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionOptionsDrawing(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionOptionsDrawing();
virtual RS2::ActionType rtti();
#include "rs_dialogfactory.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
*/
-RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Print Preview",
container, graphicView)
{
};
public:
- RS_ActionPrintPreview(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionPrintPreview(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionPrintPreview();
virtual RS2::ActionType rtti();
#include "rs_actionselectsingle.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionSelect::RS_ActionSelect(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ActionType nextAction):
+RS_ActionSelect::RS_ActionSelect(RS_EntityContainer & container, GraphicView & graphicView, RS2::ActionType nextAction):
RS_ActionInterface("Select Entities", container, graphicView)
{
this->nextAction = nextAction;
class RS_ActionSelect: public RS_ActionInterface
{
public:
- RS_ActionSelect(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ActionType nextAction);
+ RS_ActionSelect(RS_EntityContainer & container, GraphicView & graphicView, RS2::ActionType nextAction);
~RS_ActionSelect();
void init(int status);
#include "rs_selection.h"
RS_ActionSelectAll::RS_ActionSelectAll(RS_EntityContainer & container,
- RS_GraphicView & graphicView, bool select):
+ GraphicView & graphicView, bool select):
RS_ActionInterface("Select All Entities", container, graphicView)
{
this->select = select;
class RS_ActionSelectAll: public RS_ActionInterface
{
public:
- RS_ActionSelectAll(RS_EntityContainer & container, RS_GraphicView & graphicView, bool select);
+ RS_ActionSelectAll(RS_EntityContainer & container, GraphicView & graphicView, bool select);
~RS_ActionSelectAll();
virtual RS2::ActionType rtti();
#include "rs_actionselectbase.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
RS_ActionSelectBase::RS_ActionSelectBase(const char * name,
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface(name, container, graphicView)
{
}
class RS_ActionSelectBase: public RS_ActionInterface
{
public:
- RS_ActionSelectBase(const char * name, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSelectBase(const char * name, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSelectBase();
virtual void keyReleaseEvent(QKeyEvent * e);
#include "rs_selection.h"
RS_ActionSelectContour::RS_ActionSelectContour(RS_EntityContainer & container,
- RS_GraphicView & graphicView):
+ GraphicView & graphicView):
RS_ActionInterface("Select Contours", container, graphicView)
{
en = NULL;
class RS_ActionSelectContour: public RS_ActionInterface
{
public:
- RS_ActionSelectContour(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSelectContour(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSelectContour();
virtual RS2::ActionType rtti();
* @param select true: select window. false: deselect window
*/
RS_ActionSelectIntersected::RS_ActionSelectIntersected(
- RS_EntityContainer & container, RS_GraphicView & graphicView, bool select):
+ RS_EntityContainer & container, GraphicView & graphicView, bool select):
RS_PreviewActionInterface("Select Intersected", container, graphicView)
{
this->select = select;
};
public:
- RS_ActionSelectIntersected(RS_EntityContainer & container, RS_GraphicView & graphicView, bool select);
+ RS_ActionSelectIntersected(RS_EntityContainer & container, GraphicView & graphicView, bool select);
~RS_ActionSelectIntersected();
virtual RS2::ActionType rtti();
#include "rs_selection.h"
RS_ActionSelectInvert::RS_ActionSelectInvert(RS_EntityContainer & container,
- RS_GraphicView & graphicView): RS_ActionInterface("Invert Selection",
+ GraphicView & graphicView): RS_ActionInterface("Invert Selection",
container, graphicView)
{
}
class RS_ActionSelectInvert: public RS_ActionInterface
{
public:
- RS_ActionSelectInvert(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSelectInvert(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSelectInvert();
virtual RS2::ActionType rtti();
#include "rs_dialogfactory.h"
#include "rs_selection.h"
-RS_ActionSelectLayer::RS_ActionSelectLayer(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionSelectLayer::RS_ActionSelectLayer(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Select Layers", container, graphicView)
{
en = NULL;
class RS_ActionSelectLayer: public RS_ActionInterface
{
public:
- RS_ActionSelectLayer(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSelectLayer(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSelectLayer();
virtual RS2::ActionType rtti();
#include "rs_dialogfactory.h"
#include "rs_selection.h"
-RS_ActionSelectSingle::RS_ActionSelectSingle(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionSelectSingle::RS_ActionSelectSingle(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Select Entities", container, graphicView)
{
en = NULL;
class RS_ActionSelectSingle: public RS_ActionInterface
{
public:
- RS_ActionSelectSingle(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSelectSingle(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSelectSingle();
virtual RS2::ActionType rtti();
* @param select true: select window. false: deselect window
*/
RS_ActionSelectWindow::RS_ActionSelectWindow(RS_EntityContainer & container,
- RS_GraphicView & graphicView, bool select):
+ GraphicView & graphicView, bool select):
RS_PreviewActionInterface("Select Window", container, graphicView)
{
this->select = select;
};
public:
- RS_ActionSelectWindow(RS_EntityContainer & container, RS_GraphicView & graphicView, bool select);
+ RS_ActionSelectWindow(RS_EntityContainer & container, GraphicView & graphicView, bool select);
~RS_ActionSelectWindow();
virtual RS2::ActionType rtti();
#include "rs_actionsetrelativezero.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
RS_ActionSetRelativeZero::RS_ActionSetRelativeZero(RS_EntityContainer & container,
- RS_GraphicView & graphicView): RS_PreviewActionInterface("Set the relative Zero",
+ GraphicView & graphicView): RS_PreviewActionInterface("Set the relative Zero",
container, graphicView)
{
}
class RS_ActionSetRelativeZero: public RS_PreviewActionInterface
{
public:
- RS_ActionSetRelativeZero(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSetRelativeZero(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSetRelativeZero();
virtual RS2::ActionType rtti();
#include "rs_actionsetsnapmode.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
*
* @param snapMode The new snap mode used from now on.
*/
-RS_ActionSetSnapMode::RS_ActionSetSnapMode(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapMode snapMode):
+RS_ActionSetSnapMode::RS_ActionSetSnapMode(RS_EntityContainer & container, GraphicView & graphicView, RS2::SnapMode snapMode):
RS_ActionInterface("Set Snap Mode", container, graphicView)
{
this->snapMode = snapMode;
class RS_ActionSetSnapMode: public RS_ActionInterface
{
public:
- RS_ActionSetSnapMode(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapMode snapMode);
+ RS_ActionSetSnapMode(RS_EntityContainer & container, GraphicView & graphicView, RS2::SnapMode snapMode);
~RS_ActionSetSnapMode();
virtual void init(int status = 0);
#include "rs_actionsetsnaprestriction.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
* @param set true: set additional snap mode / false: unset
*/
RS_ActionSetSnapRestriction::RS_ActionSetSnapRestriction(
- RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapRestriction snapRes):
+ RS_EntityContainer & container, GraphicView & graphicView, RS2::SnapRestriction snapRes):
RS_ActionInterface("Set Additional Snap Mode", container, graphicView)
{
this->snapRes = snapRes;
class RS_ActionSetSnapRestriction: public RS_ActionInterface
{
public:
- RS_ActionSetSnapRestriction(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::SnapRestriction snapRes);
+ RS_ActionSetSnapRestriction(RS_EntityContainer & container, GraphicView & graphicView, RS2::SnapRestriction snapRes);
~RS_ActionSetSnapRestriction();
virtual void init(int status = 0);
#include "rs_actionsnapintersectionmanual.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
#include "rs_preview.h"
* @param both Trim both entities.
*/
RS_ActionSnapIntersectionManual::RS_ActionSnapIntersectionManual(
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Trim Entity", container, graphicView)
{
entity2 = NULL;
};
public:
- RS_ActionSnapIntersectionManual(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionSnapIntersectionManual(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionSnapIntersectionManual();
virtual void init(int status = 0);
#include "rs_dialogfactory.h"
#include "rs_dimension.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
-RS_ActionToolRegenerateDimensions::RS_ActionToolRegenerateDimensions(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionToolRegenerateDimensions::RS_ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Tool Regen Dim", container, graphicView)
{
}
class RS_ActionToolRegenerateDimensions: public RS_ActionInterface
{
public:
- RS_ActionToolRegenerateDimensions(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionToolRegenerateDimensions();
virtual void init(int status = 0);
#include "rs_actionzoomauto.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
* false: adjust both x and y individually
*/
RS_ActionZoomAuto::RS_ActionZoomAuto(RS_EntityContainer & container,
- RS_GraphicView & graphicView, bool keepAspectRatio):
+ GraphicView & graphicView, bool keepAspectRatio):
RS_ActionInterface("Auto zoom", container, graphicView)
{
this->keepAspectRatio = keepAspectRatio;
class RS_ActionZoomAuto: public RS_ActionInterface
{
public:
- RS_ActionZoomAuto(RS_EntityContainer & container, RS_GraphicView & graphicView, bool keepAspectRatio = true);
+ RS_ActionZoomAuto(RS_EntityContainer & container, GraphicView & graphicView, bool keepAspectRatio = true);
~RS_ActionZoomAuto();
virtual void init(int status = 0);
#include "rs_actionzoomautoy.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionZoomAutoY::RS_ActionZoomAutoY(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionZoomAutoY::RS_ActionZoomAutoY(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Auto zoom Y", container, graphicView)
{
}
class RS_ActionZoomAutoY: public RS_ActionInterface
{
public:
- RS_ActionZoomAutoY(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionZoomAutoY(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionZoomAutoY();
virtual void init(int status = 0);
#include "rs_actionzoomin.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Default constructor.
* @param direction In for zooming in, Out for zooming out.
* @param axis Axis that are affected by the zoom (OnlyX, OnlyY or Both)
*/
-RS_ActionZoomIn::RS_ActionZoomIn(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ZoomDirection direction, RS2::Axis axis, const Vector & center):
+RS_ActionZoomIn::RS_ActionZoomIn(RS_EntityContainer & container, GraphicView & graphicView, RS2::ZoomDirection direction, RS2::Axis axis, const Vector & center):
RS_ActionInterface("Zoom in", container, graphicView)
{
this->direction = direction;
class RS_ActionZoomIn: public RS_ActionInterface
{
public:
- RS_ActionZoomIn(RS_EntityContainer & container, RS_GraphicView & graphicView, RS2::ZoomDirection direction = RS2::In, RS2::Axis axis = RS2::Both, const Vector & center = Vector(false));
+ RS_ActionZoomIn(RS_EntityContainer & container, GraphicView & graphicView, RS2::ZoomDirection direction = RS2::In, RS2::Axis axis = RS2::Both, const Vector & center = Vector(false));
~RS_ActionZoomIn();
virtual void init(int status = 0);
#include "rs_actionzoompan.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Zoom Pan", container, graphicView)
{
}
class RS_ActionZoomPan: public RS_ActionInterface
{
public:
- RS_ActionZoomPan(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionZoomPan();
virtual void init(int status = 0);
#include "rs_actionzoomprevious.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
*/
-RS_ActionZoomPrevious::RS_ActionZoomPrevious(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionZoomPrevious::RS_ActionZoomPrevious(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Previous zoom", container, graphicView)
{
}
class RS_ActionZoomPrevious: public RS_ActionInterface
{
public:
- RS_ActionZoomPrevious(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionZoomPrevious(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionZoomPrevious();
virtual void init(int status = 0);
#include "rs_actionzoomredraw.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
* @param keepAspectRatio true: keep same zoom value for x/y.
* false: adjust both x and y individually
*/
-RS_ActionZoomRedraw::RS_ActionZoomRedraw(RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionZoomRedraw::RS_ActionZoomRedraw(RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Redraw", container, graphicView)
{
}
class RS_ActionZoomRedraw: public RS_ActionInterface
{
public:
- RS_ActionZoomRedraw(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionZoomRedraw(RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionZoomRedraw();
virtual void init(int status = 0);
#include "rs_actionzoomscroll.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
-RS_ActionZoomScroll::RS_ActionZoomScroll(RS2::Direction direction, RS_EntityContainer & container, RS_GraphicView & graphicView):
+RS_ActionZoomScroll::RS_ActionZoomScroll(RS2::Direction direction, RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Zoom scroll", container, graphicView)
{
this->direction = direction;
class RS_ActionZoomScroll: public RS_ActionInterface
{
public:
- RS_ActionZoomScroll(RS2::Direction direction, RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_ActionZoomScroll(RS2::Direction direction, RS_EntityContainer & container, GraphicView & graphicView);
~RS_ActionZoomScroll();
virtual void init(int status = 0);
#include "rs_actionzoomwindow.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
/**
* area will be fit to the viewport.
*/
RS_ActionZoomWindow::RS_ActionZoomWindow(RS_EntityContainer & container,
- RS_GraphicView & graphicView, bool keepAspectRatio):
+ GraphicView & graphicView, bool keepAspectRatio):
RS_PreviewActionInterface("Zoom Window", container, graphicView)
{
this->keepAspectRatio = keepAspectRatio;
class RS_ActionZoomWindow: public RS_PreviewActionInterface
{
public:
- RS_ActionZoomWindow(RS_EntityContainer & container, RS_GraphicView & graphicView, bool keepAspectRatio = true);
+ RS_ActionZoomWindow(RS_EntityContainer & container, GraphicView & graphicView, bool keepAspectRatio = true);
~RS_ActionZoomWindow();
virtual void init(int status = 0);
#include "commands.h"
#include "rs_debug.h"
#include "rs_entitycontainer.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* Constructor.
* be reset to the one given here.
*/
RS_ActionInterface::RS_ActionInterface(const char * name,
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_Snapper(container, graphicView)
{
RS_DEBUG->print("RS_ActionInterface::RS_ActionInterface: Setting up action: \"%s\"", name);
class RS_Document;
class Drawing;
class RS_EntityContainer;
-class RS_GraphicView;
+class GraphicView;
class Vector;
/**
//huh? no slots/signals here... Q_OBJECT
//WHY derive from QObject???
//for the TR macro???
+//mebbe...
public:
RS_ActionInterface(const char * name, RS_EntityContainer & container,
- RS_GraphicView & graphicView);
+ GraphicView & graphicView);
virtual ~RS_ActionInterface();
virtual RS2::ActionType rtti();
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void keyPressEvent(QKeyEvent * e);
virtual void keyReleaseEvent(QKeyEvent * e);
-// virtual void coordinateEvent(RS_CoordinateEvent *);
virtual void coordinateEvent(Vector *);
virtual void commandEvent(RS_CommandEvent *);
virtual QStringList getAvailableCommands();
// Who When What
// --- ---------- -----------------------------------------------------------
// JLH 05/28/2010 Added this text. :-)
+// JLH 06/16/2010 Moved implementation from header file to this file
//
#include "rs_arc.h"
#include "rs_linetypepattern.h"
#include "rs_information.h"
#include "rs_math.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "paintintf.h"
/**
* Default constructor.
*/
-RS_Arc::RS_Arc(RS_EntityContainer* parent,
- const RS_ArcData& d)
- : RS_AtomicEntity(parent), data(d) {
- calculateEndpoints();
- calculateBorders();
+RS_Arc::RS_Arc(RS_EntityContainer * parent, const RS_ArcData & d):
+ RS_AtomicEntity(parent), data(d)
+{
+ calculateEndpoints();
+ calculateBorders();
+}
+
+/*virtual*/ RS_Arc::~RS_Arc()
+{
+}
+
+/*virtual*/ RS_Entity * RS_Arc::clone()
+{
+ RS_Arc * a = new RS_Arc(*this);
+ a->initId();
+ return a;
+}
+
+/** @return RS2::EntityArc */
+/*virtual*/ RS2::EntityType RS_Arc::rtti() const
+{
+ return RS2::EntityArc;
+}
+
+/** @return true */
+/*virtual*/ bool RS_Arc::isEdge() const
+{
+ return true;
+}
+
+/** @return Copy of data that defines the arc. **/
+RS_ArcData RS_Arc::getData() const
+{
+ return data;
+}
+
+/*virtual*/ VectorSolutions RS_Arc::getRefPoints()
+{
+ VectorSolutions ret(startpoint, endpoint, data.center);
+ return ret;
+}
+
+/** Sets new arc parameters. **/
+void RS_Arc::setData(RS_ArcData d)
+{
+ data = d;
+}
+
+/** @return The center point (x) of this arc */
+Vector RS_Arc::getCenter() const
+{
+ return data.center;
+}
+
+/** Sets new center. */
+void RS_Arc::setCenter(const Vector & c)
+{
+ data.center = c;
+}
+
+/** @return The radius of this arc */
+double RS_Arc::getRadius() const
+{
+ return data.radius;
+}
+
+/** Sets new radius. */
+void RS_Arc::setRadius(double r)
+{
+ data.radius = r;
+}
+
+/** @return The start angle of this arc */
+double RS_Arc::getAngle1() const
+{
+ return data.angle1;
+}
+
+/** Sets new start angle. */
+void RS_Arc::setAngle1(double a1)
+{
+ data.angle1 = a1;
+}
+
+/** @return The end angle of this arc */
+double RS_Arc::getAngle2() const
+{
+ return data.angle2;
+}
+
+/** Sets new end angle. */
+void RS_Arc::setAngle2(double a2)
+{
+ data.angle2 = a2;
}
+/**
+ * @return Direction 1. The angle at which the arc starts at
+ * the startpoint.
+ */
+double RS_Arc::getDirection1() const
+{
+ if (!data.reversed)
+ return RS_Math::correctAngle(data.angle1 + M_PI / 2.0);
+
+ return RS_Math::correctAngle(data.angle1 - M_PI / 2.0);
+}
+
+/**
+ * @return Direction 2. The angle at which the arc starts at
+ * the endpoint.
+ */
+double RS_Arc::getDirection2() const
+{
+ if (!data.reversed)
+ return RS_Math::correctAngle(data.angle2 - M_PI / 2.0);
+
+ return RS_Math::correctAngle(data.angle2 + M_PI / 2.0);
+}
+
+/**
+ * @retval true if the arc is reversed (clockwise),
+ * @retval false otherwise
+ */
+bool RS_Arc::isReversed() const
+{
+ return data.reversed;
+}
+
+/** sets the reversed status. */
+void RS_Arc::setReversed(bool r)
+{
+ data.reversed = r;
+}
+
+/** @return Start point of the entity. */
+/*virtual*/ Vector RS_Arc::getStartpoint() const
+{
+ return startpoint;
+}
+/** @return End point of the entity. */
+/*virtual*/ Vector RS_Arc::getEndpoint() const
+{
+ return endpoint;
+}
/**
* Creates this arc from 3 given points which define the arc line.
* @param p2 2nd point.
* @param p3 3rd point.
*/
-bool RS_Arc::createFrom3P(const Vector& p1, const Vector& p2,
- const Vector& p3) {
- if (p1.distanceTo(p2)>RS_TOLERANCE &&
- p2.distanceTo(p3)>RS_TOLERANCE &&
- p3.distanceTo(p1)>RS_TOLERANCE) {
-
- // middle points between 3 points:
- Vector mp1, mp2;
- Vector dir1, dir2;
- double a1, a2;
-
- // intersection of two middle lines
- mp1 = (p1 + p2)/2.0;
- a1 = p1.angleTo(p2) + M_PI/2.0;
- dir1.setPolar(100.0, a1);
- mp2 = (p2 + p3)/2.0;
- a2 = p2.angleTo(p3) + M_PI/2.0;
- dir2.setPolar(100.0, a2);
-
- RS_ConstructionLineData d1(mp1, mp1 + dir1);
- RS_ConstructionLineData d2(mp2, mp2 + dir2);
- RS_ConstructionLine midLine1(NULL, d1);
- RS_ConstructionLine midLine2(NULL, d2);
-
- VectorSolutions sol =
- RS_Information::getIntersection(&midLine1, &midLine2);
-
- data.center = sol.get(0);
- data.radius = data.center.distanceTo(p3);
- data.angle1 = data.center.angleTo(p1);
- data.angle2 = data.center.angleTo(p3);
- data.reversed = RS_Math::isAngleBetween(data.center.angleTo(p2),
- data.angle1, data.angle2, true);
-
- if (sol.get(0).valid && data.radius<1.0e14 &&
- data.radius>RS_TOLERANCE) {
- calculateEndpoints();
- calculateBorders();
- return true;
- } else {
- RS_DEBUG->print("RS_Arc::createFrom3P(): "
- "Cannot create an arc with inf radius.");
- return false;
- }
- } else {
- RS_DEBUG->print("RS_Arc::createFrom3P(): "
- "Cannot create an arc with radius 0.0.");
- return false;
- }
+bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3)
+{
+ if (p1.distanceTo(p2) > RS_TOLERANCE
+ && p2.distanceTo(p3) > RS_TOLERANCE
+ && p3.distanceTo(p1) > RS_TOLERANCE)
+ {
+ // middle points between 3 points:
+ Vector mp1, mp2;
+ Vector dir1, dir2;
+ double a1, a2;
+
+ // intersection of two middle lines
+ mp1 = (p1 + p2) / 2.0;
+ a1 = p1.angleTo(p2) + M_PI / 2.0;
+ dir1.setPolar(100.0, a1);
+ mp2 = (p2 + p3) / 2.0;
+ a2 = p2.angleTo(p3) + M_PI / 2.0;
+ dir2.setPolar(100.0, a2);
+
+ RS_ConstructionLineData d1(mp1, mp1 + dir1);
+ RS_ConstructionLineData d2(mp2, mp2 + dir2);
+ RS_ConstructionLine midLine1(NULL, d1);
+ RS_ConstructionLine midLine2(NULL, d2);
+
+ VectorSolutions sol =
+ RS_Information::getIntersection(&midLine1, &midLine2);
+
+ data.center = sol.get(0);
+ data.radius = data.center.distanceTo(p3);
+ data.angle1 = data.center.angleTo(p1);
+ data.angle2 = data.center.angleTo(p3);
+ data.reversed = RS_Math::isAngleBetween(data.center.angleTo(p2),
+ data.angle1, data.angle2, true);
+
+ if (sol.get(0).valid && data.radius < 1.0e14
+ && data.radius > RS_TOLERANCE)
+ {
+ calculateEndpoints();
+ calculateBorders();
+ return true;
+ }
+ else
+ {
+ RS_DEBUG->print("RS_Arc::createFrom3P(): "
+ "Cannot create an arc with inf radius.");
+ return false;
+ }
+ }
+ else
+ {
+ RS_DEBUG->print("RS_Arc::createFrom3P(): "
+ "Cannot create an arc with radius 0.0.");
+ return false;
+ }
}
-
-
/**
* Creates an arc from its startpoint, endpoint, start direction (angle)
* and radius.
* @retval true Successfully created arc
* @retval false Cannot creats arc (radius to small or endpoint to far away)
*/
-bool RS_Arc::createFrom2PDirectionRadius(const Vector& startPoint,
- const Vector& endPoint,
- double direction1, double radius) {
+bool RS_Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius)
+{
+ Vector ortho;
+ ortho.setPolar(radius, direction1 + M_PI / 2.0);
+ Vector center1 = startPoint + ortho;
+ Vector center2 = startPoint - ortho;
- Vector ortho;
- ortho.setPolar(radius, direction1 + M_PI/2.0);
- Vector center1 = startPoint + ortho;
- Vector center2 = startPoint - ortho;
+ if (center1.distanceTo(endPoint) < center2.distanceTo(endPoint))
+ data.center = center1;
+ else
+ data.center = center2;
- if (center1.distanceTo(endPoint) < center2.distanceTo(endPoint)) {
- data.center = center1;
- } else {
- data.center = center2;
- }
+ data.radius = radius;
+ data.angle1 = data.center.angleTo(startPoint);
+ data.angle2 = data.center.angleTo(endPoint);
+ data.reversed = false;
- data.radius = radius;
- data.angle1 = data.center.angleTo(startPoint);
- data.angle2 = data.center.angleTo(endPoint);
- data.reversed = false;
+ double diff = RS_Math::correctAngle(getDirection1() - direction1);
- double diff = RS_Math::correctAngle(getDirection1()-direction1);
- if (fabs(diff-M_PI)<1.0e-1) {
- data.reversed = true;
- }
+ if (fabs(diff - M_PI) < 1.0e-1)
+ data.reversed = true;
- calculateEndpoints();
- calculateBorders();
+ calculateEndpoints();
+ calculateBorders();
- return true;
+ return true;
}
-
-
/**
* Creates an arc from its startpoint, endpoint and bulge.
*/
-bool RS_Arc::createFrom2PBulge(const Vector& startPoint, const Vector& endPoint,
- double bulge) {
- data.reversed = (bulge<0.0);
- double alpha = atan(bulge)*4.0;
+bool RS_Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge)
+{
+ data.reversed = (bulge < 0.0);
+ double alpha = atan(bulge) * 4.0;
- Vector middle = (startPoint+endPoint)/2.0;
- double dist = startPoint.distanceTo(endPoint)/2.0;
+ Vector middle = (startPoint + endPoint) / 2.0;
+ double dist = startPoint.distanceTo(endPoint) / 2.0;
- // alpha can't be 0.0 at this point
- data.radius = fabs(dist / sin(alpha/2.0));
+ // alpha can't be 0.0 at this point
+ data.radius = fabs(dist / sin(alpha / 2.0));
- double wu = fabs(RS_Math::pow(data.radius, 2.0) - RS_Math::pow(dist, 2.0));
- double h = sqrt(wu);
- double angle = startPoint.angleTo(endPoint);
+ double wu = fabs(RS_Math::pow(data.radius, 2.0) - RS_Math::pow(dist, 2.0));
+ double h = sqrt(wu);
+ double angle = startPoint.angleTo(endPoint);
- if (bulge>0.0) {
- angle+=M_PI/2.0;
- } else {
- angle-=M_PI/2.0;
- }
+ if (bulge > 0.0)
+ angle += M_PI / 2.0;
+ else
+ angle -= M_PI / 2.0;
- if (fabs(alpha)>M_PI) {
- h*=-1.0;
- }
+ if (fabs(alpha) > M_PI)
+ h *= -1.0;
- data.center.setPolar(h, angle);
- data.center+=middle;
- data.angle1 = data.center.angleTo(startPoint);
- data.angle2 = data.center.angleTo(endPoint);
+ data.center.setPolar(h, angle);
+ data.center += middle;
+ data.angle1 = data.center.angleTo(startPoint);
+ data.angle2 = data.center.angleTo(endPoint);
- calculateEndpoints();
- calculateBorders();
+ calculateEndpoints();
+ calculateBorders();
return true;
}
-
-
/**
* Recalculates the endpoints using the angles and the radius.
*/
-void RS_Arc::calculateEndpoints() {
- startpoint.set(data.center.x + cos(data.angle1) * data.radius,
- data.center.y + sin(data.angle1) * data.radius);
- endpoint.set(data.center.x + cos(data.angle2) * data.radius,
- data.center.y + sin(data.angle2) * data.radius);
+void RS_Arc::calculateEndpoints()
+{
+ startpoint.set(data.center.x + cos(data.angle1) * data.radius,
+ data.center.y + sin(data.angle1) * data.radius);
+ endpoint.set(data.center.x + cos(data.angle2) * data.radius,
+ data.center.y + sin(data.angle2) * data.radius);
}
+void RS_Arc::calculateBorders()
+{
+ double minX = std::min(startpoint.x, endpoint.x);
+ double minY = std::min(startpoint.y, endpoint.y);
+ double maxX = std::max(startpoint.x, endpoint.x);
+ double maxY = std::max(startpoint.y, endpoint.y);
-void RS_Arc::calculateBorders() {
- double minX = std::min(startpoint.x, endpoint.x);
- double minY = std::min(startpoint.y, endpoint.y);
- double maxX = std::max(startpoint.x, endpoint.x);
- double maxY = std::max(startpoint.y, endpoint.y);
-
- double a1 = !isReversed() ? data.angle1 : data.angle2;
- double a2 = !isReversed() ? data.angle2 : data.angle1;
-
- // check for left limit:
- if ((a1<M_PI && a2>M_PI) ||
- (a1>a2-1.0e-12 && a2>M_PI) ||
- (a1>a2-1.0e-12 && a1<M_PI) ) {
-
- minX = std::min(data.center.x - data.radius, minX);
- }
-
- // check for right limit:
- if (a1 > a2-1.0e-12) {
- maxX = std::max(data.center.x + data.radius, maxX);
- }
+ double a1 = !isReversed() ? data.angle1 : data.angle2;
+ double a2 = !isReversed() ? data.angle2 : data.angle1;
- // check for bottom limit:
- if ((a1<(M_PI_2*3) && a2>(M_PI_2*3)) ||
- (a1>a2-1.0e-12 && a2>(M_PI_2*3)) ||
- (a1>a2-1.0e-12 && a1<(M_PI_2*3)) ) {
+ // check for left limit:
+ if ((a1 < M_PI && a2 > M_PI)
+ || (a1 > a2 - 1.0e-12 && a2 > M_PI)
+ || (a1 > a2 - 1.0e-12 && a1 < M_PI) )
- minY = std::min(data.center.y - data.radius, minY);
- }
+ minX = std::min(data.center.x - data.radius, minX);
- // check for top limit:
- if ((a1<M_PI_2 && a2>M_PI_2) ||
- (a1>a2-1.0e-12 && a2>M_PI_2) ||
- (a1>a2-1.0e-12 && a1<M_PI_2) ) {
+ // check for right limit:
+ if (a1 > a2 - 1.0e-12)
+ maxX = std::max(data.center.x + data.radius, maxX);
- maxY = std::max(data.center.y + data.radius, maxY);
- }
+ // check for bottom limit:
+ if ((a1 < (M_PI_2 * 3) && a2 > (M_PI_2 * 3))
+ || (a1 > a2 - 1.0e-12 && a2 > (M_PI_2 * 3))
+ || (a1 > a2 - 1.0e-12 && a1 < (M_PI_2 * 3)) )
- minV.set(minX, minY);
- maxV.set(maxX, maxY);
-}
+ minY = std::min(data.center.y - data.radius, minY);
+ // check for top limit:
+ if ((a1 < M_PI_2 && a2 > M_PI_2)
+ || (a1 > a2 - 1.0e-12 && a2 > M_PI_2)
+ || (a1 > a2 - 1.0e-12 && a1 < M_PI_2) )
+ maxY = std::max(data.center.y + data.radius, maxY);
-VectorSolutions RS_Arc::getRefPoints() {
- VectorSolutions ret(startpoint, endpoint, data.center);
- return ret;
+ minV.set(minX, minY);
+ maxV.set(maxX, maxY);
}
+Vector RS_Arc::getNearestEndpoint(const Vector & coord, double * dist)
+{
+ double dist1, dist2;
+ Vector * nearerPoint;
-Vector RS_Arc::getNearestEndpoint(const Vector& coord, double* dist) {
- double dist1, dist2;
- Vector* nearerPoint;
-
- dist1 = startpoint.distanceTo(coord);
- dist2 = endpoint.distanceTo(coord);
+ dist1 = startpoint.distanceTo(coord);
+ dist2 = endpoint.distanceTo(coord);
- if (dist2<dist1) {
- if (dist!=NULL) {
- *dist = dist2;
- }
- nearerPoint = &endpoint;
- } else {
- if (dist!=NULL) {
- *dist = dist1;
- }
- nearerPoint = &startpoint;
- }
+ if (dist2 < dist1)
+ {
+ if (dist != NULL)
+ *dist = dist2;
+ nearerPoint = &endpoint;
+ }
+ else
+ {
+ if (dist != NULL)
+ *dist = dist1;
+ nearerPoint = &startpoint;
+ }
- return *nearerPoint;
+ return *nearerPoint;
}
+Vector RS_Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity)
+{
+ Vector vec(false);
+ if (entity != NULL)
+ *entity = this;
-Vector RS_Arc::getNearestPointOnEntity(const Vector& coord,
- bool onEntity, double* dist, RS_Entity** entity) {
+ double angle = (coord - data.center).angle();
- Vector vec(false);
- if (entity!=NULL) {
- *entity = this;
- }
+ if (onEntity == false || RS_Math::isAngleBetween(angle,
+ data.angle1, data.angle2, isReversed()))
+ {
+ vec.setPolar(data.radius, angle);
+ vec += data.center;
+ }
- double angle = (coord-data.center).angle();
- if (onEntity==false || RS_Math::isAngleBetween(angle,
- data.angle1, data.angle2, isReversed())) {
- vec.setPolar(data.radius, angle);
- vec+=data.center;
- }
- if (dist!=NULL) {
- *dist = fabs((vec-data.center).magnitude()-data.radius);
- }
+ if (dist != NULL)
+ *dist = fabs((vec - data.center).magnitude() - data.radius);
- return vec;
+ return vec;
}
-
-
-Vector RS_Arc::getNearestCenter(const Vector& coord,
- double* dist) {
- if (dist!=NULL) {
- *dist = coord.distanceTo(data.center);
- }
- return data.center;
+Vector RS_Arc::getNearestCenter(const Vector & coord, double * dist)
+{
+ if (dist != NULL)
+ *dist = coord.distanceTo(data.center);
+ return data.center;
}
+Vector RS_Arc::getNearestMiddle(const Vector & coord, double * dist)
+{
+ Vector ret = getMiddlepoint();
-
-Vector RS_Arc::getNearestMiddle(const Vector& coord,
- double* dist) {
-
- Vector ret = getMiddlepoint();
-
- if (dist!=NULL) {
- *dist = coord.distanceTo(ret);
- }
- return ret;
+ if (dist != NULL)
+ *dist = coord.distanceTo(ret);
+ return ret;
}
+Vector RS_Arc::getNearestDist(double distance, const Vector & coord, double * dist)
+{
+ if (data.radius < 1.0e-6)
+ {
+ if (dist != NULL)
+ *dist = RS_MAXDOUBLE;
+ return Vector(false);
+ }
+ double a1, a2;
+ Vector p1, p2;
+ double aDist = distance / data.radius;
-Vector RS_Arc::getNearestDist(double distance,
- const Vector& coord,
- double* dist) {
-
- if (data.radius<1.0e-6) {
- if (dist!=NULL) {
- *dist = RS_MAXDOUBLE;
- }
- return Vector(false);
- }
-
- double a1, a2;
- Vector p1, p2;
- double aDist = distance / data.radius;
-
- if (isReversed()) {
- a1 = data.angle1 - aDist;
- a2 = data.angle2 + aDist;
- } else {
- a1 = data.angle1 + aDist;
- a2 = data.angle2 - aDist;
- }
+ if (isReversed())
+ {
+ a1 = data.angle1 - aDist;
+ a2 = data.angle2 + aDist;
+ }
+ else
+ {
+ a1 = data.angle1 + aDist;
+ a2 = data.angle2 - aDist;
+ }
- p1.setPolar(data.radius, a1);
- p1 += data.center;
- p2.setPolar(data.radius, a2);
- p2 += data.center;
+ p1.setPolar(data.radius, a1);
+ p1 += data.center;
+ p2.setPolar(data.radius, a2);
+ p2 += data.center;
- double dist1, dist2;
- Vector* nearerPoint;
+ double dist1, dist2;
+ Vector * nearerPoint;
- dist1 = p1.distanceTo(coord);
- dist2 = p2.distanceTo(coord);
+ dist1 = p1.distanceTo(coord);
+ dist2 = p2.distanceTo(coord);
- if (dist2<dist1) {
- if (dist!=NULL) {
- *dist = dist2;
- }
- nearerPoint = &p2;
- } else {
- if (dist!=NULL) {
- *dist = dist1;
- }
- nearerPoint = &p1;
- }
+ if (dist2 < dist1)
+ {
+ if (dist != NULL)
+ *dist = dist2;
+ nearerPoint = &p2;
+ }
+ else
+ {
+ if (dist != NULL)
+ *dist = dist1;
+ nearerPoint = &p1;
+ }
- return *nearerPoint;
+ return *nearerPoint;
}
+Vector RS_Arc::getNearestDist(double distance, bool startp)
+{
+ if (data.radius < 1.0e-6)
+ return Vector(false);
+
+ double a;
+ Vector p;
+ double aDist = distance / data.radius;
+
+ if (isReversed())
+ {
+ if (startp)
+ a = data.angle1 - aDist;
+ else
+ a = data.angle2 + aDist;
+ }
+ else
+ {
+ if (startp)
+ a = data.angle1 + aDist;
+ else
+ a = data.angle2 - aDist;
+ }
+ p.setPolar(data.radius, a);
+ p += data.center;
-
-Vector RS_Arc::getNearestDist(double distance,
- bool startp) {
-
- if (data.radius<1.0e-6) {
- return Vector(false);
- }
-
- double a;
- Vector p;
- double aDist = distance / data.radius;
-
- if (isReversed()) {
- if (startp) {
- a = data.angle1 - aDist;
- } else {
- a = data.angle2 + aDist;
- }
- } else {
- if (startp) {
- a = data.angle1 + aDist;
- } else {
- a = data.angle2 - aDist;
- }
- }
-
- p.setPolar(data.radius, a);
- p += data.center;
-
- return p;
+ return p;
}
+double RS_Arc::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double)
+{
+ if (entity != NULL)
+ *entity = this;
+ // check endpoints first:
+ double dist = coord.distanceTo(getStartpoint());
-double RS_Arc::getDistanceToPoint(const Vector& coord,
- RS_Entity** entity,
- RS2::ResolveLevel,
- double) {
- if (entity!=NULL) {
- *entity = this;
- }
+ if (dist < 1.0e-4)
+ return dist;
+ dist = coord.distanceTo(getEndpoint());
- // check endpoints first:
- double dist = coord.distanceTo(getStartpoint());
- if (dist<1.0e-4) {
- return dist;
- }
- dist = coord.distanceTo(getEndpoint());
- if (dist<1.0e-4) {
- return dist;
- }
+ if (dist < 1.0e-4)
+ return dist;
- if (RS_Math::isAngleBetween(data.center.angleTo(coord),
- data.angle1, data.angle2,
- isReversed())) {
+ if (RS_Math::isAngleBetween(data.center.angleTo(coord),
+ data.angle1, data.angle2,
+ isReversed()))
- return fabs((coord-data.center).magnitude() - data.radius);
- } else {
- return RS_MAXDOUBLE;
- }
+ return fabs((coord - data.center).magnitude() - data.radius);
+ else
+ return RS_MAXDOUBLE;
}
-
-
-void RS_Arc::moveStartpoint(const Vector& pos) {
- // polyline arcs: move point not angle:
- //if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) {
- double bulge = getBulge();
- createFrom2PBulge(pos, getEndpoint(), bulge);
- //}
+void RS_Arc::moveStartpoint(const Vector & pos)
+{
+ // polyline arcs: move point not angle:
+ //if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) {
+ double bulge = getBulge();
+ createFrom2PBulge(pos, getEndpoint(), bulge);
+ //}
// normal arc: move angle1
/*else {
- data.angle1 = data.center.angleTo(pos);
- calculateEndpoints();
- calculateBorders();
- }*/
+ data.angle1 = data.center.angleTo(pos);
+ calculateEndpoints();
+ calculateBorders();
+ }*/
}
-
-
-void RS_Arc::moveEndpoint(const Vector& pos) {
- // polyline arcs: move point not angle:
- //if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) {
- double bulge = getBulge();
- createFrom2PBulge(getStartpoint(), pos, bulge);
- //}
+void RS_Arc::moveEndpoint(const Vector & pos)
+{
+ // polyline arcs: move point not angle:
+ //if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) {
+ double bulge = getBulge();
+ createFrom2PBulge(getStartpoint(), pos, bulge);
+ //}
// normal arc: move angle1
/*else {
- data.angle2 = data.center.angleTo(pos);
+ data.angle2 = data.center.angleTo(pos);
calculateEndpoints();
- calculateBorders();
- }*/
+ calculateBorders();
+ }*/
}
-
-
-void RS_Arc::trimStartpoint(const Vector& pos) {
- data.angle1 = data.center.angleTo(pos);
- calculateEndpoints();
- calculateBorders();
+void RS_Arc::trimStartpoint(const Vector & pos)
+{
+ data.angle1 = data.center.angleTo(pos);
+ calculateEndpoints();
+ calculateBorders();
}
-
-
-void RS_Arc::trimEndpoint(const Vector& pos) {
- data.angle2 = data.center.angleTo(pos);
- calculateEndpoints();
- calculateBorders();
+void RS_Arc::trimEndpoint(const Vector & pos)
+{
+ data.angle2 = data.center.angleTo(pos);
+ calculateEndpoints();
+ calculateBorders();
}
-
-RS2::Ending RS_Arc::getTrimPoint(const Vector& coord,
- const Vector& trimPoint) {
-
- double angEl = data.center.angleTo(trimPoint);
- double angM = data.center.angleTo(coord);
-
- if (RS_Math::getAngleDifference(angM, angEl)>M_PI) {
- if (data.reversed) {
- return RS2::EndingEnd;
- } else {
- return RS2::EndingStart;
- }
- } else {
- if (data.reversed) {
- return RS2::EndingStart;
- } else {
- return RS2::EndingEnd;
- }
- }
+RS2::Ending RS_Arc::getTrimPoint(const Vector & coord, const Vector & trimPoint)
+{
+ double angEl = data.center.angleTo(trimPoint);
+ double angM = data.center.angleTo(coord);
+
+ if (RS_Math::getAngleDifference(angM, angEl) > M_PI)
+ {
+ if (data.reversed)
+ return RS2::EndingEnd;
+ else
+ return RS2::EndingStart;
+ }
+ else
+ {
+ if (data.reversed)
+ return RS2::EndingStart;
+ else
+ return RS2::EndingEnd;
+ }
}
-
-void RS_Arc::reverse() {
- double a = data.angle1;
- data.angle1 = data.angle2;
- data.angle2 = a;
- data.reversed = !data.reversed;
- calculateEndpoints();
- calculateBorders();
+void RS_Arc::reverse()
+{
+ double a = data.angle1;
+ data.angle1 = data.angle2;
+ data.angle2 = a;
+ data.reversed = !data.reversed;
+ calculateEndpoints();
+ calculateBorders();
}
-
-void RS_Arc::move(Vector offset) {
- data.center.move(offset);
- calculateEndpoints();
- calculateBorders();
+void RS_Arc::move(Vector offset)
+{
+ data.center.move(offset);
+ calculateEndpoints();
+ calculateBorders();
}
-
-
-void RS_Arc::rotate(Vector center, double angle) {
- RS_DEBUG->print("RS_Arc::rotate");
- data.center.rotate(center, angle);
- data.angle1 = RS_Math::correctAngle(data.angle1+angle);
- data.angle2 = RS_Math::correctAngle(data.angle2+angle);
- calculateEndpoints();
- calculateBorders();
- RS_DEBUG->print("RS_Arc::rotate: OK");
+void RS_Arc::rotate(Vector center, double angle)
+{
+ RS_DEBUG->print("RS_Arc::rotate");
+ data.center.rotate(center, angle);
+ data.angle1 = RS_Math::correctAngle(data.angle1 + angle);
+ data.angle2 = RS_Math::correctAngle(data.angle2 + angle);
+ calculateEndpoints();
+ calculateBorders();
+ RS_DEBUG->print("RS_Arc::rotate: OK");
}
+void RS_Arc::scale(Vector center, Vector factor)
+{
+ // negative scaling: mirroring
+ if (factor.x < 0.0)
+ mirror(data.center, data.center + Vector(0.0, 1.0));
+ //factor.x*=-1;
-void RS_Arc::scale(Vector center, Vector factor) {
- // negative scaling: mirroring
- if (factor.x<0.0) {
- mirror(data.center, data.center + Vector(0.0, 1.0));
- //factor.x*=-1;
- }
- if (factor.y<0.0) {
- mirror(data.center, data.center + Vector(1.0, 0.0));
- //factor.y*=-1;
- }
-
- data.center.scale(center, factor);
- data.radius *= factor.x;
- if (data.radius<0.0) {
- data.radius*=-1.0;
- }
- calculateEndpoints();
- calculateBorders();
-}
+ if (factor.y < 0.0)
+ mirror(data.center, data.center + Vector(1.0, 0.0));
+ //factor.y*=-1;
+ data.center.scale(center, factor);
+ data.radius *= factor.x;
+ if (data.radius < 0.0)
+ data.radius *= -1.0;
+ calculateEndpoints();
+ calculateBorders();
+}
-void RS_Arc::mirror(Vector axisPoint1, Vector axisPoint2) {
- data.center.mirror(axisPoint1, axisPoint2);
- data.reversed = (!data.reversed);
- /*
- startpoint.mirror(axisPoint1, axisPoint2);
- endpoint.mirror(axisPoint1, axisPoint2);
+void RS_Arc::mirror(Vector axisPoint1, Vector axisPoint2)
+{
+ data.center.mirror(axisPoint1, axisPoint2);
+ data.reversed = (!data.reversed);
+ /*
+ startpoint.mirror(axisPoint1, axisPoint2);
+ endpoint.mirror(axisPoint1, axisPoint2);
- data.angle1 = data.center.angleTo(startpoint);
- data.angle2 = data.center.angleTo(endpoint);
- */
+ data.angle1 = data.center.angleTo(startpoint);
+ data.angle2 = data.center.angleTo(endpoint);
+ */
- Vector vec;
- vec.setPolar(1.0, data.angle1);
- vec.mirror(Vector(0.0,0.0), axisPoint2-axisPoint1);
- data.angle1 = vec.angle();
+ Vector vec;
+ vec.setPolar(1.0, data.angle1);
+ vec.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1);
+ data.angle1 = vec.angle();
- vec.setPolar(1.0, data.angle2);
- vec.mirror(Vector(0.0,0.0), axisPoint2-axisPoint1);
- data.angle2 = vec.angle();
+ vec.setPolar(1.0, data.angle2);
+ vec.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1);
+ data.angle2 = vec.angle();
- calculateEndpoints();
- calculateBorders();
+ calculateEndpoints();
+ calculateBorders();
}
+void RS_Arc::moveRef(const Vector & ref, const Vector & offset)
+{
+ if (ref.distanceTo(startpoint) < 1.0e-4)
+ moveStartpoint(startpoint + offset);
-void RS_Arc::moveRef(const Vector& ref, const Vector& offset) {
- if (ref.distanceTo(startpoint)<1.0e-4) {
- moveStartpoint(startpoint+offset);
- }
- if (ref.distanceTo(endpoint)<1.0e-4) {
- moveEndpoint(endpoint+offset);
- }
+ if (ref.distanceTo(endpoint) < 1.0e-4)
+ moveEndpoint(endpoint + offset);
}
+void RS_Arc::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
+{
+ if (getMin().isInWindow(firstCorner, secondCorner)
+ && getMax().isInWindow(firstCorner, secondCorner))
+ move(offset);
+ else
+ {
+ if (getStartpoint().isInWindow(firstCorner,
+ secondCorner))
+ moveStartpoint(getStartpoint() + offset);
-void RS_Arc::stretch(Vector firstCorner,
- Vector secondCorner,
- Vector offset) {
-
- if (getMin().isInWindow(firstCorner, secondCorner) &&
- getMax().isInWindow(firstCorner, secondCorner)) {
- move(offset);
- }
- else {
- if (getStartpoint().isInWindow(firstCorner,
- secondCorner)) {
- moveStartpoint(getStartpoint() + offset);
- }
- if (getEndpoint().isInWindow(firstCorner,
- secondCorner)) {
- moveEndpoint(getEndpoint() + offset);
- }
+ if (getEndpoint().isInWindow(firstCorner,
+ secondCorner))
+ moveEndpoint(getEndpoint() + offset);
}
}
-//void RS_Arc::draw(RS_Painter* painter, RS_GraphicView* view,
-void RS_Arc::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Arc::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
- if (painter == NULL || view == NULL)
- return;
+ if (painter == NULL || view == NULL)
+ return;
+
+ //double styleFactor = getStyleFactor();
+
+ // simple style-less lines
+ if (getPen().getLineType() == RS2::SolidLine
+ || isSelected()
+ || view->getDrawingMode() == RS2::ModePreview)
+
+ painter->drawArc(view->toGui(getCenter()),
+ getRadius() * view->getFactor().x,
+ getAngle1(), getAngle2(),
+ isReversed());
+ else
+ {
+ double styleFactor = getStyleFactor(view);
+
+ if (styleFactor < 0.0)
+ {
+ painter->drawArc(view->toGui(getCenter()),
+ getRadius() * view->getFactor().x,
+ getAngle1(), getAngle2(),
+ isReversed());
+ return;
+ }
- //double styleFactor = getStyleFactor();
+ // Pattern:
+ RS_LineTypePattern * pat;
- // simple style-less lines
- if (getPen().getLineType()==RS2::SolidLine ||
- isSelected() ||
- view->getDrawingMode()==RS2::ModePreview) {
+ if (isSelected())
+ pat = &patternSelected;
+ else
+ pat = view->getPattern(getPen().getLineType());
- painter->drawArc(view->toGui(getCenter()),
- getRadius() * view->getFactor().x,
- getAngle1(), getAngle2(),
- isReversed());
- } else {
- double styleFactor = getStyleFactor(view);
- if (styleFactor<0.0) {
- painter->drawArc(view->toGui(getCenter()),
- getRadius() * view->getFactor().x,
- getAngle1(), getAngle2(),
- isReversed());
+ if (pat == NULL)
return;
- }
- // Pattern:
- RS_LineTypePattern* pat;
- if (isSelected()) {
- pat = &patternSelected;
- } else {
- pat = view->getPattern(getPen().getLineType());
- }
-
- if (pat==NULL) {
- return;
- }
-
- if (getRadius()<1.0e-6) {
- return;
- }
-
- // Pen to draw pattern is always solid:
- RS_Pen pen = painter->getPen();
- pen.setLineType(RS2::SolidLine);
- painter->setPen(pen);
-
- double a1;
- double a2;
- if (data.reversed) {
- a2 = getAngle1();
- a1 = getAngle2();
- } else {
- a1 = getAngle1();
- a2 = getAngle2();
- }
-
- double* da; // array of distances in x.
- int i; // index counter
-
- double length = getAngleLength();
-
- // create scaled pattern:
- da = new double[pat->num];
-
- for (i=0; i<pat->num; ++i) {
- da[i] = fabs(pat->pattern[i] * styleFactor) / getRadius();
- }
-
- double tot=0.0;
- i=0;
- bool done = false;
- double curA = a1;
- //double cx = getCenter().x * factor.x + offsetX;
- //double cy = - a->getCenter().y * factor.y + getHeight() - offsetY;
- Vector cp = view->toGui(getCenter());
- double r = getRadius() * view->getFactor().x;
-
- do {
- if (pat->pattern[i] > 0.0) {
- if (tot+da[i]<length) {
- painter->drawArc(cp, r,
- curA,
- curA + da[i],
- false);
- } else {
- painter->drawArc(cp, r,
- curA,
- a2,
- false);
- }
- }
- curA+=da[i];
- tot+=da[i];
- done=tot>length;
-
- i++;
- if (i>=pat->num) {
- i=0;
- }
- } while(!done);
-
- delete[] da;
- }
-}
+ if (getRadius() < 1.0e-6)
+ return;
+ // Pen to draw pattern is always solid:
+ RS_Pen pen = painter->getPen();
+ pen.setLineType(RS2::SolidLine);
+ painter->setPen(pen);
+ double a1;
+ double a2;
+
+ if (data.reversed)
+ {
+ a2 = getAngle1();
+ a1 = getAngle2();
+ }
+ else
+ {
+ a1 = getAngle1();
+ a2 = getAngle2();
+ }
+
+ double * da; // array of distances in x.
+ int i; // index counter
+
+ double length = getAngleLength();
+
+ // create scaled pattern:
+ da = new double[pat->num];
+
+ for (i = 0; i < pat->num; ++i)
+ da[i] = fabs(pat->pattern[i] * styleFactor) / getRadius();
+
+ double tot = 0.0;
+ i = 0;
+ bool done = false;
+ double curA = a1;
+ //double cx = getCenter().x * factor.x + offsetX;
+ //double cy = - a->getCenter().y * factor.y + getHeight() - offsetY;
+ Vector cp = view->toGui(getCenter());
+ double r = getRadius() * view->getFactor().x;
+
+ do
+ {
+ if (pat->pattern[i] > 0.0)
+ {
+ if (tot + da[i] < length)
+ painter->drawArc(cp, r,
+ curA,
+ curA + da[i],
+ false);
+ else
+ painter->drawArc(cp, r,
+ curA,
+ a2,
+ false);
+ }
+ curA += da[i];
+ tot += da[i];
+ done = tot > length;
+
+ i++;
+
+ if (i >= pat->num)
+ i = 0;
+ }
+ while (!done);
+
+ delete[] da;
+ }
+}
/**
* @return Middle point of the entity.
*/
-Vector RS_Arc::getMiddlepoint() const {
- double a;
- Vector ret;
+Vector RS_Arc::getMiddlepoint() const
+{
+ double a;
+ Vector ret;
- if (isReversed()) {
- a = data.angle1 - getAngleLength()/2.0;
- } else {
- a = data.angle1 + getAngleLength()/2.0;
- }
- ret.setPolar(data.radius, a);
- ret+=data.center;
+ if (isReversed())
+ a = data.angle1 - getAngleLength() / 2.0;
+ else
+ a = data.angle1 + getAngleLength() / 2.0;
+ ret.setPolar(data.radius, a);
+ ret += data.center;
- return ret;
+ return ret;
}
-
-
/**
* @return Angle length in rad.
*/
-double RS_Arc::getAngleLength() const {
- double ret = 0.0;
-
- if (isReversed()) {
- if (data.angle1<data.angle2) {
- ret = data.angle1+2*M_PI-data.angle2;
- } else {
- ret = data.angle1-data.angle2;
- }
- } else {
- if (data.angle2<data.angle1) {
- ret = data.angle2+2*M_PI-data.angle1;
- } else {
- ret = data.angle2-data.angle1;
- }
- }
+double RS_Arc::getAngleLength() const
+{
+ double ret = 0.0;
+
+ if (isReversed())
+ {
+ if (data.angle1 < data.angle2)
+ ret = data.angle1 + 2 * M_PI - data.angle2;
+ else
+ ret = data.angle1 - data.angle2;
+ }
+ else
+ {
+ if (data.angle2 < data.angle1)
+ ret = data.angle2 + 2 * M_PI - data.angle1;
+ else
+ ret = data.angle2 - data.angle1;
+ }
- // full circle:
- if (fabs(ret)<1.0e-6) {
- ret = 2*M_PI;
- }
+ // full circle:
+ if (fabs(ret) < 1.0e-6)
+ ret = 2 * M_PI;
- return ret;
+ return ret;
}
-
-
/**
* @return Length of the arc.
*/
-double RS_Arc::getLength() {
- return getAngleLength()*data.radius;
+double RS_Arc::getLength()
+{
+ return getAngleLength() * data.radius;
}
-
-
/**
* Gets the arc's bulge (tangens of angle length divided by 4).
*/
-double RS_Arc::getBulge() const {
- double bulge = tan(fabs(getAngleLength())/4.0);
- if (isReversed()) {
- bulge*=-1;
- }
- return bulge;
-}
-
+double RS_Arc::getBulge() const
+{
+ double bulge = tan(fabs(getAngleLength()) / 4.0);
+ if (isReversed())
+ bulge *= -1;
+ return bulge;
+}
/**
* Dumps the point's data to stdout.
*/
-std::ostream& operator << (std::ostream& os, const RS_Arc& a) {
- os << " Arc: " << a.data << "\n";
- return os;
+std::ostream & operator<<(std::ostream & os, const RS_Arc & a)
+{
+ os << " Arc: " << a.data << "\n";
+ return os;
}
#include "rs_atomicentity.h"
class PaintInterface;
+class GraphicView;
/**
* Holds the data that defines an arc.
*/
-class RS_ArcData {
-public:
- RS_ArcData() {}
-
- RS_ArcData(const Vector& center,
- double radius,
- double angle1, double angle2,
- bool reversed) {
-
- this->center = center;
- this->radius = radius;
- this->angle1 = angle1;
- this->angle2 = angle2;
- this->reversed = reversed;
- }
-
- void reset() {
- center = Vector(false);
- radius = 0.0;
- angle1 = 0.0;
- angle2 = 0.0;
- reversed = false;
- }
-
- bool isValid() {
- return (center.valid && radius>RS_TOLERANCE &&
- fabs(angle1-angle2)>RS_TOLERANCE_ANGLE);
- }
-
- friend std::ostream& operator << (std::ostream& os, const RS_ArcData& ad) {
- os << "(" << ad.center <<
- "/" << ad.radius <<
- " " << ad.angle1 <<
- "," << ad.angle2 <<
- ")";
- return os;
- }
-
-public:
- Vector center;
- double radius;
- double angle1;
- double angle2;
- bool reversed;
-};
+class RS_ArcData
+{
+ public:
+ RS_ArcData()
+ {
+ }
+
+ RS_ArcData(const Vector & center, double radius, double angle1, double angle2, bool reversed)
+ {
+ this->center = center;
+ this->radius = radius;
+ this->angle1 = angle1;
+ this->angle2 = angle2;
+ this->reversed = reversed;
+ }
+
+ void reset()
+ {
+ center = Vector(false);
+ radius = 0.0;
+ angle1 = 0.0;
+ angle2 = 0.0;
+ reversed = false;
+ }
+
+ bool isValid()
+ {
+ return (center.valid && radius > RS_TOLERANCE
+ && fabs(angle1 - angle2) > RS_TOLERANCE_ANGLE);
+ }
+ friend std::ostream & operator<<(std::ostream & os, const RS_ArcData & ad)
+ {
+ os << "(" << ad.center
+ << "/" << ad.radius
+ << " " << ad.angle1
+ << "," << ad.angle2
+ << ")";
+ return os;
+ }
+ public:
+ Vector center;
+ double radius;
+ double angle1;
+ double angle2;
+ bool reversed;
+};
/**
* Class for an arc entity. All angles are in Rad.
*
* @author Andrew Mustun
*/
-class RS_Arc : public RS_AtomicEntity {
-public:
- RS_Arc(RS_EntityContainer* parent,
- const RS_ArcData& d);
- virtual ~RS_Arc() {}
-
- virtual RS_Entity* clone() {
- RS_Arc* a = new RS_Arc(*this);
- a->initId();
- return a;
- }
-
- /** @return RS2::EntityArc */
- virtual RS2::EntityType rtti() const {
- return RS2::EntityArc;
- }
- /** @return true */
- virtual bool isEdge() const {
- return true;
- }
-
- /** @return Copy of data that defines the arc. **/
- RS_ArcData getData() const {
- return data;
- }
-
- virtual VectorSolutions getRefPoints();
-
- /** Sets new arc parameters. **/
- void setData(RS_ArcData d) {
- data = d;
- }
-
- /** @return The center point (x) of this arc */
- Vector getCenter() const {
- return data.center;
- }
- /** Sets new center. */
- void setCenter(const Vector& c) {
- data.center = c;
- }
-
- /** @return The radius of this arc */
- double getRadius() const {
- return data.radius;
- }
- /** Sets new radius. */
- void setRadius(double r) {
- data.radius = r;
- }
-
- /** @return The start angle of this arc */
- double getAngle1() const {
- return data.angle1;
- }
- /** Sets new start angle. */
- void setAngle1(double a1) {
- data.angle1 = a1;
- }
- /** @return The end angle of this arc */
- double getAngle2() const {
- return data.angle2;
- }
- /** Sets new end angle. */
- void setAngle2(double a2) {
- data.angle2 = a2;
- }
- /**
- * @return Direction 1. The angle at which the arc starts at
- * the startpoint.
- */
- double getDirection1() const {
- if (!data.reversed) {
- return RS_Math::correctAngle(data.angle1+M_PI/2.0);
- }
- else {
- return RS_Math::correctAngle(data.angle1-M_PI/2.0);
- }
- }
- /**
- * @return Direction 2. The angle at which the arc starts at
- * the endpoint.
- */
- double getDirection2() const {
- if (!data.reversed) {
- return RS_Math::correctAngle(data.angle2-M_PI/2.0);
- }
- else {
- return RS_Math::correctAngle(data.angle2+M_PI/2.0);
- }
- }
-
- /**
- * @retval true if the arc is reversed (clockwise),
- * @retval false otherwise
- */
- bool isReversed() const {
- return data.reversed;
- }
- /** sets the reversed status. */
- void setReversed(bool r) {
- data.reversed = r;
- }
-
- /** @return Start point of the entity. */
- virtual Vector getStartpoint() const {
- return startpoint;
- }
- /** @return End point of the entity. */
- virtual Vector getEndpoint() const {
- return endpoint;
- }
- virtual void moveStartpoint(const Vector& pos);
- virtual void moveEndpoint(const Vector& pos);
-
- virtual void trimStartpoint(const Vector& pos);
- virtual void trimEndpoint(const Vector& pos);
-
- virtual RS2::Ending getTrimPoint(const Vector& coord,
- const Vector& trimPoint);
-
- virtual void reverse();
-
- Vector getMiddlepoint() const;
- double getAngleLength() const;
- virtual double getLength();
- double getBulge() const;
-
- bool createFrom3P(const Vector& p1, const Vector& p2,
- const Vector& p3);
- bool createFrom2PDirectionRadius(const Vector& startPoint, const Vector& endPoint,
- double direction1, double radius);
- bool createFrom2PBulge(const Vector& startPoint, const Vector& endPoint,
- double bulge);
-
- virtual Vector getNearestEndpoint(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestPointOnEntity(const Vector& coord,
- bool onEntity = true, double* dist = NULL, RS_Entity** entity=NULL);
- virtual Vector getNearestCenter(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestMiddle(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestDist(double distance,
- const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestDist(double distance,
- bool startp);
-
- virtual double getDistanceToPoint(const Vector& coord,
- RS_Entity** entity=NULL,
- RS2::ResolveLevel level=RS2::ResolveNone,
- double solidDist = RS_MAXDOUBLE);
- virtual void move(Vector offset);
- virtual void rotate(Vector center, double angle);
- virtual void scale(Vector center, Vector factor);
- virtual void mirror(Vector axisPoint1, Vector axisPoint2);
- virtual void moveRef(const Vector& ref, const Vector& offset);
- virtual void stretch(Vector firstCorner,
- Vector secondCorner,
- Vector offset);
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-
- friend std::ostream & operator<<(std::ostream & os, const RS_Arc & a);
-
- virtual void calculateEndpoints();
- virtual void calculateBorders();
-
-protected:
- RS_ArcData data;
-
- /**
- * Startpoint. This is redundant but stored for performance
- * reasons.
- */
- Vector startpoint;
- /**
- * Endpoint. This is redundant but stored for performance
- * reasons.
- */
- Vector endpoint;
+class RS_Arc: public RS_AtomicEntity
+{
+ public:
+ RS_Arc(RS_EntityContainer * parent, const RS_ArcData & d);
+ virtual ~RS_Arc();
+
+ virtual RS_Entity * clone();
+ virtual RS2::EntityType rtti() const;
+ virtual bool isEdge() const;
+ RS_ArcData getData() const;
+ virtual VectorSolutions getRefPoints();
+ void setData(RS_ArcData d);
+ Vector getCenter() const;
+ void setCenter(const Vector & c);
+ double getRadius() const;
+ void setRadius(double r);
+ double getAngle1() const;
+ void setAngle1(double a1);
+ double getAngle2() const;
+ void setAngle2(double a2);
+ double getDirection1() const;
+ double getDirection2() const;
+ bool isReversed() const;
+ void setReversed(bool r);
+ virtual Vector getStartpoint() const;
+ virtual Vector getEndpoint() const;
+ virtual void moveStartpoint(const Vector & pos);
+ virtual void moveEndpoint(const Vector & pos);
+ virtual void trimStartpoint(const Vector & pos);
+ virtual void trimEndpoint(const Vector & pos);
+ virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
+ virtual void reverse();
+ Vector getMiddlepoint() const;
+ double getAngleLength() const;
+ virtual double getLength();
+ double getBulge() const;
+
+ bool createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3);
+ bool createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius);
+ bool createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge);
+
+ virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
+ virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, bool startp);
+
+ virtual double getDistanceToPoint(const Vector & coord, RS_Entity * * entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
+ virtual void move(Vector offset);
+ virtual void rotate(Vector center, double angle);
+ virtual void scale(Vector center, Vector factor);
+ virtual void mirror(Vector axisPoint1, Vector axisPoint2);
+ virtual void moveRef(const Vector & ref, const Vector & offset);
+ virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
+
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_Arc & a);
+
+ virtual void calculateEndpoints();
+ virtual void calculateBorders();
+
+ protected:
+ RS_ArcData data;
+
+ /**
+ * Startpoint. This is redundant but stored for performance
+ * reasons.
+ */
+ Vector startpoint;
+ /**
+ * Endpoint. This is redundant but stored for performance
+ * reasons.
+ */
+ Vector endpoint;
};
#endif
#include "rs_constructionline.h"
#include "rs_information.h"
-#include "rs_graphicview.h"
+#include "rs_linetypepattern.h"
+#include "graphicview.h"
#include "paintintf.h"
/**
RS_Circle::RS_Circle(RS_EntityContainer * parent, const RS_CircleData & d):
RS_AtomicEntity(parent), data(d)
{
- calculateBorders();
+ calculateBorders();
+}
+
+/*virtual*/ RS_Circle::~RS_Circle()
+{
+}
+
+/*virtual*/ RS_Entity * RS_Circle::clone()
+{
+ RS_Circle * c = new RS_Circle(*this);
+ c->initId();
+ return c;
+}
+
+/** @return RS2::EntityCircle */
+/*virtual*/ RS2::EntityType RS_Circle::rtti() const
+{
+ return RS2::EntityCircle;
+}
+
+/** @return true */
+/*virtual*/ bool RS_Circle::isEdge() const
+{
+ return true;
+}
+
+/** @return Copy of data that defines the circle. **/
+RS_CircleData RS_Circle::getData()
+{
+ return data;
+}
+
+VectorSolutions RS_Circle::getRefPoints()
+{
+ Vector v1(data.radius, 0.0);
+ Vector v2(0.0, data.radius);
+
+ VectorSolutions ret(data.center, data.center + v1, data.center + v2, data.center - v1, data.center - v2);
+ return ret;
+}
+
+/*virtual*/ Vector RS_Circle::getStartpoint() const
+{
+ return data.center + Vector(data.radius, 0.0);
+}
+
+/*virtual*/ Vector RS_Circle::getEndpoint() const
+{
+ return data.center + Vector(data.radius, 0.0);
+}
+
+/**
+ * @return Direction 1. The angle at which the arc starts at
+ * the startpoint.
+ */
+double RS_Circle::getDirection1() const
+{
+ return M_PI / 2.0;
+}
+
+/**
+ * @return Direction 2. The angle at which the arc starts at
+ * the endpoint.
+ */
+double RS_Circle::getDirection2() const
+{
+ return M_PI / 2.0 * 3.0;
+}
+
+/** @return The center point (x) of this arc */
+Vector RS_Circle::getCenter()
+{
+ return data.center;
+}
+
+/** Sets new center. */
+void RS_Circle::setCenter(const Vector & c)
+{
+ data.center = c;
+}
+
+/** @return The radius of this arc */
+double RS_Circle::getRadius()
+{
+ return data.radius;
+}
+
+/** Sets new radius. */
+void RS_Circle::setRadius(double r)
+{
+ data.radius = r;
}
void RS_Circle::calculateBorders()
{
- Vector r(data.radius,data.radius,0.0);
+ Vector r(data.radius, data.radius, 0.0);
minV = data.center - r;
maxV = data.center + r;
}
/**
* @return Angle length in rad.
*/
-double RS_Circle::getAngleLength() const {
- return 2*M_PI;
+double RS_Circle::getAngleLength() const
+{
+ return 2 * M_PI;
}
-
-
/**
* @return Length of the circle which is the circumference.
*/
-double RS_Circle::getLength() {
- return 2*M_PI*data.radius;
+double RS_Circle::getLength()
+{
+ return 2 * M_PI * data.radius;
}
-
/**
* Creates this circle from a center point and a radius.
*
* @param c Center.
* @param r Radius
*/
-bool RS_Circle::createFromCR(const Vector& c, double r) {
- if (fabs(r)>RS_TOLERANCE) {
- data.radius = fabs(r);
- data.center = c;
- return true;
- } else {
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFromCR(): "
- "Cannot create a circle with radius 0.0.");
- return false;
- }
+bool RS_Circle::createFromCR(const Vector & c, double r)
+{
+ if (fabs(r) > RS_TOLERANCE)
+ {
+ data.radius = fabs(r);
+ data.center = c;
+ return true;
+ }
+ else
+ {
+ RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFromCR(): "
+ "Cannot create a circle with radius 0.0.");
+ return false;
+ }
}
-
-
/**
* Creates this circle from two opposite points.
*
* @param p1 1st point.
* @param p2 2nd point.
*/
-bool RS_Circle::createFrom2P(const Vector& p1, const Vector& p2) {
- if (p1.distanceTo(p2)>RS_TOLERANCE) {
- data.radius = p1.distanceTo(p2)/2.0;
- data.center = p1 + (p2-p1)/2.0;
- return true;
- } else {
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom2P(): "
- "Cannot create a circle with radius 0.0.");
- return false;
- }
+bool RS_Circle::createFrom2P(const Vector & p1, const Vector & p2)
+{
+ if (p1.distanceTo(p2) > RS_TOLERANCE)
+ {
+ data.radius = p1.distanceTo(p2) / 2.0;
+ data.center = p1 + (p2 - p1) / 2.0;
+ return true;
+ }
+ else
+ {
+ RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom2P(): "
+ "Cannot create a circle with radius 0.0.");
+ return false;
+ }
}
-
-
/**
* Creates this circle from 3 given points which define the circle line.
*
* @param p2 2nd point.
* @param p3 3rd point.
*/
-bool RS_Circle::createFrom3P(const Vector& p1, const Vector& p2,
- const Vector& p3) {
- if (p1.distanceTo(p2)>RS_TOLERANCE &&
- p2.distanceTo(p3)>RS_TOLERANCE &&
- p3.distanceTo(p1)>RS_TOLERANCE) {
-
- // middle points between 3 points:
- Vector mp1, mp2;
- Vector dir1, dir2;
- double a1, a2;
-
- // intersection of two middle lines
- mp1 = (p1 + p2)/2.0;
- a1 = p1.angleTo(p2) + M_PI/2.0;
- dir1.setPolar(100.0, a1);
- mp2 = (p2 + p3)/2.0;
- a2 = p2.angleTo(p3) + M_PI/2.0;
- dir2.setPolar(100.0, a2);
-
- RS_ConstructionLineData d1(mp1, mp1 + dir1);
- RS_ConstructionLineData d2(mp2, mp2 + dir2);
- RS_ConstructionLine midLine1(NULL, d1);
- RS_ConstructionLine midLine2(NULL, d2);
-
- VectorSolutions sol =
- RS_Information::getIntersection(&midLine1, &midLine2);
-
- data.center = sol.get(0);
- data.radius = data.center.distanceTo(p3);
-
- if (sol.get(0).valid && data.radius<1.0e14 && data.radius>RS_TOLERANCE) {
- return true;
- } else {
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
- "Cannot create a circle with inf radius.");
- return false;
- }
- } else {
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
- "Cannot create a circle with radius 0.0.");
- return false;
- }
-}
-
-
-
-VectorSolutions RS_Circle::getRefPoints() {
- Vector v1(data.radius, 0.0);
- Vector v2(0.0, data.radius);
-
- VectorSolutions ret(data.center,
- data.center+v1, data.center+v2,
- data.center-v1, data.center-v2);
- return ret;
+bool RS_Circle::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3)
+{
+ if (p1.distanceTo(p2) > RS_TOLERANCE
+ && p2.distanceTo(p3) > RS_TOLERANCE
+ && p3.distanceTo(p1) > RS_TOLERANCE)
+ {
+ // middle points between 3 points:
+ Vector mp1, mp2;
+ Vector dir1, dir2;
+ double a1, a2;
+
+ // intersection of two middle lines
+ mp1 = (p1 + p2) / 2.0;
+ a1 = p1.angleTo(p2) + M_PI / 2.0;
+ dir1.setPolar(100.0, a1);
+ mp2 = (p2 + p3) / 2.0;
+ a2 = p2.angleTo(p3) + M_PI / 2.0;
+ dir2.setPolar(100.0, a2);
+
+ RS_ConstructionLineData d1(mp1, mp1 + dir1);
+ RS_ConstructionLineData d2(mp2, mp2 + dir2);
+ RS_ConstructionLine midLine1(NULL, d1);
+ RS_ConstructionLine midLine2(NULL, d2);
+
+ VectorSolutions sol =
+ RS_Information::getIntersection(&midLine1, &midLine2);
+
+ data.center = sol.get(0);
+ data.radius = data.center.distanceTo(p3);
+
+ if (sol.get(0).valid && data.radius < 1.0e14 && data.radius > RS_TOLERANCE)
+ return true;
+ else
+ {
+ RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
+ "Cannot create a circle with inf radius.");
+ return false;
+ }
+ }
+ else
+ {
+ RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
+ "Cannot create a circle with radius 0.0.");
+ return false;
+ }
}
-
/**
* @return Always an invalid vector.
*/
-Vector RS_Circle::getNearestEndpoint(const Vector& /*coord*/, double* dist) {
- if (dist!=NULL) {
- *dist = RS_MAXDOUBLE;
- }
- return Vector(false);
+Vector RS_Circle::getNearestEndpoint(const Vector & /*coord*/, double * dist)
+{
+ if (dist != NULL)
+ *dist = RS_MAXDOUBLE;
+ return Vector(false);
}
+Vector RS_Circle::getNearestPointOnEntity(const Vector & coord, bool /*onEntity*/, double * dist, RS_Entity ** entity)
+{
+ Vector vec(false);
+ if (entity != NULL)
+ *entity = this;
-Vector RS_Circle::getNearestPointOnEntity(const Vector& coord,
- bool /*onEntity*/, double* dist, RS_Entity** entity) {
-
- Vector vec(false);
- if (entity!=NULL) {
- *entity = this;
- }
-
- double angle = (coord-data.center).angle();
- vec.setPolar(data.radius, angle);
- vec+=data.center;
+ double angle = (coord - data.center).angle();
+ vec.setPolar(data.radius, angle);
+ vec += data.center;
- if (dist!=NULL) {
- *dist = fabs((vec-data.center).magnitude()-data.radius);
- }
+ if (dist != NULL)
+ *dist = fabs((vec - data.center).magnitude() - data.radius);
- return vec;
+ return vec;
}
-
-
-Vector RS_Circle::getNearestCenter(const Vector& coord,
- double* dist) {
- if (dist!=NULL) {
- *dist = coord.distanceTo(data.center);
- }
- return data.center;
+Vector RS_Circle::getNearestCenter(const Vector & coord, double * dist)
+{
+ if (dist != NULL)
+ *dist = coord.distanceTo(data.center);
+ return data.center;
}
-
-
-Vector RS_Circle::getNearestMiddle(const Vector& /*coord*/,
- double* dist) {
- if (dist!=NULL) {
- *dist = RS_MAXDOUBLE;
- }
- return Vector(false);
+Vector RS_Circle::getNearestMiddle(const Vector & /*coord*/, double * dist)
+{
+ if (dist != NULL)
+ *dist = RS_MAXDOUBLE;
+ return Vector(false);
}
-
-
-Vector RS_Circle::getNearestDist(double /*distance*/,
- const Vector& /*coord*/,
- double* dist) {
-
- if (dist!=NULL) {
- *dist = RS_MAXDOUBLE;
- }
- return Vector(false);
+Vector RS_Circle::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
+{
+ if (dist != NULL)
+ *dist = RS_MAXDOUBLE;
+ return Vector(false);
}
-Vector RS_Circle::getNearestDist(double /*distance*/,
- bool /*startp*/) {
-
- return Vector(false);
+Vector RS_Circle::getNearestDist(double /*distance*/, bool /*startp*/)
+{
+ return Vector(false);
}
+double RS_Circle::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double)
+{
+ if (entity != NULL)
+ *entity = this;
-
-double RS_Circle::getDistanceToPoint(const Vector& coord,
- RS_Entity** entity,
- RS2::ResolveLevel, double) {
- if (entity!=NULL) {
- *entity = this;
- }
-
- return fabs((coord-data.center).magnitude() - data.radius);
+ return fabs((coord - data.center).magnitude() - data.radius);
}
-
-
-void RS_Circle::move(Vector offset) {
- data.center.move(offset);
- calculateBorders();
+void RS_Circle::move(Vector offset)
+{
+ data.center.move(offset);
+ calculateBorders();
}
-
-
-void RS_Circle::rotate(Vector center, double angle) {
- data.center.rotate(center, angle);
- calculateBorders();
+void RS_Circle::rotate(Vector center, double angle)
+{
+ data.center.rotate(center, angle);
+ calculateBorders();
}
-
-
-void RS_Circle::scale(Vector center, Vector factor) {
- data.center.scale(center, factor);
- data.radius *= factor.x;
- calculateBorders();
+void RS_Circle::scale(Vector center, Vector factor)
+{
+ data.center.scale(center, factor);
+ data.radius *= factor.x;
+ calculateBorders();
}
-
-
-void RS_Circle::mirror(Vector axisPoint1, Vector axisPoint2) {
+void RS_Circle::mirror(Vector axisPoint1, Vector axisPoint2)
+{
data.center.mirror(axisPoint1, axisPoint2);
- calculateBorders();
+ calculateBorders();
}
-void RS_Circle::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Circle::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
- if (painter == NULL || view == NULL)
- return;
-
- // simple style-less lines
- if (getPen().getLineType()==RS2::SolidLine ||
- isSelected() ||
- view->getDrawingMode()==RS2::ModePreview) {
-
- painter->drawArc(view->toGui(getCenter()),
- getRadius() * view->getFactor().x,
- 0.0, 2*M_PI,
- false);
- } else {
+ if (painter == NULL || view == NULL)
+ return;
+
+ // simple style-less lines
+ if (getPen().getLineType() == RS2::SolidLine
+ || isSelected()
+ || view->getDrawingMode() == RS2::ModePreview)
+
+ painter->drawArc(view->toGui(getCenter()),
+ getRadius() * view->getFactor().x,
+ 0.0, 2 * M_PI,
+ false);
+ else
+ {
double styleFactor = getStyleFactor(view);
- if (styleFactor<0.0) {
- painter->drawArc(view->toGui(getCenter()),
- getRadius() * view->getFactor().x,
- 0.0, 2*M_PI,
- false);
+
+ if (styleFactor < 0.0)
+ {
+ painter->drawArc(view->toGui(getCenter()),
+ getRadius() * view->getFactor().x,
+ 0.0, 2 * M_PI,
+ false);
return;
}
- // Pattern:
- RS_LineTypePattern* pat;
- if (isSelected()) {
- pat = &patternSelected;
- } else {
- pat = view->getPattern(getPen().getLineType());
- }
+ // Pattern:
+ RS_LineTypePattern * pat;
- if (pat==NULL) {
- return;
- }
+ if (isSelected())
+ pat = &patternSelected;
+ else
+ pat = view->getPattern(getPen().getLineType());
- if (getRadius()<1.0e-6) {
+ if (pat == NULL)
return;
+
+ if (getRadius() < 1.0e-6)
+ return;
+
+ // Pen to draw pattern is always solid:
+ RS_Pen pen = painter->getPen();
+ pen.setLineType(RS2::SolidLine);
+ painter->setPen(pen);
+
+ double * da; // array of distances in x.
+ int i; // index counter
+
+ double length = getAngleLength();
+
+ // create pattern:
+ da = new double[pat->num];
+
+ for (i = 0; i < pat->num; ++i)
+ da[i] = fabs(pat->pattern[i] * styleFactor) / getRadius();
+
+ double tot = 0.0;
+ i = 0;
+ bool done = false;
+ double curA = 0.0;
+ //double cx = getCenter().x * factor.x + offsetX;
+ //double cy = - a->getCenter().y * factor.y + getHeight() - offsetY;
+ Vector cp = view->toGui(getCenter());
+ double r = getRadius() * view->getFactor().x;
+
+ do
+ {
+ if (pat->pattern[i] * styleFactor > 0.0)
+ {
+ if (tot + fabs(da[i]) < length)
+ painter->drawArc(cp, r,
+ curA,
+ curA + da[i],
+ false);
+ else
+ painter->drawArc(cp, r,
+ curA,
+ 2 * M_PI,
+ false);
+ }
+ curA += da[i];
+ tot += fabs(da[i]);
+ done = tot > length;
+
+ i++;
+
+ if (i >= pat->num)
+ i = 0;
}
+ while (!done);
- // Pen to draw pattern is always solid:
- RS_Pen pen = painter->getPen();
- pen.setLineType(RS2::SolidLine);
- painter->setPen(pen);
-
- double* da; // array of distances in x.
- int i; // index counter
-
- double length = getAngleLength();
-
- // create pattern:
- da = new double[pat->num];
-
- for (i=0; i<pat->num; ++i) {
- da[i] = fabs(pat->pattern[i] * styleFactor)/getRadius();
- }
-
- double tot=0.0;
- i=0;
- bool done = false;
- double curA = 0.0;
- //double cx = getCenter().x * factor.x + offsetX;
- //double cy = - a->getCenter().y * factor.y + getHeight() - offsetY;
- Vector cp = view->toGui(getCenter());
- double r = getRadius() * view->getFactor().x;
-
- do {
- if (pat->pattern[i] * styleFactor > 0.0) {
- if (tot+fabs(da[i])<length) {
- painter->drawArc(cp, r,
- curA,
- curA + da[i],
- false);
- } else {
- painter->drawArc(cp, r,
- curA,
- 2*M_PI,
- false);
- }
- }
- curA+=da[i];
- tot+=fabs(da[i]);
- done=tot>length;
-
- i++;
- if (i>=pat->num) {
- i=0;
- }
- } while(!done);
-
- delete[] da;
- }
-}
-
-
-
-void RS_Circle::moveRef(const Vector& ref, const Vector& offset) {
+ delete[] da;
+ }
+}
+
+void RS_Circle::moveRef(const Vector & ref, const Vector & offset)
+{
Vector v1(data.radius, 0.0);
Vector v2(0.0, data.radius);
- if (ref.distanceTo(data.center + v1)<1.0e-4) {
+ if (ref.distanceTo(data.center + v1) < 1.0e-4)
data.radius = data.center.distanceTo(data.center + v1 + offset);
- } else if (ref.distanceTo(data.center + v2)<1.0e-4) {
+ else if (ref.distanceTo(data.center + v2) < 1.0e-4)
data.radius = data.center.distanceTo(data.center + v2 + offset);
- } else if (ref.distanceTo(data.center - v1)<1.0e-4) {
+ else if (ref.distanceTo(data.center - v1) < 1.0e-4)
data.radius = data.center.distanceTo(data.center - v1 + offset);
- } else if (ref.distanceTo(data.center - v2)<1.0e-4) {
+ else if (ref.distanceTo(data.center - v2) < 1.0e-4)
data.radius = data.center.distanceTo(data.center - v2 + offset);
- }
}
-
/**
* Dumps the circle's data to stdout.
*/
-std::ostream& operator << (std::ostream& os, const RS_Circle& a) {
- os << " Circle: " << a.data << "\n";
- return os;
+std::ostream & operator<<(std::ostream & os, const RS_Circle & a)
+{
+ os << " Circle: " << a.data << "\n";
+ return os;
}
*/
class RS_CircleData
{
-public:
- RS_CircleData() {}
-
- RS_CircleData(const Vector& center,
- double radius) {
-
- this->center = center;
- this->radius = radius;
- }
-
- void reset() {
- center = Vector(false);
- radius = 0.0;
- }
-
- bool isValid() {
- return (center.valid && radius>RS_TOLERANCE);
- }
-
- friend class RS_Circle;
-
- friend std::ostream& operator << (std::ostream& os,
- const RS_CircleData& ad) {
- os << "(" << ad.center <<
- "/" << ad.radius <<
- ")";
- return os;
- }
-
-public:
- Vector center;
- double radius;
+ public:
+ RS_CircleData()
+ {
+ }
+
+ RS_CircleData(const Vector & center, double radius)
+ {
+ this->center = center;
+ this->radius = radius;
+ }
+
+ void reset()
+ {
+ center = Vector(false);
+ radius = 0.0;
+ }
+
+ bool isValid()
+ {
+ return (center.valid && radius > RS_TOLERANCE);
+ }
+
+ friend class RS_Circle;
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_CircleData & ad)
+ {
+ os << "(" << ad.center << "/" << ad.radius << ")";
+ return os;
+ }
+
+ public:
+ Vector center;
+ double radius;
};
-
-
/**
* Class for a circle entity.
*
* @author Andrew Mustun
*/
-class RS_Circle : public RS_AtomicEntity
+class RS_Circle: public RS_AtomicEntity
{
-public:
- RS_Circle (RS_EntityContainer* parent,
- const RS_CircleData& d);
- virtual ~RS_Circle() {}
-
- virtual RS_Entity* clone() {
- RS_Circle* c = new RS_Circle(*this);
- c->initId();
- return c;
- }
-
- /** @return RS2::EntityCircle */
- virtual RS2::EntityType rtti() const {
- return RS2::EntityCircle;
- }
- /** @return true */
- virtual bool isEdge() const {
- return true;
- }
-
- /** @return Copy of data that defines the circle. **/
- RS_CircleData getData() {
- return data;
- }
-
- virtual VectorSolutions getRefPoints();
-
- virtual Vector getStartpoint() const {
- return data.center + Vector(data.radius, 0.0);
- }
- virtual Vector getEndpoint() const {
- return data.center + Vector(data.radius, 0.0);
- }
- /**
- * @return Direction 1. The angle at which the arc starts at
- * the startpoint.
- */
- double getDirection1() const {
- return M_PI/2.0;
- }
- /**
- * @return Direction 2. The angle at which the arc starts at
- * the endpoint.
- */
- double getDirection2() const {
- return M_PI/2.0*3.0;
- }
-
- /** @return The center point (x) of this arc */
- Vector getCenter() {
- return data.center;
- }
- /** Sets new center. */
- void setCenter(const Vector& c) {
- data.center = c;
- }
- /** @return The radius of this arc */
- double getRadius() {
- return data.radius;
- }
- /** Sets new radius. */
- void setRadius(double r) {
- data.radius = r;
- }
- double getAngleLength() const;
- virtual double getLength();
-
- bool createFromCR(const Vector& c, double r);
- bool createFrom2P(const Vector& p1, const Vector& p2);
- bool createFrom3P(const Vector& p1, const Vector& p2,
- const Vector& p3);
-
- virtual Vector getNearestEndpoint(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestPointOnEntity(const Vector& coord,
- bool onEntity = true, double* dist = NULL, RS_Entity** entity=NULL);
- virtual Vector getNearestCenter(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestMiddle(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestDist(double distance,
- const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestDist(double distance,
- bool startp);
- virtual double getDistanceToPoint(const Vector& coord,
- RS_Entity** entity=NULL,
- RS2::ResolveLevel level=RS2::ResolveNone,
- double solidDist = RS_MAXDOUBLE);
-
- virtual void move(Vector offset);
- virtual void rotate(Vector center, double angle);
- virtual void scale(Vector center, Vector factor);
- virtual void mirror(Vector axisPoint1, Vector axisPoint2);
- virtual void moveRef(const Vector& ref, const Vector& offset);
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-
- friend std::ostream & operator<<(std::ostream & os, const RS_Circle & a);
-
- virtual void calculateBorders();
-
-protected:
- RS_CircleData data;
+ public:
+ RS_Circle (RS_EntityContainer * parent, const RS_CircleData & d);
+ virtual ~RS_Circle();
+
+ virtual RS_Entity * clone();
+ virtual RS2::EntityType rtti() const;
+ virtual bool isEdge() const;
+ RS_CircleData getData();
+ virtual VectorSolutions getRefPoints();
+ virtual Vector getStartpoint() const;
+ virtual Vector getEndpoint() const;
+ double getDirection1() const;
+ double getDirection2() const;
+ Vector getCenter();
+ void setCenter(const Vector & c);
+ double getRadius();
+ void setRadius(double r);
+ double getAngleLength() const;
+ virtual double getLength();
+
+ bool createFromCR(const Vector & c, double r);
+ bool createFrom2P(const Vector & p1, const Vector & p2);
+ bool createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3);
+ virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true,
+ double * dist = NULL, RS_Entity ** entity = NULL);
+ virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, bool startp);
+ virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
+
+ virtual void move(Vector offset);
+ virtual void rotate(Vector center, double angle);
+ virtual void scale(Vector center, Vector factor);
+ virtual void mirror(Vector axisPoint1, Vector axisPoint2);
+ virtual void moveRef(const Vector & ref, const Vector & offset);
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_Circle & a);
+
+ virtual void calculateBorders();
+
+ protected:
+ RS_CircleData data;
};
#endif
data.point2.mirror(axisPoint1, axisPoint2);
}
+/*virtual*/ void RS_ConstructionLine::draw(PaintInterface *, GraphicView *, double)
+{
+}
+
/**
* Dumps the point's data to stdout.
*/
virtual void rotate(Vector center, double angle);
virtual void scale(Vector center, Vector factor);
virtual void mirror(Vector axisPoint1, Vector axisPoint2);
- virtual void draw(PaintInterface * /*painter*/, RS_GraphicView * /*view*/,
- double /*patternOffset*/) {}
+ virtual void draw(PaintInterface * /*painter*/, GraphicView * /*view*/,
+ double /*patternOffset*/);
friend std::ostream & operator<<(std::ostream & os, const RS_ConstructionLine & l);
virtual void calculateBorders();
#include "rs_constructionline.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_image.h"
#include "rs_information.h"
#include "rs_insert.h"
* entities. Usually that's an Drawing entity but
* it can also be a polyline, text, ...
*/
-RS_Creation::RS_Creation(RS_EntityContainer * container, RS_GraphicView * graphicView,
+RS_Creation::RS_Creation(RS_EntityContainer * container, GraphicView * graphicView,
bool handleUndo)
{
this->container = container;
class Drawing;
class RS_Entity;
class RS_EntityContainer;
-class RS_GraphicView;
+class GraphicView;
class RS_Image;
class RS_ImageData;
class RS_Insert;
class RS_Creation
{
public:
- RS_Creation(RS_EntityContainer * container, RS_GraphicView * graphicView = NULL,
+ RS_Creation(RS_EntityContainer * container, GraphicView * graphicView = NULL,
bool handleUndo = true);
RS_Entity * createParallelThrough(const Vector & coord, int number,
RS_EntityContainer * container;
Drawing * graphic;
RS_Document * document;
- RS_GraphicView * graphicView;
+ GraphicView * graphicView;
bool handleUndo;
};
virtual ~RS_DialogFactoryAdapter() {}
virtual void requestPreviousMenu() {}
virtual void requestWarningDialog(const QString &) {}
- virtual RS_GraphicView * requestNewDocument(const QString & = QString::null,
+ virtual GraphicView * requestNewDocument(const QString & = QString::null,
RS_Document * = NULL) { return NULL; }
virtual void requestSimulationControls() {}
virtual RS_Layer * requestNewLayerDialog(RS_LayerList * = NULL) { return NULL; }
class RS_DimLinearData;
class RS_DimensionData;
class RS_Document;
+class Drawing;
class RS_Entity;
class RS_EventHandler;
-class Drawing;
-class RS_GraphicView;
+class GraphicView;
class RS_Grid;
class RS_Hatch;
class RS_Insert;
* window for the given document or for a new document if no document
* is given.
*/
- virtual RS_GraphicView * requestNewDocument(const QString & fileName = QString::null,
+ virtual GraphicView * requestNewDocument(const QString & fileName = QString::null,
RS_Document * doc = NULL) = 0;
/**
#include "rs_ellipse.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_information.h"
+#include "rs_linetypepattern.h"
#include "paintintf.h"
/**
calculateBorders();
}
-/**
- * Recalculates the endpoints using the angles and the radius.
- */
- /*
-void RS_Ellipse::calculateEndpoints() {
- double angle = data.majorP.angle();
- double radius1 = getMajorRadius();
- double radius2 = getMinorRadius();
+/*virtual*/ RS_Ellipse::~RS_Ellipse()
+{
+}
- startpoint.set(data.center.x + cos(data.angle1) * radius1,
- data.center.y + sin(data.angle1) * radius2);
- startpoint.rotate(data.center, angle);
- endpoint.set(data.center.x + cos(data.angle2) * radius1,
- data.center.y + sin(data.angle2) * radius2);
- endpoint.rotate(data.center, angle);
+/*virtual*/ RS_Entity * RS_Ellipse::clone()
+{
+ RS_Ellipse * e = new RS_Ellipse(*this);
+ e->initId();
+ return e;
}
-*/
+/** @return RS2::EntityEllipse */
+/*virtual*/ RS2::EntityType RS_Ellipse::rtti() const
+{
+ return RS2::EntityEllipse;
+}
/**
- * Calculates the boundary box of this ellipse.
- *
- * @todo Fix that - the algorithm used is really bad / slow.
+ * @return Start point of the entity.
*/
-void RS_Ellipse::calculateBorders() {
- RS_DEBUG->print("RS_Ellipse::calculateBorders");
-
- double radius1 = getMajorRadius();
- double radius2 = getMinorRadius();
- double angle = getAngle();
- double a1 = ((!isReversed()) ? data.angle1 : data.angle2);
- double a2 = ((!isReversed()) ? data.angle2 : data.angle1);
- Vector startpoint = getStartpoint();
- Vector endpoint = getEndpoint();
+/*virtual*/ Vector RS_Ellipse::getStartpoint() const
+{
+ Vector p;
+ p.set(data.center.x + cos(data.angle1) * getMajorRadius(),
+ data.center.y + sin(data.angle1) * getMinorRadius());
+ p.rotate(data.center, getAngle());
+ return p;
+}
- double minX = std::min(startpoint.x, endpoint.x);
- double minY = std::min(startpoint.y, endpoint.y);
- double maxX = std::max(startpoint.x, endpoint.x);
- double maxY = std::max(startpoint.y, endpoint.y);
+/**
+ * @return End point of the entity.
+ */
+/*virtual*/ Vector RS_Ellipse::getEndpoint() const
+{
+ Vector p;
+ p.set(data.center.x + cos(data.angle2) * getMajorRadius(),
+ data.center.y + sin(data.angle2) * getMinorRadius());
+ p.rotate(data.center, getAngle());
+ return p;
+}
- // kind of a brute force. TODO: exact calculation
- Vector vp;
- double a = a1;
- do {
- vp.set(data.center.x + radius1 * cos(a),
- data.center.y + radius2 * sin(a));
- vp.rotate(data.center, angle);
+void RS_Ellipse::moveStartpoint(const Vector & pos)
+{
+ data.angle1 = getEllipseAngle(pos);
+ //data.angle1 = data.center.angleTo(pos);
+ //calculateEndpoints();
+ calculateBorders();
+}
- minX = std::min(minX, vp.x);
- minY = std::min(minY, vp.y);
- maxX = std::max(maxX, vp.x);
- maxY = std::max(maxY, vp.y);
+void RS_Ellipse::moveEndpoint(const Vector & pos)
+{
+ data.angle2 = getEllipseAngle(pos);
+ //data.angle2 = data.center.angleTo(pos);
+ //calculateEndpoints();
+ calculateBorders();
+}
- a += 0.03;
- } while (RS_Math::isAngleBetween(RS_Math::correctAngle(a), a1, a2, false) &&
- a<4*M_PI);
+RS2::Ending RS_Ellipse::getTrimPoint(const Vector & coord, const Vector & trimPoint)
+{
+ double angEl = getEllipseAngle(trimPoint);
+ double angM = getEllipseAngle(coord);
+ if (RS_Math::getAngleDifference(angM, angEl) > M_PI)
+ //if (data.reversed) {
+ // return RS2::EndingEnd;
+ //}
+ //else {
+ return RS2::EndingStart;
+ //}
+ else
+ //if (data.reversed) {
+ // return RS2::EndingStart;
+ //}
+ //else {
+ return RS2::EndingEnd;
+ //}
+}
- minV.set(minX, minY);
- maxV.set(maxX, maxY);
- RS_DEBUG->print("RS_Ellipse::calculateBorders: OK");
+double RS_Ellipse::getEllipseAngle(const Vector & pos)
+{
+ Vector m = pos;
+ m.rotate(data.center, -data.majorP.angle());
+ Vector v = m - data.center;
+ v.scale(Vector(1.0, 1.0 / data.ratio));
+ return v.angle();
}
+/** @return Copy of data that defines the ellipse. **/
+RS_EllipseData RS_Ellipse::getData()
+{
+ return data;
+}
+VectorSolutions RS_Ellipse::getRefPoints()
+{
+ VectorSolutions ret(getStartpoint(), getEndpoint(), data.center);
+ return ret;
+}
-VectorSolutions RS_Ellipse::getRefPoints() {
- VectorSolutions ret(getStartpoint(), getEndpoint(), data.center);
- return ret;
+/**
+ * @retval true if the arc is reversed (clockwise),
+ * @retval false otherwise
+ */
+bool RS_Ellipse::isReversed() const
+{
+ return data.reversed;
}
+/** sets the reversed status. */
+void RS_Ellipse::setReversed(bool r)
+{
+ data.reversed = r;
+}
+/** @return The rotation angle of this ellipse */
+double RS_Ellipse::getAngle() const
+{
+ return data.majorP.angle();
+}
-Vector RS_Ellipse::getNearestEndpoint(const Vector& coord, double* dist) {
- double dist1, dist2;
- Vector nearerPoint;
- Vector startpoint = getStartpoint();
- Vector endpoint = getEndpoint();
+/** @return The start angle of this arc */
+double RS_Ellipse::getAngle1()
+{
+ return data.angle1;
+}
- dist1 = startpoint.distanceTo(coord);
- dist2 = endpoint.distanceTo(coord);
-
- if (dist2<dist1) {
- if (dist!=NULL) {
- *dist = dist2;
- }
- nearerPoint = endpoint;
- } else {
- if (dist!=NULL) {
- *dist = dist1;
- }
- nearerPoint = startpoint;
- }
-
- return nearerPoint;
-}
-
-
-
-Vector RS_Ellipse::getNearestPointOnEntity(const Vector& coord,
- bool onEntity, double* dist, RS_Entity** entity) {
-
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity");
-
- Vector ret(false);
-
- if (entity!=NULL) {
- *entity = this;
- }
- double ang = getAngle();
-
- Vector normalized = (coord - data.center).rotate(-ang);
-
- double dU = normalized.x;
- double dV = normalized.y;
- double dA = getMajorRadius();
- double dB = getMinorRadius();
- double dEpsilon = 1.0e-8;
- int iMax = 32;
- int riIFinal = 0;
- double rdX = 0.0;
- double rdY = 0.0;
- double dDistance;
- bool swap = false;
- bool majorSwap = false;
-
- if (dA<dB) {
- double dum = dA;
- dA = dB;
- dB = dum;
- dum = dU;
- dU = dV;
- dV = dum;
- majorSwap = true;
- }
-
- if (dV<0.0) {
- dV*=-1.0;
- swap = true;
- }
-
- // initial guess
- double dT = dB*(dV - dB);
-
- // Newton s method
- int i;
- for (i = 0; i < iMax; i++) {
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: i: %d", i);
- double dTpASqr = dT + dA*dA;
- double dTpBSqr = dT + dB*dB;
- double dInvTpASqr = 1.0/dTpASqr;
- double dInvTpBSqr = 1.0/dTpBSqr;
- double dXDivA = dA*dU*dInvTpASqr;
- double dYDivB = dB*dV*dInvTpBSqr;
- double dXDivASqr = dXDivA*dXDivA;
- double dYDivBSqr = dYDivB*dYDivB;
- double dF = dXDivASqr + dYDivBSqr - 1.0;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dF: %f", dF);
- if ( fabs(dF) < dEpsilon ) {
- // F(t0) is close enough to zero, terminate the iteration:
- rdX = dXDivA*dA;
- rdY = dYDivB*dB;
- riIFinal = i;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 1: %f,%f", rdX, rdY);
- break;
- }
- double dFDer = 2.0*(dXDivASqr*dInvTpASqr + dYDivBSqr*dInvTpBSqr);
- double dRatio = dF/dFDer;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dRatio: %f", dRatio);
- if ( fabs(dRatio) < dEpsilon ) {
- // t1-t0 is close enough to zero, terminate the iteration:
- rdX = dXDivA*dA;
- rdY = dYDivB*dB;
- riIFinal = i;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
- break;
- }
- dT += dRatio;
- }
- if ( i == iMax ) {
- // failed to converge:
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: failed");
- dDistance = RS_MAXDOUBLE;
- }
- else {
- double dDelta0 = rdX - dU;
- double dDelta1 = rdY - dV;
- dDistance = sqrt(dDelta0*dDelta0 + dDelta1*dDelta1);
- ret = Vector(rdX, rdY);
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: ret: %f,%f", ret.x, ret.y);
- }
-
- if (dist!=NULL) {
- if (ret.valid) {
- *dist = dDistance;
- } else {
- *dist = RS_MAXDOUBLE;
- }
- }
-
- if (ret.valid) {
- if (swap) {
- ret.y*=-1.0;
- }
- if (majorSwap) {
- double dum = ret.x;
- ret.x = ret.y;
- ret.y = dum;
- }
- ret = (ret.rotate(ang) + data.center);
-
- if (onEntity) {
- double a1 = data.center.angleTo(getStartpoint());
- double a2 = data.center.angleTo(getEndpoint());
- double a = data.center.angleTo(ret);
- if (!RS_Math::isAngleBetween(a, a1, a2, data.reversed)) {
- ret = Vector(false);
- }
- }
- }
-
- return ret;
+/** Sets new start angle. */
+void RS_Ellipse::setAngle1(double a1)
+{
+ data.angle1 = a1;
}
+/** @return The end angle of this arc */
+double RS_Ellipse::getAngle2()
+{
+ return data.angle2;
+}
+/** Sets new end angle. */
+void RS_Ellipse::setAngle2(double a2)
+{
+ data.angle2 = a2;
+}
-/**
- * @param tolerance Tolerance.
- *
- * @retval true if the given point is on this entity.
- * @retval false otherwise
- */
-bool RS_Ellipse::isPointOnEntity(const Vector& coord,
- double tolerance) {
- double dist = getDistanceToPoint(coord, NULL, RS2::ResolveNone);
- return (dist<=tolerance);
+/** @return The center point (x) of this arc */
+Vector RS_Ellipse::getCenter()
+{
+ return data.center;
}
+/** Sets new center. */
+void RS_Ellipse::setCenter(const Vector & c)
+{
+ data.center = c;
+}
+/** @return The endpoint of the major axis (relative to center). */
+Vector RS_Ellipse::getMajorP()
+{
+ return data.majorP;
+}
-Vector RS_Ellipse::getNearestCenter(const Vector& coord,
- double* dist) {
- if (dist!=NULL) {
- *dist = coord.distanceTo(data.center);
- }
- return data.center;
+/** Sets new major point (relative to center). */
+void RS_Ellipse::setMajorP(const Vector & p)
+{
+ data.majorP = p;
}
+/** @return The ratio of minor to major axis */
+double RS_Ellipse::getRatio()
+{
+ return data.ratio;
+}
+/** Sets new ratio. */
+void RS_Ellipse::setRatio(double r)
+{
+ data.ratio = r;
+}
/**
- * @todo Implement this.
+ * @return Angle length in rad.
*/
-Vector RS_Ellipse::getNearestMiddle(const Vector& /*coord*/,
- double* dist) {
- if (dist!=NULL) {
- *dist = RS_MAXDOUBLE;
- }
- return Vector(false);
+/*virtual*/ double RS_Ellipse::getAngleLength() const
+{
+ if (isReversed())
+ return data.angle1 - data.angle2;
+ else
+ return data.angle2 - data.angle1;
}
+/** @return The major radius of this ellipse. Same as getRadius() */
+double RS_Ellipse::getMajorRadius() const
+{
+ return data.majorP.magnitude();
+}
-
-Vector RS_Ellipse::getNearestDist(double /*distance*/,
- const Vector& /*coord*/,
- double* dist) {
- if (dist!=NULL) {
- *dist = RS_MAXDOUBLE;
- }
- return Vector(false);
+/** @return The minor radius of this ellipse */
+double RS_Ellipse::getMinorRadius() const
+{
+ return data.majorP.magnitude() * data.ratio;
}
+/**
+ * Recalculates the endpoints using the angles and the radius.
+ */
+/*
+ void RS_Ellipse::calculateEndpoints() {
+ double angle = data.majorP.angle();
+ double radius1 = getMajorRadius();
+ double radius2 = getMinorRadius();
+
+ startpoint.set(data.center.x + cos(data.angle1) * radius1,
+ data.center.y + sin(data.angle1) * radius2);
+ startpoint.rotate(data.center, angle);
+ endpoint.set(data.center.x + cos(data.angle2) * radius1,
+ data.center.y + sin(data.angle2) * radius2);
+ endpoint.rotate(data.center, angle);
+ }
+ */
+/**
+ * Calculates the boundary box of this ellipse.
+ *
+ * @todo Fix that - the algorithm used is really bad / slow.
+ */
+void RS_Ellipse::calculateBorders()
+{
+ RS_DEBUG->print("RS_Ellipse::calculateBorders");
+
+ double radius1 = getMajorRadius();
+ double radius2 = getMinorRadius();
+ double angle = getAngle();
+ double a1 = ((!isReversed()) ? data.angle1 : data.angle2);
+ double a2 = ((!isReversed()) ? data.angle2 : data.angle1);
+ Vector startpoint = getStartpoint();
+ Vector endpoint = getEndpoint();
-double RS_Ellipse::getDistanceToPoint(const Vector& coord,
- RS_Entity** entity,
- RS2::ResolveLevel, double /*solidDist*/) {
- double dist = RS_MAXDOUBLE;
- getNearestPointOnEntity(coord, true, &dist, entity);
+ double minX = std::min(startpoint.x, endpoint.x);
+ double minY = std::min(startpoint.y, endpoint.y);
+ double maxX = std::max(startpoint.x, endpoint.x);
+ double maxY = std::max(startpoint.y, endpoint.y);
- return dist;
+ // kind of a brute force. TODO: exact calculation
+ Vector vp;
+ double a = a1;
-}
+ do
+ {
+ vp.set(data.center.x + radius1 * cos(a),
+ data.center.y + radius2 * sin(a));
+ vp.rotate(data.center, angle);
+ minX = std::min(minX, vp.x);
+ minY = std::min(minY, vp.y);
+ maxX = std::max(maxX, vp.x);
+ maxY = std::max(maxY, vp.y);
+ a += 0.03;
+ }
+ while (RS_Math::isAngleBetween(RS_Math::correctAngle(a), a1, a2, false)
+ && a < 4 * M_PI);
-void RS_Ellipse::move(Vector offset) {
- data.center.move(offset);
- //calculateEndpoints();
- calculateBorders();
+ minV.set(minX, minY);
+ maxV.set(maxX, maxY);
+ RS_DEBUG->print("RS_Ellipse::calculateBorders: OK");
}
+Vector RS_Ellipse::getNearestEndpoint(const Vector & coord, double * dist)
+{
+ double dist1, dist2;
+ Vector nearerPoint;
+ Vector startpoint = getStartpoint();
+ Vector endpoint = getEndpoint();
+ dist1 = startpoint.distanceTo(coord);
+ dist2 = endpoint.distanceTo(coord);
-void RS_Ellipse::rotate(Vector center, double angle) {
- data.center.rotate(center, angle);
- data.majorP.rotate(angle);
- //calculateEndpoints();
- calculateBorders();
+ if (dist2 < dist1)
+ {
+ if (dist != NULL)
+ *dist = dist2;
+ nearerPoint = endpoint;
+ }
+ else
+ {
+ if (dist != NULL)
+ *dist = dist1;
+ nearerPoint = startpoint;
+ }
+
+ return nearerPoint;
}
+Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity)
+{
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity");
+
+ Vector ret(false);
+
+ if (entity != NULL)
+ *entity = this;
+ double ang = getAngle();
+
+ Vector normalized = (coord - data.center).rotate(-ang);
+
+ double dU = normalized.x;
+ double dV = normalized.y;
+ double dA = getMajorRadius();
+ double dB = getMinorRadius();
+ double dEpsilon = 1.0e-8;
+ int iMax = 32;
+ int riIFinal = 0;
+ double rdX = 0.0;
+ double rdY = 0.0;
+ double dDistance;
+ bool swap = false;
+ bool majorSwap = false;
+
+ if (dA < dB)
+ {
+ double dum = dA;
+ dA = dB;
+ dB = dum;
+ dum = dU;
+ dU = dV;
+ dV = dum;
+ majorSwap = true;
+ }
+ if (dV < 0.0)
+ {
+ dV *= -1.0;
+ swap = true;
+ }
-void RS_Ellipse::moveStartpoint(const Vector& pos) {
- data.angle1 = getEllipseAngle(pos);
- //data.angle1 = data.center.angleTo(pos);
- //calculateEndpoints();
- calculateBorders();
-}
+ // initial guess
+ double dT = dB * (dV - dB);
+ // Newton s method
+ int i;
+ for (i = 0; i < iMax; i++)
+ {
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: i: %d", i);
+ double dTpASqr = dT + dA * dA;
+ double dTpBSqr = dT + dB * dB;
+ double dInvTpASqr = 1.0 / dTpASqr;
+ double dInvTpBSqr = 1.0 / dTpBSqr;
+ double dXDivA = dA * dU * dInvTpASqr;
+ double dYDivB = dB * dV * dInvTpBSqr;
+ double dXDivASqr = dXDivA * dXDivA;
+ double dYDivBSqr = dYDivB * dYDivB;
+ double dF = dXDivASqr + dYDivBSqr - 1.0;
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dF: %f", dF);
+
+ if (fabs(dF) < dEpsilon)
+ {
+ // F(t0) is close enough to zero, terminate the iteration:
+ rdX = dXDivA * dA;
+ rdY = dYDivB * dB;
+ riIFinal = i;
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 1: %f,%f", rdX, rdY);
+ break;
+ }
+ double dFDer = 2.0 * (dXDivASqr * dInvTpASqr + dYDivBSqr * dInvTpBSqr);
+ double dRatio = dF / dFDer;
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dRatio: %f", dRatio);
-void RS_Ellipse::moveEndpoint(const Vector& pos) {
- data.angle2 = getEllipseAngle(pos);
- //data.angle2 = data.center.angleTo(pos);
- //calculateEndpoints();
- calculateBorders();
-}
+ if (fabs(dRatio) < dEpsilon)
+ {
+ // t1-t0 is close enough to zero, terminate the iteration:
+ rdX = dXDivA * dA;
+ rdY = dYDivB * dB;
+ riIFinal = i;
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
+ break;
+ }
+ dT += dRatio;
+ }
+ if (i == iMax)
+ {
+ // failed to converge:
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: failed");
+ dDistance = RS_MAXDOUBLE;
+ }
+ else
+ {
+ double dDelta0 = rdX - dU;
+ double dDelta1 = rdY - dV;
+ dDistance = sqrt(dDelta0 * dDelta0 + dDelta1 * dDelta1);
+ ret = Vector(rdX, rdY);
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
+ RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: ret: %f,%f", ret.x, ret.y);
+ }
-RS2::Ending RS_Ellipse::getTrimPoint(const Vector& coord,
- const Vector& trimPoint) {
+ if (dist != NULL)
+ {
+ if (ret.valid)
+ *dist = dDistance;
+ else
+ *dist = RS_MAXDOUBLE;
+ }
- double angEl = getEllipseAngle(trimPoint);
- double angM = getEllipseAngle(coord);
+ if (ret.valid)
+ {
+ if (swap)
+ ret.y *= -1.0;
- if (RS_Math::getAngleDifference(angM, angEl)>M_PI) {
- //if (data.reversed) {
- // return RS2::EndingEnd;
- //}
- //else {
- return RS2::EndingStart;
- //}
- }
- else {
- //if (data.reversed) {
- // return RS2::EndingStart;
- //}
- //else {
- return RS2::EndingEnd;
- //}
+
+ if (majorSwap)
+ {
+ double dum = ret.x;
+ ret.x = ret.y;
+ ret.y = dum;
+ }
+ ret = (ret.rotate(ang) + data.center);
+
+ if (onEntity)
+ {
+ double a1 = data.center.angleTo(getStartpoint());
+ double a2 = data.center.angleTo(getEndpoint());
+ double a = data.center.angleTo(ret);
+
+ if (!RS_Math::isAngleBetween(a, a1, a2, data.reversed))
+ ret = Vector(false);
+ }
}
+
+ return ret;
}
-double RS_Ellipse::getEllipseAngle(const Vector& pos) {
- Vector m = pos;
- m.rotate(data.center, -data.majorP.angle());
- Vector v = m-data.center;
- v.scale(Vector(1.0, 1.0/data.ratio));
- return v.angle();
+/**
+ * @param tolerance Tolerance.
+ *
+ * @retval true if the given point is on this entity.
+ * @retval false otherwise
+ */
+bool RS_Ellipse::isPointOnEntity(const Vector & coord, double tolerance)
+{
+ double dist = getDistanceToPoint(coord, NULL, RS2::ResolveNone);
+ return (dist <= tolerance);
}
+Vector RS_Ellipse::getNearestCenter(const Vector & coord, double * dist)
+{
+ if (dist != NULL)
+ *dist = coord.distanceTo(data.center);
+ return data.center;
+}
+/**
+ * @todo Implement this.
+ */
+Vector RS_Ellipse::getNearestMiddle(const Vector & /*coord*/, double * dist)
+{
+ if (dist != NULL)
+ *dist = RS_MAXDOUBLE;
+ return Vector(false);
+}
+
+Vector RS_Ellipse::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
+{
+ if (dist != NULL)
+ *dist = RS_MAXDOUBLE;
+ return Vector(false);
+}
+
+double RS_Ellipse::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double /*solidDist*/)
+{
+ double dist = RS_MAXDOUBLE;
+ getNearestPointOnEntity(coord, true, &dist, entity);
+
+ return dist;
+}
+
+void RS_Ellipse::move(Vector offset)
+{
+ data.center.move(offset);
+ //calculateEndpoints();
+ calculateBorders();
+}
-void RS_Ellipse::scale(Vector center, Vector factor) {
- data.center.scale(center, factor);
- data.majorP.scale(factor);
- //calculateEndpoints();
- calculateBorders();
+void RS_Ellipse::rotate(Vector center, double angle)
+{
+ data.center.rotate(center, angle);
+ data.majorP.rotate(angle);
+ //calculateEndpoints();
+ calculateBorders();
}
+void RS_Ellipse::scale(Vector center, Vector factor)
+{
+ data.center.scale(center, factor);
+ data.majorP.scale(factor);
+ //calculateEndpoints();
+ calculateBorders();
+}
/**
* @todo deal with angles correctly
*/
-void RS_Ellipse::mirror(Vector axisPoint1, Vector axisPoint2) {
- Vector mp = data.center + data.majorP;
+void RS_Ellipse::mirror(Vector axisPoint1, Vector axisPoint2)
+{
+ Vector mp = data.center + data.majorP;
- data.center.mirror(axisPoint1, axisPoint2);
- mp.mirror(axisPoint1, axisPoint2);
+ data.center.mirror(axisPoint1, axisPoint2);
+ mp.mirror(axisPoint1, axisPoint2);
- data.majorP = mp - data.center;
+ data.majorP = mp - data.center;
- double a = axisPoint1.angleTo(axisPoint2);
+ double a = axisPoint1.angleTo(axisPoint2);
- Vector vec;
- vec.setPolar(1.0, data.angle1);
- vec.mirror(Vector(0.0,0.0), axisPoint2-axisPoint1);
- data.angle1 = vec.angle() - 2*a;
+ Vector vec;
+ vec.setPolar(1.0, data.angle1);
+ vec.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1);
+ data.angle1 = vec.angle() - 2 * a;
- vec.setPolar(1.0, data.angle2);
- vec.mirror(Vector(0.0,0.0), axisPoint2-axisPoint1);
- data.angle2 = vec.angle() - 2*a;
+ vec.setPolar(1.0, data.angle2);
+ vec.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1);
+ data.angle2 = vec.angle() - 2 * a;
- data.reversed = (!data.reversed);
+ data.reversed = (!data.reversed);
- //calculateEndpoints();
- calculateBorders();
+ //calculateEndpoints();
+ calculateBorders();
}
-
-
-void RS_Ellipse::moveRef(const Vector& ref, const Vector& offset) {
+void RS_Ellipse::moveRef(const Vector & ref, const Vector & offset)
+{
Vector startpoint = getStartpoint();
Vector endpoint = getEndpoint();
- if (ref.distanceTo(startpoint)<1.0e-4) {
- moveStartpoint(startpoint+offset);
- }
- if (ref.distanceTo(endpoint)<1.0e-4) {
- moveEndpoint(endpoint+offset);
- }
-}
+ if (ref.distanceTo(startpoint) < 1.0e-4)
+ moveStartpoint(startpoint + offset);
+
+ if (ref.distanceTo(endpoint) < 1.0e-4)
+ moveEndpoint(endpoint + offset);
+}
-//void RS_Ellipse::draw(RS_Painter* painter, RS_GraphicView* view, double /*patternOffset*/) {
-void RS_Ellipse::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
- if (painter == NULL || view == NULL)
+ if (!painter || !view)
return;
- if (getPen().getLineType()==RS2::SolidLine || isSelected()
- || view->getDrawingMode()==RS2::ModePreview)
- {
+ if (getPen().getLineType() == RS2::SolidLine || isSelected()
+ || view->getDrawingMode() == RS2::ModePreview)
painter->drawEllipse(view->toGui(getCenter()),
getMajorRadius() * view->getFactor().x,
getMinorRadius() * view->getFactor().x,
getAngle(), getAngle1(), getAngle2(), isReversed());
- }
else
{
double styleFactor = getStyleFactor(view);
RS_LineTypePattern * pat;
if (isSelected())
- {
pat = &patternSelected;
- }
else
- {
pat = view->getPattern(getPen().getLineType());
- }
if (pat == NULL)
- {
return;
- }
// Pen to draw pattern is always solid:
RS_Pen pen = painter->getPen();
do
{
curR = sqrt(RS_Math::pow(getMinorRadius() * cos(curA), 2.0)
- + RS_Math::pow(getMajorRadius() * sin(curA), 2.0));
+ + RS_Math::pow(getMajorRadius() * sin(curA), 2.0));
if (curR > 1.0e-6)
{
if (pat->pattern[i] * styleFactor > 0.0)
{
- if (tot+fabs(da[i])<length)
- {
+ if (tot + fabs(da[i]) < length)
painter->drawEllipse(cp, r1, r2, getAngle(), curA, curA + da[i], false);
- }
else
- {
painter->drawEllipse(cp, r1, r2, getAngle(), curA, getAngle2(), false);
- }
}
}
- curA+=da[i];
- tot+=fabs(da[i]);
- done=tot>length;
+ curA += da[i];
+ tot += fabs(da[i]);
+ done = tot > length;
i++;
if (i >= pat->num)
- {
- i=0;
- }
+ i = 0;
}
- while(!done);
+ while (!done);
delete[] da;
}
/**
* Dumps the point's data to stdout.
*/
-std::ostream& operator << (std::ostream& os, const RS_Ellipse& a) {
- os << " Ellipse: " << a.data << "\n";
- return os;
+std::ostream & operator<<(std::ostream & os, const RS_Ellipse & a)
+{
+ os << " Ellipse: " << a.data << "\n";
+ return os;
}
-/****************************************************************************
-** $Id: rs_ellipse.h 2367 2005-04-04 16:57:36Z 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_ELLIPSE_H
#define RS_ELLIPSE_H
/**
* Holds the data that defines an ellipse.
*/
-class RS_EllipseData {
-public:
- RS_EllipseData(const Vector& center,
- const Vector& majorP,
- double ratio,
- double angle1, double angle2,
- bool reversed) {
-
- this->center = center;
- this->majorP = majorP;
- this->ratio = ratio;
- this->angle1 = angle1;
- this->angle2 = angle2;
- this->reversed = reversed;
- }
-
- friend class RS_Ellipse;
-
- friend std::ostream& operator << (std::ostream& os, const RS_EllipseData& ed) {
- os << "(" << ed.center <<
- "/" << ed.majorP <<
- " " << ed.ratio <<
- " " << ed.angle1 <<
- "," << ed.angle2 <<
- ")";
- return os;
- }
-
-private:
- //! Ellipse center
- Vector center;
- //! Endpoint of major axis relative to center.
- Vector majorP;
- //! Ratio of minor axis to major axis.
- double ratio;
- //! Start angle
- double angle1;
- //! End angle
- double angle2;
- //! Reversed (cw) flag
- bool reversed;
+class RS_EllipseData
+{
+ public:
+ RS_EllipseData(const Vector & center, const Vector & majorP, double ratio, double angle1, double angle2, bool reversed)
+ {
+ this->center = center;
+ this->majorP = majorP;
+ this->ratio = ratio;
+ this->angle1 = angle1;
+ this->angle2 = angle2;
+ this->reversed = reversed;
+ }
+
+ friend class RS_Ellipse;
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_EllipseData & ed)
+ {
+ os << "(" << ed.center
+ << "/" << ed.majorP
+ << " " << ed.ratio
+ << " " << ed.angle1
+ << "," << ed.angle2
+ << ")";
+ return os;
+ }
+
+ private:
+ //! Ellipse center
+ Vector center;
+ //! Endpoint of major axis relative to center.
+ Vector majorP;
+ //! Ratio of minor axis to major axis.
+ double ratio;
+ //! Start angle
+ double angle1;
+ //! End angle
+ double angle2;
+ //! Reversed (cw) flag
+ bool reversed;
};
-
-
-
/**
* Class for an ellipse entity. All angles are in Rad.
*
* @author Andrew Mustun
*/
-class RS_Ellipse : public RS_AtomicEntity {
-public:
- RS_Ellipse(RS_EntityContainer* parent,
- const RS_EllipseData& d);
- virtual ~RS_Ellipse() {}
-
- virtual RS_Entity* clone() {
- RS_Ellipse* e = new RS_Ellipse(*this);
- e->initId();
- return e;
- }
-
- /** @return RS2::EntityEllipse */
- virtual RS2::EntityType rtti() const {
- return RS2::EntityEllipse;
- }
-
-
- /**
- * @return Start point of the entity.
- */
- virtual Vector getStartpoint() const {
- Vector p;
- p.set(data.center.x + cos(data.angle1) * getMajorRadius(),
- data.center.y + sin(data.angle1) * getMinorRadius());
- p.rotate(data.center, getAngle());
- return p;
- }
- /**
- * @return End point of the entity.
- */
- virtual Vector getEndpoint() const {
- Vector p;
- p.set(data.center.x + cos(data.angle2) * getMajorRadius(),
- data.center.y + sin(data.angle2) * getMinorRadius());
- p.rotate(data.center, getAngle());
- return p;
- }
-
- virtual void moveStartpoint(const Vector& pos);
- virtual void moveEndpoint(const Vector& pos);
-
- virtual RS2::Ending getTrimPoint(const Vector& coord,
- const Vector& trimPoint);
-
- double getEllipseAngle(const Vector& pos);
-
- /** @return Copy of data that defines the ellipse. **/
- RS_EllipseData getData() {
- return data;
- }
-
- virtual VectorSolutions getRefPoints();
-
- /**
- * @retval true if the arc is reversed (clockwise),
- * @retval false otherwise
- */
- bool isReversed() const {
- return data.reversed;
- }
- /** sets the reversed status. */
- void setReversed(bool r) {
- data.reversed = r;
- }
-
- /** @return The rotation angle of this ellipse */
- double getAngle() const {
- return data.majorP.angle();
- }
-
- /** @return The start angle of this arc */
- double getAngle1() {
- return data.angle1;
- }
- /** Sets new start angle. */
- void setAngle1(double a1) {
- data.angle1 = a1;
- }
- /** @return The end angle of this arc */
- double getAngle2() {
- return data.angle2;
- }
- /** Sets new end angle. */
- void setAngle2(double a2) {
- data.angle2 = a2;
- }
-
-
- /** @return The center point (x) of this arc */
- Vector getCenter() {
- return data.center;
- }
- /** Sets new center. */
- void setCenter(const Vector& c) {
- data.center = c;
- }
-
- /** @return The endpoint of the major axis (relative to center). */
- Vector getMajorP() {
- return data.majorP;
- }
- /** Sets new major point (relative to center). */
- void setMajorP(const Vector& p) {
- data.majorP = p;
- }
-
- /** @return The ratio of minor to major axis */
- double getRatio() {
- return data.ratio;
- }
- /** Sets new ratio. */
- void setRatio(double r) {
- data.ratio = r;
- }
-
-
- /**
- * @return Angle length in rad.
- */
- virtual double getAngleLength() const {
- if (isReversed()) {
- return data.angle1-data.angle2;
- } else {
- return data.angle2-data.angle1;
- }
- }
-
- /** @return The major radius of this ellipse. Same as getRadius() */
- double getMajorRadius() const {
- return data.majorP.magnitude();
- }
-
- /** @return The minor radius of this ellipse */
- double getMinorRadius() const {
- return data.majorP.magnitude()*data.ratio;
- }
-
- virtual Vector getNearestEndpoint(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestPointOnEntity(const Vector& coord,
- bool onEntity = true, double* dist = NULL, RS_Entity** entity=NULL);
- virtual Vector getNearestCenter(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestMiddle(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestDist(double distance,
- const Vector& coord,
- double* dist = NULL);
- virtual double getDistanceToPoint(const Vector& coord,
- RS_Entity** entity=NULL,
- RS2::ResolveLevel level=RS2::ResolveNone,
- double solidDist = RS_MAXDOUBLE);
- virtual bool isPointOnEntity(const Vector& coord,
- double tolerance=RS_TOLERANCE);
-
- virtual void move(Vector offset);
- virtual void rotate(Vector center, double angle);
- virtual void scale(Vector center, Vector factor);
- virtual void mirror(Vector axisPoint1, Vector axisPoint2);
- virtual void moveRef(const Vector& ref, const Vector& offset);
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-
- friend std::ostream & operator<<(std::ostream & os, const RS_Ellipse & a);
-
- //virtual void calculateEndpoints();
- virtual void calculateBorders();
-
-protected:
- RS_EllipseData data;
+class RS_Ellipse: public RS_AtomicEntity
+{
+ public:
+ RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d);
+ virtual ~RS_Ellipse();
+
+ virtual RS_Entity * clone();
+ virtual RS2::EntityType rtti() const;
+ virtual Vector getStartpoint() const;
+ virtual Vector getEndpoint() const;
+ virtual void moveStartpoint(const Vector & pos);
+ virtual void moveEndpoint(const Vector & pos);
+ virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
+ double getEllipseAngle(const Vector & pos);
+ RS_EllipseData getData();
+ virtual VectorSolutions getRefPoints();
+ bool isReversed() const;
+ void setReversed(bool r);
+ double getAngle() const;
+ double getAngle1();
+ void setAngle1(double a1);
+ double getAngle2();
+ void setAngle2(double a2);
+ Vector getCenter();
+ void setCenter(const Vector & c);
+ Vector getMajorP();
+ void setMajorP(const Vector & p);
+ double getRatio();
+ void setRatio(double r);
+ virtual double getAngleLength() const;
+ double getMajorRadius() const;
+ double getMinorRadius() const;
+
+ virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
+ virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
+ virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
+ virtual bool isPointOnEntity(const Vector & coord, double tolerance = RS_TOLERANCE);
+
+ virtual void move(Vector offset);
+ virtual void rotate(Vector center, double angle);
+ virtual void scale(Vector center, Vector factor);
+ virtual void mirror(Vector axisPoint1, Vector axisPoint2);
+ virtual void moveRef(const Vector & ref, const Vector & offset);
+
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_Ellipse & a);
+
+ //virtual void calculateEndpoints();
+ virtual void calculateBorders();
+
+ protected:
+ RS_EllipseData data;
};
#endif
#include "rs_document.h"
#include "rs_ellipse.h"
#include "drawing.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_insert.h"
#include "rs_layer.h"
#include "rs_line.h"
* Implementations must drag the reference point(s) of all
* (sub-)entities that are very close to ref by offset.
*/
-/*virtual*/ void RS_Entity::moveRef(const Vector & /*ref*/, const Vector & /*offset*/)
+/*virtual*/ void RS_Entity::moveRef(const Vector &/*ref*/, const Vector &/*offset*/)
{
return;
}
* Implementations must drag the reference point(s) of selected
* (sub-)entities that are very close to ref by offset.
*/
-/*virtual*/ void RS_Entity::moveSelectedRef(const Vector & /*ref*/, const Vector & /*offset*/)
+/*virtual*/ void RS_Entity::moveSelectedRef(const Vector &/*ref*/, const Vector &/*offset*/)
{
return;
}
* @return Factor for scaling the line styles considering the current
* paper scaling and the fact that styles are stored in Millimeter.
*/
-double RS_Entity::getStyleFactor(RS_GraphicView * view)
+double RS_Entity::getStyleFactor(GraphicView * view)
{
double styleFactor = 1.0;
return os;
}
-
class RS_Document;
class RS_EntityContainer;
class Drawing;
-class RS_GraphicView;
+class GraphicView;
class RS_Insert;
class RS_Line;
class RS_Point;
unsigned long int getId() const;
/**
- * This method must be overwritten in subclasses and return the
- * number of <b>atomic</b> entities in this entity.
- */
+ * This method must be overwritten in subclasses and return the
+ * number of <b>atomic</b> entities in this entity.
+ */
virtual unsigned long int count() = 0;
/**
- * This method must be overwritten in subclasses and return the
- * number of <b>atomic</b> entities in this entity including sub containers.
- */
+ * This method must be overwritten in subclasses and return the
+ * number of <b>atomic</b> entities in this entity including sub containers.
+ */
virtual unsigned long int countDeep() = 0;
virtual double getLength();
RS_Pen getPen(bool resolve = true) const;
/**
- * Must be overwritten to return true if an entity type
- * is a container for other entities (e.g. polyline, group, ...).
- */
+ * Must be overwritten to return true if an entity type
+ * is a container for other entities (e.g. polyline, group, ...).
+ */
virtual bool isContainer() const = 0;
/**
- * Must be overwritten to return true if an entity type
- * is an atomic entity.
- */
+ * Must be overwritten to return true if an entity type
+ * is an atomic entity.
+ */
virtual bool isAtomic() const = 0;
virtual bool isEdge() const;
virtual VectorSolutions getRefPoints();
/**
- * Must be overwritten to get the closest endpoint to the
- * given coordinate for this entity.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param dist Pointer to a value which will contain the measured
- * distance between 'coord' and the closest endpoint. The passed
- * pointer can also be NULL in which case the distance will be
- * lost.
- *
- * @return The closest endpoint.
- */
+ * Must be overwritten to get the closest endpoint to the
+ * given coordinate for this entity.
+ *
+ * @param coord Coordinate (typically a mouse coordinate)
+ * @param dist Pointer to a value which will contain the measured
+ * distance between 'coord' and the closest endpoint. The passed
+ * pointer can also be NULL in which case the distance will be
+ * lost.
+ *
+ * @return The closest endpoint.
+ */
virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL) = 0;
/**
- * Must be overwritten to get the closest coordinate to the
- * given coordinate which is on this entity.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param dist Pointer to a value which will contain the measured
- * distance between \p coord and the point. The passed pointer can
- * also be \p NULL in which case the distance will be lost.
- *
- * @return The closest coordinate.
- */
+ * Must be overwritten to get the closest coordinate to the
+ * given coordinate which is on this entity.
+ *
+ * @param coord Coordinate (typically a mouse coordinate)
+ * @param dist Pointer to a value which will contain the measured
+ * distance between \p coord and the point. The passed pointer can
+ * also be \p NULL in which case the distance will be lost.
+ *
+ * @return The closest coordinate.
+ */
virtual Vector getNearestPointOnEntity(const Vector& /*coord*/,
bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL) = 0;
/**
- * Must be overwritten to get the (nearest) center point to the
- * given coordinate for this entity.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param dist Pointer to a value which will contain the measured
- * distance between 'coord' and the closest center point. The passed
- * pointer can also be NULL in which case the distance will be
- * lost.
- *
- * @return The closest center point.
- */
+ * Must be overwritten to get the (nearest) center point to the
+ * given coordinate for this entity.
+ *
+ * @param coord Coordinate (typically a mouse coordinate)
+ * @param dist Pointer to a value which will contain the measured
+ * distance between 'coord' and the closest center point. The passed
+ * pointer can also be NULL in which case the distance will be
+ * lost.
+ *
+ * @return The closest center point.
+ */
virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL) = 0;
/**
- * Must be overwritten to get the (nearest) middle point to the
- * given coordinate for this entity.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param dist Pointer to a value which will contain the measured
- * distance between 'coord' and the closest middle point. The passed
- * pointer can also be NULL in which case the distance will be
- * lost.
- *
- * @return The closest middle point.
- */
+ * Must be overwritten to get the (nearest) middle point to the
+ * given coordinate for this entity.
+ *
+ * @param coord Coordinate (typically a mouse coordinate)
+ * @param dist Pointer to a value which will contain the measured
+ * distance between 'coord' and the closest middle point. The passed
+ * pointer can also be NULL in which case the distance will be
+ * lost.
+ *
+ * @return The closest middle point.
+ */
virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL) = 0;
/**
virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
/**
- * Must be overwritten to get the shortest distance between this
- * entity and a coordinate.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param entity Pointer which will contain the (sub-)entity which is
- * closest to the given point or NULL if the caller is not
- * interested in this information.
- * @param level The resolve level.
- *
- * @sa RS2::ResolveLevel
- *
- * @return The measured distance between \p coord and the entity.
- */
+ * Must be overwritten to get the shortest distance between this
+ * entity and a coordinate.
+ *
+ * @param coord Coordinate (typically a mouse coordinate)
+ * @param entity Pointer which will contain the (sub-)entity which is
+ * closest to the given point or NULL if the caller is not
+ * interested in this information.
+ * @param level The resolve level.
+ *
+ * @sa RS2::ResolveLevel
+ *
+ * @return The measured distance between \p coord and the entity.
+ */
virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE) = 0;
virtual bool isPointOnEntity(const Vector & coord, double tolerance = RS_TOLERANCE);
/**
- * Implementations must move the entity by the given vector.
- */
+ * Implementations must move the entity by the given vector.
+ */
virtual void move(Vector offset) = 0;
/**
- * Implementations must rotate the entity by the given angle around
- * the given center.
- */
+ * Implementations must rotate the entity by the given angle around
+ * the given center.
+ */
virtual void rotate(Vector center, double angle) = 0;
/**
- * Implementations must scale the entity by the given factors.
- */
+ * Implementations must scale the entity by the given factors.
+ */
virtual void scale(Vector center, Vector factor) = 0;
virtual void scale(Vector center, double factor);
/**
- * Implementations must mirror the entity by the given axis.
- */
+ * Implementations must mirror the entity by the given axis.
+ */
virtual void mirror(Vector axisPoint1, Vector axisPoint2) = 0;
virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
virtual void moveSelectedRef(const Vector & /*ref*/, const Vector & /*offset*/);
/**
- * Implementations must draw the entity on the given device.
- */
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view,
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0) = 0;
+ * Implementations must draw the entity on the given device.
+ */
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0) = 0;
- double getStyleFactor(RS_GraphicView * view);
+ double getStyleFactor(GraphicView * view);
QString * getUserDefVar(QString key);
QStringList getAllKeys();
#include "rs_insert.h"
#include "rs_spline.h"
#include "rs_information.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "paintintf.h"
bool RS_EntityContainer::autoUpdateBorders = true;
calculateBorders();
}
-//void RS_EntityContainer::draw(RS_Painter* painter, RS_GraphicView* view,
-void RS_EntityContainer::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_EntityContainer::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (painter == NULL || view == NULL)
return;
virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
virtual void moveRef(const Vector & ref, const Vector & offset);
virtual void moveSelectedRef(const Vector & ref, const Vector & offset);
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
friend std::ostream & operator<<(std::ostream & os, RS_EntityContainer & ec);
#include "rs_commandevent.h"
#include "rs_debug.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_math.h"
/**
* Constructor.
*/
-RS_EventHandler::RS_EventHandler(RS_GraphicView * graphicView)
+RS_EventHandler::RS_EventHandler(GraphicView * graphicView)
{
this->graphicView = graphicView;
actionIndex = -1;
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mousePressEvent(QMouseEvent * e)
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e)
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseMoveEvent(QMouseEvent * e)
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseLeaveEvent()
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseEnterEvent()
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::keyPressEvent(QKeyEvent * e)
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
{
RS_DEBUG->print("RS_EventHandler::setCurrentAction: debugging actions");
debugActions();
- RS_DEBUG->print("RS_GraphicView::setCurrentAction: OK");
+ RS_DEBUG->print("GraphicView::setCurrentAction: OK");
}
/**
#define RS_MAXACTIONS 16
class RS_ActionInterface;
+class GraphicView;
/**
* The event handler owns and manages all actions that are currently
class RS_EventHandler
{
public:
- RS_EventHandler(RS_GraphicView * graphicView);
+ RS_EventHandler(GraphicView * graphicView);
~RS_EventHandler();
void back();
void setSnapRestriction(RS2::SnapRestriction sr);
protected:
- RS_GraphicView * graphicView;
+ GraphicView * graphicView;
RS_ActionInterface * defaultAction;
RS_ActionInterface * currentActions[RS_MAXACTIONS];
int actionIndex;
#include "rs_grid.h"
-#include "rs_units.h"
#include "drawing.h"
+#include "graphicview.h"
+//#include "rs_graphicview.h"
#include "settings.h"
+#include "rs_units.h"
+#include "vector.h"
+#warning "!!! Clean out all references to RS_GraphicView here and in header !!!"
+#if 0
/**
* Constructor.
*/
metaX(NULL), numMetaX(0), metaY(NULL), numMetaY(0)
{
}
+#endif
+
+/**
+ * Constructor II.
+ */
+RS_Grid::RS_Grid(GraphicView * gv): graphicView(gv), pt(NULL), number(0),
+ metaX(NULL), numMetaX(0), metaY(NULL), numMetaY(0)
+{
+}
/**
* Destructor.
#ifndef RS_GRID_H
#define RS_GRID_H
-#include "rs_graphicview.h"
-#include "vector.h"
+#include <QtCore>
+
+//class RS_GraphicView;
+class GraphicView;
+class Vector;
/**
* This class represents a grid. Grids can be drawn on graphic
class RS_Grid
{
public:
- RS_Grid(RS_GraphicView *);
+// RS_Grid(RS_GraphicView *);
+ RS_Grid(GraphicView *);
~RS_Grid();
void update();
protected:
//! Graphic view this grid is connected to.
- RS_GraphicView * graphicView;
+// RS_GraphicView * graphicView;
+ GraphicView * graphicView;
//! Current grid spacing
double spacing;
#include "rs_hatch.h"
#include <QtCore>
-#include "rs_graphicview.h"
#include "drawing.h"
+#include "graphicview.h"
#include "rs_information.h"
+#include "paintintf.h"
#include "rs_pattern.h"
#include "rs_patternlist.h"
-#include "paintintf.h"
/**
* Constructor.
/**
* Overrides drawing of subentities. This is only ever called for solid fills.
*/
-//void RS_Hatch::draw(RS_Painter* painter, RS_GraphicView* view,
-void RS_Hatch::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Hatch::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (!data.solid)
{
virtual void calculateBorders();
void update();
void activateContour(bool on);
-
- // virtual void draw(RS_Painter* painter, RS_GraphicView* view,
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
virtual double getLength();
virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
#include "rs_constructionline.h"
#include "rs_debug.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
+#include "rs_line.h"
#include "paintintf.h"
/**
RS_Image::~RS_Image()
{
/*if (img!=NULL) {
- delete[] img;
- }*/
+ delete[] img;
+ }*/
}
RS_Entity * RS_Image::clone()
return i;
}
+/** @return RS2::EntityImage */
+/*virtual*/ RS2::EntityType RS_Image::rtti() const
+{
+ return RS2::EntityImage;
+}
+
void RS_Image::update()
{
RS_DEBUG->print("RS_Image::update");
RS_DEBUG->print("RS_Image::update: OK");
/*
- // number of small images:
- nx = image.width()/100;
- ny = image.height()/100;
-
- // create small images:
- img = new QImage*[nx];
- RS_Pixmap pm;
- int w,h;
- for (int x = 0; x<nx; ++x) {
- img[x] = new QImage[ny];
- for (int y = 0; y<ny; ++y) {
- if (x<nx-1) {
- w = 100;
- }
- else {
- w = image.width()%100;
- }
-
- if (y<ny-1) {
- h = 100;
- }
- else {
- h = image.height()%100;
- }
-
- pm = RS_Pixmap(w, h);
- RS_PainterQt painter(&pm);
- painter.drawImage(-x*100, -y*100, image);
- img[x][y] = pm.convertToImage();
- }
- }
- */
+ // number of small images:
+ nx = image.width()/100;
+ ny = image.height()/100;
+
+ // create small images:
+ img = new QImage*[nx];
+ RS_Pixmap pm;
+ int w,h;
+ for (int x = 0; x<nx; ++x) {
+ img[x] = new QImage[ny];
+ for (int y = 0; y<ny; ++y) {
+ if (x<nx-1) {
+ w = 100;
+ }
+ else {
+ w = image.width()%100;
+ }
+
+ if (y<ny-1) {
+ h = 100;
+ }
+ else {
+ h = image.height()%100;
+ }
+
+ pm = RS_Pixmap(w, h);
+ RS_PainterQt painter(&pm);
+ painter.drawImage(-x*100, -y*100, image);
+ img[x][y] = pm.convertToImage();
+ }
+ }
+ */
+}
+
+/** @return Copy of data that defines the image. */
+RS_ImageData RS_Image::getData() const
+{
+ return data;
+}
+
+/** @return Insertion point of the entity */
+/*virtual*/ Vector RS_Image::getInsertionPoint() const
+{
+ return data.insertionPoint;
+}
+
+/** Sets the insertion point for the image. */
+void RS_Image::setInsertionPoint(Vector ip)
+{
+ data.insertionPoint = ip;
+ calculateBorders();
+}
+
+/** @return File name of the image. */
+QString RS_Image::getFile() const
+{
+ return data.file;
+}
+
+/** Sets the file name of the image. */
+void RS_Image::setFile(const QString & file)
+{
+ data.file = file;
+}
+
+/** @return u Vector. Points along bottom, 1 pixel long. */
+Vector RS_Image::getUVector() const
+{
+ return data.uVector;
+}
+
+/** @return v Vector. Points along left, 1 pixel long. */
+Vector RS_Image::getVVector() const
+{
+ return data.vVector;
+}
+
+/** @return Width of image in pixels. */
+int RS_Image::getWidth() const
+{
+ return (int)data.size.x;
+}
+
+/** @return Height of image in pixels. */
+int RS_Image::getHeight() const
+{
+ return (int)data.size.y;
+}
+
+/** @return Brightness. */
+int RS_Image::getBrightness() const
+{
+ return data.brightness;
+}
+
+/** @return Contrast. */
+int RS_Image::getContrast() const
+{
+ return data.contrast;
+}
+
+/** @return Fade. */
+int RS_Image::getFade() const
+{
+ return data.fade;
+}
+
+/** @return Image definition handle. */
+int RS_Image::getHandle() const
+{
+ return data.handle;
+}
+
+/** Sets the image definition handle. */
+void RS_Image::setHandle(int h)
+{
+ data.handle = h;
+}
+
+/** @return The four corners. **/
+VectorSolutions RS_Image::getCorners()
+{
+ VectorSolutions sol(4);
+
+ sol.set(0, data.insertionPoint);
+ sol.set(1,
+ data.insertionPoint + data.uVector * RS_Math::round(data.size.x));
+ sol.set(3,
+ data.insertionPoint + data.vVector * RS_Math::round(data.size.y));
+ sol.set(2, sol.get(3) + data.uVector * RS_Math::round(data.size.x));
+
+ return sol;
+}
+
+/**
+ * @return image with in graphic units.
+ */
+double RS_Image::getImageWidth()
+{
+ return data.size.x * data.uVector.magnitude();
+}
+
+/**
+ * @return image height in graphic units.
+ */
+double RS_Image::getImageHeight()
+{
+ return data.size.y * data.vVector.magnitude();
}
void RS_Image::calculateBorders()
resetBorders();
VectorSolutions sol = getCorners();
- for(int i=0; i<4; ++i)
+ for (int i = 0; i < 4; ++i)
{
minV = Vector::minimum(minV, sol.get(i));
maxV = Vector::maximum(maxV, sol.get(i));
return corners.getClosest(coord, dist);
}
-Vector RS_Image::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist,
- RS_Entity ** entity)
+Vector RS_Image::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity)
{
if (entity != NULL)
*entity = this;
RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0)))
};
- for(int i=0; i<4; ++i)
+ for (int i = 0; i < 4; ++i)
points.set(i, l[i].getNearestPointOnEntity(coord, onEntity));
return points.getClosest(coord, dist);
VectorSolutions points(4);
VectorSolutions corners = getCorners();
- points.set(0, (corners.get(0) + corners.get(1))/2.0);
- points.set(1, (corners.get(1) + corners.get(2))/2.0);
- points.set(2, (corners.get(2) + corners.get(3))/2.0);
- points.set(3, (corners.get(3) + corners.get(0))/2.0);
+ points.set(0, (corners.get(0) + corners.get(1)) / 2.0);
+ points.set(1, (corners.get(1) + corners.get(2)) / 2.0);
+ points.set(2, (corners.get(2) + corners.get(3)) / 2.0);
+ points.set(3, (corners.get(3) + corners.get(0)) / 2.0);
return points.getClosest(coord, dist);
}
-
-
-Vector RS_Image::getNearestMiddle(const Vector& coord,
- double* dist) {
- return getNearestCenter(coord, dist);
+Vector RS_Image::getNearestMiddle(const Vector & coord, double * dist)
+{
+ return getNearestCenter(coord, dist);
}
+Vector RS_Image::getNearestDist(double distance, const Vector & coord, double * dist)
+{
+ VectorSolutions corners = getCorners();
+ VectorSolutions points(4);
+ RS_Line l[] =
+ {
+ RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))),
+ RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))),
+ RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))),
+ RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0)))
+ };
-Vector RS_Image::getNearestDist(double distance,
- const Vector& coord,
- double* dist) {
-
- VectorSolutions corners = getCorners();
- VectorSolutions points(4);
-
- RS_Line l[] =
- {
- RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))),
- RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))),
- RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))),
- RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0)))
- };
-
- for (int i=0; i<4; ++i) {
- points.set(i, l[i].getNearestDist(distance, coord, dist));
- }
+ for (int i = 0; i < 4; ++i)
+ points.set(i, l[i].getNearestDist(distance, coord, dist));
- return points.getClosest(coord, dist);
+ return points.getClosest(coord, dist);
}
+double RS_Image::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel /*level*/, double /*solidDist*/)
+{
+ if (entity != NULL)
+ *entity = this;
+ VectorSolutions corners = getCorners();
+ double dist;
+ double minDist = RS_MAXDOUBLE;
-double RS_Image::getDistanceToPoint(const Vector& coord,
- RS_Entity** entity,
- RS2::ResolveLevel /*level*/,
- double /*solidDist*/) {
- if (entity!=NULL) {
- *entity = this;
- }
-
- VectorSolutions corners = getCorners();
- double dist;
- double minDist = RS_MAXDOUBLE;
+ RS_Line l[] =
+ {
+ RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))),
+ RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))),
+ RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))),
+ RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0)))
+ };
- RS_Line l[] =
- {
- RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))),
- RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))),
- RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))),
- RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0)))
- };
+ for (int i = 0; i < 4; ++i)
+ {
+ dist = l[i].getDistanceToPoint(coord, NULL);
- for (int i=0; i<4; ++i) {
- dist = l[i].getDistanceToPoint(coord, NULL);
- if (dist<minDist) {
- minDist = dist;
- }
- }
+ if (dist < minDist)
+ minDist = dist;
+ }
- return minDist;
+ return minDist;
}
-
-
-void RS_Image::move(Vector offset) {
- data.insertionPoint.move(offset);
- calculateBorders();
+/*virtual*/ double RS_Image::getLength()
+{
+ return -1.0;
}
-
-
-void RS_Image::rotate(Vector center, double angle) {
- data.insertionPoint.rotate(center, angle);
- data.uVector.rotate(angle);
- data.vVector.rotate(angle);
- calculateBorders();
+void RS_Image::move(Vector offset)
+{
+ data.insertionPoint.move(offset);
+ calculateBorders();
}
-
-
-void RS_Image::scale(Vector center, Vector factor) {
- data.insertionPoint.scale(center, factor);
- data.uVector.scale(factor);
- data.vVector.scale(factor);
- calculateBorders();
+void RS_Image::rotate(Vector center, double angle)
+{
+ data.insertionPoint.rotate(center, angle);
+ data.uVector.rotate(angle);
+ data.vVector.rotate(angle);
+ calculateBorders();
}
+void RS_Image::scale(Vector center, Vector factor)
+{
+ data.insertionPoint.scale(center, factor);
+ data.uVector.scale(factor);
+ data.vVector.scale(factor);
+ calculateBorders();
+}
-
-void RS_Image::mirror(Vector axisPoint1, Vector axisPoint2) {
- data.insertionPoint.mirror(axisPoint1, axisPoint2);
- data.uVector.mirror(Vector(0.0,0.0), axisPoint2-axisPoint1);
- data.vVector.mirror(Vector(0.0,0.0), axisPoint2-axisPoint1);
- calculateBorders();
+void RS_Image::mirror(Vector axisPoint1, Vector axisPoint2)
+{
+ data.insertionPoint.mirror(axisPoint1, axisPoint2);
+ data.uVector.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1);
+ data.vVector.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1);
+ calculateBorders();
}
-//void RS_Image::draw(RS_Painter* painter, RS_GraphicView* view, double /*patternOffset*/) {
-void RS_Image::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Image::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (painter == NULL || view == NULL || img.isNull())
return;
int height = view->getHeight();
Vector scale = Vector(view->toGuiDX(data.uVector.magnitude()),
- view->toGuiDY(data.vVector.magnitude()));
+ view->toGuiDY(data.vVector.magnitude()));
double angle = data.uVector.angle();
int startX, stopX, startY, stopY;
if (data.uVector.x > 1.0e-6 && data.vVector.y > 1.0e-6)
{
- startX = (int)((view->toGraphX(ox)-data.insertionPoint.x) / data.uVector.x) - 1;
+ startX = (int)((view->toGraphX(ox) - data.insertionPoint.x) / data.uVector.x) - 1;
if (startX < 0)
- {
startX = 0;
- }
- stopX = (int)((view->toGraphX(width)-data.insertionPoint.x) / data.uVector.x) + 1;
+ stopX = (int)((view->toGraphX(width) - data.insertionPoint.x) / data.uVector.x) + 1;
if (stopX > (int)data.size.x)
- {
stopX = (int)data.size.x;
- }
- startY = -(int)((view->toGraphY(oy) - (data.insertionPoint.y+getImageHeight())) /
- data.vVector.y) - 1;
+ startY = -(int)((view->toGraphY(oy) - (data.insertionPoint.y + getImageHeight()))
+ / data.vVector.y) - 1;
- if (startY<0)
- {
+ if (startY < 0)
startY = 0;
- }
- stopY = -(int)((view->toGraphY(height) - (data.insertionPoint.y+getImageHeight())) /
- data.vVector.y) + 1;
+ stopY = -(int)((view->toGraphY(height) - (data.insertionPoint.y + getImageHeight()))
+ / data.vVector.y) + 1;
- if (stopY>(int)data.size.y)
- {
+ if (stopY > (int)data.size.y)
stopY = (int)data.size.y;
- }
}
else
{
}
painter->drawImg(img, view->toGui(data.insertionPoint), angle, scale,
- startX, startY, stopX-startX, stopY-startY);
+ startX, startY, stopX - startX, stopY - startY);
if (isSelected())
{
os << " Image: " << i.getData() << "\n";
return os;
}
-
*/
class RS_ImageData
{
-public:
- /**
- * Default constructor. Leaves the data object uninitialized.
- */
- RS_ImageData() {}
-
- RS_ImageData(int handle,
- const Vector& insertionPoint,
- const Vector& uVector,
- const Vector& vVector,
- const Vector& size,
- const QString& file,
- int brightness,
- int contrast,
- int fade) {
-
- this->handle = handle;
- this->insertionPoint = insertionPoint;
- this->uVector = uVector;
- this->vVector = vVector;
- this->size = size;
- this->file = file;
- this->brightness = brightness;
- this->contrast = contrast;
- this->fade = fade;
- }
-
- friend std::ostream& operator << (std::ostream& os, const RS_ImageData& ld) {
- os << "(" << ld.insertionPoint << ")";
- return os;
- }
-
-public:
- /** Handle of image definition. */
- int handle;
- /** Insertion point. */
- Vector insertionPoint;
- /** u vector. Points along visual bottom of image. */
- Vector uVector;
- /** v vector. Points along visual left of image. */
- Vector vVector;
- /** Image size in pixel. */
- Vector size;
- /** Path to image file. */
- QString file;
- /** Brightness (0..100, default: 50). */
- int brightness;
- /** Contrast (0..100, default: 50). */
- int contrast;
- /** Fade (0..100, default: 0). */
- int fade;
+ public:
+ /**
+ * Default constructor. Leaves the data object uninitialized.
+ */
+ RS_ImageData()
+ {
+ }
+
+ RS_ImageData(int handle, const Vector & insertionPoint, const Vector & uVector, const Vector & vVector, const Vector & size, const QString & file, int brightness, int contrast, int fade)
+ {
+ this->handle = handle;
+ this->insertionPoint = insertionPoint;
+ this->uVector = uVector;
+ this->vVector = vVector;
+ this->size = size;
+ this->file = file;
+ this->brightness = brightness;
+ this->contrast = contrast;
+ this->fade = fade;
+ }
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_ImageData & ld)
+ {
+ os << "(" << ld.insertionPoint << ")";
+ return os;
+ }
+
+ public:
+ /** Handle of image definition. */
+ int handle;
+ /** Insertion point. */
+ Vector insertionPoint;
+ /** u vector. Points along visual bottom of image. */
+ Vector uVector;
+ /** v vector. Points along visual left of image. */
+ Vector vVector;
+ /** Image size in pixel. */
+ Vector size;
+ /** Path to image file. */
+ QString file;
+ /** Brightness (0..100, default: 50). */
+ int brightness;
+ /** Contrast (0..100, default: 50). */
+ int contrast;
+ /** Fade (0..100, default: 0). */
+ int fade;
};
-
-
/**
- * Class for a line entity.
+ * Class for a bitmap image entity.
*
* @author Andrew Mustun
*/
-class RS_Image : public RS_AtomicEntity
+class RS_Image: public RS_AtomicEntity
{
-public:
- RS_Image(RS_EntityContainer* parent,
- const RS_ImageData& d);
-
- virtual RS_Entity* clone();
-
- virtual ~RS_Image();
-
- /** @return RS2::EntityImage */
- virtual RS2::EntityType rtti() const {
- return RS2::EntityImage;
- }
-
- virtual void update();
-
- /** @return Copy of data that defines the image. */
- RS_ImageData getData() const {
- return data;
- }
-
- /** @return Insertion point of the entity */
- virtual Vector getInsertionPoint() const {
- return data.insertionPoint;
- }
- /** Sets the insertion point for the image. */
- void setInsertionPoint(Vector ip) {
- data.insertionPoint = ip;
- calculateBorders();
- }
-
- /** @return File name of the image. */
- QString getFile() const {
- return data.file;
- }
-
- /** Sets the file name of the image. */
- void setFile(const QString& file) {
- data.file = file;
- }
-
- /** @return u Vector. Points along bottom, 1 pixel long. */
- Vector getUVector() const {
- return data.uVector;
- }
- /** @return v Vector. Points along left, 1 pixel long. */
- Vector getVVector() const {
- return data.vVector;
- }
- /** @return Width of image in pixels. */
- int getWidth() const {
- return (int)data.size.x;
- }
- /** @return Height of image in pixels. */
- int getHeight() const {
- return (int)data.size.y;
- }
- /** @return Brightness. */
- int getBrightness() const {
- return data.brightness;
- }
- /** @return Contrast. */
- int getContrast() const {
- return data.contrast;
- }
- /** @return Fade. */
- int getFade() const {
- return data.fade;
- }
- /** @return Image definition handle. */
- int getHandle() const {
- return data.handle;
- }
- /** Sets the image definition handle. */
- void setHandle(int h) {
- data.handle = h;
- }
-
-
- /** @return The four corners. **/
- VectorSolutions getCorners() {
- VectorSolutions sol(4);
-
- sol.set(0, data.insertionPoint);
- sol.set(1,
- data.insertionPoint + data.uVector*RS_Math::round(data.size.x));
- sol.set(3,
- data.insertionPoint + data.vVector*RS_Math::round(data.size.y));
- sol.set(2, sol.get(3) + data.uVector*RS_Math::round(data.size.x));
-
- return sol;
- }
-
- /**
- * @return image with in graphic units.
- */
- double getImageWidth() {
- return data.size.x * data.uVector.magnitude();
- }
-
- /**
- * @return image height in graphic units.
- */
- double getImageHeight() {
- return data.size.y * data.vVector.magnitude();
- }
-
-
- virtual Vector getNearestEndpoint(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestPointOnEntity(const Vector& coord,
- bool onEntity=true, double* dist = NULL, RS_Entity** entity=NULL);
- virtual Vector getNearestCenter(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestMiddle(const Vector& coord,
- double* dist = NULL);
- virtual Vector getNearestDist(double distance,
- const Vector& coord,
- double* dist = NULL);
- virtual double getDistanceToPoint(const Vector& coord,
- RS_Entity** entity=NULL,
- RS2::ResolveLevel level=RS2::ResolveNone,
- double solidDist = RS_MAXDOUBLE);
-
- virtual double getLength() {
- return -1.0;
- }
-
- virtual void move(Vector offset);
- virtual void rotate(Vector center, double angle);
- virtual void scale(Vector center, Vector factor);
- virtual void mirror(Vector axisPoint1, Vector axisPoint2);
- /*virtual void stretch(Vector firstCorner,
- Vector secondCorner,
- Vector offset);*/
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-
- friend std::ostream & operator<<(std::ostream & os, const RS_Image & l);
-
- virtual void calculateBorders();
-
-protected:
- RS_ImageData data;
- QImage img;
- //RS_Img** img;
- //int nx;
- //int ny;
+ public:
+ RS_Image(RS_EntityContainer * parent, const RS_ImageData & d);
+ virtual ~RS_Image();
+
+ virtual RS_Entity * clone();
+ virtual RS2::EntityType rtti() const;
+ virtual void update();
+ RS_ImageData getData() const;
+ virtual Vector getInsertionPoint() const;
+ void setInsertionPoint(Vector ip);
+ QString getFile() const;
+ void setFile(const QString & file);
+ Vector getUVector() const;
+ Vector getVVector() const;
+ int getWidth() const;
+ int getHeight() const;
+ int getBrightness() const;
+ int getContrast() const;
+ int getFade() const;
+ int getHandle() const;
+ void setHandle(int h);
+ VectorSolutions getCorners();
+ double getImageWidth();
+ double getImageHeight();
+
+ virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, double * dist = NULL, RS_Entity * * entity = NULL);
+ virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
+ virtual double getDistanceToPoint(const Vector & coord, RS_Entity * * entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
+ virtual double getLength();
+ virtual void move(Vector offset);
+ virtual void rotate(Vector center, double angle);
+ virtual void scale(Vector center, Vector factor);
+ virtual void mirror(Vector axisPoint1, Vector axisPoint2);
+ /*virtual void stretch(Vector firstCorner,Vector secondCorner, Vector offset);*/
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_Image & l);
+
+ virtual void calculateBorders();
+
+ protected:
+ RS_ImageData data;
+ QImage img;
};
#endif
#include "rs_line.h"
#include "rs_debug.h"
-#include "rs_graphicview.h"
#include "drawing.h"
+#include "graphicview.h"
+#include "rs_linetypepattern.h"
#include "paintintf.h"
/**
}
}
-//void RS_Line::draw(RS_Painter * painter, RS_GraphicView * view, double patternOffset)
-void RS_Line::draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset)
+void RS_Line::draw(PaintInterface * painter, GraphicView * view, double patternOffset)
{
if (painter == NULL || view == NULL)
//{
virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
virtual Vector getNearestDist(double distance, bool startp);
- //virtual Vector getNearestRef(const Vector& coord,
- // double* dist = NULL);
+ //virtual Vector getNearestRef(const Vector& coord, double* dist = NULL);
virtual double getDistanceToPoint(const Vector & coord,
RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone,
double solidDist = RS_MAXDOUBLE);
virtual void mirror(Vector axisPoint1, Vector axisPoint2);
virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
virtual void moveRef(const Vector & ref, const Vector & offset);
-
-// virtual void draw(RS_Painter * painter, RS_GraphicView * view, double patternOffset = 0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
friend std::ostream & operator<<(std::ostream & os, const RS_Line & l);
protected:
RS_LineData data;
- //Vector startpoint;
- //Vector endpoint;
};
#endif
#ifndef RS_MAINWINDOWINTERFACE_H
#define RS_MAINWINDOWINTERFACE_H
-class RS_GraphicView;
+class GraphicView;
class RS_Document;
/**
RS_MainWindowInterface() {}
virtual ~RS_MainWindowInterface() {}
- virtual RS_GraphicView * getGraphicView() = 0;
+ virtual GraphicView * getGraphicView() = 0;
virtual RS_Document * getDocument() = 0;
virtual void createNewDocument(const QString & fileName = QString::null, RS_Document * doc = NULL) = 0;
* @param handleUndo true: Handle undo functionalitiy.
*/
RS_Modification::RS_Modification(RS_EntityContainer & container,
- RS_GraphicView * graphicView, bool handleUndo)
+ GraphicView * graphicView, bool handleUndo)
{
this->container = &container;
this->graphicView = graphicView;
#define RS_MODIFICATION_H
#include "rs_entitycontainer.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_line.h"
/**
{
public:
RS_Modification(RS_EntityContainer & entityContainer,
- RS_GraphicView * graphicView = NULL, bool handleUndo = true);
+ GraphicView * graphicView = NULL, bool handleUndo = true);
void remove();
bool changeAttributes(RS_AttributesData& data);
RS_EntityContainer * container;
Drawing * graphic;
RS_Document * document;
- RS_GraphicView * graphicView;
+ GraphicView * graphicView;
bool handleUndo;
};
#include "rs_point.h"
-#include "rs_graphicview.h"
-//#include "rs_painter.h"
+#include "graphicview.h"
#include "paintintf.h"
/**
calculateBorders();
}
-//void RS_Point::draw(RS_Painter * painter, RS_GraphicView * view, double /*patternOffset*/)
-void RS_Point::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Point::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (painter == NULL || view == NULL)
return;
virtual void rotate(Vector center, double angle);
virtual void scale(Vector center, Vector factor);
virtual void mirror(Vector axisPoint1, Vector axisPoint2);
-
-// virtual void draw(RS_Painter * painter, RS_GraphicView * view, double patternOffset = 0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
friend std::ostream & operator<<(std::ostream & os, const RS_Point & p);
#include "rs_debug.h"
#include "rs_line.h"
#include "rs_arc.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "paintintf.h"
/**
/**
* Slightly optimized drawing for polylines.
*/
-//void RS_Polyline::draw(RS_Painter * painter, RS_GraphicView * view, double /*patternOffset*/)
-void RS_Polyline::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Polyline::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
- if (painter == NULL || view == NULL)
+ if (!painter || !view)
return;
// draw first entity and set correct pen:
Vector getStartpoint();
void setEndpoint(Vector & v);
Vector getEndpoint();
-
double getClosingBulge();
void updateEndpoints();
-
bool isClosed() const;
void setClosed(bool cl);
virtual VectorSolutions getRefPoints();
virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
-
virtual RS_Entity * addVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
virtual void setNextBulge(double bulge);
virtual void addEntity(RS_Entity * entity);
//virtual void addSegment(RS_Entity* entity);
virtual void removeLastVertex();
virtual void endPolyline();
-
//virtual void reorder();
-
virtual void move(Vector offset);
virtual void rotate(Vector center, double angle);
virtual void scale(Vector center, Vector factor);
virtual void mirror(Vector axisPoint1, Vector axisPoint2);
virtual void moveRef(const Vector& ref, const Vector& offset);
virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
-
- // virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
friend std::ostream & operator<<(std::ostream & os, const RS_Polyline & l);
#include "rs_previewactioninterface.h"
#include "rs_debug.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
/**
* from this interface operates.
*/
RS_PreviewActionInterface::RS_PreviewActionInterface(const char * name,
- RS_EntityContainer & container, RS_GraphicView & graphicView):
+ RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface(name, container, graphicView)
{
RS_DEBUG->print("RS_PreviewActionInterface::RS_PreviewActionInterface: Setting up action with preview: \"%s\"", name);
xorPreview();
}
-//#include "qg_graphicview.h"
/**
* Draws / deletes the current preview.
*/
{
public:
RS_PreviewActionInterface(const char * name,
- RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_EntityContainer & container, GraphicView & graphicView);
virtual ~RS_PreviewActionInterface();
virtual void init(int status = 0);
* entities. Usually that's an Drawing entity but
* it can also be a polyline, text, ...
*/
-RS_Selection::RS_Selection(RS_EntityContainer & container, RS_GraphicView * graphicView)
+RS_Selection::RS_Selection(RS_EntityContainer & container, GraphicView * graphicView)
{
this->container = &container;
this->graphicView = graphicView;
#define RS_SELECTION_H
#include "rs_entitycontainer.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
/**
* API Class for selecting entities.
{
public:
RS_Selection(RS_EntityContainer & entityContainer,
- RS_GraphicView * graphicView = NULL);
+ GraphicView * graphicView = NULL);
void selectSingle(RS_Entity * e);
void selectAll(bool select = true);
protected:
RS_EntityContainer * container;
Drawing * graphic;
- RS_GraphicView * graphicView;
+ GraphicView * graphicView;
};
#endif
#include "rs_dialogfactory.h"
#include "drawing.h"
#include "rs_entitycontainer.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_grid.h"
#include "rs_information.h"
#include "settings.h"
/**
* Constructor.
*/
-RS_Snapper::RS_Snapper(RS_EntityContainer & c, RS_GraphicView & gv):
+RS_Snapper::RS_Snapper(RS_EntityContainer & c, GraphicView & gv):
container(&c), graphicView(&gv), finished(false)
{
init();
class RS_Entity;
class RS_EntityContainer;
-class RS_GraphicView;
+class GraphicView;
/**
* This class is used for snapping functions in a graphic view.
class RS_Snapper
{
public:
- RS_Snapper(RS_EntityContainer & container, RS_GraphicView & graphicView);
+ RS_Snapper(RS_EntityContainer & container, GraphicView & graphicView);
virtual ~RS_Snapper();
void init();
protected:
RS_EntityContainer * container;
- RS_GraphicView * graphicView;
+ GraphicView * graphicView;
RS_Entity * keyEntity;
Vector snapCoord;
Vector snapSpot;
#include "rs_solid.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "paintintf.h"
/**
* Default constructor.
*/
-RS_Solid::RS_Solid(RS_EntityContainer * parent, const RS_SolidData& d):
+RS_Solid::RS_Solid(RS_EntityContainer * parent, const RS_SolidData & d):
RS_AtomicEntity(parent), data(d)
{
calculateBorders();
}
+/*virtual*/ RS_Entity * RS_Solid::clone()
+{
+ RS_Solid * s = new RS_Solid(*this);
+ s->initId();
+ return s;
+}
+
+/** @return RS_ENTITY_POINT */
+/*virtual*/ RS2::EntityType RS_Solid::rtti() const
+{
+ return RS2::EntitySolid;
+}
+
+/**
+ * @return Start point of the entity.
+ */
+/*virtual*/ Vector RS_Solid::getStartpoint() const
+{
+ return Vector(false);
+}
+
+/**
+ * @return End point of the entity.
+ */
+/*virtual*/ Vector RS_Solid::getEndpoint() const
+{
+ return Vector(false);
+}
+
+/** @return Copy of data that defines the point. */
+RS_SolidData RS_Solid::getData() const
+{
+ return data;
+}
+
+/** @return true if this is a triangle. */
+bool RS_Solid::isTriangle()
+{
+ return !data.corner[3].valid;
+}
+
/**
* @return Corner number 'num'.
*/
Vector RS_Solid::getCorner(int num)
{
if (num >= 0 && num < 4)
- {
return data.corner[num];
- }
else
{
RS_DEBUG->print("Illegal corner requested from Solid", RS_Debug::D_WARNING);
void RS_Solid::shapeArrow(const Vector & point, double angle, double arrowSize)
{
double cosv1, sinv1, cosv2, sinv2;
- double arrowSide = arrowSize/cos(0.165);
+ double arrowSide = arrowSize / cos(0.165);
- cosv1 = cos(angle+0.165)*arrowSide;
- sinv1 = sin(angle+0.165)*arrowSide;
- cosv2 = cos(angle-0.165)*arrowSide;
- sinv2 = sin(angle-0.165)*arrowSide;
+ cosv1 = cos(angle + 0.165) * arrowSide;
+ sinv1 = sin(angle + 0.165) * arrowSide;
+ cosv2 = cos(angle - 0.165) * arrowSide;
+ sinv2 = sin(angle - 0.165) * arrowSide;
data.corner[0] = point;
data.corner[1] = Vector(point.x - cosv1, point.y - sinv1);
double curDist;
Vector ret;
- for (int i=0; i<4; ++i)
+ for(int i=0; i<4; ++i)
{
if (data.corner[i].valid)
{
}
}
- if (dist != NULL)
+ if (dist)
*dist = minDist;
return ret;
/**
* @todo Implement this.
*/
-Vector RS_Solid::getNearestPointOnEntity(const Vector & /*coord*/,
- bool /*onEntity*/, double * /*dist*/, RS_Entity ** /*entity*/)
+Vector RS_Solid::getNearestPointOnEntity(const Vector & /*coord*/, bool /*onEntity*/,
+ double * /*dist*/, RS_Entity ** /*entity*/)
{
Vector ret(false);
return ret;
Vector RS_Solid::getNearestCenter(const Vector & /*coord*/, double * dist)
{
- if (dist != NULL)
+ if (dist)
*dist = RS_MAXDOUBLE;
return Vector(false);
Vector RS_Solid::getNearestMiddle(const Vector & /*coord*/, double * dist)
{
- if (dist != NULL)
- *dist = RS_MAXDOUBLE;
+ if (dist)
+ *dist = RS_MAXDOUBLE;
return Vector(false);
}
Vector RS_Solid::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
{
- if (dist != NULL)
- *dist = RS_MAXDOUBLE;
+ if (dist)
+ *dist = RS_MAXDOUBLE;
return Vector(false);
}
calculateBorders();
}
-//void RS_Solid::draw(RS_Painter* painter, RS_GraphicView* view, double /*patternOffset*/)
-void RS_Solid::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Solid::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
- if (painter == NULL || view == NULL)
+ if (!painter || !view)
return;
RS_SolidData d = getData();
*/
class RS_SolidData
{
-public:
- /**
- * Default constructor. Leaves the data object uninitialized.
- */
- RS_SolidData() {
- for (int i=0; i<4; ++i) {
- corner[i] = Vector(false);
- }
- }
-
- /**
- * Constructor for a solid with 3 corners.
- */
- RS_SolidData(const Vector& corner1,
- const Vector& corner2,
- const Vector& corner3) {
-
- corner[0] = corner1;
- corner[1] = corner2;
- corner[2] = corner3;
- corner[3] = Vector(false);
- }
-
- /**
- * Constructor for a solid with 4 corners.
- */
- RS_SolidData(const Vector& corner1,
- const Vector& corner2,
- const Vector& corner3,
- const Vector& corner4) {
-
- corner[0] = corner1;
- corner[1] = corner2;
- corner[2] = corner3;
- corner[3] = corner4;
- }
-
- friend class RS_Solid;
-
- friend std::ostream& operator << (std::ostream& os,
- const RS_SolidData& pd) {
- os << "(";
- for (int i=0; i<4; i++) {
- os << pd.corner[i];
- }
- os << ")";
- return os;
- }
-
-private:
- Vector corner[4];
+ public:
+ /**
+ * Default constructor. Leaves the data object uninitialized.
+ */
+ RS_SolidData()
+ {
+ for(int i=0; i<4; ++i)
+ corner[i] = Vector(false);
+ }
+
+ /**
+ * Constructor for a solid with 3 corners.
+ */
+ RS_SolidData(const Vector & corner1, const Vector & corner2, const Vector & corner3)
+ {
+ corner[0] = corner1;
+ corner[1] = corner2;
+ corner[2] = corner3;
+ corner[3] = Vector(false);
+ }
+
+ /**
+ * Constructor for a solid with 4 corners.
+ */
+ RS_SolidData(const Vector & corner1, const Vector & corner2, const Vector & corner3, const Vector & corner4)
+ {
+ corner[0] = corner1;
+ corner[1] = corner2;
+ corner[2] = corner3;
+ corner[3] = corner4;
+ }
+
+ friend class RS_Solid;
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_SolidData & pd)
+ {
+ os << "(";
+
+ for(int i=0; i<4; i++)
+ os << pd.corner[i];
+
+ os << ")";
+ return os;
+ }
+
+ private:
+ Vector corner[4];
};
/**
*/
class RS_Solid: public RS_AtomicEntity
{
-public:
- RS_Solid(RS_EntityContainer* parent,
- const RS_SolidData& d);
-
- virtual RS_Entity* clone() {
- RS_Solid* s = new RS_Solid(*this);
- s->initId();
- return s;
- }
-
- /** @return RS_ENTITY_POINT */
- virtual RS2::EntityType rtti() const {
- return RS2::EntitySolid;
- }
-
- /**
- * @return Start point of the entity.
- */
- virtual Vector getStartpoint() const {
- return Vector(false);
- }
- /**
- * @return End point of the entity.
- */
- virtual Vector getEndpoint() const {
- return Vector(false);
- }
-
-
- /** @return Copy of data that defines the point. */
- RS_SolidData getData() const {
- return data;
- }
-
- /** @return true if this is a triangle. */
- bool isTriangle() {
- return !data.corner[3].valid;
- }
-
- Vector getCorner(int num);
-
- void shapeArrow(const Vector & point, double angle, double arrowSize);
-
- virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
- virtual Vector getNearestPointOnEntity(const Vector & coord,
- bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
- virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
- virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
- virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
-
- virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
- RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
-
- virtual void move(Vector offset);
- virtual void rotate(Vector center, double angle);
- virtual void scale(Vector center, Vector factor);
- virtual void mirror(Vector axisPoint1, Vector axisPoint2);
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-
- friend std::ostream & operator<<(std::ostream & os, const RS_Solid & p);
-
- /** Recalculates the borders of this entity. */
- virtual void calculateBorders ();
-
-protected:
- RS_SolidData data;
- //Vector point;
+ public:
+ RS_Solid(RS_EntityContainer * parent, const RS_SolidData & d);
+
+ virtual RS_Entity * clone();
+ virtual RS2::EntityType rtti() const;
+ virtual Vector getStartpoint() const;
+ virtual Vector getEndpoint() const;
+ RS_SolidData getData() const;
+ bool isTriangle();
+ Vector getCorner(int num);
+ void shapeArrow(const Vector & point, double angle, double arrowSize);
+
+ virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true,
+ double * dist = NULL, RS_Entity ** entity = NULL);
+ virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
+ virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
+ virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
+ RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
+ virtual void move(Vector offset);
+ virtual void rotate(Vector center, double angle);
+ virtual void scale(Vector center, Vector factor);
+ virtual void mirror(Vector axisPoint1, Vector axisPoint2);
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
+
+ friend std::ostream & operator<<(std::ostream & os, const RS_Solid & p);
+
+ /** Recalculates the borders of this entity. */
+ virtual void calculateBorders ();
+
+ protected:
+ RS_SolidData data;
};
#endif
#include "rs_spline.h"
#include "rs_debug.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "drawing.h"
#include "paintintf.h"
update();
}
-//void RS_Spline::draw(RS_Painter* painter, RS_GraphicView* view, double /*patternOffset*/)
-void RS_Spline::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
+void RS_Spline::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (painter == NULL || view == NULL)
return;
* Todo: draw the spline, user patterns.
*/
/*
-void RS_Spline::draw(RS_Painter* painter, RS_GraphicView* view) {
+void RS_Spline::draw(RS_Painter* painter, GraphicView* view) {
if (painter==NULL || view==NULL) {
return;
}
int getNumberOfControlPoints();
bool isClosed();
void setClosed(bool c);
-
virtual VectorSolutions getRefPoints();
virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
-
void update();
-
virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
-
virtual void addControlPoint(const Vector & v);
virtual void removeLastControlPoint();
-
virtual void move(Vector offset);
virtual void rotate(Vector center, double angle);
virtual void scale(Vector center, Vector factor);
virtual void mirror(Vector axisPoint1, Vector axisPoint2);
virtual void moveRef(const Vector & ref, const Vector & offset);
-
-// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
- virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
-// Q3ValueList<Vector> getControlPoints();
+ virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
QList<Vector> getControlPoints();
friend std::ostream & operator<<(std::ostream & os, const RS_Spline & l);
#ifndef RS_STATICGRAPHICVIEW_H
#define RS_STATICGRAPHICVIEW_H
-#include "rs_graphicview.h"
+#include "graphicview.h"
class PaintInterface;
* This is an implementation of a graphic viewer with a fixed size
* for drawing onto fixed devices (such as bitmaps).
*/
-class RS_StaticGraphicView: public RS_GraphicView
+class RS_StaticGraphicView: public GraphicView
{
public:
RS_StaticGraphicView(int w, int h, PaintInterface * p);
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarArcs::CadToolBarArcs(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarCircles::CadToolBarCircles(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarDim::CadToolBarDim(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarEllipses::CadToolBarEllipses(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarInfo::CadToolBarInfo(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarLines::CadToolBarLines(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
-
#include "createqtactions.h"
+#include "rs_debug.h"
CadToolBarMain::CadToolBarMain(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarModify::CadToolBarModify(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarPoints::CadToolBarPoints(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarPolylines::CadToolBarPolylines(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
#include "rs_actioninterface.h"
+#include "rs_debug.h"
CadToolBarSelect::CadToolBarSelect(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL), selectAction(NULL),
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarSnap::CadToolBarSnap(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "cadtoolbar.h"
#include "qg_actionhandler.h"
+#include "rs_debug.h"
CadToolBarSplines::CadToolBarSplines(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
#include "dlghatch.h"
-//#include "rs_ellipse.h"
-//#include "drawing.h"
-//#include "rs_math.h"
#include "rs_entitycontainer.h"
#include "rs_hatch.h"
#include "rs_pattern.h"
#include "qg_colorbox.h"
#include "qg_filedialog.h"
#include "qg_pentoolbar.h"
+#include "recentfiles.h"
#include "cadtoolbar.h"
#include "cadtoolbarmain.h"
#include "coordinatewidget.h"
statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
- RS_GraphicView * graphicView = getGraphicView();
+ GraphicView * graphicView = getGraphicView();
RS_Document * document = getDocument();
if (graphicView != NULL && document != NULL)
// menuBar()->insertItem(tr("De&bugging"), testMenu);
menuBar()->addMenu(testMenu);
- recentFiles = new QG_RecentFiles(this, fileMenu);
+ recentFiles = new RecentFiles(this, fileMenu);
}
/**
}
}*/
-#warning "!!! ApplicationWindow::updateRecentFilesMenu() is DEPRECATED !!!"
-/**
- * Updates the recent file list in the file menu.
- */
-void ApplicationWindow::updateRecentFilesMenu()
-{
- RS_DEBUG->print("ApplicationWindow::updateRecentFilesMenu()");
- RS_DEBUG->print("Updating recent file menu...");
-
-#if 0
- for(int i=0; i<recentFiles->getNumber(); ++i)
- {
- QString label = QString("&%1 %2").arg(i + 1).arg(recentFiles->get(i));
-
- if (fileMenu->findItem(i))
- {
- RS_DEBUG->print("Changeing item %d", i);
- fileMenu->changeItem(i, label);
- }
- else if (i < int(recentFiles->count()))
- {
- RS_DEBUG->print("Adding item %d", i);
- fileMenu->insertItem(label, this, SLOT(slotFileOpenRecent(int)), 0, i);
- }
- }
-#else
-//#warning "!!! Need to fix ApplicationWindow::updateRecentFilesMenu() !!!"
- recentFiles->UpdateGUI();
-#endif
-}
-
/**
* Goes back to the previous menu or one step in the current action.
*/
void ApplicationWindow::slotBack()
{
- RS_GraphicView * graphicView = getGraphicView();
+ GraphicView * graphicView = getGraphicView();
if (graphicView != NULL)
graphicView->back();
cadToolBar->forceNext();
else
{
- RS_GraphicView * graphicView = getGraphicView();
+ GraphicView * graphicView = getGraphicView();
if (graphicView != NULL)
graphicView->enter();
ins->update();
graphic->addEntity(ins);
- RS_GraphicView * v = getGraphicView();
+ GraphicView * v = getGraphicView();
if (v != NULL)
v->redraw();
}
*/
- RS_GraphicView * v = getGraphicView();
+ GraphicView * v = getGraphicView();
if (v != NULL)
v->redraw();
RS2::SolidLine));
graphic->addEntity(s);
- RS_GraphicView* v = getGraphicView();
+ GraphicView* v = getGraphicView();
if (v!=NULL) {
v->redraw();
}
// Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
- RS_GraphicView* v = getGraphicView();
+ GraphicView* v = getGraphicView();
if (v!=NULL) {
v->redraw();
}
QMainWindow::keyPressEvent(e);
// forward to actions:
- RS_GraphicView * graphicView = getGraphicView();
+ GraphicView * graphicView = getGraphicView();
if (graphicView != NULL)
graphicView->keyPressEvent(e);
QMainWindow::keyReleaseEvent(e);
// forward to actions:
- RS_GraphicView * graphicView = getGraphicView();
+ GraphicView * graphicView = getGraphicView();
if (graphicView != NULL)
graphicView->keyReleaseEvent(e);
* @return Pointer to the graphic view of the currently active document
* window or NULL if no window is available.
*/
-/*virtual*/ RS_GraphicView * ApplicationWindow::getGraphicView()
+/*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
{
MDIWindow * m = getMDIWindow();
#include "qg_blockwidget.h"
#include "qg_layerwidget.h"
#include "qg_mainwindowinterface.h"
-#include "qg_recentfiles.h"
#include "qg_pentoolbar.h"
#include "cadtoolbar.h"
#include "commandwidget.h"
#include "rs_simulationcontrols.h"
#endif
+class RecentFiles;
+
/**
* Main application window. Hold together document, view and controls.
*
void initStatusBar();
void initSettings();
void storeSettings();
- void updateRecentFilesMenu();
void initMDI();
void initView();
bool queryExit(bool force);
static ApplicationWindow * getAppWindow();
QMdiArea * getWorkspace();
MDIWindow * getMDIWindow();
- virtual RS_GraphicView * getGraphicView();
+ virtual GraphicView * getGraphicView();
virtual RS_Document * getDocument();
virtual void createNewDocument(const QString & fileName = QString::null, RS_Document * doc = NULL);
virtual QMainWindow * GetMainWindow();
QToolBar * optionWidget;
/** Recent files list */
- QG_RecentFiles * recentFiles;
+ RecentFiles * recentFiles;
/** Action handler. */
QG_ActionHandler * actionHandler;
-// rs_graphicview.cpp
+// graphicview.cpp
//
// Part of the Architektonas Project
// Originally part of QCad Community Edition by Andrew Mustun
//
// Who When What
// --- ---------- -----------------------------------------------------------
-// JLH 05/21/2010 Added this text. :-)
+// JLH 06/16/2010 Created this file. :-)
//
-#include "rs_graphicview.h"
+#include "graphicview.h"
-#include <stdio.h>
-#include "rs_actioninterface.h"
-#include "rs_block.h"
#include "rs_dialogfactory.h"
#include "drawing.h"
#include "rs_eventhandler.h"
#include "rs_grid.h"
-#include "rs_insert.h"
-#include "rs_layer.h"
-#include "rs_line.h"
-#include "rs_solid.h"
-#include "rs_text.h"
-#include "rs_units.h"
+#include "rs_linetypepattern.h"
#include "paintintf.h"
#include "settings.h"
+#include "rs_text.h"
+#include "rs_units.h"
/**
* Constructor.
*/
-RS_GraphicView::RS_GraphicView(): background(), foreground(), previewMode(false),
+GraphicView::GraphicView(): background(), foreground(), previewMode(false),
previewOffset(Vector(0, 0)), snapperDraw(false)
{
drawingMode = RS2::ModeFull;
/**
* Destructor.
*/
-RS_GraphicView::~RS_GraphicView()
+GraphicView::~GraphicView()
{
//delete eventHandler;
if (painter != NULL)
/**
* Must be called by any derrived class in the destructor.
*/
-void RS_GraphicView::cleanUp()
+void GraphicView::cleanUp()
{
delete eventHandler;
}
* connected to this view is a graphic and valid.
* NULL otherwise.
*/
-Drawing * RS_GraphicView::getGraphic()
+Drawing * GraphicView::getGraphic()
{
if (container != NULL && container->rtti() == RS2::EntityGraphic)
return (Drawing*)container;
/**
* Sets the drawing mode.
*/
-void RS_GraphicView::setDrawingMode(RS2::DrawingMode m)
+void GraphicView::setDrawingMode(RS2::DrawingMode m)
{
drawingMode = m;
}
/**
* @return Current drawing mode.
*/
-RS2::DrawingMode RS_GraphicView::getDrawingMode()
+RS2::DrawingMode GraphicView::getDrawingMode()
{
return drawingMode;
}
/**
* Activates or deactivates the delete mode.
*/
-void RS_GraphicView::setDeleteMode(bool m)
+void GraphicView::setDeleteMode(bool m)
{
deleteMode = m;
}
* @reval true Deleting instead of drawing.
* false Normal drawing mode.
*/
-bool RS_GraphicView::getDeleteMode()
+bool GraphicView::getDeleteMode()
{
return deleteMode;
}
/** This virtual method must be overwritten and is then
called whenever the view changed */
-void RS_GraphicView::adjustOffsetControls()
+void GraphicView::adjustOffsetControls()
{
}
/** This virtual method must be overwritten and is then
called whenever the view changed */
-void RS_GraphicView::adjustZoomControls()
+void GraphicView::adjustZoomControls()
{
}
/**
* Sets an external painter device.
*/
-//void RS_GraphicView::setPainter(RS_Painter * p)
-void RS_GraphicView::setPainter(PaintInterface * p)
+//void GraphicView::setPainter(RS_Painter * p)
+void GraphicView::setPainter(PaintInterface * p)
{
painter = p;
}
* Sets the background color. Note that applying the background
* color for the widget is up to the implementing class.
*/
-void RS_GraphicView::setBackground(const RS_Color & bg)
+void GraphicView::setBackground(const RS_Color & bg)
{
background = bg;
/**
* @return Current background color.
*/
-RS_Color RS_GraphicView::getBackground()
+RS_Color GraphicView::getBackground()
{
return background;
}
/**
* @return Current foreground color.
*/
-RS_Color RS_GraphicView::getForeground()
+RS_Color GraphicView::getForeground()
{
return foreground;
}
/**
* Sets the grid color.
*/
-void RS_GraphicView::setGridColor(const RS_Color & c)
+void GraphicView::setGridColor(const RS_Color & c)
{
gridColor = c;
}
/**
* Sets the meta grid color.
*/
-void RS_GraphicView::setMetaGridColor(const RS_Color & c)
+void GraphicView::setMetaGridColor(const RS_Color & c)
{
metaGridColor = c;
}
/**
* Sets the selection color.
*/
-void RS_GraphicView::setSelectedColor(const RS_Color & c)
+void GraphicView::setSelectedColor(const RS_Color & c)
{
selectedColor = c;
}
/**
* Sets the highlight color.
*/
-void RS_GraphicView::setHighlightedColor(const RS_Color & c)
+void GraphicView::setHighlightedColor(const RS_Color & c)
{
highlightedColor = c;
}
* This virtual method can be overwritten to set the mouse
* cursor to the given type.
*/
-void RS_GraphicView::setMouseCursor(RS2::CursorType /*c*/)
+void GraphicView::setMouseCursor(RS2::CursorType /*c*/)
{
}
-RS_EntityContainer * RS_GraphicView::getContainer()
+RS_EntityContainer * GraphicView::getContainer()
{
return container;
}
-void RS_GraphicView::setFactor(double f)
+void GraphicView::setFactor(double f)
{
setFactorX(f);
setFactorY(f);
}
-Vector RS_GraphicView::getFactor()
+Vector GraphicView::getFactor()
{
return factor;
}
/**
* Sets the offset of the graphic.
*/
-void RS_GraphicView::setOffset(int ox, int oy)
+void GraphicView::setOffset(int ox, int oy)
{
setOffsetX(ox);
setOffsetY(oy);
}
-void RS_GraphicView::setOffsetX(int ox)
+void GraphicView::setOffsetX(int ox)
{
offsetX = ox;
}
-void RS_GraphicView::setOffsetY(int oy)
+void GraphicView::setOffsetY(int oy)
{
offsetY = oy;
}
-int RS_GraphicView::getOffsetX()
+int GraphicView::getOffsetX()
{
return offsetX;
}
-int RS_GraphicView::getOffsetY()
+int GraphicView::getOffsetY()
{
return offsetY;
}
* specifies how far the user can scroll outside the graphic
* area.
*/
-void RS_GraphicView::setBorders(int left, int top, int right, int bottom)
+void GraphicView::setBorders(int left, int top, int right, int bottom)
{
borderLeft = left;
borderTop = top;
borderBottom = bottom;
}
-int RS_GraphicView::getBorderLeft()
+int GraphicView::getBorderLeft()
{
return borderLeft;
}
-int RS_GraphicView::getBorderTop()
+int GraphicView::getBorderTop()
{
return borderTop;
}
-int RS_GraphicView::getBorderRight()
+int GraphicView::getBorderRight()
{
return borderRight;
}
-int RS_GraphicView::getBorderBottom()
+int GraphicView::getBorderBottom()
{
return borderBottom;
}
-void RS_GraphicView::disableUpdate()
+void GraphicView::disableUpdate()
{
updateEnabled--;
}
-void RS_GraphicView::enableUpdate()
+void GraphicView::enableUpdate()
{
updateEnabled++;
}
-bool RS_GraphicView::isUpdateEnabled()
+bool GraphicView::isUpdateEnabled()
{
return (updateEnabled == 0);
}
-void RS_GraphicView::freezeZoom(bool freeze)
+void GraphicView::freezeZoom(bool freeze)
{
zoomFrozen = freeze;
}
-bool RS_GraphicView::isZoomFrozen()
+bool GraphicView::isZoomFrozen()
{
return zoomFrozen;
}
* Sets the pointer to the graphic which contains the entities
* which are visualized by this widget.
*/
-void RS_GraphicView::setContainer(RS_EntityContainer * container)
+void GraphicView::setContainer(RS_EntityContainer * container)
{
this->container = container;
//adjustOffsetControls();
/**
* Sets the zoom factor in X for this visualization of the graphic.
*/
-void RS_GraphicView::setFactorX(double f)
+void GraphicView::setFactorX(double f)
{
if (!zoomFrozen)
factor.x = fabs(f);
/**
* Sets the zoom factor in Y for this visualization of the graphic.
*/
-void RS_GraphicView::setFactorY(double f)
+void GraphicView::setFactorY(double f)
{
if (!zoomFrozen)
factor.y = fabs(f);
/**
* @return true if the grid is switched on.
*/
-bool RS_GraphicView::isGridOn()
+bool GraphicView::isGridOn()
{
if (container != NULL)
{
/**
* Centers the drawing in x-direction.
*/
-void RS_GraphicView::centerOffsetX()
+void GraphicView::centerOffsetX()
{
if (container != NULL && !zoomFrozen)
offsetX = (int)(((getWidth() - borderLeft - borderRight)
/**
* Centers the drawing in y-direction.
*/
-void RS_GraphicView::centerOffsetY()
+void GraphicView::centerOffsetY()
{
if (container != NULL && !zoomFrozen)
offsetY = (int)((getHeight() - borderTop - borderBottom
/**
* Centers the given coordinate in the view in x-direction.
*/
-void RS_GraphicView::centerX(double v)
+void GraphicView::centerX(double v)
{
if (!zoomFrozen)
offsetX = (int)((v * factor.x) - (double)(getWidth() - borderLeft - borderRight) / 2.0);
/**
* Centers the given coordinate in the view in y-direction.
*/
-void RS_GraphicView::centerY(double v)
+void GraphicView::centerY(double v)
{
if (!zoomFrozen)
offsetY = (int)((v * factor.y) - (double)(getHeight() - borderTop - borderBottom) / 2.0);
}
-void RS_GraphicView::updateView()
+void GraphicView::updateView()
{
static int running = 0;
running++;
/**
* @return Current action or NULL.
*/
-RS_ActionInterface * RS_GraphicView::getDefaultAction()
+RS_ActionInterface * GraphicView::getDefaultAction()
{
if (eventHandler != NULL)
return eventHandler->getDefaultAction();
/**
* Sets the default action of the event handler.
*/
-void RS_GraphicView::setDefaultAction(RS_ActionInterface * action)
+void GraphicView::setDefaultAction(RS_ActionInterface * action)
{
if (eventHandler != NULL)
eventHandler->setDefaultAction(action);
/**
* @return Current action or NULL.
*/
-RS_ActionInterface * RS_GraphicView::getCurrentAction()
+RS_ActionInterface * GraphicView::getCurrentAction()
{
if (eventHandler != NULL)
return eventHandler->getCurrentAction();
/**
* Sets the current action of the event handler.
*/
-void RS_GraphicView::setCurrentAction(RS_ActionInterface * action)
+void GraphicView::setCurrentAction(RS_ActionInterface * action)
{
- RS_DEBUG->print("RS_GraphicView::setCurrentAction");
+ RS_DEBUG->print("GraphicView::setCurrentAction");
if (eventHandler != NULL)
eventHandler->setCurrentAction(action);
- RS_DEBUG->print("RS_GraphicView::setCurrentAction: OK");
+ RS_DEBUG->print("GraphicView::setCurrentAction: OK");
}
/**
* Kills all running selection actions. Called when a selection action
* is launched to reduce confusion.
*/
-void RS_GraphicView::killSelectActions()
+void GraphicView::killSelectActions()
{
if (eventHandler)
eventHandler->killSelectActions();
/**
* Kills all running actions.
*/
-void RS_GraphicView::killAllActions()
+void GraphicView::killAllActions()
{
if (eventHandler)
eventHandler->killAllActions();
/**
* Go back in menu or current action.
*/
-void RS_GraphicView::back()
+void GraphicView::back()
{
if (eventHandler && eventHandler->hasAction())
eventHandler->back();
/**
* Go forward with the current action.
*/
-void RS_GraphicView::enter()
+void GraphicView::enter()
{
if (eventHandler && eventHandler->hasAction())
eventHandler->enter();
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about mouse events.
*/
-void RS_GraphicView::mousePressEvent(QMouseEvent * e)
+void GraphicView::mousePressEvent(QMouseEvent * e)
{
if (eventHandler)
eventHandler->mousePressEvent(e);
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about mouse events.
*/
-void RS_GraphicView::mouseReleaseEvent(QMouseEvent * e)
+void GraphicView::mouseReleaseEvent(QMouseEvent * e)
{
- RS_DEBUG->print("RS_GraphicView::mouseReleaseEvent");
+ RS_DEBUG->print("GraphicView::mouseReleaseEvent");
if (!eventHandler)
return;
e->accept();
}
- RS_DEBUG->print("RS_GraphicView::mouseReleaseEvent: OK");
+ RS_DEBUG->print("GraphicView::mouseReleaseEvent: OK");
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about mouse events.
*/
-void RS_GraphicView::mouseMoveEvent(QMouseEvent * e)
+void GraphicView::mouseMoveEvent(QMouseEvent * e)
{
- RS_DEBUG->print("RS_GraphicView::mouseMoveEvent begin");
+ RS_DEBUG->print("GraphicView::mouseMoveEvent begin");
Drawing * graphic = NULL;
if (container->rtti() == RS2::EntityGraphic)
graphic = (Drawing *)container;
- RS_DEBUG->print("RS_GraphicView::mouseMoveEvent 001");
+ RS_DEBUG->print("GraphicView::mouseMoveEvent 001");
if (e)
{
my = e->y();
}
- RS_DEBUG->print("RS_GraphicView::mouseMoveEvent 002");
+ RS_DEBUG->print("GraphicView::mouseMoveEvent 002");
if (eventHandler)
eventHandler->mouseMoveEvent(e);
- RS_DEBUG->print("RS_GraphicView::mouseMoveEvent 003");
+ RS_DEBUG->print("GraphicView::mouseMoveEvent 003");
if (!eventHandler || !eventHandler->hasAction() && graphic)
{
RS_DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
}
- RS_DEBUG->print("RS_GraphicView::mouseMoveEvent end");
+ RS_DEBUG->print("GraphicView::mouseMoveEvent end");
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about mouse events.
*/
-void RS_GraphicView::mouseLeaveEvent()
+void GraphicView::mouseLeaveEvent()
{
if (eventHandler)
eventHandler->mouseLeaveEvent();
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about mouse events.
*/
-void RS_GraphicView::mouseEnterEvent()
+void GraphicView::mouseEnterEvent()
{
if (eventHandler)
eventHandler->mouseEnterEvent();
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about key events.
*/
-void RS_GraphicView::keyPressEvent(QKeyEvent * e)
+void GraphicView::keyPressEvent(QKeyEvent * e)
{
if (eventHandler)
eventHandler->keyPressEvent(e);
}
/**
- * Called by the actual GUI class which implements the RS_GraphicView
+ * Called by the actual GUI class which implements the GraphicView
* interface to notify qcadlib about key events.
*/
-void RS_GraphicView::keyReleaseEvent(QKeyEvent * e)
+void GraphicView::keyReleaseEvent(QKeyEvent * e)
{
if (eventHandler)
eventHandler->keyReleaseEvent(e);
/**
* Called by the actual GUI class which implements a command line.
*/
-void RS_GraphicView::commandEvent(RS_CommandEvent * e)
+void GraphicView::commandEvent(RS_CommandEvent * e)
{
if (eventHandler)
eventHandler->commandEvent(e);
/**
* Enables coordinate input in the command line.
*/
-void RS_GraphicView::enableCoordinateInput()
+void GraphicView::enableCoordinateInput()
{
if (eventHandler)
eventHandler->enableCoordinateInput();
/**
* Disables coordinate input in the command line.
*/
-void RS_GraphicView::disableCoordinateInput()
+void GraphicView::disableCoordinateInput()
{
if (eventHandler)
eventHandler->disableCoordinateInput();
/**
* zooms in by factor f
*/
-void RS_GraphicView::zoomIn(double f, const Vector & center)
+void GraphicView::zoomIn(double f, const Vector & center)
{
if (f < 1.0e-6)
{
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_GraphicView::zoomIn: invalid factor");
+ RS_DEBUG->print(RS_Debug::D_WARNING, "GraphicView::zoomIn: invalid factor");
return;
}
/**
* zooms in by factor f in x
*/
-void RS_GraphicView::zoomInX(double f)
+void GraphicView::zoomInX(double f)
{
if (simulationRunning)
return;
/**
* zooms in by factor f in y
*/
-void RS_GraphicView::zoomInY(double f)
+void GraphicView::zoomInY(double f)
{
if (simulationRunning)
return;
/**
* zooms out by factor f
*/
-void RS_GraphicView::zoomOut(double f, const Vector & center)
+void GraphicView::zoomOut(double f, const Vector & center)
{
if (f < 1.0e-6)
{
RS_DEBUG->print(RS_Debug::D_WARNING,
- "RS_GraphicView::zoomOut: invalid factor");
+ "GraphicView::zoomOut: invalid factor");
return;
}
/**
* zooms out by factor f in x
*/
-void RS_GraphicView::zoomOutX(double f)
+void GraphicView::zoomOutX(double f)
{
if (f < 1.0e-6)
{
RS_DEBUG->print(RS_Debug::D_WARNING,
- "RS_GraphicView::zoomOutX: invalid factor");
+ "GraphicView::zoomOutX: invalid factor");
return;
}
}
/**
- * zooms out by factor f y
+ * zooms out by factor of y
*/
-void RS_GraphicView::zoomOutY(double f)
+void GraphicView::zoomOutY(double f)
{
if (f < 1.0e-6)
{
- RS_DEBUG->print(RS_Debug::D_WARNING,
- "RS_GraphicView::zoomOutY: invalid factor");
+ RS_DEBUG->print(RS_Debug::D_WARNING, "GraphicView::zoomOutY: invalid factor");
return;
}
* @param keepAspectRatio true: keep aspect ratio 1:1
* false: factors in x and y are stretched to the max
*/
-void RS_GraphicView::zoomAuto(bool axis, bool keepAspectRatio)
+void GraphicView::zoomAuto(bool axis, bool keepAspectRatio)
{
- RS_DEBUG->print("RS_GraphicView::zoomAuto");
+ RS_DEBUG->print("GraphicView::zoomAuto");
if (simulationRunning)
return;
redraw();
}
- RS_DEBUG->print("RS_GraphicView::zoomAuto OK");
+ RS_DEBUG->print("GraphicView::zoomAuto OK");
}
/**
* Shows previous view.
*/
-void RS_GraphicView::zoomPrevious()
+void GraphicView::zoomPrevious()
{
- RS_DEBUG->print("RS_GraphicView::zoomPrevious");
+ RS_DEBUG->print("GraphicView::zoomPrevious");
if (simulationRunning)
return;
- if (container != NULL)
+ if (container)
restoreView();
}
* Saves the current view as previous view to which we can
* switch back later with @see restoreView().
*/
-void RS_GraphicView::saveView()
+void GraphicView::saveView()
{
previousOffsetX = offsetX;
previousOffsetY = offsetY;
* Restores the view previously saved with
* @see saveView().
*/
-void RS_GraphicView::restoreView()
+void GraphicView::restoreView()
{
int pox = previousOffsetX;
int poy = previousOffsetY;
*
* @param axis include axis in zoom
*/
-void RS_GraphicView::zoomAutoY(bool axis)
+void GraphicView::zoomAutoY(bool axis)
{
if (simulationRunning)
return;
* false: zooms exactly the selected range to the
* current graphic view
*/
-void RS_GraphicView::zoomWindow(Vector v1, Vector v2, bool keepAspectRatio)
+void GraphicView::zoomWindow(Vector v1, Vector v2, bool keepAspectRatio)
{
if (simulationRunning)
return;
/**
* Centers the point v1.
*/
-void RS_GraphicView::zoomPan(int dx, int dy)
+void GraphicView::zoomPan(int dx, int dy)
{
//offsetX+=(int)toGuiDX(v1.x);
//offsetY+=(int)toGuiDY(v1.y);
/**
* Scrolls in the given direction.
*/
-void RS_GraphicView::zoomScroll(RS2::Direction direction)
+void GraphicView::zoomScroll(RS2::Direction direction)
{
if (simulationRunning)
return;
/**
* Zooms to page extends.
*/
-void RS_GraphicView::zoomPage()
+void GraphicView::zoomPage()
{
- RS_DEBUG->print("RS_GraphicView::zoomPage");
+ RS_DEBUG->print("GraphicView::zoomPage");
if (container == NULL)
return;
/**
* Draws the entities within the given range.
*/
-void RS_GraphicView::drawWindow(Vector v1, Vector v2)
+void GraphicView::drawWindow(Vector v1, Vector v2)
{
- RS_DEBUG->print("RS_GraphicView::drawWindow() begin");
+ RS_DEBUG->print("GraphicView::drawWindow() begin");
if (simulationRunning)
return;
}
}
- RS_DEBUG->print("RS_GraphicView::drawWindow() end");
+ RS_DEBUG->print("GraphicView::drawWindow() end");
}
/**
* Draws the entities. If painter is NULL a new painter will
* be created and destroyed.
*/
-void RS_GraphicView::drawIt()
+void GraphicView::drawIt()
{
if (!isUpdateEnabled())
//{
-//printf("RS_GraphicView::drawIt(): isUpdateEnabled() == false!\n");
+//printf("GraphicView::drawIt(): isUpdateEnabled() == false!\n");
return;
//}
if (simulationRunning)
//{
-//printf("RS_GraphicView::drawIt(): simulationRunning == true!\n");
+//printf("GraphicView::drawIt(): simulationRunning == true!\n");
return;
//}
if (!painter)
// {
-//printf("RS_GraphicView::drawIt(): painter == NULL!\n");
+//printf("GraphicView::drawIt(): painter == NULL!\n");
return;
// }
* Sets the pen of the painter object to the suitable pen for the given
* entity.
*/
-void RS_GraphicView::setPenForEntity(RS_Entity * e)
+void GraphicView::setPenForEntity(RS_Entity * e)
{
if (drawingMode == RS2::ModePreview /*|| draftMode==true*/)
return;
// set color of entity
- if (painter != NULL && !painter->isPreviewMode())
+ if (painter && !painter->isPreviewMode())
{
// Getting pen from entity (or layer)
RS_Pen pen = e->getPen(true);
* lines e.g. in splines).
* @param db Double buffering on (recommended) / off
*/
-void RS_GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db)
+void GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db)
{
- //RS_DEBUG->print("RS_GraphicView::drawEntity() begin");
+ //RS_DEBUG->print("GraphicView::drawEntity() begin");
// update is diabled:
if (!isUpdateEnabled())
return;
// given entity is NULL:
- if (e == NULL)
+ if (!e)
return;
// entity is not visible:
// test if the entity is in the viewport
if (!e->isContainer() && !isPrinting()
- && (painter == NULL || !painter->isPreviewMode())
+ && (!painter || !painter->isPreviewMode())
&& (toGuiX(e->getMax().x) < 0 || toGuiX(e->getMin().x) > getWidth()
|| toGuiY(e->getMin().y) < 0 || toGuiY(e->getMax().y) > getHeight()))
//{
-//printf("RS_GraphicView::drawEntity(): Bailing out of big test!!!\n");
+//printf("GraphicView::drawEntity(): Bailing out of big test!!!\n");
return;
//}
}
//RS_DEBUG->print("draw plain OK");
- //RS_DEBUG->print("RS_GraphicView::drawEntity() end");
+ //RS_DEBUG->print("GraphicView::drawEntity() end");
}
/**
* Deletes an entity with the background color.
* Might be recusively called e.g. for polylines.
*/
-void RS_GraphicView::deleteEntity(RS_Entity * e)
+void GraphicView::deleteEntity(RS_Entity * e)
{
+#warning "!!! This is part of obsolete rendering !!!"
setDeleteMode(true);
drawEntity(e);
setDeleteMode(false);
* Draws an entity.
* The painter must be initialized and all the attributes (pen) must be set.
*/
-void RS_GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset)
+void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset)
{
- if (e == NULL)
+//Problems can still occur here when passing in a deleted object... It won't be
+//NULL, but it will cause a segfault here...
+ if (!e)
//{
-//printf("RS_GraphicView::drawEntityPlain(): Entity passed in is NULL!\n");
+//printf("GraphicView::drawEntityPlain(): Entity passed in is NULL!\n");
return;
//}
-//printf("RS_GraphicView::drawEntityPlain(): Passing in painter=%08X, view=%08X\n", painter, this);
+//printf("GraphicView::drawEntityPlain(): Passing in painter=%08X, view=%08X\n", painter, this);
e->draw(painter, this, patternOffset);
}
/**
* Simulates this drawing in slow motion.
*/
-void RS_GraphicView::simulateIt()
+void GraphicView::simulateIt()
{
if (simulationRunning)
return;
//RS_DEBUG->print(" draw grid..");
//RS_DEBUG->timestamp();
- //RS_DEBUG->print("RS_GraphicView::drawIt() end");
+ //RS_DEBUG->print("GraphicView::drawIt() end");
//if (painterCreated==true) {
//jlh destroyPainter();
//}
*
* @param smooth If true, the entity will be drawn slowly (pixel by pixel).
*/
-void RS_GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
+void GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
{
if (painter == NULL || e == NULL)
return;
*
* @param step true: stepping mode (entity by entity simulation). adds a delay.
*/
-void RS_GraphicView::simulationDelay(bool step)
+void GraphicView::simulationDelay(bool step)
{
int delay;
settings.beginGroup("CAM");
/**
* Draws a line slowly from (x1, y1) to (x2, y2). This is used for simulation only.
*/
-void RS_GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen)
+void GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen)
{
double alpha = p1.angleTo(p2);
double xStep, yStep;
|| (!xIsOne && ((ly >= p1.y && ly <= p2.y) || (ly >= p2.y && ly <= p1.y))));
}
-void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double a1, double a2, bool rev,
+void GraphicView::drawArcSmooth(const Vector & center, double radius, double a1, double a2, bool rev,
const RS_Pen & pen)
{
//int icx = graphic->realToScreenX(cx);
* @return Pointer to the static pattern struct that belongs to the
* given pattern type or NULL.
*/
-RS_LineTypePattern * RS_GraphicView::getPattern(RS2::LineType t)
+RS_LineTypePattern * GraphicView::getPattern(RS2::LineType t)
{
switch (t)
{
*
* @see drawIt()
*/
-void RS_GraphicView::drawAbsoluteZero()
+void GraphicView::drawAbsoluteZero()
{
if (!painter)
return;
*
* @see drawIt()
*/
-void RS_GraphicView::drawRelativeZero()
+void GraphicView::drawRelativeZero()
{
if (!relativeZero.valid || !painter)
return;
*
* @see drawIt()
*/
-void RS_GraphicView::drawPaper()
+void GraphicView::drawPaper()
{
- if (container == NULL)
+ if (!container)
return;
Drawing * graphic = container->getGraphic();
- if (graphic == NULL)
+ if (!graphic)
return;
if (graphic->getPaperScale() < 1.0e-6)
return;
- if (painter == NULL)
+ if (!painter)
return;
// draw paper:
// shadow
painter->fillRect((int)(v1.x) + 6, (int)(v1.y) + 6,
- (int)((v2.x - v1.x)), (int)((v2.y - v1.y)),
- RS_Color(64, 64, 64));
+ (int)((v2.x - v1.x)), (int)((v2.y - v1.y)), RS_Color(64, 64, 64));
// border:
painter->fillRect((int)(v1.x), (int)(v1.y),
- (int)((v2.x - v1.x)), (int)((v2.y - v1.y)),
- RS_Color(64, 64, 64));
+ (int)((v2.x - v1.x)), (int)((v2.y - v1.y)), RS_Color(64, 64, 64));
// paper
painter->fillRect((int)(v1.x) + 1, (int)(v1.y) - 1,
- (int)((v2.x - v1.x)) - 2, (int)((v2.y - v1.y)) + 2,
- RS_Color(255, 255, 255));
+ (int)((v2.x - v1.x)) - 2, (int)((v2.y - v1.y)) + 2, RS_Color(255, 255, 255));
}
/**
*
* @see drawIt()
*/
-void RS_GraphicView::drawGrid()
+void GraphicView::drawGrid()
{
- if (grid == NULL || isGridOn() == false)
+ if (!grid || isGridOn() == false)
// {
-// printf("RS_GraphicView::drawGrid(): Aborting: grid=%08X, isGridOn=%s\n", grid, (isGridOn() ? "true" : "false"));
+// printf("GraphicView::drawGrid(): Aborting: grid=%08X, isGridOn=%s\n", grid, (isGridOn() ? "true" : "false"));
return;
// }
// draw grid:
- //painter->setPen(Qt::gray);
painter->setPen(gridColor);
-// painter->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width00, RS2::SolidLine));
//Problem here: pts is NULL!
Vector * pts = grid->getPoints();
- if (pts != NULL)
+ if (pts)
{
for(int i=0; i<grid->count(); ++i)
painter->drawGridPoint(toGui(pts[i]));
}
// else
-// printf("RS_GraphicView::drawGrid(): pts == NULL!\n");
+// printf("GraphicView::drawGrid(): pts == NULL!\n");
// draw grid info:
- //painter->setPen(Qt::white);
QString info = grid->getInfo();
- //info = QString("%1 / %2")
- // .arg(grid->getSpacing())
- // .arg(grid->getMetaSpacing());
-
updateGridStatusWidget(info);
}
*
* @see drawIt()
*/
-void RS_GraphicView::drawMetaGrid()
+void GraphicView::drawMetaGrid()
{
- if (grid == NULL || isGridOn() == false /*|| grid->getMetaSpacing()<0.0*/)
+ if (!grid || isGridOn() == false /*|| grid->getMetaSpacing()<0.0*/)
return;
- if (painter == NULL)
+ if (!painter)
return;
RS_Pen pen(metaGridColor, RS2::Width00, RS2::DotLine);
/**
* Updates the grid if there is one.
*/
-void RS_GraphicView::updateGrid()
+void GraphicView::updateGrid()
{
- if (grid != NULL)
+ if (grid)
grid->update();
}
-RS_Grid * RS_GraphicView::getGrid()
+RS_Grid * GraphicView::getGrid()
{
return grid;
}
-void RS_GraphicView::updateGridStatusWidget(const QString & /*text*/)
+void GraphicView::updateGridStatusWidget(const QString & /*text*/)
{
}
-RS2::SnapMode RS_GraphicView::getDefaultSnapMode()
+RS2::SnapMode GraphicView::getDefaultSnapMode()
{
return defaultSnapMode;
}
-RS2::SnapRestriction RS_GraphicView::getSnapRestriction()
+RS2::SnapRestriction GraphicView::getSnapRestriction()
{
return defaultSnapRes;
}
/**
* Sets the default snap mode used by newly created actions.
*/
-void RS_GraphicView::setDefaultSnapMode(RS2::SnapMode sm)
+void GraphicView::setDefaultSnapMode(RS2::SnapMode sm)
{
defaultSnapMode = sm;
/**
* Sets a snap restriction (e.g. orthogonal).
*/
-void RS_GraphicView::setSnapRestriction(RS2::SnapRestriction sr)
+void GraphicView::setSnapRestriction(RS2::SnapRestriction sr)
{
defaultSnapRes = sr;
/**
* Translates a vector in real coordinates to a vector in screen coordinates.
*/
-Vector RS_GraphicView::toGui(Vector v)
+Vector GraphicView::toGui(Vector v)
{
return Vector(toGuiX(v.x), toGuiY(v.y), 0.0);
}
* @param visible Pointer to a boolean which will contain true
* after the call if the coordinate is within the visible range.
*/
-double RS_GraphicView::toGuiX(double x, bool * visible)
+double GraphicView::toGuiX(double x, bool * visible)
{
if (visible != NULL)
{
/**
* Translates a real coordinate in Y to a screen coordinate Y.
*/
-double RS_GraphicView::toGuiY(double y)
+double GraphicView::toGuiY(double y)
{
return -y * factor.y + getHeight() - offsetY;
}
/**
* Translates a real coordinate distance to a screen coordinate distance.
*/
-double RS_GraphicView::toGuiDX(double d)
+double GraphicView::toGuiDX(double d)
{
return d * factor.x;
}
/**
* Translates a real coordinate distance to a screen coordinate distance.
*/
-double RS_GraphicView::toGuiDY(double d)
+double GraphicView::toGuiDY(double d)
{
return d * factor.y;
}
/**
* Translates a vector in screen coordinates to a vector in real coordinates.
*/
-Vector RS_GraphicView::toGraph(Vector v)
+Vector GraphicView::toGraph(Vector v)
{
return Vector(toGraphX(RS_Math::round(v.x)), toGraphY(RS_Math::round(v.y)), 0.0);
}
/**
* Translates two screen coordinates to a vector in real coordinates.
*/
-Vector RS_GraphicView::toGraph(int x, int y)
+Vector GraphicView::toGraph(int x, int y)
{
return Vector(toGraphX(x), toGraphY(y), 0.0);
}
/**
* Translates a screen coordinate in X to a real coordinate X.
*/
-double RS_GraphicView::toGraphX(int x)
+double GraphicView::toGraphX(int x)
{
return (x - offsetX) / factor.x;
}
/**
* Translates a screen coordinate in Y to a real coordinate Y.
*/
-double RS_GraphicView::toGraphY(int y)
+double GraphicView::toGraphY(int y)
{
return -(y - getHeight() + offsetY) / factor.y;
}
/**
* Translates a screen coordinate distance to a real coordinate distance.
*/
-double RS_GraphicView::toGraphDX(int d)
+double GraphicView::toGraphDX(int d)
{
return d / factor.x;
}
/**
* Translates a screen coordinate distance to a real coordinate distance.
*/
-double RS_GraphicView::toGraphDY(int d)
+double GraphicView::toGraphDY(int d)
{
return d / factor.y;
}
*
* @param lock true: lock, false: unlock
*/
-void RS_GraphicView::lockRelativeZero(bool lock)
+void GraphicView::lockRelativeZero(bool lock)
{
- relativeZeroLocked=lock;
+ relativeZeroLocked = lock;
}
/**
* @return true if the position of the realtive zero point is
* locked.
*/
-bool RS_GraphicView::isRelativeZeroLocked()
+bool GraphicView::isRelativeZeroLocked()
{
return relativeZeroLocked;
}
/**
* @return Relative zero coordinate.
*/
-Vector RS_GraphicView::getRelativeZero()
+Vector GraphicView::getRelativeZero()
{
return relativeZero;
}
* Sets the relative zero coordinate (if not locked)
* without deleting / drawing the point.
*/
-void RS_GraphicView::setRelativeZero(const Vector & pos)
+void GraphicView::setRelativeZero(const Vector & pos)
{
if (!relativeZeroLocked)
relativeZero = pos;
* Sets the relative zero coordinate, deletes the old position
* on the screen and draws the new one.
*/
-void RS_GraphicView::moveRelativeZero(const Vector & pos)
+void GraphicView::moveRelativeZero(const Vector & pos)
{
-#warning "!!! RS_GraphicView::moveRelativeZero(): Bad render path !!!"
+#warning "!!! GraphicView::moveRelativeZero(): Bad render path !!!"
if (!painter)
return;
drawRelativeZero();
}
-RS_EventHandler * RS_GraphicView::getEventHandler()
+RS_EventHandler * GraphicView::getEventHandler()
{
return eventHandler;
}
/**
* Enables or disables print preview.
*/
-void RS_GraphicView::setPrintPreview(bool pv)
+void GraphicView::setPrintPreview(bool pv)
{
printPreview = pv;
}
* @retval true This is a print preview graphic view.
* @retval false Otherwise.
*/
-bool RS_GraphicView::isPrintPreview()
+bool GraphicView::isPrintPreview()
{
return printPreview;
}
/**
* Enables or disables printing.
*/
-void RS_GraphicView::setPrinting(bool p)
+void GraphicView::setPrinting(bool p)
{
printing = p;
}
* @retval true This is a a graphic view for printing.
* @retval false Otherwise.
*/
-bool RS_GraphicView::isPrinting()
+bool GraphicView::isPrinting()
{
return printing;
}
* @retval true Draft mode is on for this view (all lines with 1 pixel / no style scaling).
* @retval false Otherwise.
*/
-bool RS_GraphicView::isDraftMode()
+bool GraphicView::isDraftMode()
{
return draftMode;
}
/**
* Sets the simulation speed in percentage.
*/
-void RS_GraphicView::setSimulationSpeed(int s)
+void GraphicView::setSimulationSpeed(int s)
{
simulationSpeed = s;
}
/**
* @return the simulation speed in percentage.
*/
-int RS_GraphicView::getSimulationSpeed()
+int GraphicView::getSimulationSpeed()
{
return simulationSpeed;
}
/**
* Sets the simulation smooth mode.
*/
-void RS_GraphicView::setSimulationSmooth(bool s)
+void GraphicView::setSimulationSmooth(bool s)
{
simulationSmooth = s;
}
/**
* Sets the simulation rapid mode.
*/
-void RS_GraphicView::setSimulationRapid(bool r)
+void GraphicView::setSimulationRapid(bool r)
{
simulationRapid = r;
}
/**
* @return the simulation rapid mode.
*/
-bool RS_GraphicView::getSimulationRapid()
+bool GraphicView::getSimulationRapid()
{
return simulationRapid;
}
// These functions are here because of the focacta way that this
// program set up its rendering...
-void RS_GraphicView::SetPreviewMode(bool mode/*= true*/)
+void GraphicView::SetPreviewMode(bool mode/*= true*/)
{
previewMode = mode;
}
-void RS_GraphicView::SetPreviewEntity(RS_Preview * p)
+void GraphicView::SetPreviewEntity(RS_Preview * p)
{
previewEntity = p;
}
-void RS_GraphicView::SetPreviewOffset(Vector o)
+void GraphicView::SetPreviewOffset(Vector o)
{
previewOffset = o;
}
-void RS_GraphicView::SetSnapperDraw(bool mode)
+void GraphicView::SetSnapperDraw(bool mode)
{
snapperDraw = mode;
}
-void RS_GraphicView::SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs)
+void GraphicView::SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs)
{
snapSpot1 = snapSpot;
snapCoord1 = snapCoord;
-#ifndef RS_GRAPHICVIEW_H
-#define RS_GRAPHICVIEW_H
+#ifndef __GRAPHICVIEW_H__
+#define __GRAPHICVIEW_H__
-#include <stdarg.h>
-#include <QtCore>
+#include <QtGui>
#include "rs.h"
-#include "rs_blocklist.h"
#include "rs_color.h"
-#include "rs_linetypepattern.h"
-#include "rs_commandevent.h"
-#include "rs_entitycontainer.h"
+#include "vector.h"
+class Drawing;
+class PaintInterface;
+class RS_EntityContainer;
class RS_ActionInterface;
+class RS_Entity;
+class RS_LineTypePattern;
+class RS_CommandEvent;
+class Vector;
+class RS_Preview;
class RS_Grid;
+class RS_Pen;
class RS_EventHandler;
-class RS_Preview;
-class PaintInterface;
-/**
- * This class is a common GUI interface for the graphic viewer
- * widget which has to be implementet by real GUI classes such
- * as the Qt graphical view.
- *
- * Note that this is just an interface used as a slot to
- * communicate with the qcadlib from a GUI level.
- */
-class RS_GraphicView
+class GraphicView
{
public:
- RS_GraphicView();
- virtual ~RS_GraphicView();
+ GraphicView();
+ ~GraphicView();
void cleanUp();
/** This virtual method must be overwritten to redraw
the widget. */
virtual void redraw() = 0;
+
/** This virtual method must be overwritten and is then
called whenever the view changed */
virtual void adjustOffsetControls();
*/
virtual void setPainter(PaintInterface * p);
-// We're removing this crap...
-#if 0
- /** This virtual method must be overwritten and must return
- the painter device for the buffer of this widget */
-// virtual PaintInterface * createPainter() = 0;
- /**
- * This virtual method must be overwritten and must return
- * the direct painter device for this widget
- */
-// virtual PaintInterface * createDirectPainter() = 0;
- /**
- * This virtual method must be overwritten and must destroy
- * the painter device and point 'painter' to NULL. If the painter
- * is static during the whole life of the application, it might
- * just do nothing.
- */
-// virtual void destroyPainter() = 0;
-#endif
-
virtual void setBackground(const RS_Color & bg);
RS_Color getBackground();
RS_Color getForeground();
int mx; //!< Last known mouse cursor position
int my; //!< Last known mouse cursor position
- // RS_Painter * painter;
PaintInterface * painter;
/** background color (any color) */
RS_Color background;
private:
int updateEnabled;
bool zoomFrozen;
- //bool gridVisible;
bool draftMode;
Vector factor;
bool printPreview;
//! Active when printing only:
bool printing;
- //int drawRecursion;
//! Simulation speed in percentage
int simulationSpeed;
Vector snapSpot1;
Vector snapCoord1;
bool showCrosshairs1;
+
+//QG
+
+
+//QC
+};
+
+#endif // __GRAPHICVIEW_H__
+
+#if 0
+class QG_GraphicView: public QWidget, public RS_GraphicView, //public Q3FilePreview,
+ public RS_LayerListListener, public RS_BlockListListener
+{
+ Q_OBJECT
+
+ public:
+ QG_GraphicView(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0);
+ virtual ~QG_GraphicView();
+
+ virtual int getWidth();
+ virtual int getHeight();
+ virtual void redraw();
+ virtual void adjustOffsetControls();
+ virtual void adjustZoomControls();
+// virtual RS_Painter * createPainter();
+// virtual RS_Painter * createDirectPainter();
+#warning "!!! Need to scrub out all instances of createPainter and createDirectPainter !!!"
+// virtual PaintInterface * createPainter();
+// virtual PaintInterface * createDirectPainter();
+// virtual void destroyPainter();
+ virtual void setBackground(const RS_Color & bg);
+ virtual void setMouseCursor(RS2::CursorType c);
+ virtual void updateGridStatusWidget(const QString & text);
+
+ // Methods from RS_LayerListListener Interface:
+ virtual void layerEdited(RS_Layer *);
+ virtual void layerRemoved(RS_Layer *);
+ virtual void layerToggled(RS_Layer *);
+
+ protected:
+ virtual void emulateMouseMoveEvent();
+ virtual void mousePressEvent(QMouseEvent * e);
+ virtual void mouseReleaseEvent(QMouseEvent * e);
+ virtual void mouseMoveEvent(QMouseEvent * e);
+ virtual void tabletEvent(QTabletEvent * e);
+ virtual void leaveEvent(QEvent *);
+ virtual void enterEvent(QEvent *);
+ virtual void focusInEvent(QFocusEvent *);
+ virtual void focusOutEvent(QFocusEvent *);
+ virtual void wheelEvent(QWheelEvent * e);
+ virtual void keyPressEvent(QKeyEvent * e);
+ virtual void keyReleaseEvent(QKeyEvent * e);
+
+ void paintEvent(QPaintEvent *);
+ virtual void resizeEvent(QResizeEvent * e);
+
+#warning "!!! File preview needs porting to Qt4 !!!"
+// void previewUrl(const Q3Url &u);
+
+ private slots:
+ void slotHScrolled(int value);
+ void slotVScrolled(int value);
+
+ private:
+#warning "!!! Double buffering is not necessary anymore !!!"
+ //! Buffer for double-buffering
+ QPixmap * buffer;
+// int refCount;
+
+ protected:
+ int lastWidth;
+ int lastHeight;
+ //! Horizontal scrollbar.
+ QG_ScrollBar * hScrollBar;
+ //! Vertical scrollbar.
+ QG_ScrollBar * vScrollBar;
+ //! Layout used to fit in the view and the scrollbars.
+ QGridLayout * layout;
+ //! Label for grid spacing.
+ QLabel * gridStatus;
+ //! CAD mouse cursor
+ QCursor * curCad;
+ //! Delete mouse cursor
+ QCursor * curDel;
+ //! Select mouse cursor
+ QCursor * curSelect;
+ //! Magnifying glass mouse cursor
+ QCursor * curMagnifier;
+ //! Hand mouse cursor
+ QCursor * curHand;
};
+#endif
+
+#if 0
+class QC_GraphicView: public QG_GraphicView
+{
+ public:
+ QC_GraphicView(RS_Document * doc, QWidget * parent = 0);
+ virtual ~QC_GraphicView();
+
+ virtual void drawIt();
+ private:
+ //RS_Document* document;
+};
#endif
#include <QtGui>
#include "qc_graphicview.h"
#include "qg_layerwidget.h"
-#include "qg_recentfiles.h"
#include "qg_pentoolbar.h"
#include "rs_document.h"
if (!isUpdateEnabled())
return;
- RS_GraphicView::drawIt();
+ GraphicView::drawIt();
}
*/
class QC_GraphicView: public QG_GraphicView
{
-// Q_OBJECT
-
public:
QC_GraphicView(RS_Document * doc, QWidget * parent = 0);
virtual ~QC_GraphicView();
#include "qg_actionhandler.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_actionblocksadd.h"
#include "rs_actionblocksattributes.h"
#include "rs_actioninfodist2.h"
#include "rs_actioninfoinside.h"
#include "rs_actioninfototallength.h"
+#include "rs_actioninterface.h"
#include "rs_actionlayersadd.h"
#include "rs_actionlayersedit.h"
#include "rs_actionlayersfreezeall.h"
*/
void QG_ActionHandler::killSelectActions()
{
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
if (gv != NULL)
gv->killSelectActions();
*/
RS_ActionInterface * QG_ActionHandler::getCurrentAction()
{
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
if (gv)
return gv->getCurrentAction();
Instead of the following giant switch statement, you could something like the following:
RS_ActionInterface * QG_ActionHandler::setCurrentAction(RS_ActionInterface * action)
{
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
RS_Document * doc = mainWindow->getDocument();
// only global options are allowed without a document:
{
RS_DEBUG->print("QG_ActionHandler::setCurrentAction()");
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
RS_Document * doc = mainWindow->getDocument();
RS_ActionInterface * a = NULL;
// pass keycode on to running action:
//RS_keycodeEvent e(cmd);
- //RS_GraphicView* gv = mainWindow->getGraphicView();
+ //GraphicView* gv = mainWindow->getGraphicView();
//if (gv!=NULL) {
// gv->keycodeEvent(&e);
//}
if (c == "\n")
{
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
if (gv != NULL)
gv->back();
// pass command on to running action:
RS_CommandEvent e(cmd);
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
if (gv != NULL)
{
#define QG_ACTIONHANDLER_H
#include <QtGui>
-#include "rs_document.h"
-#include "qg_graphicview.h"
+#include "rs.h"
class QG_MainWindowInterface;
class CadToolBarSnap;
+class RS_ActionInterface;
/**
* This class can trigger actions (from menus, buttons, ...).
#include "qg_dialogfactory.h"
+#include "graphicview.h"
#include "qg_layerwidget.h"
#include "qg_mainwindowinterface.h"
#include "rs_actiondimlinear.h"
#include "rs_actioninterface.h"
+#include "rs_blocklist.h"
#include "rs_document.h"
#include "rs_hatch.h"
#include "rs_patternlist.h"
/**
* Requests a new document from the main window.
*/
-RS_GraphicView * QG_DialogFactory::requestNewDocument(const QString & fileName, RS_Document * doc)
+GraphicView * QG_DialogFactory::requestNewDocument(const QString & fileName, RS_Document * doc)
{
if (mainWindow != NULL)
{
class CommandWidget;
class CoordinateWidget;
class RS_Document;
+class GraphicView;
class QG_MainWindowInterface;
class MouseWidget;
class SelectionWidget;
virtual void setMainWindow(QG_MainWindowInterface * mw);
virtual void requestWarningDialog(const QString& warning);
- virtual RS_GraphicView * requestNewDocument(const QString& fileName = QString::null,
+ virtual GraphicView * requestNewDocument(const QString & fileName = QString::null,
RS_Document * doc = NULL);
virtual void requestSimulationControls();
#include "rs_actionmodifydelete.h"
#include "rs_actionselectsingle.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_preview.h"
#include "drawing.h"
#include "settings.h"
* Constructor.
*/
QG_GraphicView::QG_GraphicView(QWidget * parent, const char */*name*/, Qt::WindowFlags f):
- QWidget(parent, f), RS_GraphicView()//, refCount(0)
+ QWidget(parent, f), GraphicView()//, refCount(0)
{
setBackground(background);
buffer = NULL;
*/
void QG_GraphicView::setBackground(const RS_Color & bg)
{
- RS_GraphicView::setBackground(bg);
+ GraphicView::setBackground(bg);
// setBackgroundColor(bg);
QPalette palette;
if (e->button() == Qt::MidButton /*|| (e->state()==Qt::LeftButton|Qt::AltButton)*/)
setCurrentAction(new RS_ActionZoomPan(*container, *this));
- RS_GraphicView::mousePressEvent(e);
+ GraphicView::mousePressEvent(e);
QWidget::mousePressEvent(e);
}
void QG_GraphicView::mouseReleaseEvent(QMouseEvent * e)
{
RS_DEBUG->print("QG_GraphicView::mouseReleaseEvent");
- RS_GraphicView::mouseReleaseEvent(e);
+ GraphicView::mouseReleaseEvent(e);
//QWidget::mouseReleaseEvent(e);
if (!e->isAccepted())
//RS_DEBUG->print("QG_GraphicView::mouseMoveEvent begin");
//QMouseEvent rsm = QG_Qt2Rs::mouseEvent(e);
- RS_GraphicView::mouseMoveEvent(e);
+ GraphicView::mouseMoveEvent(e);
QWidget::mouseMoveEvent(e);
//What kind of cacamamie crap is this???
void QG_GraphicView::leaveEvent(QEvent * e)
{
- RS_GraphicView::mouseLeaveEvent();
+ GraphicView::mouseLeaveEvent();
QWidget::leaveEvent(e);
}
void QG_GraphicView::enterEvent(QEvent * e)
{
- RS_GraphicView::mouseEnterEvent();
+ GraphicView::mouseEnterEvent();
QWidget::enterEvent(e);
}
void QG_GraphicView::focusInEvent(QFocusEvent * e)
{
//printf("-->QG_GraphicView::focusInEvent(): Start. this %s focus...\n", (hasFocus() ? "has" : "DOES NOT HAVE"));
- RS_GraphicView::mouseEnterEvent();
+ GraphicView::mouseEnterEvent();
QWidget::focusInEvent(e);
//printf("-->QG_GraphicView::focusInEvent(): End. this %s focus...\n", (hasFocus() ? "has" : "DOES NOT HAVE"));
}
if (scroll)
setCurrentAction(new RS_ActionZoomScroll(direction, *container, *this));
- RS_GraphicView::keyPressEvent(e);
+ GraphicView::keyPressEvent(e);
}
void QG_GraphicView::keyReleaseEvent(QKeyEvent * e)
{
- RS_GraphicView::keyReleaseEvent(e);
+ GraphicView::keyReleaseEvent(e);
}
/**
#define QG_GRAPHICVIEW_H
#include <QtGui>
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_layerlistlistener.h"
#include "rs_blocklistlistener.h"
#include "qg_scrollbar.h"
* Instances of this class can be linked to layer lists using
* addLayerListListener().
*/
-class QG_GraphicView: public QWidget, public RS_GraphicView, //public Q3FilePreview,
+//class QG_GraphicView: public QWidget, public RS_GraphicView, //public Q3FilePreview,
+class QG_GraphicView: public QWidget, public GraphicView, //public Q3FilePreview,
public RS_LayerListListener, public RS_BlockListListener
{
Q_OBJECT
virtual void redraw();
virtual void adjustOffsetControls();
virtual void adjustZoomControls();
-// virtual RS_Painter * createPainter();
-// virtual RS_Painter * createDirectPainter();
-#warning "!!! Need to scrub out all instances of createPainter and createDirectPainter !!!"
-// virtual PaintInterface * createPainter();
-// virtual PaintInterface * createDirectPainter();
-// virtual void destroyPainter();
virtual void setBackground(const RS_Color & bg);
virtual void setMouseCursor(RS2::CursorType c);
virtual void updateGridStatusWidget(const QString & text);
#ifndef QG_MAINWINDOWINTERFACE_H
#define QG_MAINWINDOWINTERFACE_H
-#include "rs_document.h"
+//#include "rs_document.h"
#include "rs_mainwindowinterface.h"
-#include "qg_graphicview.h"
-#include "qg_actionhandler.h"
+//#include "qg_graphicview.h"
+//#include "qg_actionhandler.h"
class QMainWindow;
+class QG_ActionHandler;
/**
* Interface for main application windows.
+++ /dev/null
-/****************************************************************************
-** $Id: qg_qt2rs.h 1346 2003-06-11 06:58:22Z 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 QG_QT2RS_H
-#define QG_QT2RS_H
-
-//#include <qnamespace.h>
-//#include "rs_mouseevent.h"
-#warning "!!! QG_Qt2Rs is an empty class !!!"
-
-/**
- * Translates Qt stuff into qcadlib stuff.
- */
-class QG_Qt2Rs {
-
-public:
- QG_Qt2Rs() {}
- ~QG_Qt2Rs() {}
-
- /*static RS_MouseEvent mouseEvent(QMouseEvent* e) {
- RS_MouseButton button;
- switch (e->button()) {
- case Qt::LeftButton:
- button = LEFT;
- break;
- case Qt::RightButton:
- button = RIGHT;
- break;
- case Qt::MidButton:
- button = MIDDLE;
- break;
- default:
- button = NONE;
- break;
- }
-
- return RS_MouseEvent(e->pos().x(),
- e->pos().y(),
- button );
-}*/
-}
-;
-
-#endif
-
-// qg_recentfiles.cpp
+// recentfiles.cpp
//
// Part of the Architektonas Project
// Originally part of QCad Community Edition by Andrew Mustun
// JLH 05/11/2010 Added this text. :-)
//
-#include "qg_recentfiles.h"
+#include "recentfiles.h"
-#include "qc_applicationwindow.h"
+#include "applicationwindow.h"
#include "rs_debug.h"
/**
* Constructor
* @param number Number of files that can be stored in the list at maximum
*/
-QG_RecentFiles::QG_RecentFiles(QWidget * parent, QMenu * menu, int num/*= 9*/):
+RecentFiles::RecentFiles(QWidget * parent, QMenu * menu, int num/*= 9*/):
QObject(), number(num)
{
// We make a separator that we can control the visibility of...
/**
* Destructor
*/
-QG_RecentFiles::~QG_RecentFiles()
+RecentFiles::~RecentFiles()
{
while (!actionList.isEmpty())
delete actionList.takeFirst();
* Adds a file to the list of recently loaded files if
* it's not already in the list.
*/
-void QG_RecentFiles::add(const QString & filename)
+void RecentFiles::add(const QString & filename)
{
- RS_DEBUG->print("QG_RecentFiles::add");
+ RS_DEBUG->print("RecentFiles::add");
// Is the file already in the list? Bail out if so...
if (files.indexOf(filename) != -1)
if ((int)files.count() > number)
files.pop_front();
- RS_DEBUG->print("QG_RecentFiles::add: OK");
+ RS_DEBUG->print("RecentFiles::add: OK");
}
/**
* @return complete path and name of the file stored in the
* list at index i
*/
-QString QG_RecentFiles::get(int i)
+QString RecentFiles::get(int i)
{
if (i < (int)files.count())
return files[i];
}
/** @return number of files currently stored in the list */
-int QG_RecentFiles::count(void)
+int RecentFiles::count(void)
{
return files.count();
}
/** @return number of files that can be stored in the list at maximum */
-int QG_RecentFiles::Maximum(void)
+int RecentFiles::Maximum(void)
{
return number;
}
-void QG_RecentFiles::UpdateGUI(void)
+void RecentFiles::UpdateGUI(void)
{
int numRecentFiles = count();
-#ifndef QG_RECENTFILES_H
-#define QG_RECENTFILES_H
+#ifndef __RECENTFILES_H__
+#define __RECENTFILES_H__
#include <QtGui>
/**
* This class can store recent files in a list.
*/
-class QG_RecentFiles: public QObject
+class RecentFiles: public QObject
{
public:
- QG_RecentFiles(QWidget * parent, QMenu * menu, int num = 9);
- ~QG_RecentFiles();
+ RecentFiles(QWidget * parent, QMenu * menu, int num = 9);
+ ~RecentFiles();
void add(const QString & filename);
QString get(int i);
QAction * separator;
};
-#endif
+#endif // __RECENTFILES_H__