#define __GRAPHICVIEW_H__
#include <QtGui>
-#include "rs.h"
-#include "rs_color.h"
-#include "rs_snapper.h"
+#include "enums.h"
+#include "color.h"
+#include "preview.h"
+#include "snapper.h"
#include "vector.h"
+class ActionInterface;
+class CommandEvent;
class Drawing;
class PaintInterface;
-class RS_EntityContainer;
-class RS_ActionInterface;
-class RS_Entity;
-class RS_LineTypePattern;
-class RS_CommandEvent;
-class Vector;
-class RS_Preview;
-class RS_Grid;
-class RS_Pen;
-class RS_EventHandler;
+class Entity;
+class EntityContainer;
+class EventHandler;
+class Grid;
+class LineTypePattern;
+class Pen;
class GraphicView
{
/** 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 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 setBackground(const Color & bg);
+ Color getBackground();
+ Color getForeground();
+ void setGridColor(const Color & c);
+ void setMetaGridColor(const Color & c);
+ void setSelectedColor(const Color & c);
+ void setHighlightedColor(const Color & c);
virtual void setMouseCursor(RS2::CursorType /*c*/);
- void setContainer(RS_EntityContainer * container);
- RS_EntityContainer * getContainer();
+ void setContainer(EntityContainer * container);
+ EntityContainer * getContainer();
void setFactor(double f);
void setFactorX(double f);
void setFactorY(double f);
void freezeZoom(bool freeze);
bool isZoomFrozen();
- void setDefaultAction(RS_ActionInterface * action);
- RS_ActionInterface * getDefaultAction();
- void setCurrentAction(RS_ActionInterface * action);
- RS_ActionInterface * getCurrentAction();
+ void setDefaultAction(ActionInterface * action);
+ ActionInterface * getDefaultAction();
+ void setCurrentAction(ActionInterface * action);
+ ActionInterface * getCurrentAction();
void killSelectActions();
void killAllActions();
void mouseEnterEvent();
void keyPressEvent(QKeyEvent * e);
void keyReleaseEvent(QKeyEvent * e);
- void commandEvent(RS_CommandEvent * e);
+ void commandEvent(CommandEvent * e);
void enableCoordinateInput();
void disableCoordinateInput();
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);
+ virtual void drawEntity(Entity * e, double patternOffset = 0.0, bool db = false);
+ virtual void drawEntityPlain(Entity * e, double patternOffset = 0.0);
+ virtual void setPenForEntity(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 simulateEntity(Entity * e, const Pen & pen);
+ void drawLineSmooth(const Vector & p1, const Vector & p2, const Pen & pen);
void drawArcSmooth(const Vector & center, double radius,
- double a1, double a2, bool rev, const RS_Pen & pen);
+ double a1, double a2, bool rev, const Pen & pen);
void simulationDelay(bool step = false);
- virtual RS_LineTypePattern * getPattern(RS2::LineType t);
+ virtual LineTypePattern * getPattern(RS2::LineType t);
virtual void drawAbsoluteZero();
virtual void drawRelativeZero();
virtual void drawGrid();
virtual void drawMetaGrid();
virtual void updateGrid();
- RS_Grid * getGrid();
+ Grid * getGrid();
virtual void updateGridStatusWidget(const QString & /*text*/);
void setDefaultSnapMode(RS2::SnapMode sm);
RS2::SnapRestriction getSnapRestriction();
bool isGridOn();
+/*
+What to do about this shiatsu? This stuff is used in the snapper rendering
+code... Maybe move all the snapper rendering back into this class???
+Seems to make sense, though it kinda blows encapsulation. But it's already
+blown by the snapper class having to use these functions in the first place!
+
+How to fix???
+
+The snapper as a separate class makes sense, since it has several functions
+for finding various snapping points. But what about rendering???
+
+Having this class derive from that one *might* make sense... *Maybe*. Not sure.
+
+*/
Vector toGui(Vector v);
double toGuiX(double x, bool * visible = NULL);
double toGuiY(double y);
void setRelativeZero(const Vector & pos);
void moveRelativeZero(const Vector & pos);
- RS_EventHandler * getEventHandler();
+ EventHandler * getEventHandler();
void setPrintPreview(bool pv);
bool isPrintPreview();
void setPrinting(bool p);
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);
+ Entity * CatchEntity(const Vector &, RS2::ResolveLevel level = RS2::ResolveNone);
+ Entity * CatchEntity(QMouseEvent *, RS2::ResolveLevel level = RS2::ResolveNone);
+ Entity * GetSnapperEntity(void);
+ Vector SnapPoint(QMouseEvent *);
+ Vector SnapGrid(Vector);
+ void DrawSnapper(PaintInterface *);
+ void SetSnapperVisible(bool visibility = true);
+ bool SnapperVisible(void);
protected:
- RS_EntityContainer * container;
- RS_EventHandler * eventHandler;
-
- int mx; //!< Last known mouse cursor position
- int my; //!< Last known mouse cursor position
-
+ EntityContainer * container;
+ EventHandler * eventHandler;
+ int mx; //!< Last known mouse cursor position
+ int my; //!< Last known mouse cursor position
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;
+ Color background; //! background color (any color)
+ Color foreground; //! foreground color (black or white)
+ Color gridColor; //! grid color
+ Color metaGridColor; //! meta grid color
+ Color selectedColor; //! selected color
+ Color highlightedColor; //! highlighted color
+ Grid * grid; //! Grid
/**
- * Current default snap mode for this graphic view. Used for new
- * actions.
- */
+ * 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.
- */
+ * 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.
- */
+ * Delete mode. If true, all drawing actions will delete in background color
+ * instead.
+ */
bool deleteMode;
- //! If true, the simulation is currectly running
- bool simulationRunning;
+ bool simulationRunning; //! If true, the simulation is currectly running
+ double snapDistance; //! Manually set snap distance
+ Entity * snapEntity; //! Entity to snap to (if any)
+ Vector snapSpot;
+ Vector snapCoord;
+ bool snapperVisible; //! Snapper visibility
+ int snapRange;
+ bool showCrosshairs; //! Snapper crosshair visibility
private:
int updateEnabled;
bool zoomFrozen;
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;
-
- //! 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;
+ bool printPreview; //! Print preview flag
+ bool printing; //! Active when printing only:
+ int simulationSpeed; //! Simulation speed in percentage
+ bool simulationSmooth; //! If true, the entity is drawn slowly (pixel by pixel).
+ bool simulationRapid; //! If true, the way between entities is also shown.
+ Vector simulationLast; //! Last position (for rapid move)
public://for now
// We use this here instead of deriving ActionInterface from it because
// this makes more sense.
- RS_Snapper snapper;
-
- protected:
- // crap to make painting with update() possible
- RS_Preview * previewEntity;
- bool previewMode;
- Vector previewOffset;
- bool snapperDraw;
- Vector snapSpot1;
- Vector snapCoord1;
- bool showCrosshairs1;
+// Snapper snapper;
+//yer next
+ Preview preview;
//QG
protected:
int lastWidth;
int lastHeight;
- //! Horizontal scrollbar.
- QScrollBar * hScrollBar;
- //! Vertical scrollbar.
- QScrollBar * vScrollBar;
-// //! Layout used to fit in the view and the scrollbars.
-// QGridLayout * layout;
- //! Label for grid spacing.
- QLabel * gridStatus;
- //! CAD mouse cursor
- QCursor * curCad;
- //! Delete mouse cursor
- QCursor * curDel;
- //! Select mouse cursor
- QCursor * curSelect;
- //! Magnifying glass mouse cursor
- QCursor * curMagnifier;
- //! Hand mouse cursor
- QCursor * curHand;
-
-//QC
+ QScrollBar * hScrollBar; //! Horizontal scrollbar.
+ QScrollBar * vScrollBar; //! Vertical scrollbar.
+ QLabel * gridStatus; //! Label for grid spacing.
+ QCursor * curCad; //! CAD mouse cursor
+ QCursor * curDel; //! Delete mouse cursor
+ QCursor * curSelect; //! Select mouse cursor
+ QCursor * curMagnifier; //! Magnifying glass mouse cursor
+ QCursor * curHand; //! Hand mouse cursor
+
+//QC was merged with QG
};
#endif // __GRAPHICVIEW_H__
#if 0
-class QG_GraphicView: public QWidget, public RS_GraphicView, //public Q3FilePreview,
- public RS_LayerListListener, public RS_BlockListListener
+class QG_GraphicView: public QWidget, public RS_GraphicView
{
Q_OBJECT
virtual void redraw();
virtual void adjustOffsetControls();
virtual void adjustZoomControls();
-// virtual RS_Painter * createPainter();
-// virtual RS_Painter * createDirectPainter();
-#warning "!!! Need to scrub out all instances of createPainter and createDirectPainter !!!"
-// virtual PaintInterface * createPainter();
-// virtual PaintInterface * createDirectPainter();
-// virtual void destroyPainter();
- virtual void setBackground(const RS_Color & bg);
+ virtual void setBackground(const Color & bg);
virtual void setMouseCursor(RS2::CursorType c);
virtual void updateGridStatusWidget(const QString & text);
- // Methods from RS_LayerListListener Interface:
- virtual void layerEdited(RS_Layer *);
- virtual void layerRemoved(RS_Layer *);
- virtual void layerToggled(RS_Layer *);
-
protected:
virtual void emulateMouseMoveEvent();
virtual void mousePressEvent(QMouseEvent * e);
void paintEvent(QPaintEvent *);
virtual void resizeEvent(QResizeEvent * e);
-#warning "!!! File preview needs porting to Qt4 !!!"
-// void previewUrl(const Q3Url &u);
-
private slots:
void slotHScrolled(int value);
void slotVScrolled(int value);
-
- private:
-#warning "!!! Double buffering is not necessary anymore !!!"
- //! Buffer for double-buffering
- QPixmap * buffer;
-// int refCount;
-
- protected:
- int lastWidth;
- int lastHeight;
- //! Horizontal scrollbar.
- QG_ScrollBar * hScrollBar;
- //! Vertical scrollbar.
- QG_ScrollBar * vScrollBar;
- //! Layout used to fit in the view and the scrollbars.
- QGridLayout * layout;
- //! Label for grid spacing.
- QLabel * gridStatus;
- //! CAD mouse cursor
- QCursor * curCad;
- //! Delete mouse cursor
- QCursor * curDel;
- //! Select mouse cursor
- QCursor * curSelect;
- //! Magnifying glass mouse cursor
- QCursor * curMagnifier;
- //! Hand mouse cursor
- QCursor * curHand;
-};
-#endif
-
-#if 0
-class QC_GraphicView: public QG_GraphicView
-{
- public:
- QC_GraphicView(RS_Document * doc, QWidget * parent = 0);
- virtual ~QC_GraphicView();
-
- virtual void drawIt();
};
#endif