-public:
- RS_GraphicView();
- virtual ~RS_GraphicView();
-
- void cleanUp();
-
- Drawing * getGraphic();
- void setDrawingMode(RS2::DrawingMode m);
- RS2::DrawingMode getDrawingMode();
- void setDeleteMode(bool m);
- bool getDeleteMode();
-
- /** This virtual method must be overwritten to return
- the width of the widget the graphic is shown in */
- virtual int getWidth() = 0;
- /** This virtual method must be overwritten to return
- the height of the widget the graphic is shown in */
- virtual int getHeight() = 0;
- /** This virtual method must be overwritten to redraw
- the widget. */
- virtual void redraw() = 0;
- /** This virtual method must be overwritten and is then
- called whenever the view changed */
- virtual void adjustOffsetControls();
- /** This virtual method must be overwritten and is then
- called whenever the view changed */
- virtual void adjustZoomControls();
- /**
- * Sets an external painter device.
- */
- virtual void setPainter(PaintInterface * p);
-// virtual void setPainter(RS_Painter * p);
- /** This virtual method must be overwritten and must return
- the painter device for the buffer of this widget */
- virtual PaintInterface * createPainter() = 0;
-// virtual RS_Painter * createPainter() = 0;
- /**
- * This virtual method must be overwritten and must return
- * the direct painter device for this widget
- */
- virtual PaintInterface * createDirectPainter() = 0;
-// virtual RS_Painter * createDirectPainter() = 0;
- /**
- * This virtual method must be overwritten and must destroy
- * the painter device and point 'painter' to NULL. If the painter
- * is static during the whole life of the application, it might
- * just do nothing.
- */
- virtual void destroyPainter() = 0;
-
- virtual void setBackground(const RS_Color & bg);
- RS_Color getBackground();
- RS_Color getForeground();
- void setGridColor(const RS_Color & c);
- void setMetaGridColor(const RS_Color & c);
- void setSelectedColor(const RS_Color & c);
- void setHighlightedColor(const RS_Color & c);
- virtual void setMouseCursor(RS2::CursorType /*c*/);
- void setContainer(RS_EntityContainer * container);
- RS_EntityContainer* getContainer();
- void setFactor(double f);
- void setFactorX(double f);
- void setFactorY(double f);
- Vector getFactor();
- void setOffset(int ox, int oy);
- void setOffsetX(int ox);
- void setOffsetY(int oy);
- int getOffsetX();
- int getOffsetY();
- void centerOffsetX();
- void centerOffsetY();
- void centerX(double x);
- void centerY(double y);
- virtual void updateView();
- void setBorders(int left, int top, int right, int bottom);
- int getBorderLeft();
- int getBorderTop();
- int getBorderRight();
- int getBorderBottom();
- void disableUpdate();
- void enableUpdate();
- bool isUpdateEnabled();
- void freezeZoom(bool freeze);
- bool isZoomFrozen();
-
- void setDefaultAction(RS_ActionInterface * action);
- RS_ActionInterface * getDefaultAction();
- void setCurrentAction(RS_ActionInterface * action);
- RS_ActionInterface * getCurrentAction();
-
- void killSelectActions();
- void killAllActions();
-
- /**
- * Must be overwritten to emulate a mouse move event with
- * the last known mouse position.
- *
- * @see mx, my
- */
- virtual void emulateMouseMoveEvent() = 0;
-
- void back();
- void enter();
-
- void mousePressEvent(QMouseEvent * e);
- void mouseReleaseEvent(QMouseEvent * e);
- void mouseMoveEvent(QMouseEvent * e);
- void mouseLeaveEvent();
- void mouseEnterEvent();
- void keyPressEvent(QKeyEvent * e);
- void keyReleaseEvent(QKeyEvent * e);
- void commandEvent(RS_CommandEvent * e);
- void enableCoordinateInput();
- void disableCoordinateInput();
-
- virtual void zoomIn(double f = 1.5, const Vector & center = Vector(false));
- virtual void zoomInX(double f = 1.5);
- virtual void zoomInY(double f = 1.5);
- virtual void zoomOut(double f = 1.5, const Vector & center = Vector(false));
- virtual void zoomOutX(double f = 1.5);
- virtual void zoomOutY(double f = 1.5);
- virtual void zoomAuto(bool axis = true, bool keepAspectRatio = true);
- virtual void zoomAutoY(bool axis = true);
- virtual void zoomPrevious();
- virtual void saveView();
- virtual void restoreView();
- virtual void zoomWindow(Vector v1, Vector v2, bool keepAspectRatio = true);
- //virtual void zoomPan(Vector v1);
- virtual void zoomPan(int dx, int dy);
- virtual void zoomScroll(RS2::Direction direction);
- virtual void zoomPage();
-
- virtual void drawWindow(Vector v1, Vector v2);
- virtual void drawIt();
- virtual void deleteEntity(RS_Entity * e);
- virtual void drawEntity(RS_Entity * e, double patternOffset = 0.0, bool db = false);
- virtual void drawEntityPlain(RS_Entity * e, double patternOffset = 0.0);
- virtual void setPenForEntity(RS_Entity * e);
-
- void simulateIt();
- void simulateEntity(RS_Entity * e, const RS_Pen & pen);
- void drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen);
- void drawArcSmooth(const Vector & center, double radius,
- double a1, double a2, bool rev, const RS_Pen & pen);
- void simulationDelay(bool step = false);
-
- virtual RS_LineTypePattern * getPattern(RS2::LineType t);
-
- virtual void drawAbsoluteZero();
- virtual void drawRelativeZero();
- virtual void drawPaper();
- virtual void drawGrid();
- virtual void drawMetaGrid();
- virtual void updateGrid();
- RS_Grid * getGrid();
- virtual void updateGridStatusWidget(const QString & /*text*/);
-
- void setDefaultSnapMode(RS2::SnapMode sm);
- RS2::SnapMode getDefaultSnapMode();
- void setSnapRestriction(RS2::SnapRestriction sr);
- RS2::SnapRestriction getSnapRestriction();
- bool isGridOn();
-
- Vector toGui(Vector v);
- double toGuiX(double x, bool * visible = NULL);
- double toGuiY(double y);
- double toGuiDX(double d);
- double toGuiDY(double d);
-
- Vector toGraph(Vector v);
- Vector toGraph(int x, int y);
- double toGraphX(int x);
- double toGraphY(int y);
- double toGraphDX(int d);
- double toGraphDY(int d);
-
- void lockRelativeZero(bool lock);
- bool isRelativeZeroLocked();
- Vector getRelativeZero();
- void setRelativeZero(const Vector & pos);
- void moveRelativeZero(const Vector & pos);
-
- RS_EventHandler * getEventHandler();
- void setPrintPreview(bool pv);
- bool isPrintPreview();
- void setPrinting(bool p);
- bool isPrinting();
- bool isDraftMode();
- void setSimulationSpeed(int s);
- int getSimulationSpeed();
- void setSimulationSmooth(bool s);
- void setSimulationRapid(bool r);
- bool getSimulationRapid();
-
- //this is here because of crappy braindead infrastructure
- void SetPreviewMode(bool mode = true);
- void SetPreviewEntity(RS_Preview *);
- void SetPreviewOffset(Vector);
- void SetSnapperDraw(bool);
- void SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs);
-
-protected:
- RS_EntityContainer * container;
- RS_EventHandler * eventHandler;
-
- int mx; //!< Last known mouse cursor position
- int my; //!< Last known mouse cursor position
-
-// RS_Painter * painter;
- PaintInterface * painter;
- /** background color (any color) */
- RS_Color background;
- /** foreground color (black or white) */
- RS_Color foreground;
- /** grid color */
- RS_Color gridColor;
- /** meta grid color */
- RS_Color metaGridColor;
- /** selected color */
- RS_Color selectedColor;
- /** highlighted color */
- RS_Color highlightedColor;
- /** Grid */
- RS_Grid * grid;
- /**
- * Current default snap mode for this graphic view. Used for new
- * actions.
- */
- RS2::SnapMode defaultSnapMode;
- /**
- * Current default snap restriction for this graphic view. Used for new
- * actions.
- */
- RS2::SnapRestriction defaultSnapRes;
-
- RS2::DrawingMode drawingMode;
-
- /**
- * Delete mode. If true, all drawing actions will delete in background color
- * instead.
- */
- bool deleteMode;
- //! If true, the simulation is currectly running
- bool simulationRunning;
-
-private:
- int updateEnabled;
- bool zoomFrozen;
- //bool gridVisible;
- bool draftMode;
-
- Vector factor;
- int offsetX;
- int offsetY;
-
- Vector previousFactor;
- int previousOffsetX;
- int previousOffsetY;
-
- int borderLeft;
- int borderTop;
- int borderRight;
- int borderBottom;
-
- Vector relativeZero;
- bool relativeZeroLocked;
- //! Print preview flag
- bool printPreview;
- //! Active when printing only:
- bool printing;
- //int drawRecursion;
-
- //! Simulation speed in percentage
- int simulationSpeed;
- //! If true, the entity is drawn slowly (pixel by pixel).
- bool simulationSmooth;
- //! If true, the way between entities is also shown.
- bool simulationRapid;
- //! Last position (for rapid move)
- Vector simulationLast;
-
-protected:
- // crap to make painting with update() possible
- RS_Preview * previewEntity;
- bool previewMode;
- Vector previewOffset;
- bool snapperDraw;
- Vector snapSpot1;
- Vector snapCoord1;
- bool showCrosshairs1;
+ public:
+ RS_GraphicView();
+ virtual ~RS_GraphicView();
+
+ void cleanUp();
+
+ Drawing * getGraphic();
+ void setDrawingMode(RS2::DrawingMode m);
+ RS2::DrawingMode getDrawingMode();
+ void setDeleteMode(bool m);
+ bool getDeleteMode();
+
+ /** This virtual method must be overwritten to return
+ the width of the widget the graphic is shown in */
+ virtual int getWidth() = 0;
+ /** This virtual method must be overwritten to return
+ the height of the widget the graphic is shown in */
+ virtual int getHeight() = 0;
+ /** This virtual method must be overwritten to redraw
+ the widget. */
+ virtual void redraw() = 0;
+ /** This virtual method must be overwritten and is then
+ called whenever the view changed */
+ virtual void adjustOffsetControls();
+ /** This virtual method must be overwritten and is then
+ called whenever the view changed */
+ virtual void adjustZoomControls();
+ /**
+ * Sets an external painter device.
+ */
+ virtual void setPainter(PaintInterface * p);
+
+// We're removing this crap...
+#if 0
+ /** This virtual method must be overwritten and must return
+ the painter device for the buffer of this widget */
+// virtual PaintInterface * createPainter() = 0;
+ /**
+ * This virtual method must be overwritten and must return
+ * the direct painter device for this widget
+ */
+// virtual PaintInterface * createDirectPainter() = 0;
+ /**
+ * This virtual method must be overwritten and must destroy
+ * the painter device and point 'painter' to NULL. If the painter
+ * is static during the whole life of the application, it might
+ * just do nothing.
+ */
+// virtual void destroyPainter() = 0;
+#endif
+
+ virtual void setBackground(const RS_Color & bg);
+ RS_Color getBackground();
+ RS_Color getForeground();
+ void setGridColor(const RS_Color & c);
+ void setMetaGridColor(const RS_Color & c);
+ void setSelectedColor(const RS_Color & c);
+ void setHighlightedColor(const RS_Color & c);
+ virtual void setMouseCursor(RS2::CursorType /*c*/);
+ void setContainer(RS_EntityContainer * container);
+ RS_EntityContainer * getContainer();
+ void setFactor(double f);
+ void setFactorX(double f);
+ void setFactorY(double f);
+ Vector getFactor();
+ void setOffset(int ox, int oy);
+ void setOffsetX(int ox);
+ void setOffsetY(int oy);
+ int getOffsetX();
+ int getOffsetY();
+ void centerOffsetX();
+ void centerOffsetY();
+ void centerX(double x);
+ void centerY(double y);
+ virtual void updateView();
+ void setBorders(int left, int top, int right, int bottom);
+ int getBorderLeft();
+ int getBorderTop();
+ int getBorderRight();
+ int getBorderBottom();
+ void disableUpdate();
+ void enableUpdate();
+ bool isUpdateEnabled();
+ void freezeZoom(bool freeze);
+ bool isZoomFrozen();
+
+ void setDefaultAction(RS_ActionInterface * action);
+ RS_ActionInterface * getDefaultAction();
+ void setCurrentAction(RS_ActionInterface * action);
+ RS_ActionInterface * getCurrentAction();
+
+ void killSelectActions();
+ void killAllActions();
+
+ /**
+ * Must be overwritten to emulate a mouse move event with
+ * the last known mouse position.
+ *
+ * @see mx, my
+ */
+ virtual void emulateMouseMoveEvent() = 0;
+
+ void back();
+ void enter();
+
+ void mousePressEvent(QMouseEvent * e);
+ void mouseReleaseEvent(QMouseEvent * e);
+ void mouseMoveEvent(QMouseEvent * e);
+ void mouseLeaveEvent();
+ void mouseEnterEvent();
+ void keyPressEvent(QKeyEvent * e);
+ void keyReleaseEvent(QKeyEvent * e);
+ void commandEvent(RS_CommandEvent * e);
+ void enableCoordinateInput();
+ void disableCoordinateInput();
+
+ virtual void zoomIn(double f = 1.5, const Vector & center = Vector(false));
+ virtual void zoomInX(double f = 1.5);
+ virtual void zoomInY(double f = 1.5);
+ virtual void zoomOut(double f = 1.5, const Vector & center = Vector(false));
+ virtual void zoomOutX(double f = 1.5);
+ virtual void zoomOutY(double f = 1.5);
+ virtual void zoomAuto(bool axis = true, bool keepAspectRatio = true);
+ virtual void zoomAutoY(bool axis = true);
+ virtual void zoomPrevious();
+ virtual void saveView();
+ virtual void restoreView();
+ virtual void zoomWindow(Vector v1, Vector v2, bool keepAspectRatio = true);
+ //virtual void zoomPan(Vector v1);
+ virtual void zoomPan(int dx, int dy);
+ virtual void zoomScroll(RS2::Direction direction);
+ virtual void zoomPage();
+
+ virtual void drawWindow(Vector v1, Vector v2);
+ virtual void drawIt();
+ virtual void deleteEntity(RS_Entity * e);
+ virtual void drawEntity(RS_Entity * e, double patternOffset = 0.0, bool db = false);
+ virtual void drawEntityPlain(RS_Entity * e, double patternOffset = 0.0);
+ virtual void setPenForEntity(RS_Entity * e);
+
+ void simulateIt();
+ void simulateEntity(RS_Entity * e, const RS_Pen & pen);
+ void drawLineSmooth(const Vector & p1, const Vector & p2, const RS_Pen & pen);
+ void drawArcSmooth(const Vector & center, double radius,
+ double a1, double a2, bool rev, const RS_Pen & pen);
+ void simulationDelay(bool step = false);
+
+ virtual RS_LineTypePattern * getPattern(RS2::LineType t);
+
+ virtual void drawAbsoluteZero();
+ virtual void drawRelativeZero();
+ virtual void drawPaper();
+ virtual void drawGrid();
+ virtual void drawMetaGrid();
+ virtual void updateGrid();
+ RS_Grid * getGrid();
+ virtual void updateGridStatusWidget(const QString & /*text*/);
+
+ void setDefaultSnapMode(RS2::SnapMode sm);
+ RS2::SnapMode getDefaultSnapMode();
+ void setSnapRestriction(RS2::SnapRestriction sr);
+ RS2::SnapRestriction getSnapRestriction();
+ bool isGridOn();
+
+ Vector toGui(Vector v);
+ double toGuiX(double x, bool * visible = NULL);
+ double toGuiY(double y);
+ double toGuiDX(double d);
+ double toGuiDY(double d);
+
+ Vector toGraph(Vector v);
+ Vector toGraph(int x, int y);
+ double toGraphX(int x);
+ double toGraphY(int y);
+ double toGraphDX(int d);
+ double toGraphDY(int d);
+
+ void lockRelativeZero(bool lock);
+ bool isRelativeZeroLocked();
+ Vector getRelativeZero();
+ void setRelativeZero(const Vector & pos);
+ void moveRelativeZero(const Vector & pos);
+
+ RS_EventHandler * getEventHandler();
+ void setPrintPreview(bool pv);
+ bool isPrintPreview();
+ void setPrinting(bool p);
+ bool isPrinting();
+ bool isDraftMode();
+ void setSimulationSpeed(int s);
+ int getSimulationSpeed();
+ void setSimulationSmooth(bool s);
+ void setSimulationRapid(bool r);
+ bool getSimulationRapid();
+
+ //this is here because of crappy braindead infrastructure
+ void SetPreviewMode(bool mode = true);
+ void SetPreviewEntity(RS_Preview *);
+ void SetPreviewOffset(Vector);
+ void SetSnapperDraw(bool);
+ void SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs);
+
+ protected:
+ RS_EntityContainer * container;
+ RS_EventHandler * eventHandler;
+
+ int mx; //!< Last known mouse cursor position
+ int my; //!< Last known mouse cursor position
+
+ // RS_Painter * painter;
+ PaintInterface * painter;
+ /** background color (any color) */
+ RS_Color background;
+ /** foreground color (black or white) */
+ RS_Color foreground;
+ /** grid color */
+ RS_Color gridColor;
+ /** meta grid color */
+ RS_Color metaGridColor;
+ /** selected color */
+ RS_Color selectedColor;
+ /** highlighted color */
+ RS_Color highlightedColor;
+ /** Grid */
+ RS_Grid * grid;
+ /**
+ * Current default snap mode for this graphic view. Used for new
+ * actions.
+ */
+ RS2::SnapMode defaultSnapMode;
+ /**
+ * Current default snap restriction for this graphic view. Used for new
+ * actions.
+ */
+ RS2::SnapRestriction defaultSnapRes;
+
+ RS2::DrawingMode drawingMode;
+
+ /**
+ * Delete mode. If true, all drawing actions will delete in background color
+ * instead.
+ */
+ bool deleteMode;
+ //! If true, the simulation is currectly running
+ bool simulationRunning;
+
+ private:
+ int updateEnabled;
+ bool zoomFrozen;
+ //bool gridVisible;
+ bool draftMode;
+
+ Vector factor;
+ int offsetX;
+ int offsetY;
+
+ Vector previousFactor;
+ int previousOffsetX;
+ int previousOffsetY;
+
+ int borderLeft;
+ int borderTop;
+ int borderRight;
+ int borderBottom;
+
+ Vector relativeZero;
+ bool relativeZeroLocked;
+ //! Print preview flag
+ bool printPreview;
+ //! Active when printing only:
+ bool printing;
+ //int drawRecursion;
+
+ //! Simulation speed in percentage
+ int simulationSpeed;
+ //! If true, the entity is drawn slowly (pixel by pixel).
+ bool simulationSmooth;
+ //! If true, the way between entities is also shown.
+ bool simulationRapid;
+ //! Last position (for rapid move)
+ Vector simulationLast;
+
+ protected:
+ // crap to make painting with update() possible
+ RS_Preview * previewEntity;
+ bool previewMode;
+ Vector previewOffset;
+ bool snapperDraw;
+ Vector snapSpot1;
+ Vector snapCoord1;
+ bool showCrosshairs1;