wxArt2D
imageioh.h
Go to the documentation of this file.
1 /*! \file wx/canextobj/imageioh.h
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: imageioh.h,v 1.17 2009/10/01 19:22:35 titato Exp $
9 */
10 
11 #ifndef __A2D_WXIMAGEIOH_H__
12 #define __A2D_WXIMAGEIOH_H__
13 
14 #ifndef WX_PRECOMP
15 #include "wx/wx.h"
16 #endif
17 
18 #include "wx/canvas/canmod.h"
19 #include "wx/editor/candoc.h"
20 #include "wx/canvas/sttool.h"
21 
22 
23 //! Input and output handler for a2dCanvasDocument to/from a wxImage
24 /*!
25  \ingroup fileio
26 */
28 {
29 public:
30  //! Constructor.
31  a2dCanvasDocumentIOHandlerImageIn( wxBitmapType type = wxBITMAP_TYPE_ANY );
32 
33  //! Destructor.
35 
36  //! The image loaded, will be added to this object
37  void SetShowObject( a2dCanvasObject* showObject ) { m_showObject = showObject; };
38 
39  //! The image loaded, will be added to this object
40  /*!
41  \return pointer to the objects where the image will be added to.
42  */
43  a2dCanvasObject* GetShowObject() const { return m_showObject; }
44 
45 
46  //! test header of the file to see if it can be loaded
47  virtual bool CanLoad( a2dDocumentInputStream& stream, const wxObject* obj = NULL, wxClassInfo* docClassInfo = NULL );
48 
49  //! load a complete document which contains an image
50  /*!
51  */
52  virtual bool Load( a2dDocumentInputStream& stream , wxObject* doc );
53 
54  //! scale the a2dImage by this factor, taking width and height from image imported.
55  void SetScale( double scale ) { m_scale = scale; }
56 
57  double GetScale() { return m_scale; }
58 
59  //! set the image type to load from, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave().
60  void SetType( wxBitmapType type ) { m_type = type; }
61 
62  //! return the image type to load from, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave().
63  wxBitmapType GetType() { return m_type; }
64 
65 protected:
66 
67  //! for the stream, detect what image type it contains
68  wxBitmapType DetectImageType();
69 
70  //! the document to store/load the data found into
72 
73  double m_scale;
74 
75  //! image type
76  wxBitmapType m_type;
77 
78  a2dCanvasObject* m_showObject;
79 
80 };
81 
82 //! Input and output handler for a2dCanvasDocument to/from a wxImage
83 /*!
84  This IoHandler is to render parts of a a2dCanvasDocument to an wxImage, and save this as
85  a bitmap to a stream. The maximum size of the bitmap in X or Y is given upfront or else asked for.
86  The a2dCanvasObject to display is set, or the root object of the a2dCanvasDocument is used.
87  The part to display is set as a rectangle defined in world coordinates. That part seen from the
88  m_showObject, is rendered to the image. The image is sized, taking into account the maximum size, such
89  that the view rectangle fits it. The image size can be set upfront, in which case the drawing will be
90  centered on that image size.
91 
92  The rendering itself is done via a a2dDrawer2D, which can be set. The default is a2dMemDcDrawer.
93  You can use a2dAggDrawer for antialiased drawing etc.
94 
95  \ingroup fileio
96 */
98 {
99 public:
100  //! Constructor.
101  a2dCanvasDocumentIOHandlerImageOut( wxBitmapType type = wxBITMAP_TYPE_ANY );
102 
103  //! Destructor.
105 
106  //! this handler can also save as CVG
107  bool CanSave( const wxObject* obj = NULL );
108 
109  //! save a2dCanvasDocument as image
110  virtual bool Save( a2dDocumentOutputStream& stream, const wxObject* obj );
111 
112  //! document will be rendered as seen from this object, if NULL, the root of the document will be used.
113  void SetShowObject( a2dCanvasObject* showObject ) { m_showObject = showObject; };
114 
115  //!return pointer of then currently shown object on the drawer.
116  /*!
117  \return pointer to the current object that is shown.
118  */
119  a2dCanvasObject* GetShowObject() const { return m_showObject; }
120 
121  //! render the document into an image.
122  wxImage RenderImage( a2dCanvasDocument* document );
123 
124  //! Set the size of the image to create.
125  void SetImageSize( const wxSize& size ) { m_imageSize = size; }
126 
127  //! Give the virtual size to be rendered to an image.
128  /*!
129  Here you give the minimum and maximum in world coordinates, which must be displayed on the bitmap.
130 
131  SetImageSize() is used for the image size itself.
132 
133  \param minx minimum x coordinate of display area
134  \param miny minimum y coordinate of display area
135  \param maxx maximum x coordinate of display area
136  \param maxy maximum y coordinate of display area
137 
138  \remark these setting are only used when m_automaticScale is set false.
139  */
140  void SetViewRectangle( double minx, double miny, double maxx, double maxy );
141 
142  //! Give the virtual size to be rendered to an image as boundingbox
143  /*!
144  Here you give the minimum and maximum in world coordinates, which must be displayed on the bitmap.
145 
146  \param viewBox boundingbox in world coordinates to display
147  */
148  void SetViewRectangle( a2dBoundingBox viewBox ) { m_viewBox = viewBox; }
149 
150  //!set if the Yaxis goes up or down
151  void SetYaxis( bool up ) { m_yaxis = up; }
152 
153  //!get y axis orientation
154  inline bool GetYaxis() const { return m_yaxis; }
155 
156  //! set the image type to save to, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave().
157  void SetType( wxBitmapType type ) { m_type = type; }
158 
159  //! return the image type to save to, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave().
160  long GetType() const { return m_type; }
161 
162  //! when image size is calculated, this is the maximum size possible
163  void SetMaxWidthHeight( long maxWidthHeight ) { m_maxWidthHeight = maxWidthHeight; }
164 
165  //! leafs a border of this amount of pixels around the drawing
166  void SetBorder( wxUint16 border, bool percentual = true );
167 
168  //! set the internal m_drawer2D to be used for rendering the document
169  void SetDrawer2D( a2dDrawer2D* drawer2d );
170 
171  //! get the internal m_drawer2D that is used for rendering the document
172  a2dDrawer2D* GetDrawer2D() const { return m_drawer2D; }
173 
174 protected:
175 
176  //! the drawing engine to use
178 
179  //! the document to store/load the data found into
181 
182  //! image size that will be created.
183  wxSize m_imageSize;
184 
185  //! calculate image size as set by user when m_imageSize = (0,0) else eqauls m_imageSize
187 
188  //! render the document using this object as ShowObject.
190 
191  //! create a border in this ammount of pixels.
192  int m_border;
193 
194  //! border is not in pixel but a percentage of the smallest height/width
196 
197  //! image type
198  wxBitmapType m_type;
199 
200  //! image type as detected in CanSave(), wil be used in Save() if m_type is wxBITMAP_TYPE_ANY
202 
203  //! axis is up or down
204  bool m_yaxis;
205 
206  //! viewing area in world coordinates to display on bitmap
208 
209  long m_maxWidthHeight;
210 };
211 
212 #endif
213 
wxBitmapType m_type
image type
Definition: imageioh.h:198
wxSize m_imageSizeCalc
calculate image size as set by user when m_imageSize = (0,0) else eqauls m_imageSize ...
Definition: imageioh.h:186
long GetType() const
return the image type to save to, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave()...
Definition: imageioh.h:160
virtual bool Load(a2dDocumentInputStream &stream, wxObject *obj)=0
override to read the stream and store (part of) the contents in to a specific a2dDocument or othere o...
wxSize m_imageSize
image size that will be created.
Definition: imageioh.h:183
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
Definition: gen.h:3458
wxBitmapType GetType()
return the image type to load from, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave()...
Definition: imageioh.h:63
void SetImageSize(const wxSize &size)
Set the size of the image to create.
Definition: imageioh.h:125
using a file stream for input, stream the file into a a2dDocument or other object ...
Definition: gen.h:3632
void SetShowObject(a2dCanvasObject *showObject)
The image loaded, will be added to this object.
Definition: imageioh.h:37
a2dDrawer2D * GetDrawer2D() const
get the internal m_drawer2D that is used for rendering the document
Definition: imageioh.h:172
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)=0
Should return true if the handler can read from the stream.
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
void SetMaxWidthHeight(long maxWidthHeight)
when image size is calculated, this is the maximum size possible
Definition: imageioh.h:163
a2dBoundingBox m_viewBox
viewing area in world coordinates to display on bitmap
Definition: imageioh.h:207
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: imageioh.h:119
void SetViewRectangle(a2dBoundingBox viewBox)
Give the virtual size to be rendered to an image as boundingbox.
Definition: imageioh.h:148
a2dDrawer2D * m_drawer2D
the drawing engine to use
Definition: imageioh.h:177
a2dCanvasDocument * m_doc
the document to store/load the data found into
Definition: imageioh.h:180
void SetYaxis(bool up)
set if the Yaxis goes up or down
Definition: imageioh.h:151
a2dCanvasDocument * m_doc
the document to store/load the data found into
Definition: imageioh.h:71
wxBitmapType m_type
image type
Definition: imageioh.h:76
Drawing context abstraction.
Definition: drawer2d.h:177
Input and output handler for a2dCanvasDocument to/from a wxImage.
Definition: imageioh.h:27
Input and output handler for a2dCanvasDocument to/from a wxImage.
Definition: imageioh.h:97
void SetShowObject(a2dCanvasObject *showObject)
document will be rendered as seen from this object, if NULL, the root of the document will be used...
Definition: imageioh.h:113
virtual bool Save(a2dDocumentOutputStream &stream, const wxObject *obj)=0
Override to write to the stream and store (part of) of the document contents in the stream...
void SetScale(double scale)
scale the a2dImage by this factor, taking width and height from image imported.
Definition: imageioh.h:55
void SetType(wxBitmapType type)
set the image type to load from, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave()...
Definition: imageioh.h:60
using a file stream for output, stream a a2dDocument or other wxObject into a stream.
Definition: gen.h:3751
wxInputStream a2dDocumentInputStream
input stream based wxStreams
Definition: gen.h:3456
virtual bool CanSave(const wxObject *obj=NULL)=0
Should return true if the handler can write this document to a stream.
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
a2dCanvasObject * GetShowObject() const
The image loaded, will be added to this object.
Definition: imageioh.h:43
void SetType(wxBitmapType type)
set the image type to save to, wxBITMAP_TYPE_ANY means outdetect from filename in CanSave()...
Definition: imageioh.h:157
bool m_borderpercentual
border is not in pixel but a percentage of the smallest height/width
Definition: imageioh.h:195
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
all headers of the canvas module
int m_border
create a border in this ammount of pixels.
Definition: imageioh.h:192
a2dCanvasObject * m_showObject
render the document using this object as ShowObject.
Definition: imageioh.h:189
wxBitmapType m_typeDetectedFromFilename
image type as detected in CanSave(), wil be used in Save() if m_type is wxBITMAP_TYPE_ANY ...
Definition: imageioh.h:201
stack based tools controller and tools for drawing and editing.
bool GetYaxis() const
get y axis orientation
Definition: imageioh.h:154
bool m_yaxis
axis is up or down
Definition: imageioh.h:204
imageioh.h Source File -- Sun Oct 12 2014 17:04:21 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation