wxArt2D
|
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object and all that is nested in that choosen object. More...
#include <canvas.h>
Public Member Functions | |
a2dCanvas (wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxScrolledWindowStyle, a2dDrawer2D *drawer2D=0) | |
constructor More... | |
a2dCanvas (a2dDrawingPart *drawingPart, wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxScrolledWindowStyle) | |
constructor More... | |
virtual | ~a2dCanvas () |
destructor More... | |
a2dDrawingPart * | GetDrawingPart () |
void | SetDrawingPart (a2dDrawingPart *drawpart) |
a2dDrawing * | GetDrawing () const |
void | SetDrawing (a2dDrawing *drawing) |
a2dDrawer2D * | GetDrawer2D () const |
Get the drawer of the view. | |
void | ClearBackground () |
Clears the canvas (like wxWindow::ClearBackground) More... | |
virtual void | Refresh (bool eraseBackground=true, const wxRect *rect=NULL) |
Refresh window. More... | |
void | SetBackgroundFill (const a2dFill &backgroundfill) |
background fill for the canvas | |
void | SetGridAtFront (bool gridatfront) |
Set grid setting for drawing grid in front or back. | |
bool | GetGridAtFront () |
Get grid setting for drawing grid in front or back. | |
void | SetGridStroke (const a2dStroke &gridstroke) |
set stroke used for grid drawing | |
void | SetGridSize (wxUint16 gridsize) |
set size of grid circle | |
void | SetGridFill (const a2dFill &gridfill) |
set brush used for grid drawing | |
double | GetGridX () |
Get grid distance in X. | |
void | SetGridX (double gridx) |
Set grid distance in X. | |
double | GetGridY () |
Get grid distance in Y. | |
void | SetGridY (double gridy) |
Set grid distance in Y. | |
void | SetGrid (bool grid) |
Set grid on/off. | |
bool | GetGrid () |
Get grid setting on/off. | |
void | SetGridLines (bool gridlines) |
Get grid setting for line drawing. More... | |
bool | GetGridLines () |
set grid to draw lines instead of points | |
void | SetShowOrigin (bool show) |
Set showorigin on/off. | |
void | SetYaxis (bool up) |
set if the Yaxis goes up or down | |
bool | GetYaxis () const |
get currently used Yaxis setting | |
void | SetScaleOnResize (bool val) |
set if the drawing should be resclaed on a window resize More... | |
bool | GetScaleOnResize () |
get current setting for ScaleOnResize | |
void | SetContinuesSizeUpdate (bool val) |
set if the drawing should be rescaled on a window resize | |
bool | GetContinuesSizeUpdate () |
get current setting for ContinuesSizeUpdate flag | |
void | AppendEventHandler (wxEvtHandler *handler) |
append an eventhandler to the list, this event handler will be called if the other skipped the event to process. | |
wxEvtHandler * | RemoveLastEventHandler (bool deleteHandler) |
remove last event handler in the list | |
bool | IsFrozen () |
Returns if canvas is frozen. | |
void | Freeze () |
prevent changing the a2dCanvasView buffer and blitting it to the window More... | |
void | Thaw () |
allow a2dCanvasView buffer to be changed and blitting it to the window More... | |
void | SetMappingWidthHeight (double vx1, double vy1, double width, double height, bool scrollbars) |
Give the virtual size to be displayed, the mappingmatrix will be calculated. More... | |
void | SetMappingShowAll (bool centre=true) |
use the boundingbox of the ShowObject to set the mapping such that it will be displayed completely. More... | |
void | ZoomOut (double n) |
zoom out from the center by a factor n (zoomin if <1 ) | |
void | ZoomOutAtXy (int x, int y, double n) |
zoom out from position x,y by a factor n (zoomin if <1 ) | |
void | SetMappingUpp (double vx1, double vy1, double xpp, double ypp) |
Give the virtual size to be displayed, the mappingmatrix will be calculated. More... | |
void | SetScrollbars (double pixelsPerUnitX, double pixelsPerUnitY, double noUnitsX, double noUnitsY, double xPos=0, double yPos=0) |
set scrollbars More... | |
double | GetVisibleMinX () const |
get Minimal X of the visible part in world coordinates | |
double | GetVisibleMinY () const |
get Minimal X of the visible part in world coordinates | |
double | GetVisibleMaxX () const |
get Maximum X of the visible part in world coordinates | |
double | GetVisibleMaxY () const |
get Maximum Y of the visible part in world coordinates | |
double | GetVisibleWidth () const |
get Width of visible part in world coordinates | |
double | GetVisibleHeight () const |
get Height of visible part in world coordinates | |
double | GetUppX () const |
double | GetUppY () const |
bool | ScrollWindowConstrained (double dx, double dy) |
scroll the window in world coordinates More... | |
bool | SetScrollMaximum (double vx1, double vy1, double vx2, double vy2) |
to set the total area in world coordinates that can be scrolled to. More... | |
void | SetMinX (double vxmin) |
Set horizontal scrollbar position in world coordinates. | |
void | SetMinY (double vymin) |
Set vertical scrollbar position in world coordinates. | |
double | GetScrollMinX () const |
get the minimum scroll X in world coordinates that can be scrolled to | |
double | GetScrollMinY () const |
get the minimum scroll Y in world coordinates that can be scrolled to | |
double | GetScrollMaxX () const |
get the maximum scroll X in world coordinates that can be scrolled to | |
double | GetScrollMaxY () const |
get the maximum scroll Y in world coordinates that can be scrolled to | |
void | SetScrollStepX (double x) |
set granularity (step size) for scrolling in world units for Horizontal Scrollbar More... | |
void | SetScrollStepY (double y) |
set granularity (step size) for scrolling in world units for Vertical Scrollbar More... | |
void | FixScrollMaximum (bool fixed) |
at all times the virtual displayed area will stay within the maximum scrollable area | |
void | SetScrollBarsVisible (bool onoff) |
show scrollbars if set true. | |
void | SetScrollTrackDraw (bool scrollTrackDraw) |
if set, when dragging scrollbar handles, do a redraw, esle only at release. | |
bool | GetScrollTrackDraw () const |
if set, when dragging scrollbar handles, do a redraw, esle only at release. | |
void | ClipToScrollMaximum (bool clip) |
when scrolling outside the maximum scroll region and More... | |
bool | CheckInsideScrollMaximum (double worldminx, double worldminy) |
check if the given scroll in worldcoordinates (X and Y) will stay within ScrollMaximum. More... | |
a2dCanvasObject * | SetShowObject (const wxString &name) |
set object available in the a2dCanvasDocument to be shown on the canvas More... | |
bool | SetShowObject (a2dCanvasObject *obj) |
set top object available in the a2dCanvasDocument to be shown on the canvas More... | |
a2dCanvasObject * | GetShowObject () const |
return pointer of then currently shown object on the canvas. More... | |
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 More... | |
void | SetMouseEvents (bool onoff) |
bool | GetMouseEvents () |
bool | WriteSVG (const wxString &filename, double Width, double Height, wxString unit) |
write what you see to an SVG( scalable vector graphics file ) | |
bool | ProcessEvent (wxEvent &event) |
Protected Member Functions | |
bool | MakeVirtualMaxFitVisibleArea () |
void | GetSaveClientSize (int *dvx, int *dvy) const |
same as normal client size, but when dx or dy is zero, it will be set to 1000. More... | |
void | OnActivate (wxActivateEvent &event) |
void | OnPaint (wxPaintEvent &event) |
repaint damaged araes, taking into acount non updated araes in a2dCanvasView. | |
void | OnSize (wxSizeEvent &event) |
resize, adjusting buffer of a2dCanvasView if needed. | |
void | OnWheel (wxMouseEvent &event) |
mouse wheel handler | |
void | OnEraseBackground (wxEraseEvent &event) |
Not yet implemented. | |
void | OnScroll (wxScrollWinEvent &event) |
what to do while scrollling | |
void | OnChar (wxKeyEvent &event) |
what to do for characters received | |
void | DeleteAllPendingAreas () |
remove all pending update areas in a2dCanvasView | |
bool | CheckInsideScrollMaximum (int dx, int dy) |
check if the given scroll in pixels (X and Y) will be oke to stay within ScrollMaximum. More... | |
void | Init (int dvx, int dvy) |
Protected Attributes | |
double | m_virtm_minX |
virtual coordinates of total scrollable area for the drawing, used to set scrollbars | |
double | m_virtm_minY |
double | m_virtm_maxX |
double | m_virtm_maxY |
bool | m_scaleonresize |
are scroll bars active? | |
bool | m_wantScroll |
set true by wxWindow style parameter wxVSCROLL | wxHSCROLL | |
bool | m_aboveScrolledFixedAdjustUpp |
when because resizing or setting maximum scrollable area, it becomes smaller then the visible area, More... | |
int | m_scrollrangex |
Total range of X scroll bar, which gets always adjusted by the m_scrollstepx. More... | |
int | m_scrollrangey |
Total range of Y scroll bar, which gets always adjusted by the m_scrollstepy. More... | |
int | m_thumbx |
current thumbsize of X scrollbar which gets always adjusted by the m_scrollstepx More... | |
int | m_thumby |
current thumbsize of Y scrollbar which gets always adjusted by the m_scrollstepy More... | |
double | m_scrollstepx |
step for X line up and down in world coordinates | |
double | m_scrollstepy |
step for Y line up and down in world coordinates | |
bool | m_scrolled |
are scroll bars active? | |
bool | m_xscroll_changed |
a flag for ignoring size events when scrollbars change | |
bool | m_yscroll_changed |
a flag for ignoring size events when scrollbars change | |
bool | m_has_x_scroll |
flag if there is a horizontal scrollbar | |
bool | m_has_y_scroll |
flag if there is a vertical scrollbar | |
bool | m_scrollmaxfixed |
stay within maximum scrollable area | |
bool | m_clipToScrollMax |
see ClipToScrollMaximum() | |
bool | m_scrollTrackDraw |
redraw at drag fo scrollbars | |
int | m_oldw |
to optimize onsize events | |
int | m_oldh |
int | m_prevh |
int | m_prevw |
int | m_prevClientW |
int | m_prevClientH |
int | m_delta |
oversize of buffer compared to screen width and height | |
bool | m_frozen |
prevent updating activity if true | |
int | m_oversizeX |
in future the offset from window to drawer in X | |
int | m_oversizeY |
in future the offset from window to drawer in Y | |
a2dSmrtPtr< a2dDrawingPart > | m_drawingPart |
bool | m_inSetScrollMaximum |
prevent SetScrollMaximum beeing called recursively | |
bool | m_ContinuesSizeUpdate |
at small resize also update the buffer directly. More... | |
int | m_normalize |
used to normalize scroll thumb and range | |
a2dDrawingPtr | m_drawing |
set if the canvas own the drawing | |
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object and all that is nested in that choosen object.
This is a canvas that defines the viewport in world coordinates. The area of the a2dCanvasDocument drawing in world coordinates that is visible on the canvas can be set, which is called mapping. Parts of this area can be zoomed into resulting in scroll bars to be displayed.
Most functions here just redirect the calls to the member a2dCanvasView. They are available for convenience, but all of them can be accessed through the GetCanvasView() member function also.
The main thing done is to have the result of the a2dCanvasView rendering, blitted to the screen. The scrolling bars adjust the a2dCanvasView mapping to have the right mapping again after a scroll. It is optimized to miminize redrawing.
An update of the damaged parts will blitted from the a2dCanvasView buffer to the screen. This is done in Idle time, but can also be forced.
Settings like background drawing and grid drawing is done through the a2dCanvasView member.
The area of the drawing in world coordinates that is visible on the canvas can be set. Parts of this area can be zoomed into resulting in scroll bars to be displayed.
a2dCanvas::a2dCanvas | ( | wxWindow * | parent, |
wxWindowID | id = -1 , |
||
const wxPoint & | pos = wxDefaultPosition , |
||
const wxSize & | size = wxDefaultSize , |
||
long | style = wxScrolledWindowStyle , |
||
a2dDrawer2D * | drawer2D = 0 |
||
) |
constructor
construct a canvas window.
Internal a a2dDrawingPart and a2dDrawing are created to render all objects stored in the a2dDrawing into this a2dCanvas window.
The document and view or deleted in the destructor.
parent | parent window (use wxNO_FULL_REPAINT_ON_RESIZE on parent wxFrame) |
id | window id |
pos | position of window |
size | size of window |
style | type of window (wxHSCROLL|wxVSCROLL) |
drawer2D | the drawer to be used to render to the window ( construct with zero size, it will be set to the canvas size ) If 0 the default is a2dMemDcDrawer() |
Definition at line 50 of file canvas.cpp.
a2dCanvas::a2dCanvas | ( | a2dDrawingPart * | drawingPart, |
wxWindow * | parent, | ||
wxWindowID | id = -1 , |
||
const wxPoint & | pos = wxDefaultPosition , |
||
const wxSize & | size = wxDefaultSize , |
||
long | style = wxScrolledWindowStyle |
||
) |
constructor
construct a canvas window, normally created by a a2dCanvasView/wxView.
view | a2dCanvasView object used to render into this window. |
parent | parent window (use wxNO_FULL_REPAINT_ON_RESIZE on parent wxFrame) |
id | window id |
pos | position of window |
size | size of window |
style | type of window (wxHSCROLL|wxVSCROLL) |
Definition at line 106 of file canvas.cpp.
|
virtual |
destructor
when a tool controller was set is will be deleted also.
Definition at line 277 of file canvas.cpp.
bool a2dCanvas::CheckInsideScrollMaximum | ( | double | worldminx, |
double | worldminy | ||
) |
check if the given scroll in worldcoordinates (X and Y) will stay within ScrollMaximum.
Definition at line 1048 of file canvas.cpp.
|
protected |
check if the given scroll in pixels (X and Y) will be oke to stay within ScrollMaximum.
dy | > contents of window moves up |
dx | > contents of window moves right |
Definition at line 1035 of file canvas.cpp.
void a2dCanvas::ClearBackground | ( | ) |
Clears the canvas (like wxWindow::ClearBackground)
Calls internally a2dCanvas::ClearBackground() Clear() was renamed in wxWin 2.5 to ClearBackground()
Definition at line 258 of file canvas.cpp.
|
inline |
void a2dCanvas::Freeze | ( | ) |
prevent changing the a2dCanvasView buffer and blitting it to the window
To make sure the contents displayed into the a2dCanvasView buffer does not change.
Pending objects inside a root will be added to the update list of the a2dCanvasView, but not redrawn into the buffer until Thaw.
Definition at line 409 of file canvas.cpp.
bool a2dCanvas::GetMouseEvents | ( | ) |
Definition at line 1065 of file canvas.cpp.
|
protected |
same as normal client size, but when dx or dy is zero, it will be set to 1000.
This is to prevent an irational mapping and/or divide by zero problems.
Definition at line 250 of file canvas.cpp.
|
inline |
double a2dCanvas::GetUppX | ( | ) | const |
Definition at line 360 of file canvas.cpp.
double a2dCanvas::GetUppY | ( | ) | const |
Definition at line 367 of file canvas.cpp.
a2dCanvasObject * a2dCanvas::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
x,: | x of point to do hittest |
y,: | y of point to do hittest |
layer | only if object is on this layer or if set to wxLAYER_ALL ignore layer id. |
how | in which way the object was hit (stroke, fill, ...) |
Definition at line 489 of file canvas.cpp.
|
protected |
adjust either the maximum scrollable area to contain the current visible area or if fixed, change the visible area to stay within.
Definition at line 704 of file canvas.cpp.
|
virtual |
Refresh window.
Next to base class, makes sure all pending objects are processed, and scrolling is set right.
Definition at line 265 of file canvas.cpp.
bool a2dCanvas::ScrollWindowConstrained | ( | double | dx, |
double | dy | ||
) |
scroll the window in world coordinates
In case of FixScrollMaximum it will be done if it fits within the scrollmaximum else best possible.
Definition at line 1278 of file canvas.cpp.
|
inline |
void a2dCanvas::SetMappingShowAll | ( | bool | centre = true | ) |
use the boundingbox of the ShowObject to set the mapping such that it will be displayed completely.
centre | if true centre on window, else to (0,0) of device |
Definition at line 548 of file canvas.cpp.
void a2dCanvas::SetMappingUpp | ( | double | vx1, |
double | vy1, | ||
double | xpp, | ||
double | ypp | ||
) |
Give the virtual size to be displayed, the mappingmatrix will be calculated.
To display all of a drawing, set this here to the boundingbox of the show object of the canvas. So vx1 and vx2 to the miminum x and y of the boundingbox. Calculate xpp and ypp in such a manner that it will show the whole drawing.
Setting virtual area to boundingbox of a drawing (currently visible group)
If a scrollable area is set, it will be called also to adjust it.
vx1 | minimum world x coordinate |
vy1 | minimum world y coordiante ( either Lower or Upper Left corner depending on SetYaxis() ) |
xpp,: | Number of world units per pixel in x |
ypp,: | Number of world units per pixel in y |
Definition at line 534 of file canvas.cpp.
void a2dCanvas::SetMappingWidthHeight | ( | double | vx1, |
double | vy1, | ||
double | width, | ||
double | height, | ||
bool | scrollbars | ||
) |
Give the virtual size to be displayed, the mappingmatrix will be calculated.
The current window size in pixels is used to calculate the mapping such that at least it will display all of the area given.
Setting virtual area to boundingbox of a drawing (currently visible ShowObject()
vx1 | minimum world x coordinate |
vy1 | minimum world y coordiante ( either Lower or Upper Left corner depending on SetYaxis() ) |
width | minimum width in world coordinates which we want to display on this window |
height | minimum height in world coordinates which we want to display on this window |
scrollbars,: | The scroll region are set to display this also. |
Definition at line 503 of file canvas.cpp.
void a2dCanvas::SetMouseEvents | ( | bool | onoff | ) |
Definition at line 478 of file canvas.cpp.
|
inline |
set if the drawing should be resclaed on a window resize
When set, each resize of the window, result in scaling the visible draing up or down. The center of the window in world coordinates is kept the same. The drawing itself is scaled to the smallest of the width or height.
When m_ContinuesSizeUpdate is set each resize will scale the drawing, else only after a double buffer enlargement.
void a2dCanvas::SetScrollbars | ( | double | pixelsPerUnitX, |
double | pixelsPerUnitY, | ||
double | noUnitsX, | ||
double | noUnitsY, | ||
double | xPos = 0 , |
||
double | yPos = 0 |
||
) |
set scrollbars
pixelsPerUnitX | the number of pixels per world unit in X |
pixelsPerUnitY | the number of pixels per world unit in Y |
noUnitsX | number of scroll units in X |
noUnitsY | number of scroll units in Y |
xPos | position of thumb in X |
yPos | position of thumb in Y |
Definition at line 682 of file canvas.cpp.
bool a2dCanvas::SetScrollMaximum | ( | double | vx1, |
double | vy1, | ||
double | vx2, | ||
double | vy2 | ||
) |
to set the total area in world coordinates that can be scrolled to.
To be able to scroll the whole of a drawing, set this here to the boundingbox of the root group of the canvas. If the current Virtual display area does not fit inside the scrollable area, and the FixScrollMaximum is not set, the scroll area will be adjusted to have it fit. else scrollbars are disabled and return value is false.
Definition at line 983 of file canvas.cpp.
void a2dCanvas::SetScrollStepX | ( | double | x | ) |
set granularity (step size) for scrolling in world units for Horizontal Scrollbar
Scrolling is done when receiving wxEVT_SCROLLWIN_LINEUP wxEVT_SCROLLWIN_LINEDOWN. This is function is also internaly used to redraw the scrollbar
Definition at line 1021 of file canvas.cpp.
void a2dCanvas::SetScrollStepY | ( | double | y | ) |
set granularity (step size) for scrolling in world units for Vertical Scrollbar
Scrolling is done when receiving wxEVT_SCROLLWIN_LINEUP wxEVT_SCROLLWIN_LINEDOWN. This is function is also internaly used to redraw the scrollbar
Definition at line 1028 of file canvas.cpp.
a2dCanvasObject * a2dCanvas::SetShowObject | ( | const wxString & | name | ) |
set object available in the a2dCanvasDocument to be shown on the canvas
name,: | name of top object |
Definition at line 294 of file canvas.cpp.
bool a2dCanvas::SetShowObject | ( | a2dCanvasObject * | obj | ) |
set top object available in the a2dCanvasDocument to be shown on the canvas
obj,: | pointer to object to show |
Definition at line 301 of file canvas.cpp.
void a2dCanvas::Thaw | ( | ) |
allow a2dCanvasView buffer to be changed and blitting it to the window
Enable updating of the a2dCanvasView buffer contents.
Definition at line 415 of file canvas.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |