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 && 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()
165 * Sets an external painter device.
167 //void GraphicView::setPainter(RS_Painter * p)
168 void GraphicView::setPainter(PaintInterface * p)
175 * Sets the background color. Note that applying the background
176 * color for the widget is up to the implementing class.
178 void GraphicView::setBackground(const RS_Color & bg)
182 // bright background:
183 if (bg.red() + bg.green() + bg.blue() > 380)
184 // foreground = Qt::black;
185 foreground = RS_Color(0, 0, 0);
187 // foreground = Qt::white;
188 foreground = RS_Color(255, 255, 255);
192 * @return Current background color.
194 RS_Color GraphicView::getBackground()
200 * @return Current foreground color.
202 RS_Color GraphicView::getForeground()
208 * Sets the grid color.
210 void GraphicView::setGridColor(const RS_Color & c)
216 * Sets the meta grid color.
218 void GraphicView::setMetaGridColor(const RS_Color & c)
224 * Sets the selection color.
226 void GraphicView::setSelectedColor(const RS_Color & c)
232 * Sets the highlight color.
234 void GraphicView::setHighlightedColor(const RS_Color & c)
236 highlightedColor = c;
240 * This virtual method can be overwritten to set the mouse
241 * cursor to the given type.
243 void GraphicView::setMouseCursor(RS2::CursorType /*c*/)
247 RS_EntityContainer * GraphicView::getContainer()
252 void GraphicView::setFactor(double f)
258 Vector GraphicView::getFactor()
264 * Sets the offset of the graphic.
266 void GraphicView::setOffset(int ox, int oy)
272 void GraphicView::setOffsetX(int ox)
277 void GraphicView::setOffsetY(int oy)
282 int GraphicView::getOffsetX()
287 int GraphicView::getOffsetY()
293 * Sets a fixed border in pixel around the graphic. This border
294 * specifies how far the user can scroll outside the graphic
297 void GraphicView::setBorders(int left, int top, int right, int bottom)
302 borderBottom = bottom;
305 int GraphicView::getBorderLeft()
310 int GraphicView::getBorderTop()
315 int GraphicView::getBorderRight()
320 int GraphicView::getBorderBottom()
325 void GraphicView::disableUpdate()
330 void GraphicView::enableUpdate()
335 bool GraphicView::isUpdateEnabled()
337 return (updateEnabled == 0);
340 void GraphicView::freezeZoom(bool freeze)
345 bool GraphicView::isZoomFrozen()
351 * Sets the pointer to the graphic which contains the entities
352 * which are visualized by this widget.
354 void GraphicView::setContainer(RS_EntityContainer * container)
356 this->container = container;
357 //adjustOffsetControls();
361 * Sets the zoom factor in X for this visualization of the graphic.
363 void GraphicView::setFactorX(double f)
370 * Sets the zoom factor in Y for this visualization of the graphic.
372 void GraphicView::setFactorY(double f)
379 * @return true if the grid is switched on.
381 bool GraphicView::isGridOn()
383 if (container != NULL)
385 Drawing * g = container->getGraphic();
388 return g->isGridOn();
395 * Centers the drawing in x-direction.
397 void GraphicView::centerOffsetX()
399 if (container != NULL && !zoomFrozen)
400 offsetX = (int)(((getWidth() - borderLeft - borderRight)
401 - (container->getSize().x * factor.x)) / 2.0
402 - (container->getMin().x * factor.x)) + borderLeft;
406 * Centers the drawing in y-direction.
408 void GraphicView::centerOffsetY()
410 if (container != NULL && !zoomFrozen)
411 offsetY = (int)((getHeight() - borderTop - borderBottom
412 - (container->getSize().y * factor.y)) / 2.0
413 - (container->getMin().y * factor.y)) + borderBottom;
417 * Centers the given coordinate in the view in x-direction.
419 void GraphicView::centerX(double v)
422 offsetX = (int)((v * factor.x) - (double)(getWidth() - borderLeft - borderRight) / 2.0);
426 * Centers the given coordinate in the view in y-direction.
428 void GraphicView::centerY(double v)
431 offsetY = (int)((v * factor.y) - (double)(getHeight() - borderTop - borderBottom) / 2.0);
434 void GraphicView::updateView()
436 static int running = 0;
441 adjustZoomControls();
442 adjustOffsetControls();
452 * @return Current action or NULL.
454 RS_ActionInterface * GraphicView::getDefaultAction()
456 if (eventHandler != NULL)
457 return eventHandler->getDefaultAction();
463 * Sets the default action of the event handler.
465 void GraphicView::setDefaultAction(RS_ActionInterface * action)
467 if (eventHandler != NULL)
468 eventHandler->setDefaultAction(action);
472 * @return Current action or NULL.
474 RS_ActionInterface * GraphicView::getCurrentAction()
476 if (eventHandler != NULL)
477 return eventHandler->getCurrentAction();
483 * Sets the current action of the event handler.
485 void GraphicView::setCurrentAction(RS_ActionInterface * action)
487 RS_DEBUG->print("GraphicView::setCurrentAction");
489 if (eventHandler != NULL)
490 eventHandler->setCurrentAction(action);
492 RS_DEBUG->print("GraphicView::setCurrentAction: OK");
496 * Kills all running selection actions. Called when a selection action
497 * is launched to reduce confusion.
499 void GraphicView::killSelectActions()
502 eventHandler->killSelectActions();
506 * Kills all running actions.
508 void GraphicView::killAllActions()
511 eventHandler->killAllActions();
515 * Go back in menu or current action.
517 void GraphicView::back()
519 if (eventHandler && eventHandler->hasAction())
520 eventHandler->back();
521 else if (RS_DIALOGFACTORY)
522 RS_DIALOGFACTORY->requestPreviousMenu();
526 * Go forward with the current action.
528 void GraphicView::enter()
530 if (eventHandler && eventHandler->hasAction())
531 eventHandler->enter();
535 * Called by the actual GUI class which implements the GraphicView
536 * interface to notify qcadlib about mouse events.
538 void GraphicView::mousePressEvent(QMouseEvent * e)
541 eventHandler->mousePressEvent(e);
545 * Called by the actual GUI class which implements the GraphicView
546 * interface to notify qcadlib about mouse events.
548 void GraphicView::mouseReleaseEvent(QMouseEvent * e)
550 RS_DEBUG->print("GraphicView::mouseReleaseEvent");
555 if (e->button() != Qt::RightButton || eventHandler->hasAction())
557 eventHandler->mouseReleaseEvent(e);
566 RS_DEBUG->print("GraphicView::mouseReleaseEvent: OK");
570 * Called by the actual GUI class which implements the GraphicView
571 * interface to notify qcadlib about mouse events.
573 void GraphicView::mouseMoveEvent(QMouseEvent * e)
575 RS_DEBUG->print("GraphicView::mouseMoveEvent begin");
577 Drawing * graphic = NULL;
579 if (container->rtti() == RS2::EntityGraphic)
580 graphic = (Drawing *)container;
582 RS_DEBUG->print("GraphicView::mouseMoveEvent 001");
590 RS_DEBUG->print("GraphicView::mouseMoveEvent 002");
593 eventHandler->mouseMoveEvent(e);
595 RS_DEBUG->print("GraphicView::mouseMoveEvent 003");
597 if (!eventHandler || !eventHandler->hasAction() && graphic)
599 Vector mouse = toGraph(Vector(mx, my));
600 Vector relMouse = mouse - getRelativeZero();
602 if (RS_DIALOGFACTORY)
603 RS_DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
606 RS_DEBUG->print("GraphicView::mouseMoveEvent end");
610 * Called by the actual GUI class which implements the GraphicView
611 * interface to notify qcadlib about mouse events.
613 void GraphicView::mouseLeaveEvent()
616 eventHandler->mouseLeaveEvent();
620 * Called by the actual GUI class which implements the GraphicView
621 * interface to notify qcadlib about mouse events.
623 void GraphicView::mouseEnterEvent()
626 eventHandler->mouseEnterEvent();
630 * Called by the actual GUI class which implements the GraphicView
631 * interface to notify qcadlib about key events.
633 void GraphicView::keyPressEvent(QKeyEvent * e)
636 eventHandler->keyPressEvent(e);
640 * Called by the actual GUI class which implements the GraphicView
641 * interface to notify qcadlib about key events.
643 void GraphicView::keyReleaseEvent(QKeyEvent * e)
646 eventHandler->keyReleaseEvent(e);
650 * Called by the actual GUI class which implements a command line.
652 void GraphicView::commandEvent(RS_CommandEvent * e)
655 eventHandler->commandEvent(e);
659 * Enables coordinate input in the command line.
661 void GraphicView::enableCoordinateInput()
664 eventHandler->enableCoordinateInput();
668 * Disables coordinate input in the command line.
670 void GraphicView::disableCoordinateInput()
673 eventHandler->disableCoordinateInput();
677 * zooms in by factor f
679 void GraphicView::zoomIn(double f, const Vector & center)
683 RS_DEBUG->print(RS_Debug::D_WARNING, "GraphicView::zoomIn: invalid factor");
687 if (simulationRunning)
691 if (c.valid == false)
692 c = toGraph(Vector(getWidth() / 2, getHeight() / 2));
695 toGraph(Vector(0, 0)).scale(c, Vector(1.0 / f, 1.0 / f)),
696 toGraph(Vector(getWidth(), getHeight())).scale(c, Vector(1.0 / f, 1.0 / f)));
698 //adjustOffsetControls();
699 //adjustZoomControls();
705 * zooms in by factor f in x
707 void GraphicView::zoomInX(double f)
709 if (simulationRunning)
713 offsetX = (int)((offsetX - getWidth() / 2) * f) + getWidth() / 2;
714 adjustOffsetControls();
715 adjustZoomControls();
721 * zooms in by factor f in y
723 void GraphicView::zoomInY(double f)
725 if (simulationRunning)
729 offsetY = (int)((offsetY - getHeight() / 2) * f)+getHeight() / 2;
730 adjustOffsetControls();
731 adjustZoomControls();
737 * zooms out by factor f
739 void GraphicView::zoomOut(double f, const Vector & center)
743 RS_DEBUG->print(RS_Debug::D_WARNING,
744 "GraphicView::zoomOut: invalid factor");
748 if (simulationRunning)
755 * zooms out by factor f in x
757 void GraphicView::zoomOutX(double f)
761 RS_DEBUG->print(RS_Debug::D_WARNING,
762 "GraphicView::zoomOutX: invalid factor");
766 if (simulationRunning)
770 offsetX = (int)(offsetX / f);
771 adjustOffsetControls();
772 adjustZoomControls();
778 * zooms out by factor of y
780 void GraphicView::zoomOutY(double f)
784 RS_DEBUG->print(RS_Debug::D_WARNING, "GraphicView::zoomOutY: invalid factor");
788 if (simulationRunning)
792 offsetY = (int)(offsetY / f);
793 adjustOffsetControls();
794 adjustZoomControls();
802 * @param axis include axis in zoom
803 * @param keepAspectRatio true: keep aspect ratio 1:1
804 * false: factors in x and y are stretched to the max
806 void GraphicView::zoomAuto(bool axis, bool keepAspectRatio)
808 RS_DEBUG->print("GraphicView::zoomAuto");
810 if (simulationRunning)
815 if (container != NULL)
817 container->calculateBorders();
822 sx = std::max(container->getMax().x, 0.0) - std::min(container->getMin().x, 0.0);
823 sy = std::max(container->getMax().y, 0.0) - std::min(container->getMin().y, 0.0);
827 sx = container->getSize().x;
828 sy = container->getSize().y;
833 if (sx > RS_TOLERANCE)
834 fx = (getWidth() - borderLeft - borderRight) / sx;
838 if (sy > RS_TOLERANCE)
839 fy = (getHeight() - borderTop - borderBottom) / sy;
843 RS_DEBUG->print("f: %f/%f", fx, fy);
846 fx = fy = std::min(fx, fy);
848 RS_DEBUG->print("f: %f/%f", fx, fy);
850 if (fx < RS_TOLERANCE)
856 RS_DEBUG->print("f: %f/%f", fx, fy);
858 RS_DEBUG->print("adjustOffsetControls");
859 adjustOffsetControls();
860 RS_DEBUG->print("adjustZoomControls");
861 adjustZoomControls();
862 RS_DEBUG->print("centerOffsetX");
864 RS_DEBUG->print("centerOffsetY");
866 RS_DEBUG->print("updateGrid");
871 RS_DEBUG->print("GraphicView::zoomAuto OK");
875 * Shows previous view.
877 void GraphicView::zoomPrevious()
879 RS_DEBUG->print("GraphicView::zoomPrevious");
881 if (simulationRunning)
889 * Saves the current view as previous view to which we can
890 * switch back later with @see restoreView().
892 void GraphicView::saveView()
894 previousOffsetX = offsetX;
895 previousOffsetY = offsetY;
896 previousFactor = factor;
900 * Restores the view previously saved with
903 void GraphicView::restoreView()
905 int pox = previousOffsetX;
906 int poy = previousOffsetY;
907 Vector pf = previousFactor;
915 adjustOffsetControls();
916 adjustZoomControls();
922 * performs autozoom in y only
924 * @param axis include axis in zoom
926 void GraphicView::zoomAutoY(bool axis)
928 if (simulationRunning)
931 if (container != NULL)
933 double visibleHeight = 0.0;
934 double minY = RS_MAXDOUBLE;
935 double maxY = RS_MINDOUBLE;
936 bool noChange = false;
938 for(RS_Entity * e=container->firstEntity(RS2::ResolveNone);
939 e!=NULL; e = container->nextEntity(RS2::ResolveNone))
941 if (e->rtti() == RS2::EntityLine)
943 RS_Line * l = (RS_Line *)e;
945 x1 = toGuiX(l->getStartpoint().x);
946 x2 = toGuiX(l->getEndpoint().x);
948 if (x1 > 0.0 && x1 < (double)getWidth() || x2 > 0.0 && x2 < (double)getWidth())
950 minY = std::min(minY, l->getStartpoint().y);
951 minY = std::min(minY, l->getEndpoint().y);
952 maxY = std::max(maxY, l->getStartpoint().y);
953 maxY = std::max(maxY, l->getEndpoint().y);
959 visibleHeight = std::max(maxY, 0.0) - std::min(minY, 0.0);
961 visibleHeight = maxY - minY;
963 if (visibleHeight < 1.0)
968 if (visibleHeight > 1.0e-6)
970 fy = (getHeight() - borderTop - borderBottom) / visibleHeight;
972 if (factor.y < 0.000001)
976 if (noChange == false)
980 offsetY = (int)((getHeight() - borderTop - borderBottom - (visibleHeight * factor.y)) / 2.0
981 - (minY * factor.y)) + borderBottom;
982 adjustOffsetControls();
983 adjustZoomControls();
987 RS_DEBUG->print("Auto zoom y ok");
992 * Zooms the area given by v1 and v2.
994 * @param keepAspectRatio true: keeps the aspect ratio 1:1
995 * false: zooms exactly the selected range to the
996 * current graphic view
998 void GraphicView::zoomWindow(Vector v1, Vector v2, bool keepAspectRatio)
1000 if (simulationRunning)
1005 double zoomX = 480.0; // Zoom for X-Axis
1006 double zoomY = 640.0; // Zoom for Y-Axis (Set smaller one)
1007 double dum; // Dummy for switching values
1010 // Switch left/right and top/bottom is necessary:
1025 // Get zoom in X and zoom in Y:
1026 if (v2.x - v1.x > 1.0e-6)
1027 zoomX = getWidth() / (v2.x - v1.x);
1029 if (v2.y - v1.y > 1.0e-6)
1030 zoomY = getHeight() / (v2.y - v1.y);
1032 // Take smaller zoom:
1033 if (keepAspectRatio)
1037 if (getWidth() != 0)
1039 zoomX = zoomY = ((double)(getWidth() - 2 * zoomBorder)) /
1040 (double)getWidth() * zoomX;
1045 if (getHeight() != 0)
1047 zoomX = zoomY = ((double)(getHeight() - 2 * zoomBorder)) /
1048 (double)getHeight() * zoomY;
1059 // Borders in pixel after zoom
1060 int pixLeft = (int)(v1.x * zoomX);
1061 int pixTop = (int)(v2.y * zoomY);
1062 int pixRight = (int)(v2.x * zoomX);
1063 int pixBottom = (int)(v1.y * zoomY);
1065 // Set new offset for zero point:
1066 offsetX = - pixLeft + (getWidth() - pixRight + pixLeft) / 2;
1067 offsetY = - pixTop + (getHeight() - pixBottom + pixTop) / 2;
1071 adjustOffsetControls();
1072 adjustZoomControls();
1078 * Centers the point v1.
1080 void GraphicView::zoomPan(int dx, int dy)
1082 //offsetX+=(int)toGuiDX(v1.x);
1083 //offsetY+=(int)toGuiDY(v1.y);
1084 if (simulationRunning)
1091 adjustOffsetControls();
1092 //adjustZoomControls();
1099 * Scrolls in the given direction.
1101 void GraphicView::zoomScroll(RS2::Direction direction)
1103 if (simulationRunning)
1122 adjustOffsetControls();
1123 adjustZoomControls();
1129 * Zooms to page extends.
1131 void GraphicView::zoomPage()
1133 RS_DEBUG->print("GraphicView::zoomPage");
1135 if (container == NULL)
1138 if (simulationRunning)
1141 Drawing * graphic = container->getGraphic();
1143 if (graphic == NULL)
1146 Vector s = graphic->getPaperSize();
1147 Vector pinsbase = graphic->getPaperInsertionBase();
1151 if (s.x > RS_TOLERANCE)
1152 fx = (getWidth() - borderLeft - borderRight) / s.x;
1156 if (s.y > RS_TOLERANCE)
1157 fy = (getHeight() - borderTop - borderBottom) / s.y;
1161 RS_DEBUG->print("f: %f/%f", fx, fy);
1163 fx = fy = std::min(fx, fy);
1165 RS_DEBUG->print("f: %f/%f", fx, fy);
1167 if (fx < RS_TOLERANCE)
1173 RS_DEBUG->print("f: %f/%f", fx, fy);
1177 adjustOffsetControls();
1178 adjustZoomControls();
1184 * Draws the entities within the given range.
1186 void GraphicView::drawWindow(Vector v1, Vector v2)
1188 RS_DEBUG->print("GraphicView::drawWindow() begin");
1190 if (simulationRunning)
1195 for(RS_Entity * se=container->firstEntity(RS2::ResolveNone); se!=NULL;
1196 se=container->nextEntity(RS2::ResolveNone))
1198 if (se->isInWindow(v1, v2))
1203 RS_DEBUG->print("GraphicView::drawWindow() end");
1207 * Draws the entities. If painter is NULL a new painter will
1208 * be created and destroyed.
1210 void GraphicView::drawIt()
1212 if (!isUpdateEnabled())
1214 //printf("GraphicView::drawIt(): isUpdateEnabled() == false!\n");
1218 if (simulationRunning)
1220 //printf("GraphicView::drawIt(): simulationRunning == true!\n");
1224 settings.beginGroup("Appearance");
1225 draftMode = settings.value("DraftMode", false).toBool();
1226 settings.endGroup();
1230 //printf("GraphicView::drawIt(): painter == NULL!\n");
1236 // drawing paper border:
1237 if (isPrintPreview())
1239 // drawing meta grid:
1243 // drawing entities:
1244 //#warning "!!! This looks like a bug, no match for 'drawEntity(RS_Entity *, bool) !!!"
1245 // and indeed it *is* a bug... true is converted to 1.0 here. Dumb, dumb, dumb.
1246 drawEntity(container);//, true);
1248 // drawing zero points:
1249 if (!isPrintPreview())
1256 if (!isPrintPreview())
1261 * Sets the pen of the painter object to the suitable pen for the given
1264 void GraphicView::setPenForEntity(RS_Entity * e)
1266 if (drawingMode == RS2::ModePreview /*|| draftMode==true*/)
1269 if (!painter || painter->isPreviewMode())
1272 // set color of entity
1273 // Getting pen from entity (or layer)
1274 RS_Pen pen = e->getPen(true);
1276 int w = pen.getWidth();
1284 double uf = 1.0; // unit factor
1285 double wf = 1.0; // width factor
1286 Drawing * graphic = container->getGraphic();
1290 uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
1292 if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6)
1293 wf = 1.0 / graphic->getPaperScale();
1296 pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
1300 //pen.setWidth(RS2::Width00);
1301 pen.setScreenWidth(0);
1304 // prevent drawing with 1-width which is slow:
1305 if (RS_Math::round(pen.getScreenWidth()) == 1)
1306 pen.setScreenWidth(0.0);
1308 // prevent background color on background drawing:
1309 if (pen.getColor().stripFlags() == background.stripFlags())
1310 pen.setColor(foreground);
1312 // this entity is selected:
1313 if (e->isSelected())
1315 pen.setLineType(RS2::DotLine);
1316 //pen.setColor(RS_Color(0xa5,0x47,0x47));
1317 pen.setColor(selectedColor);
1320 // this entity is highlighted:
1321 if (e->isHighlighted())
1323 //pen.setColor(RS_Color(0x73, 0x93, 0x73));
1324 pen.setColor(highlightedColor);
1327 // deleting not drawing:
1328 if (getDeleteMode())
1329 pen.setColor(background);
1331 painter->setPen(pen);
1335 * Draws an entity. Might be recusively called e.g. for polylines.
1336 * If the class wide painter is NULL a new painter will be created
1337 * and destroyed afterwards.
1339 * @param patternOffset Offset of line pattern (used for connected
1340 * lines e.g. in splines).
1341 * @param db Double buffering on (recommended) / off
1343 void GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db)
1345 //RS_DEBUG->print("GraphicView::drawEntity() begin");
1347 // update is diabled:
1348 if (!isUpdateEnabled())
1351 // given entity is NULL:
1355 // entity is not visible:
1356 if (!e->isVisible())
1359 // test if the entity is in the viewport
1360 if (!e->isContainer() && !isPrinting()
1361 && (!painter || !painter->isPreviewMode())
1362 && (toGuiX(e->getMax().x) < 0 || toGuiX(e->getMin().x) > getWidth()
1363 || toGuiY(e->getMin().y) < 0 || toGuiY(e->getMax().y) > getHeight()))
1365 //printf("GraphicView::drawEntity(): Bailing out of big test!!!\n");
1370 //RS_DEBUG->print("recursion 1: %d", drawRecursion);
1375 //RS_DEBUG->print("draw plain");
1378 // large texts as rectangles:
1379 if (e->rtti() == RS2::EntityText)
1381 if (toGuiDX(((RS_Text *)e)->getHeight()) < 4 || e->countDeep() > 100)
1382 painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
1384 drawEntityPlain(e, patternOffset);
1386 // all images as rectangles:
1387 else if (e->rtti() == RS2::EntityImage)
1388 painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
1390 else if (e->rtti() == RS2::EntityHatch)
1395 drawEntityPlain(e, patternOffset);
1398 drawEntityPlain(e, patternOffset);
1400 // draw reference points:
1401 if (e->isSelected())
1403 if (!e->isParentSelected())
1405 VectorSolutions s = e->getRefPoints();
1407 for(int i=0; i<s.getNumber(); ++i)
1410 RS_Color col = RS_Color(0, 0, 255);
1412 if (e->rtti() == RS2::EntityPolyline)
1414 if (i == 0 || i == s.getNumber() - 1)
1419 // col = QColor(0, 64, 255);
1420 col = RS_Color(0, 64, 255);
1425 // col = QColor(0, 0, 128);
1426 col = RS_Color(0, 0, 128);
1431 if (getDeleteMode())
1432 painter->drawHandle(toGui(s.get(i)), background, sz);
1434 painter->drawHandle(toGui(s.get(i)), col, sz);
1439 //RS_DEBUG->print("draw plain OK");
1440 //RS_DEBUG->print("GraphicView::drawEntity() end");
1444 * Deletes an entity with the background color.
1445 * Might be recusively called e.g. for polylines.
1447 void GraphicView::deleteEntity(RS_Entity * e)
1449 #warning "!!! This is part of obsolete rendering !!!"
1450 setDeleteMode(true);
1452 setDeleteMode(false);
1457 * The painter must be initialized and all the attributes (pen) must be set.
1459 void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset/*= 0.0*/)
1461 //Problems can still occur here when passing in a deleted object... It won't be
1462 //NULL, but it will cause a segfault here...
1465 //printf("GraphicView::drawEntityPlain(): Entity passed in is NULL!\n");
1469 //printf("GraphicView::drawEntityPlain(): Passing in painter=%08X, view=%08X\n", painter, this);
1470 e->draw(painter, this, patternOffset);
1474 * Simulates this drawing in slow motion.
1476 void GraphicView::simulateIt()
1478 if (simulationRunning)
1481 simulationRunning = true;
1482 simulationLast = Vector(0.0, 0.0);
1484 //jlh destroyPainter();
1488 // drawing paper border:
1489 if (isPrintPreview())
1492 // drawing meta grid:
1493 if (!isPrintPreview())
1497 if (!isPrintPreview())
1501 //painter->setPen(RS_Pen(foreground,
1502 // RS2::Width00, RS2::SolidLine));
1505 // drawing entities:
1506 RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1507 simulateEntity(container, pen);
1509 //RS_DEBUG->timestamp();
1510 //RS_DEBUG->print(" draw zero..");
1512 // drawing zero points:
1513 if (!isPrintPreview())
1519 //RS_DEBUG->timestamp();
1520 //RS_DEBUG->print(" draw grid..");
1522 //RS_DEBUG->timestamp();
1523 //RS_DEBUG->print("GraphicView::drawIt() end");
1524 //if (painterCreated==true) {
1525 //jlh destroyPainter();
1527 simulationRunning = false;
1531 * Simulates the given entity.
1533 * @param smooth If true, the entity will be drawn slowly (pixel by pixel).
1535 void GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
1537 if (painter == NULL || e == NULL)
1540 if (e->isContainer())
1542 RS_EntityContainer * ec = (RS_EntityContainer *)e;
1544 for(RS_Entity* en=ec->firstEntity(RS2::ResolveNone);
1545 en!=NULL; en = ec->nextEntity(RS2::ResolveNone))
1547 if (en->isVisible() && en->isUndone() == false)
1550 if (en->isAtomic() && simulationRapid)
1552 Vector sp = ((RS_AtomicEntity *)en)->getStartpoint();
1554 if (sp.distanceTo(simulationLast) > 1.0e-4)
1556 //jlh createDirectPainter();
1557 RS_Pen rpen(RS_Color(0, 0, 255), RS2::Width00, RS2::SolidLine);
1558 //painter->setPen(pen);
1559 RS_Line rapidLine(NULL, RS_LineData(simulationLast, sp));
1560 simulateEntity(&rapidLine, rpen);
1564 if (en->isHighlighted())
1566 RS_Pen hpen(highlightedColor, RS2::Width00, RS2::SolidLine);
1567 simulateEntity(en, hpen);
1570 simulateEntity(en, pen);
1573 simulationLast = ((RS_AtomicEntity *)en)->getEndpoint();
1575 if (!simulationSmooth)
1576 simulationDelay(true);
1582 if (simulationSmooth)
1586 case RS2::EntityLine:
1588 RS_Line * line = (RS_Line *)e;
1589 drawLineSmooth(toGui(line->getStartpoint()), toGui(line->getEndpoint()), pen);
1594 case RS2::EntityArc:
1596 RS_Arc * arc = (RS_Arc *)e;
1597 drawArcSmooth(toGui(arc->getCenter()), toGuiDX(arc->getRadius()),
1598 arc->getAngle1(), arc->getAngle2(), arc->isReversed(), pen);
1602 case RS2::EntityCircle:
1604 RS_Circle * circle = (RS_Circle *)e;
1605 drawArcSmooth(toGui(circle->getCenter()), toGuiDX(circle->getRadius()),
1606 0.0, 2.0 * M_PI, false, pen);
1616 //jlh createDirectPainter();
1617 //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1618 painter->setPen(pen);
1625 * Delay for slow motion simulation.
1627 * @param step true: stepping mode (entity by entity simulation). adds a delay.
1629 void GraphicView::simulationDelay(bool step)
1632 settings.beginGroup("CAM");
1633 double fact = settings.value("SimulationFactor", 12000.0).toDouble();
1634 settings.endGroup();
1636 // simulationSpeed: 0..100
1639 delay = (int)(((1.0 / (simulationSpeed + 1.0)) * fact) - (fact / 100.0));
1644 static int call = 0;
1646 if (call >= (fact - delay) / 1000)
1649 for(int i=0; i<delay; ++i)
1650 RS_APP->processEvents(10);
1655 delay = (int)(((1.0 / (simulationSpeed + 1.0)) * fact) - (fact / 100.0));
1662 for(int i=0; i<delay; ++i)
1664 #warning "Qt3->4 conversion: commented out problem line... !!! FIX !!!"
1665 // RS_APP->processEvents(10);
1671 * Draws a line slowly from (x1, y1) to (x2, y2). This is used for simulation only.
1673 void GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen)
1675 double alpha = p1.angleTo(p2);
1676 double xStep, yStep;
1679 if (RS_Math::cmpDouble(alpha, 0.0) || RS_Math::cmpDouble(alpha, 2 * M_PI))
1685 else if (RS_Math::cmpDouble(alpha, M_PI / 2.0))
1691 else if (RS_Math::cmpDouble(alpha, M_PI))
1697 else if (RS_Math::cmpDouble(alpha, M_PI / 2.0 * 3.0))
1703 else if (fabs(p2.x - p1.x) > fabs(p2.y - p1.y))
1710 yStep = tan(alpha) * xStep;
1720 xStep = yStep / tan(alpha);
1726 //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1730 if (lx >= 0.0 && lx <= (double)getWidth() && ly >= 0.0 && ly <= (double)getHeight())
1732 //if (painter==NULL) {
1733 //jlh createDirectPainter();
1735 painter->setPen(pen);
1736 painter->drawGridPoint(Vector(lx, ly));
1745 while ((xIsOne && ((lx >= p1.x && lx <= p2.x) || (lx >= p2.x && lx <= p1.x)))
1746 || (!xIsOne && ((ly >= p1.y && ly <= p2.y) || (ly >= p2.y && ly <= p1.y))));
1749 void GraphicView::drawArcSmooth(const Vector & center, double radius, double a1, double a2, bool rev,
1752 //int icx = graphic->realToScreenX(cx);
1753 //int icy = graphic->realToScreenY(cy);
1754 //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
1758 //jlh createDirectPainter();
1759 painter->setPen(pen);
1760 painter->drawGridPoint(center);
1764 int ix1 = RS_Math::round(center.x + cos(a1) * radius);
1765 int iy1 = RS_Math::round(center.y - sin(a1) * radius);
1766 int ix2 = RS_Math::round(center.x + cos(a2) * radius);
1767 int iy2 = RS_Math::round(center.y - sin(a2) * radius);
1768 int k2x = 0; // Next point on circle
1770 int k1x = ix1; // Prev point on circle
1772 double aStep; // Angle Step (rad)
1773 double a; // Actual Angle (rad)
1774 double a2cp = a2; // Copy of a2
1776 if (1.0 / (radius * factor.x) <= 1.0)
1777 aStep = asin(1.0 / (radius * factor.x));
1786 // Arc Counterclockwise:
1788 if (a1 > a2cp - 0.01)
1791 //if (painter==NULL) {
1792 //painter->setPen(pen);
1793 //createDirectPainter();
1795 //painter->moveTo(ix1, iy1);
1797 for(a=a1+aStep; a<=a2cp; a+=aStep)
1799 k2x = RS_Math::round(center.x+cos(a)*radius);
1800 k2y = RS_Math::round(center.y-sin(a)*radius);
1801 //if(graphic->isPointOnScreen(k2x, k2y) ||
1802 // graphic->isPointOnScreen(k1x, k1y) ) {
1803 //jlh createDirectPainter();
1804 painter->setPen(pen);
1805 if ((k2x >= 0 && k2x <= painter->getWidth()
1806 && k2y >= 0 && k2y <= painter->getHeight())
1807 || (k1x >= 0 && k1x <= painter->getWidth()
1808 && k1y >= 0 && k1y <= painter->getHeight()))
1810 //painter->lineTo(k2x, k2y);
1811 painter->drawLine(Vector(k1x, k1y), Vector(k2x, k2y));
1813 //graphic->simulationDelay();
1815 //createDirectPainter();
1816 //painter->setPen(pen);
1817 //painter->moveTo(k2x, k2y);
1823 //jlh createDirectPainter();
1824 painter->setPen(pen);
1825 painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2));
1826 //painter->lineTo(ix2, iy2);
1832 if (a1 < a2cp + 0.01)
1835 //createDirectPainter();
1836 //painter->setPen(pen);
1837 //painter->moveTo(ix1, iy1);
1838 for(a=a1-aStep; a>=a2cp; a-=aStep)
1840 k2x = RS_Math::round(center.x + cos(a) * radius);
1841 k2y = RS_Math::round(center.y - sin(a) * radius);
1842 //if(graphic->isPointOnScreen(k2x, k2y) ||
1843 // graphic->isPointOnScreen(k1x, k1y) ) {
1844 //jlh createDirectPainter();
1845 painter->setPen(pen);
1846 if ((k2x >=0 && k2x <= painter->getWidth()
1847 && k2y >= 0 && k2y <= painter->getHeight())
1848 || (k1x >= 0 && k1x <= painter->getWidth()
1849 && k1y >= 0 && k1y <= painter->getHeight()))
1851 //painter->lineTo(k2x, k2y);
1852 painter->drawLine(Vector(k1x, k1y), Vector(k2x, k2y));
1855 //createDirectPainter();
1856 //painter->setPen(pen);
1857 //painter->moveTo(k2x, k2y);
1862 //jlh createDirectPainter();
1863 painter->setPen(pen);
1864 //painter->lineTo(ix2, iy2);
1865 painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2));
1871 * @return Pointer to the static pattern struct that belongs to the
1872 * given pattern type or NULL.
1874 RS_LineTypePattern * GraphicView::getPattern(RS2::LineType t)
1878 case RS2::SolidLine:
1879 return &patternSolidLine;
1883 return &patternDotLine;
1886 return &patternDotLine2;
1888 case RS2::DotLineX2:
1889 return &patternDotLineX2;
1893 return &patternDashLine;
1895 case RS2::DashLine2:
1896 return &patternDashLine2;
1898 case RS2::DashLineX2:
1899 return &patternDashLineX2;
1902 case RS2::DashDotLine:
1903 return &patternDashDotLine;
1905 case RS2::DashDotLine2:
1906 return &patternDashDotLine2;
1908 case RS2::DashDotLineX2:
1909 return &patternDashDotLineX2;
1912 case RS2::DivideLine:
1913 return &patternDivideLine;
1915 case RS2::DivideLine2:
1916 return &patternDivideLine2;
1918 case RS2::DivideLineX2:
1919 return &patternDivideLineX2;
1922 case RS2::CenterLine:
1923 return &patternCenterLine;
1925 case RS2::CenterLine2:
1926 return &patternCenterLine2;
1928 case RS2::CenterLineX2:
1929 return &patternCenterLineX2;
1932 case RS2::BorderLine:
1933 return &patternBorderLine;
1935 case RS2::BorderLine2:
1936 return &patternBorderLine2;
1938 case RS2::BorderLineX2:
1939 return &patternBorderLineX2;
1942 case RS2::LineByLayer:
1943 return &patternBlockLine;
1945 case RS2::LineByBlock:
1946 return &patternBlockLine;
1956 * This virtual method can be overwritten to draw the absolute
1957 * zero. It's called from within drawIt(). The default implemetation
1958 * draws a simple red round zero point.
1960 * Actually, we have to rework the rendering code because the way that QCad did
1961 * it was wrong on so many levels... Part of that is making sure the rendering
1962 * path is 100% clear!
1966 void GraphicView::drawAbsoluteZero()
1973 // RS_Pen pen(metaGridColor, RS2::Width00, RS2::SolidLine);
1974 // painter->setPen(pen);
1975 // RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
1976 //Using Qt::red doesn't seem to work here...
1977 //It's because Qt colors and RS_Color are not 100% compatible...
1978 RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine);
1981 painter->drawLine(Vector(toGuiX(0.0) - zr, toGuiY(0.0)),
1982 Vector(toGuiX(0.0) + zr, toGuiY(0.0)));
1984 painter->drawLine(Vector(toGuiX(0.0), toGuiY(0.0) - zr),
1985 Vector(toGuiX(0.0), toGuiY(0.0) + zr));
1989 * This virtual method can be overwritten to draw the relative
1990 * zero point. It's called from within drawIt(). The default implemetation
1991 * draws a simple red round zero point.
1995 void GraphicView::drawRelativeZero()
1997 // PROBLEM: relativeZero IS NOT VALID!!!
1998 if (!relativeZero.valid || !painter)
2003 if (!relativeZero.valid)
2004 printf("GraphicView::drawRelativeZero(): relativeZero is NOT valid!!!\n");
2007 printf("GraphicView::drawRelativeZero(): painter is NOT valid!!!\n");
2013 // RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
2014 // p.setScreenWidth(0);
2015 //Using Qt::red doesn't seem to work here...
2016 RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine);
2018 painter->setXORMode();
2022 painter->drawLine(Vector(toGuiX(relativeZero.x) - zr, toGuiY(relativeZero.y)),
2023 Vector(toGuiX(relativeZero.x) + zr, toGuiY(relativeZero.y)));
2025 painter->drawLine(Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) - zr),
2026 Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) + zr));
2028 painter->drawCircle(toGui(relativeZero), zr);
2029 painter->setNormalMode();
2033 * Draws the paper border (for print previews).
2037 void GraphicView::drawPaper()
2042 Drawing * graphic = container->getGraphic();
2047 if (graphic->getPaperScale() < 1.0e-6)
2054 painter->setPen(RS_Pen(Qt::gray));
2056 Vector pinsbase = graphic->getPaperInsertionBase();
2057 Vector size = graphic->getPaperSize();
2058 double scale = graphic->getPaperScale();
2060 Vector v1 = toGui((Vector(0, 0) - pinsbase) / scale);
2061 Vector v2 = toGui((size - pinsbase) / scale);
2064 painter->fillRect(0,0, getWidth(), getHeight(), RS_Color(200, 200, 200));
2067 painter->fillRect((int)(v1.x) + 6, (int)(v1.y) + 6,
2068 (int)((v2.x - v1.x)), (int)((v2.y - v1.y)), RS_Color(64, 64, 64));
2071 painter->fillRect((int)(v1.x), (int)(v1.y),
2072 (int)((v2.x - v1.x)), (int)((v2.y - v1.y)), RS_Color(64, 64, 64));
2075 painter->fillRect((int)(v1.x) + 1, (int)(v1.y) - 1,
2076 (int)((v2.x - v1.x)) - 2, (int)((v2.y - v1.y)) + 2, RS_Color(255, 255, 255));
2084 void GraphicView::drawGrid()
2086 if (!grid || isGridOn() == false)
2088 // printf("GraphicView::drawGrid(): Aborting: grid=%08X, isGridOn=%s\n", grid, (isGridOn() ? "true" : "false"));
2093 painter->setPen(gridColor);
2095 //Problem here: pts is NULL!
2096 Vector * pts = grid->getPoints();
2100 for(int i=0; i<grid->count(); ++i)
2101 painter->drawGridPoint(toGui(pts[i]));
2104 // printf("GraphicView::drawGrid(): pts == NULL!\n");
2107 QString info = grid->getInfo();
2108 updateGridStatusWidget(info);
2112 * Draws the meta grid.
2116 void GraphicView::drawMetaGrid()
2118 if (!grid || isGridOn() == false /*|| grid->getMetaSpacing()<0.0*/)
2124 RS_Pen pen(metaGridColor, RS2::Width00, RS2::DotLine);
2125 painter->setPen(pen);
2128 double * mx = grid->getMetaX();
2129 double * my = grid->getMetaY();
2133 for(int i=0; i<grid->countMetaX(); ++i)
2134 painter->drawLine(Vector(toGuiX(mx[i]), 0), Vector(toGuiX(mx[i]), getHeight()));
2139 for(int i=0; i<grid->countMetaY(); ++i)
2140 painter->drawLine(Vector(0, toGuiY(my[i])), Vector(getWidth(), toGuiY(my[i])));
2145 * Updates the grid if there is one.
2147 void GraphicView::updateGrid()
2153 RS_Grid * GraphicView::getGrid()
2158 void GraphicView::updateGridStatusWidget(const QString & /*text*/)
2162 RS2::SnapMode GraphicView::getDefaultSnapMode()
2164 return defaultSnapMode;
2167 RS2::SnapRestriction GraphicView::getSnapRestriction()
2169 return defaultSnapRes;
2173 * Sets the default snap mode used by newly created actions.
2175 void GraphicView::setDefaultSnapMode(RS2::SnapMode sm)
2177 defaultSnapMode = sm;
2180 eventHandler->setSnapMode(sm);
2182 //OK, the above sets the snap mode in the snapper that's derived from
2183 //the RS_ActionInterface and RS_Snapper. So the following should fix
2184 //us up, hm notwithstanding. [and it does. :-)]
2186 snapper.setSnapMode(sm);
2190 * Sets a snap restriction (e.g. orthogonal).
2192 void GraphicView::setSnapRestriction(RS2::SnapRestriction sr)
2194 defaultSnapRes = sr;
2196 if (eventHandler != NULL)
2197 eventHandler->setSnapRestriction(sr);
2201 * Translates a vector in real coordinates to a vector in screen coordinates.
2203 Vector GraphicView::toGui(Vector v)
2205 return Vector(toGuiX(v.x), toGuiY(v.y), 0.0);
2209 * Translates a real coordinate in X to a screen coordinate X.
2210 * @param visible Pointer to a boolean which will contain true
2211 * after the call if the coordinate is within the visible range.
2213 double GraphicView::toGuiX(double x, bool * visible)
2215 if (visible != NULL)
2217 double res = x * factor.x + offsetX;
2219 if (res > 0.0 && res < getWidth())
2225 return x * factor.x + offsetX;
2229 * Translates a real coordinate in Y to a screen coordinate Y.
2231 double GraphicView::toGuiY(double y)
2233 return -y * factor.y + getHeight() - offsetY;
2237 * Translates a real coordinate distance to a screen coordinate distance.
2239 double GraphicView::toGuiDX(double d)
2241 return d * factor.x;
2245 * Translates a real coordinate distance to a screen coordinate distance.
2247 double GraphicView::toGuiDY(double d)
2249 return d * factor.y;
2253 * Translates a vector in screen coordinates to a vector in real coordinates.
2255 Vector GraphicView::toGraph(Vector v)
2257 return Vector(toGraphX(RS_Math::round(v.x)), toGraphY(RS_Math::round(v.y)), 0.0);
2261 * Translates two screen coordinates to a vector in real coordinates.
2263 Vector GraphicView::toGraph(int x, int y)
2265 return Vector(toGraphX(x), toGraphY(y), 0.0);
2269 * Translates a screen coordinate in X to a real coordinate X.
2271 double GraphicView::toGraphX(int x)
2273 return (x - offsetX) / factor.x;
2277 * Translates a screen coordinate in Y to a real coordinate Y.
2279 double GraphicView::toGraphY(int y)
2281 return -(y - getHeight() + offsetY) / factor.y;
2285 * Translates a screen coordinate distance to a real coordinate distance.
2287 double GraphicView::toGraphDX(int d)
2289 return d / factor.x;
2293 * Translates a screen coordinate distance to a real coordinate distance.
2295 double GraphicView::toGraphDY(int d)
2297 return d / factor.y;
2301 * (Un-)Locks the position of the relative zero.
2303 * @param lock true: lock, false: unlock
2305 void GraphicView::lockRelativeZero(bool lock)
2307 relativeZeroLocked = lock;
2311 * @return true if the position of the realtive zero point is
2314 bool GraphicView::isRelativeZeroLocked()
2316 return relativeZeroLocked;
2320 * @return Relative zero coordinate.
2322 Vector GraphicView::getRelativeZero()
2324 return relativeZero;
2328 * Sets the relative zero coordinate (if not locked)
2329 * without deleting / drawing the point.
2331 void GraphicView::setRelativeZero(const Vector & pos)
2333 if (!relativeZeroLocked)
2338 * Sets the relative zero coordinate, deletes the old position
2339 * on the screen and draws the new one.
2341 void GraphicView::moveRelativeZero(const Vector & pos)
2343 //this is crap. we're taking this shit out.
2344 //#warning "!!! GraphicView::moveRelativeZero(): Bad render path !!!"
2348 //painter->setXORMode();
2349 // drawRelativeZero();
2350 setRelativeZero(pos);
2351 // drawRelativeZero();
2354 RS_EventHandler * GraphicView::getEventHandler()
2356 return eventHandler;
2360 * Enables or disables print preview.
2362 void GraphicView::setPrintPreview(bool pv)
2368 * @retval true This is a print preview graphic view.
2369 * @retval false Otherwise.
2371 bool GraphicView::isPrintPreview()
2373 return printPreview;
2377 * Enables or disables printing.
2379 void GraphicView::setPrinting(bool p)
2385 * @retval true This is a a graphic view for printing.
2386 * @retval false Otherwise.
2388 bool GraphicView::isPrinting()
2394 * @retval true Draft mode is on for this view (all lines with 1 pixel / no style scaling).
2395 * @retval false Otherwise.
2397 bool GraphicView::isDraftMode()
2403 * Sets the simulation speed in percentage.
2405 void GraphicView::setSimulationSpeed(int s)
2407 simulationSpeed = s;
2411 * @return the simulation speed in percentage.
2413 int GraphicView::getSimulationSpeed()
2415 return simulationSpeed;
2419 * Sets the simulation smooth mode.
2421 void GraphicView::setSimulationSmooth(bool s)
2423 simulationSmooth = s;
2426 * Sets the simulation rapid mode.
2428 void GraphicView::setSimulationRapid(bool r)
2430 simulationRapid = r;
2434 * @return the simulation rapid mode.
2436 bool GraphicView::getSimulationRapid()
2438 return simulationRapid;
2441 // These functions are here because of the focacta way that this
2442 // program set up its rendering...
2443 void GraphicView::SetPreviewMode(bool mode/*= true*/)
2448 void GraphicView::SetPreviewEntity(RS_Preview * p)
2453 void GraphicView::SetPreviewOffset(Vector o)
2458 //Don't need this no more...
2460 void GraphicView::SetSnapperDraw(bool mode)
2465 void GraphicView::SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs)
2467 snapSpot1 = snapSpot;
2468 snapCoord1 = snapCoord;
2469 showCrosshairs1 = showCrosshairs;