3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/16/2010 Created this file. :-)
15 #include "graphicview.h"
17 #include "rs_dialogfactory.h"
19 #include "rs_eventhandler.h"
21 #include "rs_linetypepattern.h"
22 #include "paintintf.h"
30 GraphicView::GraphicView(): background(), foreground(), previewMode(false),
31 previewOffset(Vector(0, 0)), snapperDraw(false)
33 drawingMode = RS2::ModeFull;
36 factor = Vector(1.0, 1.0);
39 previousFactor = Vector(1.0, 1.0);
43 eventHandler = new RS_EventHandler(this);
45 metaGridColor = RS_Color(64, 64, 64);
46 grid = new RS_Grid(this);
59 relativeZero = Vector(false);
60 relativeZeroLocked = false;
64 defaultSnapMode = RS2::SnapFree;
65 defaultSnapRes = RS2::RestrictNothing;
67 settings.beginGroup("Appearance");
68 setBackground(QColor(settings.value("BackgroundColor", "#000000").toString()));
69 setGridColor(QColor(settings.value("GridColor", "#7F7F7F").toString()));
70 setMetaGridColor(QColor(settings.value("MetaGridColor", "#3F3F3F").toString()));
71 setSelectedColor(QColor(settings.value("SelectedColor", "#A54747").toString()));
72 setHighlightedColor(QColor(settings.value("HighlightedColor", "#739373").toString()));
77 simulationSpeed = 100;
78 simulationSmooth = false;
79 simulationRapid = false;
80 simulationRunning = false;
82 //currentInsert = NULL;
88 GraphicView::~GraphicView()
90 //delete eventHandler;
98 * Must be called by any derrived class in the destructor.
100 void GraphicView::cleanUp()
106 * @return Pointer to the graphic entity if the entity container
107 * connected to this view is a graphic and valid.
110 Drawing * GraphicView::getGraphic()
112 if (container != NULL && container->rtti() == RS2::EntityGraphic)
113 return (Drawing*)container;
119 * Sets the drawing mode.
121 void GraphicView::setDrawingMode(RS2::DrawingMode m)
127 * @return Current drawing mode.
129 RS2::DrawingMode GraphicView::getDrawingMode()
135 * Activates or deactivates the delete mode.
137 void GraphicView::setDeleteMode(bool m)
143 * @reval true Deleting instead of drawing.
144 * false Normal drawing mode.
146 bool GraphicView::getDeleteMode()
151 /** This virtual method must be overwritten and is then
152 called whenever the view changed */
153 void GraphicView::adjustOffsetControls()
157 /** This virtual method must be overwritten and is then
158 called whenever the view changed */
159 void GraphicView::adjustZoomControls()
164 * Sets an external painter device.
166 //void GraphicView::setPainter(RS_Painter * p)
167 void GraphicView::setPainter(PaintInterface * p)
173 * Sets the background color. Note that applying the background
174 * color for the widget is up to the implementing class.
176 void GraphicView::setBackground(const RS_Color & bg)
180 // bright background:
181 if (bg.red() + bg.green() + bg.blue() > 380)
182 // foreground = Qt::black;
183 foreground = RS_Color(0, 0, 0);
185 // foreground = Qt::white;
186 foreground = RS_Color(255, 255, 255);
190 * @return Current background color.
192 RS_Color GraphicView::getBackground()
198 * @return Current foreground color.
200 RS_Color GraphicView::getForeground()
206 * Sets the grid color.
208 void GraphicView::setGridColor(const RS_Color & c)
214 * Sets the meta grid color.
216 void GraphicView::setMetaGridColor(const RS_Color & c)
222 * Sets the selection color.
224 void GraphicView::setSelectedColor(const RS_Color & c)
230 * Sets the highlight color.
232 void GraphicView::setHighlightedColor(const RS_Color & c)
234 highlightedColor = c;
238 * This virtual method can be overwritten to set the mouse
239 * cursor to the given type.
241 void GraphicView::setMouseCursor(RS2::CursorType /*c*/)
245 RS_EntityContainer * GraphicView::getContainer()
250 void GraphicView::setFactor(double f)
256 Vector GraphicView::getFactor()
262 * Sets the offset of the graphic.
264 void GraphicView::setOffset(int ox, int oy)
270 void GraphicView::setOffsetX(int ox)
275 void GraphicView::setOffsetY(int oy)
280 int GraphicView::getOffsetX()
285 int GraphicView::getOffsetY()
291 * Sets a fixed border in pixel around the graphic. This border
292 * specifies how far the user can scroll outside the graphic
295 void GraphicView::setBorders(int left, int top, int right, int bottom)
300 borderBottom = bottom;
303 int GraphicView::getBorderLeft()
308 int GraphicView::getBorderTop()
313 int GraphicView::getBorderRight()
318 int GraphicView::getBorderBottom()
323 void GraphicView::disableUpdate()
328 void GraphicView::enableUpdate()
333 bool GraphicView::isUpdateEnabled()
335 return (updateEnabled == 0);
338 void GraphicView::freezeZoom(bool freeze)
343 bool GraphicView::isZoomFrozen()
349 * Sets the pointer to the graphic which contains the entities
350 * which are visualized by this widget.
352 void GraphicView::setContainer(RS_EntityContainer * container)
354 this->container = container;
355 //adjustOffsetControls();
359 * Sets the zoom factor in X for this visualization of the graphic.
361 void GraphicView::setFactorX(double f)
368 * Sets the zoom factor in Y for this visualization of the graphic.
370 void GraphicView::setFactorY(double f)
377 * @return true if the grid is switched on.
379 bool GraphicView::isGridOn()
381 if (container != NULL)
383 Drawing * g = container->getGraphic();
386 return g->isGridOn();
393 * Centers the drawing in x-direction.
395 void GraphicView::centerOffsetX()
397 if (container != NULL && !zoomFrozen)
398 offsetX = (int)(((getWidth() - borderLeft - borderRight)
399 - (container->getSize().x * factor.x)) / 2.0
400 - (container->getMin().x * factor.x)) + borderLeft;
404 * Centers the drawing in y-direction.
406 void GraphicView::centerOffsetY()
408 if (container != NULL && !zoomFrozen)
409 offsetY = (int)((getHeight() - borderTop - borderBottom
410 - (container->getSize().y * factor.y)) / 2.0
411 - (container->getMin().y * factor.y)) + borderBottom;
415 * Centers the given coordinate in the view in x-direction.
417 void GraphicView::centerX(double v)
420 offsetX = (int)((v * factor.x) - (double)(getWidth() - borderLeft - borderRight) / 2.0);
424 * Centers the given coordinate in the view in y-direction.
426 void GraphicView::centerY(double v)
429 offsetY = (int)((v * factor.y) - (double)(getHeight() - borderTop - borderBottom) / 2.0);
432 void GraphicView::updateView()
434 static int running = 0;
439 adjustZoomControls();
440 adjustOffsetControls();
450 * @return Current action or NULL.
452 RS_ActionInterface * GraphicView::getDefaultAction()
454 if (eventHandler != NULL)
455 return eventHandler->getDefaultAction();
461 * Sets the default action of the event handler.
463 void GraphicView::setDefaultAction(RS_ActionInterface * action)
465 if (eventHandler != NULL)
466 eventHandler->setDefaultAction(action);
470 * @return Current action or NULL.
472 RS_ActionInterface * GraphicView::getCurrentAction()
474 if (eventHandler != NULL)
475 return eventHandler->getCurrentAction();
481 * Sets the current action of the event handler.
483 void GraphicView::setCurrentAction(RS_ActionInterface * action)
485 RS_DEBUG->print("GraphicView::setCurrentAction");
487 if (eventHandler != NULL)
488 eventHandler->setCurrentAction(action);
490 RS_DEBUG->print("GraphicView::setCurrentAction: OK");
494 * Kills all running selection actions. Called when a selection action
495 * is launched to reduce confusion.
497 void GraphicView::killSelectActions()
500 eventHandler->killSelectActions();
504 * Kills all running actions.
506 void GraphicView::killAllActions()
509 eventHandler->killAllActions();
513 * Go back in menu or current action.
515 void GraphicView::back()
517 if (eventHandler && eventHandler->hasAction())
518 eventHandler->back();
519 else if (RS_DIALOGFACTORY)
520 RS_DIALOGFACTORY->requestPreviousMenu();
524 * Go forward with the current action.
526 void GraphicView::enter()
528 if (eventHandler && eventHandler->hasAction())
529 eventHandler->enter();
533 * Called by the actual GUI class which implements the GraphicView
534 * interface to notify qcadlib about mouse events.
536 void GraphicView::mousePressEvent(QMouseEvent * e)
539 eventHandler->mousePressEvent(e);
543 * Called by the actual GUI class which implements the GraphicView
544 * interface to notify qcadlib about mouse events.
546 void GraphicView::mouseReleaseEvent(QMouseEvent * e)
548 RS_DEBUG->print("GraphicView::mouseReleaseEvent");
553 if (e->button() != Qt::RightButton || eventHandler->hasAction())
555 eventHandler->mouseReleaseEvent(e);
564 RS_DEBUG->print("GraphicView::mouseReleaseEvent: OK");
568 * Called by the actual GUI class which implements the GraphicView
569 * interface to notify qcadlib about mouse events.
571 void GraphicView::mouseMoveEvent(QMouseEvent * e)
573 RS_DEBUG->print("GraphicView::mouseMoveEvent begin");
575 Drawing * graphic = NULL;
577 if (container->rtti() == RS2::EntityGraphic)
578 graphic = (Drawing *)container;
580 RS_DEBUG->print("GraphicView::mouseMoveEvent 001");
588 RS_DEBUG->print("GraphicView::mouseMoveEvent 002");
591 eventHandler->mouseMoveEvent(e);
593 RS_DEBUG->print("GraphicView::mouseMoveEvent 003");
595 if (!eventHandler || !eventHandler->hasAction() && graphic)
597 Vector mouse = toGraph(Vector(mx, my));
598 Vector relMouse = mouse - getRelativeZero();
600 if (RS_DIALOGFACTORY)
601 RS_DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
604 RS_DEBUG->print("GraphicView::mouseMoveEvent end");
608 * Called by the actual GUI class which implements the GraphicView
609 * interface to notify qcadlib about mouse events.
611 void GraphicView::mouseLeaveEvent()
614 eventHandler->mouseLeaveEvent();
618 * Called by the actual GUI class which implements the GraphicView
619 * interface to notify qcadlib about mouse events.
621 void GraphicView::mouseEnterEvent()
624 eventHandler->mouseEnterEvent();
628 * Called by the actual GUI class which implements the GraphicView
629 * interface to notify qcadlib about key events.
631 void GraphicView::keyPressEvent(QKeyEvent * e)
634 eventHandler->keyPressEvent(e);
638 * Called by the actual GUI class which implements the GraphicView
639 * interface to notify qcadlib about key events.
641 void GraphicView::keyReleaseEvent(QKeyEvent * e)
644 eventHandler->keyReleaseEvent(e);
648 * Called by the actual GUI class which implements a command line.
650 void GraphicView::commandEvent(RS_CommandEvent * e)
653 eventHandler->commandEvent(e);
657 * Enables coordinate input in the command line.
659 void GraphicView::enableCoordinateInput()
662 eventHandler->enableCoordinateInput();
666 * Disables coordinate input in the command line.
668 void GraphicView::disableCoordinateInput()
671 eventHandler->disableCoordinateInput();
675 * zooms in by factor f
677 void GraphicView::zoomIn(double f, const Vector & center)
681 RS_DEBUG->print(RS_Debug::D_WARNING, "GraphicView::zoomIn: invalid factor");
685 if (simulationRunning)
689 if (c.valid == false)
690 c = toGraph(Vector(getWidth() / 2, getHeight() / 2));
693 toGraph(Vector(0, 0)).scale(c, Vector(1.0 / f, 1.0 / f)),
694 toGraph(Vector(getWidth(), getHeight())).scale(c, Vector(1.0 / f, 1.0 / f)));
696 //adjustOffsetControls();
697 //adjustZoomControls();
703 * zooms in by factor f in x
705 void GraphicView::zoomInX(double f)
707 if (simulationRunning)
711 offsetX = (int)((offsetX - getWidth() / 2) * f) + getWidth() / 2;
712 adjustOffsetControls();
713 adjustZoomControls();
719 * zooms in by factor f in y
721 void GraphicView::zoomInY(double f)
723 if (simulationRunning)
727 offsetY = (int)((offsetY - getHeight() / 2) * f)+getHeight() / 2;
728 adjustOffsetControls();
729 adjustZoomControls();
735 * zooms out by factor f
737 void GraphicView::zoomOut(double f, const Vector & center)
741 RS_DEBUG->print(RS_Debug::D_WARNING,
742 "GraphicView::zoomOut: invalid factor");
746 if (simulationRunning)
753 * zooms out by factor f in x
755 void GraphicView::zoomOutX(double f)
759 RS_DEBUG->print(RS_Debug::D_WARNING,
760 "GraphicView::zoomOutX: invalid factor");
764 if (simulationRunning)
768 offsetX = (int)(offsetX / f);
769 adjustOffsetControls();
770 adjustZoomControls();
776 * zooms out by factor of y
778 void GraphicView::zoomOutY(double f)
782 RS_DEBUG->print(RS_Debug::D_WARNING, "GraphicView::zoomOutY: invalid factor");
786 if (simulationRunning)
790 offsetY = (int)(offsetY / f);
791 adjustOffsetControls();
792 adjustZoomControls();
800 * @param axis include axis in zoom
801 * @param keepAspectRatio true: keep aspect ratio 1:1
802 * false: factors in x and y are stretched to the max
804 void GraphicView::zoomAuto(bool axis, bool keepAspectRatio)
806 RS_DEBUG->print("GraphicView::zoomAuto");
808 if (simulationRunning)
813 if (container != NULL)
815 container->calculateBorders();
820 sx = std::max(container->getMax().x, 0.0) - std::min(container->getMin().x, 0.0);
821 sy = std::max(container->getMax().y, 0.0) - std::min(container->getMin().y, 0.0);
825 sx = container->getSize().x;
826 sy = container->getSize().y;
831 if (sx > RS_TOLERANCE)
832 fx = (getWidth() - borderLeft - borderRight) / sx;
836 if (sy > RS_TOLERANCE)
837 fy = (getHeight() - borderTop - borderBottom) / sy;
841 RS_DEBUG->print("f: %f/%f", fx, fy);
844 fx = fy = std::min(fx, fy);
846 RS_DEBUG->print("f: %f/%f", fx, fy);
848 if (fx < RS_TOLERANCE)
854 RS_DEBUG->print("f: %f/%f", fx, fy);
856 RS_DEBUG->print("adjustOffsetControls");
857 adjustOffsetControls();
858 RS_DEBUG->print("adjustZoomControls");
859 adjustZoomControls();
860 RS_DEBUG->print("centerOffsetX");
862 RS_DEBUG->print("centerOffsetY");
864 RS_DEBUG->print("updateGrid");
869 RS_DEBUG->print("GraphicView::zoomAuto OK");
873 * Shows previous view.
875 void GraphicView::zoomPrevious()
877 RS_DEBUG->print("GraphicView::zoomPrevious");
879 if (simulationRunning)
887 * Saves the current view as previous view to which we can
888 * switch back later with @see restoreView().
890 void GraphicView::saveView()
892 previousOffsetX = offsetX;
893 previousOffsetY = offsetY;
894 previousFactor = factor;
898 * Restores the view previously saved with
901 void GraphicView::restoreView()
903 int pox = previousOffsetX;
904 int poy = previousOffsetY;
905 Vector pf = previousFactor;
913 adjustOffsetControls();
914 adjustZoomControls();
920 * performs autozoom in y only
922 * @param axis include axis in zoom
924 void GraphicView::zoomAutoY(bool axis)
926 if (simulationRunning)
929 if (container != NULL)
931 double visibleHeight = 0.0;
932 double minY = RS_MAXDOUBLE;
933 double maxY = RS_MINDOUBLE;
934 bool noChange = false;
936 for(RS_Entity * e=container->firstEntity(RS2::ResolveNone);
937 e!=NULL; e = container->nextEntity(RS2::ResolveNone))
939 if (e->rtti() == RS2::EntityLine)
941 RS_Line * l = (RS_Line *)e;
943 x1 = toGuiX(l->getStartpoint().x);
944 x2 = toGuiX(l->getEndpoint().x);
946 if (x1 > 0.0 && x1 < (double)getWidth() || x2 > 0.0 && x2 < (double)getWidth())
948 minY = std::min(minY, l->getStartpoint().y);
949 minY = std::min(minY, l->getEndpoint().y);
950 maxY = std::max(maxY, l->getStartpoint().y);
951 maxY = std::max(maxY, l->getEndpoint().y);
957 visibleHeight = std::max(maxY, 0.0) - std::min(minY, 0.0);
959 visibleHeight = maxY - minY;
961 if (visibleHeight < 1.0)
966 if (visibleHeight > 1.0e-6)
968 fy = (getHeight() - borderTop - borderBottom) / visibleHeight;
970 if (factor.y < 0.000001)
974 if (noChange == false)
978 offsetY = (int)((getHeight() - borderTop - borderBottom - (visibleHeight * factor.y)) / 2.0
979 - (minY * factor.y)) + borderBottom;
980 adjustOffsetControls();
981 adjustZoomControls();
985 RS_DEBUG->print("Auto zoom y ok");
990 * Zooms the area given by v1 and v2.
992 * @param keepAspectRatio true: keeps the aspect ratio 1:1
993 * false: zooms exactly the selected range to the
994 * current graphic view
996 void GraphicView::zoomWindow(Vector v1, Vector v2, bool keepAspectRatio)
998 if (simulationRunning)
1003 double zoomX = 480.0; // Zoom for X-Axis
1004 double zoomY = 640.0; // Zoom for Y-Axis (Set smaller one)
1005 double dum; // Dummy for switching values
1008 // Switch left/right and top/bottom is necessary:
1023 // Get zoom in X and zoom in Y:
1024 if (v2.x - v1.x > 1.0e-6)
1025 zoomX = getWidth() / (v2.x - v1.x);
1027 if (v2.y - v1.y > 1.0e-6)
1028 zoomY = getHeight() / (v2.y - v1.y);
1030 // Take smaller zoom:
1031 if (keepAspectRatio)
1035 if (getWidth() != 0)
1037 zoomX = zoomY = ((double)(getWidth() - 2 * zoomBorder)) /
1038 (double)getWidth() * zoomX;
1043 if (getHeight() != 0)
1045 zoomX = zoomY = ((double)(getHeight() - 2 * zoomBorder)) /
1046 (double)getHeight() * zoomY;
1057 // Borders in pixel after zoom
1058 int pixLeft = (int)(v1.x * zoomX);
1059 int pixTop = (int)(v2.y * zoomY);
1060 int pixRight = (int)(v2.x * zoomX);
1061 int pixBottom = (int)(v1.y * zoomY);
1063 // Set new offset for zero point:
1064 offsetX = - pixLeft + (getWidth() - pixRight + pixLeft) / 2;
1065 offsetY = - pixTop + (getHeight() - pixBottom + pixTop) / 2;
1069 adjustOffsetControls();
1070 adjustZoomControls();
1076 * Centers the point v1.
1078 void GraphicView::zoomPan(int dx, int dy)
1080 //offsetX+=(int)toGuiDX(v1.x);
1081 //offsetY+=(int)toGuiDY(v1.y);
1082 if (simulationRunning)
1089 adjustOffsetControls();
1090 //adjustZoomControls();
1097 * Scrolls in the given direction.
1099 void GraphicView::zoomScroll(RS2::Direction direction)
1101 if (simulationRunning)
1120 adjustOffsetControls();
1121 adjustZoomControls();
1127 * Zooms to page extends.
1129 void GraphicView::zoomPage()
1131 RS_DEBUG->print("GraphicView::zoomPage");
1133 if (container == NULL)
1136 if (simulationRunning)
1139 Drawing * graphic = container->getGraphic();
1141 if (graphic == NULL)
1144 Vector s = graphic->getPaperSize();
1145 Vector pinsbase = graphic->getPaperInsertionBase();
1149 if (s.x > RS_TOLERANCE)
1150 fx = (getWidth() - borderLeft - borderRight) / s.x;
1154 if (s.y > RS_TOLERANCE)
1155 fy = (getHeight() - borderTop - borderBottom) / s.y;
1159 RS_DEBUG->print("f: %f/%f", fx, fy);
1161 fx = fy = std::min(fx, fy);
1163 RS_DEBUG->print("f: %f/%f", fx, fy);
1165 if (fx < RS_TOLERANCE)
1171 RS_DEBUG->print("f: %f/%f", fx, fy);
1175 adjustOffsetControls();
1176 adjustZoomControls();
1182 * Draws the entities within the given range.
1184 void GraphicView::drawWindow(Vector v1, Vector v2)
1186 RS_DEBUG->print("GraphicView::drawWindow() begin");
1188 if (simulationRunning)
1193 for(RS_Entity * se=container->firstEntity(RS2::ResolveNone); se!=NULL;
1194 se=container->nextEntity(RS2::ResolveNone))
1196 if (se->isInWindow(v1, v2))
1201 RS_DEBUG->print("GraphicView::drawWindow() end");
1205 * Draws the entities. If painter is NULL a new painter will
1206 * be created and destroyed.
1208 void GraphicView::drawIt()
1210 if (!isUpdateEnabled())
1212 //printf("GraphicView::drawIt(): isUpdateEnabled() == false!\n");
1216 if (simulationRunning)
1218 //printf("GraphicView::drawIt(): simulationRunning == true!\n");
1222 settings.beginGroup("Appearance");
1223 draftMode = settings.value("DraftMode", false).toBool();
1224 settings.endGroup();
1228 //printf("GraphicView::drawIt(): painter == NULL!\n");
1234 // drawing paper border:
1235 if (isPrintPreview())
1237 // drawing meta grid:
1241 // drawing entities:
1242 //#warning "!!! This looks like a bug, no match for 'drawEntity(RS_Entity *, bool) !!!"
1243 // and indeed it *is* a bug... true is converted to 1.0 here. Dumb, dumb, dumb.
1244 drawEntity(container);//, true);
1246 // drawing zero points:
1247 if (!isPrintPreview())
1254 if (!isPrintPreview())
1259 * Sets the pen of the painter object to the suitable pen for the given
1262 void GraphicView::setPenForEntity(RS_Entity * e)
1264 if (drawingMode == RS2::ModePreview /*|| draftMode==true*/)
1267 // set color of entity
1268 if (painter && !painter->isPreviewMode())
1270 // Getting pen from entity (or layer)
1271 RS_Pen pen = e->getPen(true);
1273 int w = pen.getWidth();
1281 double uf = 1.0; // unit factor
1282 double wf = 1.0; // width factor
1283 Drawing * graphic = container->getGraphic();
1285 if (graphic != NULL)
1287 uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
1289 if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6)
1290 wf = 1.0 / graphic->getPaperScale();
1293 pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
1297 //pen.setWidth(RS2::Width00);
1298 pen.setScreenWidth(0);
1301 // prevent drawing with 1-width which is slow:
1302 if (RS_Math::round(pen.getScreenWidth()) == 1)
1303 pen.setScreenWidth(0.0);
1305 // prevent background color on background drawing:
1306 if (pen.getColor().stripFlags() == background.stripFlags())
1307 pen.setColor(foreground);
1309 // this entity is selected:
1310 if (e->isSelected())
1312 pen.setLineType(RS2::DotLine);
1313 //pen.setColor(RS_Color(0xa5,0x47,0x47));
1314 pen.setColor(selectedColor);
1317 // this entity is highlighted:
1318 if (e->isHighlighted())
1320 //pen.setColor(RS_Color(0x73, 0x93, 0x73));
1321 pen.setColor(highlightedColor);
1324 // deleting not drawing:
1325 if (getDeleteMode())
1326 pen.setColor(background);
1328 painter->setPen(pen);
1333 * Draws an entity. Might be recusively called e.g. for polylines.
1334 * If the class wide painter is NULL a new painter will be created
1335 * and destroyed afterwards.
1337 * @param patternOffset Offset of line pattern (used for connected
1338 * lines e.g. in splines).
1339 * @param db Double buffering on (recommended) / off
1341 void GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db)
1343 //RS_DEBUG->print("GraphicView::drawEntity() begin");
1345 // update is diabled:
1346 if (!isUpdateEnabled())
1349 // given entity is NULL:
1353 // entity is not visible:
1354 if (!e->isVisible())
1357 // test if the entity is in the viewport
1358 if (!e->isContainer() && !isPrinting()
1359 && (!painter || !painter->isPreviewMode())
1360 && (toGuiX(e->getMax().x) < 0 || toGuiX(e->getMin().x) > getWidth()
1361 || toGuiY(e->getMin().y) < 0 || toGuiY(e->getMax().y) > getHeight()))
1363 //printf("GraphicView::drawEntity(): Bailing out of big test!!!\n");
1368 //RS_DEBUG->print("recursion 1: %d", drawRecursion);
1373 //RS_DEBUG->print("draw plain");
1376 // large texts as rectangles:
1377 if (e->rtti() == RS2::EntityText)
1379 if (toGuiDX(((RS_Text *)e)->getHeight()) < 4 || e->countDeep() > 100)
1380 painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
1382 drawEntityPlain(e, patternOffset);
1384 // all images as rectangles:
1385 else if (e->rtti() == RS2::EntityImage)
1386 painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
1388 else if (e->rtti() == RS2::EntityHatch)
1393 drawEntityPlain(e, patternOffset);
1396 drawEntityPlain(e, patternOffset);
1398 // draw reference points:
1399 if (e->isSelected())
1401 if (!e->isParentSelected())
1403 VectorSolutions s = e->getRefPoints();
1405 for(int i=0; i<s.getNumber(); ++i)
1408 RS_Color col = RS_Color(0, 0, 255);
1410 if (e->rtti() == RS2::EntityPolyline)
1412 if (i == 0 || i == s.getNumber() - 1)
1417 // col = QColor(0, 64, 255);
1418 col = RS_Color(0, 64, 255);
1423 // col = QColor(0, 0, 128);
1424 col = RS_Color(0, 0, 128);
1429 if (getDeleteMode())
1430 painter->drawHandle(toGui(s.get(i)), background, sz);
1432 painter->drawHandle(toGui(s.get(i)), col, sz);
1437 //RS_DEBUG->print("draw plain OK");
1438 //RS_DEBUG->print("GraphicView::drawEntity() end");
1442 * Deletes an entity with the background color.
1443 * Might be recusively called e.g. for polylines.
1445 void GraphicView::deleteEntity(RS_Entity * e)
1447 #warning "!!! This is part of obsolete rendering !!!"
1448 setDeleteMode(true);
1450 setDeleteMode(false);
1455 * The painter must be initialized and all the attributes (pen) must be set.
1457 void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset)
1459 //Problems can still occur here when passing in a deleted object... It won't be
1460 //NULL, but it will cause a segfault here...
1463 //printf("GraphicView::drawEntityPlain(): Entity passed in is NULL!\n");
1467 //printf("GraphicView::drawEntityPlain(): Passing in painter=%08X, view=%08X\n", painter, this);
1468 e->draw(painter, this, patternOffset);
1472 * Simulates this drawing in slow motion.
1474 void GraphicView::simulateIt()
1476 if (simulationRunning)
1479 simulationRunning = true;
1480 simulationLast = Vector(0.0, 0.0);
1482 //jlh destroyPainter();
1486 // drawing paper border:
1487 if (isPrintPreview())
1490 // drawing meta grid:
1491 if (!isPrintPreview())
1495 if (!isPrintPreview())
1499 //painter->setPen(RS_Pen(foreground,
1500 // RS2::Width00, RS2::SolidLine));
1503 // drawing entities:
1504 RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1505 simulateEntity(container, pen);
1507 //RS_DEBUG->timestamp();
1508 //RS_DEBUG->print(" draw zero..");
1510 // drawing zero points:
1511 if (!isPrintPreview())
1517 //RS_DEBUG->timestamp();
1518 //RS_DEBUG->print(" draw grid..");
1520 //RS_DEBUG->timestamp();
1521 //RS_DEBUG->print("GraphicView::drawIt() end");
1522 //if (painterCreated==true) {
1523 //jlh destroyPainter();
1525 simulationRunning = false;
1529 * Simulates the given entity.
1531 * @param smooth If true, the entity will be drawn slowly (pixel by pixel).
1533 void GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
1535 if (painter == NULL || e == NULL)
1538 if (e->isContainer())
1540 RS_EntityContainer * ec = (RS_EntityContainer *)e;
1542 for(RS_Entity* en=ec->firstEntity(RS2::ResolveNone);
1543 en!=NULL; en = ec->nextEntity(RS2::ResolveNone))
1545 if (en->isVisible() && en->isUndone() == false)
1548 if (en->isAtomic() && simulationRapid)
1550 Vector sp = ((RS_AtomicEntity *)en)->getStartpoint();
1552 if (sp.distanceTo(simulationLast) > 1.0e-4)
1554 //jlh createDirectPainter();
1555 RS_Pen rpen(RS_Color(0, 0, 255), RS2::Width00, RS2::SolidLine);
1556 //painter->setPen(pen);
1557 RS_Line rapidLine(NULL, RS_LineData(simulationLast, sp));
1558 simulateEntity(&rapidLine, rpen);
1562 if (en->isHighlighted())
1564 RS_Pen hpen(highlightedColor, RS2::Width00, RS2::SolidLine);
1565 simulateEntity(en, hpen);
1568 simulateEntity(en, pen);
1571 simulationLast = ((RS_AtomicEntity *)en)->getEndpoint();
1573 if (!simulationSmooth)
1574 simulationDelay(true);
1580 if (simulationSmooth)
1584 case RS2::EntityLine:
1586 RS_Line * line = (RS_Line *)e;
1587 drawLineSmooth(toGui(line->getStartpoint()), toGui(line->getEndpoint()), pen);
1592 case RS2::EntityArc:
1594 RS_Arc * arc = (RS_Arc *)e;
1595 drawArcSmooth(toGui(arc->getCenter()), toGuiDX(arc->getRadius()),
1596 arc->getAngle1(), arc->getAngle2(), arc->isReversed(), pen);
1600 case RS2::EntityCircle:
1602 RS_Circle * circle = (RS_Circle *)e;
1603 drawArcSmooth(toGui(circle->getCenter()), toGuiDX(circle->getRadius()),
1604 0.0, 2.0 * M_PI, false, pen);
1614 //jlh createDirectPainter();
1615 //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1616 painter->setPen(pen);
1623 * Delay for slow motion simulation.
1625 * @param step true: stepping mode (entity by entity simulation). adds a delay.
1627 void GraphicView::simulationDelay(bool step)
1630 settings.beginGroup("CAM");
1631 double fact = settings.value("SimulationFactor", 12000.0).toDouble();
1632 settings.endGroup();
1634 // simulationSpeed: 0..100
1637 delay = (int)(((1.0 / (simulationSpeed + 1.0)) * fact) - (fact / 100.0));
1642 static int call = 0;
1644 if (call >= (fact - delay) / 1000)
1647 for(int i=0; i<delay; ++i)
1648 RS_APP->processEvents(10);
1653 delay = (int)(((1.0 / (simulationSpeed + 1.0)) * fact) - (fact / 100.0));
1660 for(int i=0; i<delay; ++i)
1662 #warning "Qt3->4 conversion: commented out problem line... !!! FIX !!!"
1663 // RS_APP->processEvents(10);
1669 * Draws a line slowly from (x1, y1) to (x2, y2). This is used for simulation only.
1671 void GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen)
1673 double alpha = p1.angleTo(p2);
1674 double xStep, yStep;
1677 if (RS_Math::cmpDouble(alpha, 0.0) || RS_Math::cmpDouble(alpha, 2 * M_PI))
1683 else if (RS_Math::cmpDouble(alpha, M_PI / 2.0))
1689 else if (RS_Math::cmpDouble(alpha, M_PI))
1695 else if (RS_Math::cmpDouble(alpha, M_PI / 2.0 * 3.0))
1701 else if (fabs(p2.x - p1.x) > fabs(p2.y - p1.y))
1708 yStep = tan(alpha) * xStep;
1718 xStep = yStep / tan(alpha);
1724 //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1728 if (lx >= 0.0 && lx <= (double)getWidth() && ly >= 0.0 && ly <= (double)getHeight())
1730 //if (painter==NULL) {
1731 //jlh createDirectPainter();
1733 painter->setPen(pen);
1734 painter->drawGridPoint(Vector(lx, ly));
1743 while ((xIsOne && ((lx >= p1.x && lx <= p2.x) || (lx >= p2.x && lx <= p1.x)))
1744 || (!xIsOne && ((ly >= p1.y && ly <= p2.y) || (ly >= p2.y && ly <= p1.y))));
1747 void GraphicView::drawArcSmooth(const Vector & center, double radius, double a1, double a2, bool rev,
1750 //int icx = graphic->realToScreenX(cx);
1751 //int icy = graphic->realToScreenY(cy);
1752 //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1756 //jlh createDirectPainter();
1757 painter->setPen(pen);
1758 painter->drawGridPoint(center);
1762 int ix1 = RS_Math::round(center.x + cos(a1) * radius);
1763 int iy1 = RS_Math::round(center.y - sin(a1) * radius);
1764 int ix2 = RS_Math::round(center.x + cos(a2) * radius);
1765 int iy2 = RS_Math::round(center.y - sin(a2) * radius);
1766 int k2x = 0; // Next point on circle
1768 int k1x = ix1; // Prev point on circle
1770 double aStep; // Angle Step (rad)
1771 double a; // Actual Angle (rad)
1772 double a2cp = a2; // Copy of a2
1774 if (1.0 / (radius * factor.x) <= 1.0)
1775 aStep = asin(1.0 / (radius * factor.x));
1784 // Arc Counterclockwise:
1786 if (a1 > a2cp - 0.01)
1789 //if (painter==NULL) {
1790 //painter->setPen(pen);
1791 //createDirectPainter();
1793 //painter->moveTo(ix1, iy1);
1795 for(a=a1+aStep; a<=a2cp; a+=aStep)
1797 k2x = RS_Math::round(center.x+cos(a)*radius);
1798 k2y = RS_Math::round(center.y-sin(a)*radius);
1799 //if(graphic->isPointOnScreen(k2x, k2y) ||
1800 // graphic->isPointOnScreen(k1x, k1y) ) {
1801 //jlh createDirectPainter();
1802 painter->setPen(pen);
1803 if ((k2x >= 0 && k2x <= painter->getWidth()
1804 && k2y >= 0 && k2y <= painter->getHeight())
1805 || (k1x >= 0 && k1x <= painter->getWidth()
1806 && k1y >= 0 && k1y <= painter->getHeight()))
1808 //painter->lineTo(k2x, k2y);
1809 painter->drawLine(Vector(k1x, k1y), Vector(k2x, k2y));
1811 //graphic->simulationDelay();
1813 //createDirectPainter();
1814 //painter->setPen(pen);
1815 //painter->moveTo(k2x, k2y);
1821 //jlh createDirectPainter();
1822 painter->setPen(pen);
1823 painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2));
1824 //painter->lineTo(ix2, iy2);
1830 if (a1 < a2cp + 0.01)
1833 //createDirectPainter();
1834 //painter->setPen(pen);
1835 //painter->moveTo(ix1, iy1);
1836 for(a=a1-aStep; a>=a2cp; a-=aStep)
1838 k2x = RS_Math::round(center.x + cos(a) * radius);
1839 k2y = RS_Math::round(center.y - sin(a) * radius);
1840 //if(graphic->isPointOnScreen(k2x, k2y) ||
1841 // graphic->isPointOnScreen(k1x, k1y) ) {
1842 //jlh createDirectPainter();
1843 painter->setPen(pen);
1844 if ((k2x >=0 && k2x <= painter->getWidth()
1845 && k2y >= 0 && k2y <= painter->getHeight())
1846 || (k1x >= 0 && k1x <= painter->getWidth()
1847 && k1y >= 0 && k1y <= painter->getHeight()))
1849 //painter->lineTo(k2x, k2y);
1850 painter->drawLine(Vector(k1x, k1y), Vector(k2x, k2y));
1853 //createDirectPainter();
1854 //painter->setPen(pen);
1855 //painter->moveTo(k2x, k2y);
1860 //jlh createDirectPainter();
1861 painter->setPen(pen);
1862 //painter->lineTo(ix2, iy2);
1863 painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2));
1869 * @return Pointer to the static pattern struct that belongs to the
1870 * given pattern type or NULL.
1872 RS_LineTypePattern * GraphicView::getPattern(RS2::LineType t)
1876 case RS2::SolidLine:
1877 return &patternSolidLine;
1881 return &patternDotLine;
1884 return &patternDotLine2;
1886 case RS2::DotLineX2:
1887 return &patternDotLineX2;
1891 return &patternDashLine;
1893 case RS2::DashLine2:
1894 return &patternDashLine2;
1896 case RS2::DashLineX2:
1897 return &patternDashLineX2;
1900 case RS2::DashDotLine:
1901 return &patternDashDotLine;
1903 case RS2::DashDotLine2:
1904 return &patternDashDotLine2;
1906 case RS2::DashDotLineX2:
1907 return &patternDashDotLineX2;
1910 case RS2::DivideLine:
1911 return &patternDivideLine;
1913 case RS2::DivideLine2:
1914 return &patternDivideLine2;
1916 case RS2::DivideLineX2:
1917 return &patternDivideLineX2;
1920 case RS2::CenterLine:
1921 return &patternCenterLine;
1923 case RS2::CenterLine2:
1924 return &patternCenterLine2;
1926 case RS2::CenterLineX2:
1927 return &patternCenterLineX2;
1930 case RS2::BorderLine:
1931 return &patternBorderLine;
1933 case RS2::BorderLine2:
1934 return &patternBorderLine2;
1936 case RS2::BorderLineX2:
1937 return &patternBorderLineX2;
1940 case RS2::LineByLayer:
1941 return &patternBlockLine;
1943 case RS2::LineByBlock:
1944 return &patternBlockLine;
1954 * This virtual method can be overwritten to draw the absolute
1955 * zero. It's called from within drawIt(). The default implemetation
1956 * draws a simple red round zero point.
1958 * Actually, we have to rework the rendering code because the way that QCad did
1959 * it was wrong on so many levels... Part of that is making sure the rendering
1960 * path is 100% clear!
1964 void GraphicView::drawAbsoluteZero()
1971 // RS_Pen pen(metaGridColor, RS2::Width00, RS2::SolidLine);
1972 // painter->setPen(pen);
1973 // RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
1974 //Using Qt::red doesn't seem to work here...
1975 //It's because Qt colors and RS_Color are not 100% compatible...
1976 RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine);
1979 painter->drawLine(Vector(toGuiX(0.0) - zr, toGuiY(0.0)),
1980 Vector(toGuiX(0.0) + zr, toGuiY(0.0)));
1982 painter->drawLine(Vector(toGuiX(0.0), toGuiY(0.0) - zr),
1983 Vector(toGuiX(0.0), toGuiY(0.0) + zr));
1987 * This virtual method can be overwritten to draw the relative
1988 * zero point. It's called from within drawIt(). The default implemetation
1989 * draws a simple red round zero point.
1993 void GraphicView::drawRelativeZero()
1995 if (!relativeZero.valid || !painter)
1998 // RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
1999 // p.setScreenWidth(0);
2000 //Using Qt::red doesn't seem to work here...
2001 RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine);
2003 painter->setXORMode();
2007 painter->drawLine(Vector(toGuiX(relativeZero.x) - zr, toGuiY(relativeZero.y)),
2008 Vector(toGuiX(relativeZero.x) + zr, toGuiY(relativeZero.y)));
2010 painter->drawLine(Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) - zr),
2011 Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) + zr));
2013 painter->drawCircle(toGui(relativeZero), zr);
2014 painter->setNormalMode();
2018 * Draws the paper border (for print previews).
2022 void GraphicView::drawPaper()
2027 Drawing * graphic = container->getGraphic();
2032 if (graphic->getPaperScale() < 1.0e-6)
2039 painter->setPen(RS_Pen(Qt::gray));
2041 Vector pinsbase = graphic->getPaperInsertionBase();
2042 Vector size = graphic->getPaperSize();
2043 double scale = graphic->getPaperScale();
2045 Vector v1 = toGui((Vector(0, 0) - pinsbase) / scale);
2046 Vector v2 = toGui((size - pinsbase) / scale);
2049 painter->fillRect(0,0, getWidth(), getHeight(), RS_Color(200, 200, 200));
2052 painter->fillRect((int)(v1.x) + 6, (int)(v1.y) + 6,
2053 (int)((v2.x - v1.x)), (int)((v2.y - v1.y)), RS_Color(64, 64, 64));
2056 painter->fillRect((int)(v1.x), (int)(v1.y),
2057 (int)((v2.x - v1.x)), (int)((v2.y - v1.y)), RS_Color(64, 64, 64));
2060 painter->fillRect((int)(v1.x) + 1, (int)(v1.y) - 1,
2061 (int)((v2.x - v1.x)) - 2, (int)((v2.y - v1.y)) + 2, RS_Color(255, 255, 255));
2069 void GraphicView::drawGrid()
2071 if (!grid || isGridOn() == false)
2073 // printf("GraphicView::drawGrid(): Aborting: grid=%08X, isGridOn=%s\n", grid, (isGridOn() ? "true" : "false"));
2078 painter->setPen(gridColor);
2080 //Problem here: pts is NULL!
2081 Vector * pts = grid->getPoints();
2085 for(int i=0; i<grid->count(); ++i)
2086 painter->drawGridPoint(toGui(pts[i]));
2089 // printf("GraphicView::drawGrid(): pts == NULL!\n");
2092 QString info = grid->getInfo();
2093 updateGridStatusWidget(info);
2097 * Draws the meta grid.
2101 void GraphicView::drawMetaGrid()
2103 if (!grid || isGridOn() == false /*|| grid->getMetaSpacing()<0.0*/)
2109 RS_Pen pen(metaGridColor, RS2::Width00, RS2::DotLine);
2110 painter->setPen(pen);
2113 double * mx = grid->getMetaX();
2114 double * my = grid->getMetaY();
2118 for(int i=0; i<grid->countMetaX(); ++i)
2119 painter->drawLine(Vector(toGuiX(mx[i]), 0), Vector(toGuiX(mx[i]), getHeight()));
2124 for(int i=0; i<grid->countMetaY(); ++i)
2125 painter->drawLine(Vector(0, toGuiY(my[i])), Vector(getWidth(), toGuiY(my[i])));
2130 * Updates the grid if there is one.
2132 void GraphicView::updateGrid()
2138 RS_Grid * GraphicView::getGrid()
2143 void GraphicView::updateGridStatusWidget(const QString & /*text*/)
2147 RS2::SnapMode GraphicView::getDefaultSnapMode()
2149 return defaultSnapMode;
2152 RS2::SnapRestriction GraphicView::getSnapRestriction()
2154 return defaultSnapRes;
2158 * Sets the default snap mode used by newly created actions.
2160 void GraphicView::setDefaultSnapMode(RS2::SnapMode sm)
2162 defaultSnapMode = sm;
2164 if (eventHandler != NULL)
2165 eventHandler->setSnapMode(sm);
2169 * Sets a snap restriction (e.g. orthogonal).
2171 void GraphicView::setSnapRestriction(RS2::SnapRestriction sr)
2173 defaultSnapRes = sr;
2175 if (eventHandler != NULL)
2176 eventHandler->setSnapRestriction(sr);
2180 * Translates a vector in real coordinates to a vector in screen coordinates.
2182 Vector GraphicView::toGui(Vector v)
2184 return Vector(toGuiX(v.x), toGuiY(v.y), 0.0);
2188 * Translates a real coordinate in X to a screen coordinate X.
2189 * @param visible Pointer to a boolean which will contain true
2190 * after the call if the coordinate is within the visible range.
2192 double GraphicView::toGuiX(double x, bool * visible)
2194 if (visible != NULL)
2196 double res = x * factor.x + offsetX;
2198 if (res > 0.0 && res < getWidth())
2204 return x * factor.x + offsetX;
2208 * Translates a real coordinate in Y to a screen coordinate Y.
2210 double GraphicView::toGuiY(double y)
2212 return -y * factor.y + getHeight() - offsetY;
2216 * Translates a real coordinate distance to a screen coordinate distance.
2218 double GraphicView::toGuiDX(double d)
2220 return d * factor.x;
2224 * Translates a real coordinate distance to a screen coordinate distance.
2226 double GraphicView::toGuiDY(double d)
2228 return d * factor.y;
2232 * Translates a vector in screen coordinates to a vector in real coordinates.
2234 Vector GraphicView::toGraph(Vector v)
2236 return Vector(toGraphX(RS_Math::round(v.x)), toGraphY(RS_Math::round(v.y)), 0.0);
2240 * Translates two screen coordinates to a vector in real coordinates.
2242 Vector GraphicView::toGraph(int x, int y)
2244 return Vector(toGraphX(x), toGraphY(y), 0.0);
2248 * Translates a screen coordinate in X to a real coordinate X.
2250 double GraphicView::toGraphX(int x)
2252 return (x - offsetX) / factor.x;
2256 * Translates a screen coordinate in Y to a real coordinate Y.
2258 double GraphicView::toGraphY(int y)
2260 return -(y - getHeight() + offsetY) / factor.y;
2264 * Translates a screen coordinate distance to a real coordinate distance.
2266 double GraphicView::toGraphDX(int d)
2268 return d / factor.x;
2272 * Translates a screen coordinate distance to a real coordinate distance.
2274 double GraphicView::toGraphDY(int d)
2276 return d / factor.y;
2280 * (Un-)Locks the position of the relative zero.
2282 * @param lock true: lock, false: unlock
2284 void GraphicView::lockRelativeZero(bool lock)
2286 relativeZeroLocked = lock;
2290 * @return true if the position of the realtive zero point is
2293 bool GraphicView::isRelativeZeroLocked()
2295 return relativeZeroLocked;
2299 * @return Relative zero coordinate.
2301 Vector GraphicView::getRelativeZero()
2303 return relativeZero;
2307 * Sets the relative zero coordinate (if not locked)
2308 * without deleting / drawing the point.
2310 void GraphicView::setRelativeZero(const Vector & pos)
2312 if (!relativeZeroLocked)
2317 * Sets the relative zero coordinate, deletes the old position
2318 * on the screen and draws the new one.
2320 void GraphicView::moveRelativeZero(const Vector & pos)
2322 #warning "!!! GraphicView::moveRelativeZero(): Bad render path !!!"
2326 //painter->setXORMode();
2328 setRelativeZero(pos);
2332 RS_EventHandler * GraphicView::getEventHandler()
2334 return eventHandler;
2338 * Enables or disables print preview.
2340 void GraphicView::setPrintPreview(bool pv)
2346 * @retval true This is a print preview graphic view.
2347 * @retval false Otherwise.
2349 bool GraphicView::isPrintPreview()
2351 return printPreview;
2355 * Enables or disables printing.
2357 void GraphicView::setPrinting(bool p)
2363 * @retval true This is a a graphic view for printing.
2364 * @retval false Otherwise.
2366 bool GraphicView::isPrinting()
2372 * @retval true Draft mode is on for this view (all lines with 1 pixel / no style scaling).
2373 * @retval false Otherwise.
2375 bool GraphicView::isDraftMode()
2381 * Sets the simulation speed in percentage.
2383 void GraphicView::setSimulationSpeed(int s)
2385 simulationSpeed = s;
2389 * @return the simulation speed in percentage.
2391 int GraphicView::getSimulationSpeed()
2393 return simulationSpeed;
2397 * Sets the simulation smooth mode.
2399 void GraphicView::setSimulationSmooth(bool s)
2401 simulationSmooth = s;
2404 * Sets the simulation rapid mode.
2406 void GraphicView::setSimulationRapid(bool r)
2408 simulationRapid = r;
2412 * @return the simulation rapid mode.
2414 bool GraphicView::getSimulationRapid()
2416 return simulationRapid;
2419 // These functions are here because of the focacta way that this
2420 // program set up its rendering...
2421 void GraphicView::SetPreviewMode(bool mode/*= true*/)
2426 void GraphicView::SetPreviewEntity(RS_Preview * p)
2431 void GraphicView::SetPreviewOffset(Vector o)
2436 void GraphicView::SetSnapperDraw(bool mode)
2441 void GraphicView::SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs)
2443 snapSpot1 = snapSpot;
2444 snapCoord1 = snapCoord;
2445 showCrosshairs1 = showCrosshairs;