-// 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;