25 #include <wx/wfstream.h>
32 #define WIDTHSCROLLBAR 20
43 EVT_PAINT( a2dCanvasSim::OnPaint )
44 EVT_ERASE_BACKGROUND( a2dCanvasSim::OnEraseBackground )
45 EVT_SIZE( a2dCanvasSim::OnSize )
49 a2dCanvasSim::a2dCanvasSim( wxWindow* parent, wxWindowID
id, const wxPoint& pos, const wxSize& size,
long style ):
50 wxScrolledWindow( parent,
id, pos, size, style )
55 int dvx = size.GetWidth();
56 int dvy = size.GetHeight();
58 if ( size == wxDefaultSize )
64 GetClientSize( &dvx, &dvy );
69 m_drawingPart->SetDisplayWindow(
this );
71 m_drawingPart->SetShowObject( m_drawing->GetRootObject() );
93 GetClientSize( &w, &h );
96 m_drawingPart = drawingPart;
110 wxWindow::ClearBackground();
115 if ( m_drawingPart && !rect )
119 wxWindow::Refresh( eraseBackground, rect );
124 m_drawingPart = NULL;
130 if ( !m_drawingPart )
137 if ( !m_drawingPart )
144 if ( !m_drawingPart )
152 if ( !m_drawingPart )
171 wxPaintDC dc(
this );
176 if ( !m_drawingPart )
181 if ( m_drawingPart->
IsFrozen() )
return;
195 bool eventHandlerEnabledState = m_drawingPart->GetEvtHandlerEnabled();
196 if ( !eventHandlerEnabledState )
197 m_drawingPart->SetEvtHandlerEnabled(
true );
205 m_drawingPart->SetEvtHandlerEnabled( eventHandlerEnabledState );
212 wxRegionIterator it( GetUpdateRegion() );
218 int w = it.GetWidth();
219 int h = it.GetHeight();
223 CalcUnscrolledPosition( x, y, &xx, &yy );
233 if ( !m_drawingPart )
249 if ( !m_drawingPart )
251 return m_drawingPart->
IsHitWorld( x, y, layer, option );
266 GetVirtualSize( &dxn, &dyn );
268 if ( dxn == 0 ) dxn = 1000;
269 if ( dyn == 0 ) dyn = 1000;
271 double xupp = width / dxn;
272 double yupp = height / dyn;
274 if ( yupp == 0 || xupp == 0 )
293 GetVirtualSize( &dxn, &dyn );
295 if ( dxn == 0 ) dxn = 1000;
296 if ( dyn == 0 ) dyn = 1000;
312 bool a2dCanvasSim::GetMouseEvents()
323 if ( !m_drawingPart )
342 GetVirtualSize( &w, &h );
346 w = w + WIDTHSCROLLBAR + m_delta;
347 h = h + WIDTHSCROLLBAR + m_delta;
349 if ( abs( oldw - w ) > m_delta || abs( oldh - h ) > m_delta )
401 int clientw, clienth;
402 GetVirtualSize( &clientw, &clienth );
405 if ( clientw - m_border > 0 )
406 uppx = w / ( clientw - m_border );
411 if ( clienth - m_border > 0 )
412 uppy = h / ( clienth - m_border );
433 double middlexworld = untr.
GetMinX() + w / 2.0;
434 double middleyworld = untr.
GetMinY() + h / 2.0;
435 GetDrawer2D()->
SetMappingUpp( middlexworld - clientw / 2.0 * uppx, middleyworld - clienth / 2.0 * uppx, uppx, uppx );
439 int clientwNew, clienthNew;
440 GetVirtualSize( &clientwNew, &clienthNew );
441 if ( clientw != clientwNew || clienth != clienthNew )
444 if ( clientw - m_border > 0 )
445 uppx = w / ( clientw - m_border );
450 if ( clienth - m_border > 0 )
451 uppy = h / ( clienth - m_border );
470 double middlexworld = untr.
GetMinX() + w / 2.0;
471 double middleyworld = untr.
GetMinY() + h / 2.0;
472 GetDrawer2D()->
SetMappingUpp( middlexworld - clientwNew / 2.0 * uppx, middleyworld - clienthNew / 2.0 * uppx, uppx, uppx );
void SetMappingUpp(double vx1, double vy1, double xpp, double ypp)
Give the virtual size to be displayed, the mapping matrix will be calculated.
virtual void SetYaxis(bool up)
set if the Yaxis goes up or down
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
double GetHeight() const
returns height of the boundingbox
void EndRefreshDisplayDisable()
see StartRefreshDisplayDisable()
void SetMappingUpp(double vx1, double vy1, double xpp, double ypp)
Give the virtual size to be displayed, the mappingmatrix will be calculated.
void SetYaxis(bool up)
set if the Yaxis goes up or down
void OnPaint(wxPaintEvent &event)
repaint damaged araes, taking into acount non updated araes in a2dCanvasView.
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
void Thaw()
allow a2dCanvasView buffer to be changed and blitting it to the window
bool IsFrozen()
Returns if canvas is frozen.
simple canvas which takes as view the whole of the scrollable area. While a2dCanvas display and draws...
bool WriteSVG(const wxString &filename, double Width, double Height, wxString unit)
write what you see to an SVG( scalable vector graphics file )
void SetMappingDeviceRect(int mapx, int mapy, int mapWidth, int mapHeight, bool remap=false)
to change the default mapping (to the complete buffer).
Simple canvas using a whole view for all of the scrolled window.
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate
bool GetYaxis() const
get y axis orientation
void SetBackgroundFill(const a2dFill &backgroundfill)
background fill for the canvas
a2dCanvasObject is the base class for Canvas Objects.
virtual void SetBufferSize(int w, int h)
sets buffersize ( if used ) for the a2dDrawer2D
bool GetMouseEvents() const
return true if this a2dDrawingPart allows mouse events to be processed.
a2dCanvasObject * GetShowObject() const
void ClearBackground()
Clears the canvas (like wxWindow::ClearBackground)
void SetMouseEvents(bool onoff)
double GetMinX() const
get minimum X of the boundingbox
void AddPendingUpdateArea(a2dCanvasObject *obj, wxUint8 id=0, bool refsalso=true)
add pending update for the area that is the boundingbox of the given object
a2dHitOption
Enum for hit test options.
void SetMappingWidthHeight(double vx1, double vy1, double width, double height)
Give the virtual size to be displayed, the mappingmatrix will be calculated.
void SetMappingShowAll(bool centre=true)
use the boundingbox of the ShowObject to set the mapping such that it will be displayed completely...
int GetHeight() const
get buffer/device height
void SetMouseEvents(bool onoff)
If not set do not process mouse events.
void SetActiveDrawingPart(a2dDrawingPart *part)
get the drawing part that has the focus/is active in a window.
Contains graphical drawing context specific classes. a2dDcDrawer and derived classes are used for dra...
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
a2dCanvasObject * SetShowObject(const wxString &name)
A 2x3 affine matrix class for 2D transformations.
void SetBackgroundFill(const a2dFill &backgroundfill)
background fill for the canvas
bool GetYaxis() const
get currently used Yaxis setting
a2dCanvasObject * IsHitWorld(double x, double y, int layer=wxLAYER_ALL, a2dHitOption option=a2dCANOBJHITOPTION_NOROOT|a2dCANOBJHITOPTION_LAYERS)
do a hittest on the canvas at coordinates x,y
int GetWidth() const
get buffer/device width
void MapBbox(const a2dAffineMatrix &matrix)
virtual wxBitmap GetBuffer() const =0
Return the buffer as a bitmap.
virtual void BeginDraw()=0
start to draw on this context (used to initialize a specific drawer)
double GetWidth() const
returns width of the boundingbox
a2dCanvasObject * SetShowObject(const wxString &name)
set object available in the a2dDrawing to be shown on the drawer
void StartRefreshDisplayDisable()
when called a mapping change will result not result in a refresh of the m_display.
virtual ~a2dCanvasSim()
destructor
void BlitBuffer()
blit whole buffer to device
void Freeze()
prevent changing the a2dCanvasView buffer and blitting it to the window
wxColour GetColour() const
return colour
a2dCanvasObject * IsHitWorld(double x, double y, int layer=wxLAYER_ALL, a2dHitOption option=a2dCANOBJHITOPTION_NONE, bool filterSelectableLayers=false)
do a hittest on the view at coordinates x,y
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
bool Invert(void)
Invert matrix.
double GetMinY() const
get minimum Y of the boundingbox
a2dDrawing * GetDrawing() const
get drawing via top object
virtual void EndDraw()=0
end drawing on this context (used to reset a specific drawer)
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
void OnEraseBackground(wxEraseEvent &event)
Not yet implemented.
a2dDrawer2D * GetDrawer2D() const
Get the drawer of the view.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
Refresh window.
a2dFill & GetBackgroundFill()
get current background fill for the canvas
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Contain one drawing as hierarchical tree of a2dCanvasObject's.
void OnSize(wxSizeEvent &event)
resize, adjusting buffer of a2dCanvasView if needed.