X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmainapp%2Fgraphicview.cpp;fp=src%2Fbase%2Frs_graphicview.cpp;h=69efb100c08b92ab542c0ebc79cdfd2067cd8977;hb=27d4a138d23453e93a833e9347444b828a971cb4;hp=a2dcb73fd5e9e17747eb6feb1a7cf6477778fb3a;hpb=3b479913b79032e514ce8c74ba915c6c91ab0f15;p=architektonas diff --git a/src/base/rs_graphicview.cpp b/src/mainapp/graphicview.cpp similarity index 80% rename from src/base/rs_graphicview.cpp rename to src/mainapp/graphicview.cpp index a2dcb73..69efb10 100644 --- a/src/base/rs_graphicview.cpp +++ b/src/mainapp/graphicview.cpp @@ -1,4 +1,4 @@ -// rs_graphicview.cpp +// graphicview.cpp // // Part of the Architektonas Project // Originally part of QCad Community Edition by Andrew Mustun @@ -9,31 +9,25 @@ // // 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 -#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; @@ -91,7 +85,7 @@ RS_GraphicView::RS_GraphicView(): background(), foreground(), previewMode(false) /** * Destructor. */ -RS_GraphicView::~RS_GraphicView() +GraphicView::~GraphicView() { //delete eventHandler; if (painter != NULL) @@ -103,7 +97,7 @@ RS_GraphicView::~RS_GraphicView() /** * Must be called by any derrived class in the destructor. */ -void RS_GraphicView::cleanUp() +void GraphicView::cleanUp() { delete eventHandler; } @@ -113,7 +107,7 @@ void RS_GraphicView::cleanUp() * 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; @@ -124,7 +118,7 @@ Drawing * RS_GraphicView::getGraphic() /** * Sets the drawing mode. */ -void RS_GraphicView::setDrawingMode(RS2::DrawingMode m) +void GraphicView::setDrawingMode(RS2::DrawingMode m) { drawingMode = m; } @@ -132,7 +126,7 @@ void RS_GraphicView::setDrawingMode(RS2::DrawingMode m) /** * @return Current drawing mode. */ -RS2::DrawingMode RS_GraphicView::getDrawingMode() +RS2::DrawingMode GraphicView::getDrawingMode() { return drawingMode; } @@ -140,7 +134,7 @@ RS2::DrawingMode RS_GraphicView::getDrawingMode() /** * Activates or deactivates the delete mode. */ -void RS_GraphicView::setDeleteMode(bool m) +void GraphicView::setDeleteMode(bool m) { deleteMode = m; } @@ -149,28 +143,28 @@ void RS_GraphicView::setDeleteMode(bool 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; } @@ -179,7 +173,7 @@ void RS_GraphicView::setPainter(PaintInterface * 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; @@ -195,7 +189,7 @@ void RS_GraphicView::setBackground(const RS_Color & bg) /** * @return Current background color. */ -RS_Color RS_GraphicView::getBackground() +RS_Color GraphicView::getBackground() { return background; } @@ -203,7 +197,7 @@ RS_Color RS_GraphicView::getBackground() /** * @return Current foreground color. */ -RS_Color RS_GraphicView::getForeground() +RS_Color GraphicView::getForeground() { return foreground; } @@ -211,7 +205,7 @@ RS_Color RS_GraphicView::getForeground() /** * Sets the grid color. */ -void RS_GraphicView::setGridColor(const RS_Color & c) +void GraphicView::setGridColor(const RS_Color & c) { gridColor = c; } @@ -219,7 +213,7 @@ void RS_GraphicView::setGridColor(const RS_Color & c) /** * Sets the meta grid color. */ -void RS_GraphicView::setMetaGridColor(const RS_Color & c) +void GraphicView::setMetaGridColor(const RS_Color & c) { metaGridColor = c; } @@ -227,7 +221,7 @@ void RS_GraphicView::setMetaGridColor(const RS_Color & c) /** * Sets the selection color. */ -void RS_GraphicView::setSelectedColor(const RS_Color & c) +void GraphicView::setSelectedColor(const RS_Color & c) { selectedColor = c; } @@ -235,7 +229,7 @@ void RS_GraphicView::setSelectedColor(const RS_Color & c) /** * Sets the highlight color. */ -void RS_GraphicView::setHighlightedColor(const RS_Color & c) +void GraphicView::setHighlightedColor(const RS_Color & c) { highlightedColor = c; } @@ -244,22 +238,22 @@ void RS_GraphicView::setHighlightedColor(const RS_Color & 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; } @@ -267,28 +261,28 @@ Vector RS_GraphicView::getFactor() /** * 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; } @@ -298,7 +292,7 @@ int RS_GraphicView::getOffsetY() * 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; @@ -306,47 +300,47 @@ void RS_GraphicView::setBorders(int left, int top, int right, int bottom) 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; } @@ -355,7 +349,7 @@ bool RS_GraphicView::isZoomFrozen() * 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(); @@ -364,7 +358,7 @@ void RS_GraphicView::setContainer(RS_EntityContainer * container) /** * 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); @@ -373,7 +367,7 @@ void RS_GraphicView::setFactorX(double 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); @@ -382,7 +376,7 @@ void RS_GraphicView::setFactorY(double f) /** * @return true if the grid is switched on. */ -bool RS_GraphicView::isGridOn() +bool GraphicView::isGridOn() { if (container != NULL) { @@ -398,7 +392,7 @@ bool RS_GraphicView::isGridOn() /** * Centers the drawing in x-direction. */ -void RS_GraphicView::centerOffsetX() +void GraphicView::centerOffsetX() { if (container != NULL && !zoomFrozen) offsetX = (int)(((getWidth() - borderLeft - borderRight) @@ -409,7 +403,7 @@ void RS_GraphicView::centerOffsetX() /** * Centers the drawing in y-direction. */ -void RS_GraphicView::centerOffsetY() +void GraphicView::centerOffsetY() { if (container != NULL && !zoomFrozen) offsetY = (int)((getHeight() - borderTop - borderBottom @@ -420,7 +414,7 @@ void RS_GraphicView::centerOffsetY() /** * 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); @@ -429,13 +423,13 @@ void RS_GraphicView::centerX(double v) /** * 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++; @@ -455,7 +449,7 @@ void RS_GraphicView::updateView() /** * @return Current action or NULL. */ -RS_ActionInterface * RS_GraphicView::getDefaultAction() +RS_ActionInterface * GraphicView::getDefaultAction() { if (eventHandler != NULL) return eventHandler->getDefaultAction(); @@ -466,7 +460,7 @@ RS_ActionInterface * RS_GraphicView::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); @@ -475,7 +469,7 @@ void RS_GraphicView::setDefaultAction(RS_ActionInterface * action) /** * @return Current action or NULL. */ -RS_ActionInterface * RS_GraphicView::getCurrentAction() +RS_ActionInterface * GraphicView::getCurrentAction() { if (eventHandler != NULL) return eventHandler->getCurrentAction(); @@ -486,21 +480,21 @@ RS_ActionInterface * RS_GraphicView::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(); @@ -509,7 +503,7 @@ void RS_GraphicView::killSelectActions() /** * Kills all running actions. */ -void RS_GraphicView::killAllActions() +void GraphicView::killAllActions() { if (eventHandler) eventHandler->killAllActions(); @@ -518,7 +512,7 @@ void RS_GraphicView::killAllActions() /** * Go back in menu or current action. */ -void RS_GraphicView::back() +void GraphicView::back() { if (eventHandler && eventHandler->hasAction()) eventHandler->back(); @@ -529,29 +523,29 @@ void RS_GraphicView::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; @@ -567,23 +561,23 @@ void RS_GraphicView::mouseReleaseEvent(QMouseEvent * e) 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) { @@ -591,12 +585,12 @@ void RS_GraphicView::mouseMoveEvent(QMouseEvent * 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) { @@ -607,44 +601,44 @@ void RS_GraphicView::mouseMoveEvent(QMouseEvent * e) 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); @@ -653,7 +647,7 @@ void RS_GraphicView::keyReleaseEvent(QKeyEvent * 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); @@ -662,7 +656,7 @@ void RS_GraphicView::commandEvent(RS_CommandEvent * e) /** * Enables coordinate input in the command line. */ -void RS_GraphicView::enableCoordinateInput() +void GraphicView::enableCoordinateInput() { if (eventHandler) eventHandler->enableCoordinateInput(); @@ -671,7 +665,7 @@ void RS_GraphicView::enableCoordinateInput() /** * Disables coordinate input in the command line. */ -void RS_GraphicView::disableCoordinateInput() +void GraphicView::disableCoordinateInput() { if (eventHandler) eventHandler->disableCoordinateInput(); @@ -680,11 +674,11 @@ void RS_GraphicView::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; } @@ -708,7 +702,7 @@ void RS_GraphicView::zoomIn(double f, const Vector & center) /** * zooms in by factor f in x */ -void RS_GraphicView::zoomInX(double f) +void GraphicView::zoomInX(double f) { if (simulationRunning) return; @@ -724,7 +718,7 @@ void RS_GraphicView::zoomInX(double f) /** * zooms in by factor f in y */ -void RS_GraphicView::zoomInY(double f) +void GraphicView::zoomInY(double f) { if (simulationRunning) return; @@ -740,12 +734,12 @@ void RS_GraphicView::zoomInY(double f) /** * 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; } @@ -758,12 +752,12 @@ void RS_GraphicView::zoomOut(double f, const Vector & center) /** * 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; } @@ -779,14 +773,13 @@ void RS_GraphicView::zoomOutX(double f) } /** - * 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; } @@ -808,9 +801,9 @@ void RS_GraphicView::zoomOutY(double f) * @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; @@ -873,20 +866,20 @@ void RS_GraphicView::zoomAuto(bool axis, bool keepAspectRatio) 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(); } @@ -894,7 +887,7 @@ void RS_GraphicView::zoomPrevious() * 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; @@ -905,7 +898,7 @@ void RS_GraphicView::saveView() * Restores the view previously saved with * @see saveView(). */ -void RS_GraphicView::restoreView() +void GraphicView::restoreView() { int pox = previousOffsetX; int poy = previousOffsetY; @@ -928,7 +921,7 @@ void RS_GraphicView::restoreView() * * @param axis include axis in zoom */ -void RS_GraphicView::zoomAutoY(bool axis) +void GraphicView::zoomAutoY(bool axis) { if (simulationRunning) return; @@ -1000,7 +993,7 @@ void RS_GraphicView::zoomAutoY(bool axis) * 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; @@ -1082,7 +1075,7 @@ void RS_GraphicView::zoomWindow(Vector v1, Vector v2, bool keepAspectRatio) /** * 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); @@ -1103,7 +1096,7 @@ void RS_GraphicView::zoomPan(int dx, int dy) /** * Scrolls in the given direction. */ -void RS_GraphicView::zoomScroll(RS2::Direction direction) +void GraphicView::zoomScroll(RS2::Direction direction) { if (simulationRunning) return; @@ -1133,9 +1126,9 @@ void RS_GraphicView::zoomScroll(RS2::Direction direction) /** * 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; @@ -1188,9 +1181,9 @@ void RS_GraphicView::zoomPage() /** * 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; @@ -1205,24 +1198,24 @@ void RS_GraphicView::drawWindow(Vector v1, Vector v2) } } - 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; //} @@ -1232,7 +1225,7 @@ void RS_GraphicView::drawIt() if (!painter) // { -//printf("RS_GraphicView::drawIt(): painter == NULL!\n"); +//printf("GraphicView::drawIt(): painter == NULL!\n"); return; // } @@ -1266,13 +1259,13 @@ void RS_GraphicView::drawIt() * 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); @@ -1345,16 +1338,16 @@ void RS_GraphicView::setPenForEntity(RS_Entity * e) * 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: @@ -1363,11 +1356,11 @@ void RS_GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db) // 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; //} @@ -1442,15 +1435,16 @@ void RS_GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db) } //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); @@ -1460,22 +1454,24 @@ void RS_GraphicView::deleteEntity(RS_Entity * e) * 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; @@ -1522,7 +1518,7 @@ void RS_GraphicView::simulateIt() //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(); //} @@ -1534,7 +1530,7 @@ void RS_GraphicView::simulateIt() * * @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; @@ -1628,7 +1624,7 @@ void RS_GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen) * * @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"); @@ -1672,7 +1668,7 @@ void RS_GraphicView::simulationDelay(bool step) /** * 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; @@ -1748,7 +1744,7 @@ void RS_GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const || (!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); @@ -1873,7 +1869,7 @@ void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double * @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) { @@ -1965,7 +1961,7 @@ RS_LineTypePattern * RS_GraphicView::getPattern(RS2::LineType t) * * @see drawIt() */ -void RS_GraphicView::drawAbsoluteZero() +void GraphicView::drawAbsoluteZero() { if (!painter) return; @@ -1994,7 +1990,7 @@ void RS_GraphicView::drawAbsoluteZero() * * @see drawIt() */ -void RS_GraphicView::drawRelativeZero() +void GraphicView::drawRelativeZero() { if (!relativeZero.valid || !painter) return; @@ -2023,20 +2019,20 @@ void RS_GraphicView::drawRelativeZero() * * @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: @@ -2054,18 +2050,15 @@ void RS_GraphicView::drawPaper() // 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)); } /** @@ -2073,37 +2066,30 @@ void RS_GraphicView::drawPaper() * * @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; icount(); ++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); } @@ -2112,12 +2098,12 @@ void RS_GraphicView::drawGrid() * * @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); @@ -2143,27 +2129,27 @@ void RS_GraphicView::drawMetaGrid() /** * 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; } @@ -2171,7 +2157,7 @@ RS2::SnapRestriction RS_GraphicView::getSnapRestriction() /** * 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; @@ -2182,7 +2168,7 @@ void RS_GraphicView::setDefaultSnapMode(RS2::SnapMode sm) /** * Sets a snap restriction (e.g. orthogonal). */ -void RS_GraphicView::setSnapRestriction(RS2::SnapRestriction sr) +void GraphicView::setSnapRestriction(RS2::SnapRestriction sr) { defaultSnapRes = sr; @@ -2193,7 +2179,7 @@ void RS_GraphicView::setSnapRestriction(RS2::SnapRestriction 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); } @@ -2203,7 +2189,7 @@ Vector RS_GraphicView::toGui(Vector v) * @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) { @@ -2221,7 +2207,7 @@ double RS_GraphicView::toGuiX(double x, bool * visible) /** * 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; } @@ -2229,7 +2215,7 @@ double RS_GraphicView::toGuiY(double y) /** * 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; } @@ -2237,7 +2223,7 @@ double RS_GraphicView::toGuiDX(double d) /** * 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; } @@ -2245,7 +2231,7 @@ double RS_GraphicView::toGuiDY(double d) /** * 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); } @@ -2253,7 +2239,7 @@ Vector RS_GraphicView::toGraph(Vector v) /** * 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); } @@ -2261,7 +2247,7 @@ Vector RS_GraphicView::toGraph(int x, int y) /** * 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; } @@ -2269,7 +2255,7 @@ double RS_GraphicView::toGraphX(int 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; } @@ -2277,7 +2263,7 @@ double RS_GraphicView::toGraphY(int 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; } @@ -2285,7 +2271,7 @@ double RS_GraphicView::toGraphDX(int d) /** * 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; } @@ -2295,16 +2281,16 @@ double RS_GraphicView::toGraphDY(int d) * * @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; } @@ -2312,7 +2298,7 @@ bool RS_GraphicView::isRelativeZeroLocked() /** * @return Relative zero coordinate. */ -Vector RS_GraphicView::getRelativeZero() +Vector GraphicView::getRelativeZero() { return relativeZero; } @@ -2321,7 +2307,7 @@ Vector RS_GraphicView::getRelativeZero() * 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; @@ -2331,9 +2317,9 @@ void RS_GraphicView::setRelativeZero(const Vector & 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; @@ -2343,7 +2329,7 @@ void RS_GraphicView::moveRelativeZero(const Vector & pos) drawRelativeZero(); } -RS_EventHandler * RS_GraphicView::getEventHandler() +RS_EventHandler * GraphicView::getEventHandler() { return eventHandler; } @@ -2351,7 +2337,7 @@ RS_EventHandler * RS_GraphicView::getEventHandler() /** * Enables or disables print preview. */ -void RS_GraphicView::setPrintPreview(bool pv) +void GraphicView::setPrintPreview(bool pv) { printPreview = pv; } @@ -2360,7 +2346,7 @@ void RS_GraphicView::setPrintPreview(bool pv) * @retval true This is a print preview graphic view. * @retval false Otherwise. */ -bool RS_GraphicView::isPrintPreview() +bool GraphicView::isPrintPreview() { return printPreview; } @@ -2368,7 +2354,7 @@ bool RS_GraphicView::isPrintPreview() /** * Enables or disables printing. */ -void RS_GraphicView::setPrinting(bool p) +void GraphicView::setPrinting(bool p) { printing = p; } @@ -2377,7 +2363,7 @@ void RS_GraphicView::setPrinting(bool p) * @retval true This is a a graphic view for printing. * @retval false Otherwise. */ -bool RS_GraphicView::isPrinting() +bool GraphicView::isPrinting() { return printing; } @@ -2386,7 +2372,7 @@ bool RS_GraphicView::isPrinting() * @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; } @@ -2394,7 +2380,7 @@ bool RS_GraphicView::isDraftMode() /** * Sets the simulation speed in percentage. */ -void RS_GraphicView::setSimulationSpeed(int s) +void GraphicView::setSimulationSpeed(int s) { simulationSpeed = s; } @@ -2402,7 +2388,7 @@ void RS_GraphicView::setSimulationSpeed(int s) /** * @return the simulation speed in percentage. */ -int RS_GraphicView::getSimulationSpeed() +int GraphicView::getSimulationSpeed() { return simulationSpeed; } @@ -2410,14 +2396,14 @@ int RS_GraphicView::getSimulationSpeed() /** * 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; } @@ -2425,34 +2411,34 @@ void RS_GraphicView::setSimulationRapid(bool 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;