QCAD
Open Source 2D CAD
ROrthoGrid.h
Go to the documentation of this file.
1 
20 #ifndef RORTHOGRID_H
21 #define RORTHOGRID_H
22 
23 #include "grid_global.h"
24 
25 #include "RGrid.h"
26 
27 class RGraphicsView;
28 class RRuler;
29 
30 
31 
41 public:
43  virtual ~ROrthoGrid();
44 
45  virtual void clearCache();
46 
47  RVector snapToGrid(const RVector& positionUcs);
48  virtual void update(bool force=false);
49  virtual void paint();
50  virtual void paintMetaGrid();
51 
52  virtual void paintGridLines(const RVector& space, const RBox& box, bool meta);
53  virtual void paintGridPoints(const RVector& space, const RBox& box);
54 
55  virtual void paintCursor(const RVector& pos);
56 
57  virtual void paintRuler(RRuler& ruler, qreal devicePixelRatio = 1.0);
58 
59  virtual QString getInfoText();
60 
61  QList<RVector> getIdealSpacing(int minPixelSpacing, const RVector& minSpacing, const RVector& minMetaSpacing);
62 
63  // This is just an idea. This might update the grid for
64  // an entity that is viewed as elevation view. This might be at
65  // any angle.
66  //void updateGrid(REntity& entity);
67 
68  bool isIsometric() const;
69  void setIsometric(bool on);
70 
71  RS::IsoProjectionType getProjection() const;
72  void setProjection(RS::IsoProjectionType p);
73 
74  static QList<RVector> getIdealGridSpacing(RGraphicsView& view, int minPixelSpacing, const RVector& minSpacing, const RVector& minMetaSpacing);
75  static bool isFractionalFormat(RS::LinearFormat linearFormat);
76 
77 private:
78  static double inchAutoscale(double value, double idealSpacing, RS::Unit unit);
79 
80 private:
84 
85  // current grid spacing:
87  // automatically calculated grid spacing based on minimum
88  // grid spacing and minimum pixel spacing:
90  // minimum spacing:
92 
96 
97  bool scaleGrid;
99  QString infoText;
100 
101  // cached:
102  mutable int isometric;
103  mutable int projection;
104 };
105 
107 
108 #endif
Represents a box e.g.
Definition: RBox.h:43
int isometric
Definition: ROrthoGrid.h:102
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual RVector snapToGrid(const RVector &positionUcs)=0
Snaps the given UCS position to the grid.
virtual void paintCursor(const RVector &pos)=0
RVector metaSpacing
Definition: ROrthoGrid.h:93
virtual void paint()=0
This is called by the graphics view this grid is attached to whenever the grid should be painted...
int projection
Definition: ROrthoGrid.h:103
RVector autoMetaSpacing
Definition: ROrthoGrid.h:94
QString infoText
Definition: ROrthoGrid.h:99
RBox viewBox
Definition: ROrthoGrid.h:81
RVector minSpacing
Definition: ROrthoGrid.h:91
RBox gridBox
Definition: ROrthoGrid.h:82
bool scaleGrid
Definition: ROrthoGrid.h:97
Q_DECLARE_METATYPE(RMath *)
IsoProjectionType
Projection type for isometric projections.
Definition: RS.h:194
LinearFormat
Format for length values.
Definition: RS.h:251
int minPixelSpacing
Definition: ROrthoGrid.h:98
RBox metaGridBox
Definition: ROrthoGrid.h:83
RVector minMetaSpacing
Definition: ROrthoGrid.h:95
Abstract base class for grid implementations.
Definition: RGrid.h:39
Unit
Enum of supported units (values correspond to DXF spec).
Definition: RS.h:206
virtual void update(bool force=false)=0
This is called by the graphics view this grid is attached to whenever the view port changes and the g...
Grid representation.
Definition: ROrthoGrid.h:40
virtual void paintMetaGrid()=0
This is called by the graphics view this grid is attached to whenever the meta grid should be painted...
virtual QString getInfoText()=0
virtual void paintRuler(RRuler &ruler, qreal devicePixelRatio=1.0)=0
Abstract base class for widgets that display a ruler, usually shown at the top and left of a graphics...
Definition: RRuler.h:37
RVector spacing
Definition: ROrthoGrid.h:86
virtual void clearCache()
Definition: RGrid.cpp:31
RVector autoSpacing
Definition: ROrthoGrid.h:89
Graphics view.
Definition: RGraphicsView.h:58
#define QCADGRID_EXPORT
Definition: grid_global.h:10