wxArt2D
rendimg.h
Go to the documentation of this file.
1 /*! \file wx/canextobj/rendimg.h
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: rendimg.h,v 1.10 2008/07/19 18:29:42 titato Exp $
9 */
10 
11 #ifndef __WXRENDIMG_H__
12 #define __WXRENDIMG_H__
13 
14 #ifndef WX_PRECOMP
15 #include "wx/wx.h"
16 #endif
17 
18 #include "wx/canvas/canobj.h"
19 
20 class A2DCANVASDLLEXP a2dCanvasDocument;
21 
22 #include "wx/canvas/drawer.h"
23 
24 
25 
26 //! a2dRenderImage is an a2dCanvasObject that is able to display a complete a2dCanvasDocument as a a2dCanvasObject.
27 /*!
28  It uses a bitmap to render the specified a2dCanvasDocument (a2dCanvasObject topobject) into.
29  And this bitmap is displayed when the a2dRenderImage is
30  rendered within the a2dCanvasDocument where this object itself belongs to.
31 
32  re-rendering the bitmap happens only when size of the object changes.
33 
34  Settings for background drawing and grid drawing is done through the a2dCanvasView member.
35 
36 \sa class: a2dCanvasView
37 \sa class: a2dCanvasDocument
38 \sa class: a2dCanvasObject
39 
40  \ingroup drawer canvasobject meta
41 */
42 class A2DEDITORDLLEXP a2dRenderImage: public a2dCanvasObject
43 {
44 public:
45 
46  a2dRenderImage( a2dCanvasObject* top, double xc, double yc, double w, double h );
47 
48  virtual ~a2dRenderImage();
49 
50  a2dRenderImage( const a2dRenderImage& other, CloneOptions options, a2dRefMap* refs );
51 
52  a2dDrawingPart* GetDrawingPart() { return m_drawingPart; }
53 
54  //!get y axis orientation
55  inline bool GetYaxis() const { return m_drawingPart->GetDrawer2D()->GetYaxis(); }
56 
57  //!set if the Yaxis goes up or down
58  virtual void SetYaxis( bool up ) { m_drawingPart->GetDrawer2D()->SetYaxis( up ); }
59 
60  //!background fill for the canvas
61  void SetBackgroundFill( const a2dFill& backgroundfill ) { m_drawingPart->SetBackgroundFill( backgroundfill ); }
62 
63  //!get current background fill for the canvas
64  a2dFill& GetBackgroundFill() { return m_drawingPart->GetBackgroundFill(); }
65 
66  //!Set grid setting for drawing grid in front or back
67  void SetGridAtFront( bool gridatfront ) { m_drawingPart->SetGridAtFront( gridatfront ); }
68 
69  //!Get grid setting for drawing grid in front or back
70  bool GetGridAtFront() { return m_drawingPart->GetGridAtFront(); }
71 
72  //!set stroke used for grid drawing
73  void SetGridStroke( const a2dStroke& gridstroke ) { m_drawingPart->SetGridStroke( gridstroke ); }
74 
75  //!set size of grid circle
76  void SetGridSize( int gridsize ) { m_drawingPart->SetGridSize( gridsize ); };
77 
78  //!set fill used for grid drawing
79  void SetGridFill( const a2dFill& gridfill ) { m_drawingPart->SetGridFill( gridfill ); }
80 
81  //!Get grid distance in X
82  double GetGridX() {return m_drawingPart->GetGridX();}
83 
84  //!Set grid distance in X
85  void SetGridX( double gridx ) { m_drawingPart->SetGridX( gridx ); }
86 
87  //!Get grid distance in Y
88  double GetGridY() { return m_drawingPart->GetGridY(); }
89 
90  //!Set grid distance in Y
91  void SetGridY( double gridy ) { m_drawingPart->SetGridY( gridy ); }
92 
93  //!Set grid on/off
94  void SetGrid( bool grid ) { m_drawingPart->SetGrid( grid ); }
95 
96  //!Get grid setting on/off
97  bool GetGrid() { return m_drawingPart->GetGrid(); }
98 
99  //!Get grid setting for line drawing
100  void SetGridLines( bool gridlines ) { m_drawingPart->SetGridLines( gridlines ); }
101 
102  //!set grid to draw lines instead of points
103  bool GetGridLines() { return m_drawingPart->GetGridLines(); }
104 
105  //!Set showorigin on/off
106  void SetShowOrigin( bool show ) { m_drawingPart->SetShowOrigin( show ); };
107 
108  /*! Give the virtual size to be displayed, the mappingmatrix will be calculated.
109  The current window size is used to at least display all of the area given.
110  !ex: Setting virtual area to boundingbox of a drawing (currently visible group)
111  !code: SetMappingWidthHeight(GetShowGroup()->GetXMin(),
112  !code: GetShowGroup()->GetYMin(),
113  !code: GetShowGroup()->GetWidth(),
114  !code: GetShowGroup()->GetHeight())
115  !comm: do not use during start up since window size is not well defined in that case resulting in
116  !comm: bad settings for the mapping.
117  */
118  void SetMappingWidthHeight( double vx1, double vy1, double width, double height );
119 
120  void SetMappingUpp( double vx1, double vy1, double xpp, double ypp );
121 
122  //!set mapping using absolute world coordinates of parent
123  void SetMappingAbs( a2dIterC& ic, double vx1, double vy1, double width, double height );
124 
125  //!set object available in the a2dCanvasDocument to be shown on the canvas
126  /*!
127  \param name: name of topobject
128  \return pointer to the object found else NULL
129  */
130  a2dCanvasObject* SetShowObject( const wxString& name );
131 
132  //!set top object available in the a2dCanvasDocument to be shown on the canvas
133  /*!
134  \param obj pointer to object to show
135  */
136  bool SetShowObject( a2dCanvasObject* obj );
137 
138  //!return pointer of then currently shown object on the canvas.
139  /*!
140  \return pointer to the current group that is shown.
141  */
142  a2dCanvasObject* GetShowObject() const;
143 
144  //!calculate for top the boundingbox's that became invalid.
145  /*!
146  If force is true, do them all.
147  */
148  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
149 
150  //!set if the drawing should be resclaed on a window resize
151  void SetScaleOnResize( bool val ) { m_scaleonresize = val; }
152 
153  //!get current setting for ScaleOnResize
154  virtual bool GetScaleOnResize() { return m_scaleonresize; }
155 
156  void SetWidth( double width );
157  double GetWidth() { return m_width; }
158 
159  void SetHeight( double height );
160  double GetHeight() { return m_height; }
161 
162  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
163 
164 protected:
165 
166  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
167  void DoRender( a2dIterC& ic, OVERLAP clipparent );
168  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
169 
170  //!background brush of canvas; and back ground color of background brush in case of mono colour brush
172 
173  //! showorigin?
175 
176  //! are scroll bars active?
178 
179  double m_width;
180  double m_height;
181 
182 
183 private:
184 
185  a2dSmrtPtr<a2dDrawingPart> m_drawingPart;
186 
187  // cache
188  bool m_is_cached;
189  wxImage m_cImage;
190  bool m_b_is_cached;
191  wxBitmap m_cBitmap;
192  int m_cW;
193  int m_cH;
194  double m_cR;
195 
196  DECLARE_CLASS( a2dRenderImage )
197 
198 private:
199  //!this is a not implemented copy constructor that avoids automatic creation of one
200  a2dRenderImage( const a2dRenderImage& other );
201 };
202 
203 
204 #endif /* __WXRENDIMG_H__ */
205 
206 
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
virtual bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: canobj.cpp:3713
bool GetGridAtFront()
Get grid setting for drawing grid in front or back.
Definition: rendimg.h:70
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: canobj.cpp:1426
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
void SetBackgroundFill(const a2dFill &backgroundfill)
background fill for the canvas
Definition: rendimg.h:61
void SetGridLines(bool gridlines)
Get grid setting for line drawing.
Definition: rendimg.h:100
Ref Counted base object.
Definition: gen.h:1045
a2dRenderImage is an a2dCanvasObject that is able to display a complete a2dCanvasDocument as a a2dCan...
Definition: rendimg.h:42
void SetGridSize(int gridsize)
set size of grid circle
Definition: rendimg.h:76
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
bool m_scaleonresize
are scroll bars active?
Definition: rendimg.h:177
The base class for all drawable objects in a a2dCanvasDocument.
bool GetYaxis() const
get y axis orientation
Definition: rendimg.h:55
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
double GetGridY()
Get grid distance in Y.
Definition: rendimg.h:88
void SetGridFill(const a2dFill &gridfill)
set fill used for grid drawing
Definition: rendimg.h:79
a2dFill m_backgroundfill
background brush of canvas; and back ground color of background brush in case of mono colour brush ...
Definition: rendimg.h:171
void SetGrid(bool grid)
Set grid on/off.
Definition: rendimg.h:94
bool GetGridLines()
set grid to draw lines instead of points
Definition: rendimg.h:103
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
void SetGridStroke(const a2dStroke &gridstroke)
set stroke used for grid drawing
Definition: rendimg.h:73
void SetGridAtFront(bool gridatfront)
Set grid setting for drawing grid in front or back.
Definition: rendimg.h:67
void SetGridY(double gridy)
Set grid distance in Y.
Definition: rendimg.h:91
void SetShowOrigin(bool show)
Set showorigin on/off.
Definition: rendimg.h:106
double GetGridX()
Get grid distance in X.
Definition: rendimg.h:82
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
bool GetGrid()
Get grid setting on/off.
Definition: rendimg.h:97
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
virtual a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: canobj.cpp:5031
virtual void SetYaxis(bool up)
set if the Yaxis goes up or down
Definition: rendimg.h:58
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canobj.cpp:5098
a2dFill & GetBackgroundFill()
get current background fill for the canvas
Definition: rendimg.h:64
virtual bool GetScaleOnResize()
get current setting for ScaleOnResize
Definition: rendimg.h:154
void SetGridX(double gridx)
Set grid distance in X.
Definition: rendimg.h:85
bool m_showorigin
showorigin?
Definition: rendimg.h:174
void SetScaleOnResize(bool val)
set if the drawing should be resclaed on a window resize
Definition: rendimg.h:151
CloneOptions
options for cloning
Definition: gen.h:1200
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
rendimg.h Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation