a2dBaseTool Class Reference
[Objects used for interactive manipulation.]

The a2dBaseTool is used to derive tools from that are controlled by. More...

#include <tools.h>

Inheritance diagram for a2dBaseTool:

Inheritance graph
[legend]
Collaboration diagram for a2dBaseTool:

Collaboration graph
[legend]

List of all members.

Public Member Functions

bool ProcessEvent (wxEvent &event)
 events recieved from controller processed here
void SetEvtHandler (a2dEvtHandler *handler)
 to reroute events to this event handler
a2dEvtHandlerGetEventHandler ()
 a2dBaseTool (a2dToolContr *controller)
 construct a new tool for the given controller.
 a2dBaseTool (const a2dBaseTool &other, CloneOptions options)
 constructor initializing partly from other tool
virtual ~a2dBaseTool ()
 destructor
a2dBaseToolTClone (CloneOptions options)
virtual bool StartTool (a2dBaseTool *currenttool)
 called to initiate while pushing tool to toolcontroller
void SetOneShot ()
 Only one action of the tool, after that it will ask the controller to stop this tool.
virtual bool ZoomSave ()=0
 Is Zooming while the tool is busy Save.
virtual bool AllowPop ()
 tells if a tool can be poped from the stack.
void StopTool (bool abort=false)
 call to stop a tool, internal and external.
bool GetStopTool ()
 checked by controller to see if the tool needs to be stopped e.g. after a oneshot.
bool GetActive ()
 is the tool active?
virtual void SetActive (bool active=true)
 set the tool active or inactive.
bool GetBusy ()
 Check if the tool is busy editing a distinct object */.
virtual bool EnterBusyMode ()
 Called when the user selects a distinct object for editing */.
virtual void FinishBusyMode (bool closeCommandGroup=true)
 Called when the user finishes editing a distinct object */.
virtual void AbortBusyMode ()
 Called when the user aborts editing a distinct object */.
void SetFill (const a2dFill &fill)
 set fill if used inside a tool
const a2dFillGetFill () const
 get the current fill
void SetStroke (const a2dStroke &stroke)
 set stroke if used inside a tool
const a2dStrokeGetStroke () const
 get the current stroke
void SetLayer (wxUint16 layer)
 layer set for the object that is drawn using a tool
wxUint16 GetLayer ()
 layer set for new objects.
void SetShowAnotation (bool show)
 when true anotation will be shown, if used inside a tool
void SetAnotationFont (const wxFont &font)
 font to use for anotation
void SetCursorType (const wxCursor &cursor)
 Sets cursor which the tool should use when started.
void SetBusyCursorType (const wxCursor &cursor)
 Sets cursor which the tool should use when busy.
wxCursor GetCursorType ()
 what cursor is used when tool is started
wxCursor GetBusyCursorType ()
 what cursor is used when tool is busy
virtual void SetMode (int mode)
 general integer to set operation modes for a tool (e.g the way it draws)
int GetMode ()
 can be used to modify the behaviour of the derived tool.
void SetPending (bool pending=true)
 a tool is set pending when it needs to be redrawn.
bool GetPending ()
 return if the tool is set pending for redraw.
virtual void Render ()
 render the tool chain
a2dToolContrGetToolController ()
 to get the tool controller to which this tool is attached.
a2dCanvasViewGetCanvasView ()
 Access to the tool controllers drawer.
a2dDrawer2DGetDrawer2D ()
 Access to the tool controllers drawers drawer2d.
wxWindow * GetDisplayWindow ()
 Access to the tool controllers drawers canvas.
a2dCanvasDocumentGetCanvasDocument ()
 Returns a pointer to the document.
a2dCanvasCommandProcessorGetCanvasCommandProcessor ()
 Returns a pointer to the command processor associated with this document.
virtual void OpenCommandGroup (bool restart)
 called when starting an editing operation (e.g. on mouse down)
virtual void OpenCommandGroupNamed (const wxString &name)
 called when starting an editing operation with another than the default name
virtual void CloseCommandGroup ()
 called when ending an editing operation (e.g. mouse up)
virtual wxString GetCommandGroupName ()
 return the command group name for commands of a derived class
a2dCommandGroupGetCommandgroup ()
 return the command group that is open else NULL.
wxMenu * GetMousePopupMenu ()
 to get the current mouse menu of the tool
void SetMousePopupMenu (wxMenu *mousemenu)
 to set the current mouse menu of the tool
a2dCanvasObjectGetParentObject ()
 parent object relative to which the actions take place.
void AddEditobject (a2dCanvasObject *object)
 Add an editcopy object to the tool/document.
void RemoveEditobject (a2dCanvasObject *object)
 Remove an editcopy object to the tool/document.
void AddDecorationObject (a2dCanvasObject *object)
 Add a decoration object to be rendered by the tool.
void RemoveAllDecorations ()
 remove all object that were added as decorations.
void SetIgnorePendingObjects (bool onoff)
 Switches ignorance of pending objects on and off.
bool GetIgnorePendingObjects ()
 get setting of ignore pending objects /sa GetUpdatesPending()
a2dCorridorGetCorridor ()
 get reference to the corridor list
void SetCorridor (const a2dCorridor &corridor)
 set a corridor from a list of objects
void SetContourWidth (double width)
double GetContourWidth () const
 get the Contour width of the shape
void ResetContext ()
 context like corridor and parentobject are reset

Public Attributes

bool m_halted
 if a tool is deactivated while m_busy is true, this flag is set
bool m_pending
 set when tool needs an redraw (after a a2dCanvas Repaint etc.)
bool m_oneshot
 do it only once
bool m_stop
 stop the tool
a2dFill m_fill
 fill for new object
a2dStroke m_stroke
 stroke for new object
double m_contourwidth
 if != 0 the polygon is contoured at distance m_contourwidth/2
wxUint16 m_layer
 layer for a new object
bool m_canvas_mouseevents_restore
 used to save the a2dCanvas mouse event setting.
bool m_anotate
 when true anotation will be shown, if used inside a tool
wxFont m_annotateFont
 font to use for anotation
int m_mode
 general operation mode setting for a tool.
a2dCommandGroupm_commandgroup
 the command group of the command processor
wxMenu * m_mousemenu
 popup menu
a2dCanvasObjectPtr m_parentobject
 ( if needed ) parent a2dCanvasObject relative to which the tool actions take place.

Static Public Attributes

static const wxEventType sm_toolPushed
 sent to new first tool when tool was pushed
static const wxEventType sm_toolPoped
 sent to new first tool when last first tool was poped
static const wxEventType sm_toolBeforePush
static const wxEventType sm_toolDoPopBeforePush
 return id after a sm_toolBeforePush, to tell current tool needs to be poped.
static const wxEventType sm_toolComEvent
 not yet used.
static a2dPropertyIdBoolPROPID_Oneshot = NULL
static a2dPropertyIdBoolPROPID_Stop = NULL
static a2dPropertyIdFillPROPID_Fill = NULL
static a2dPropertyIdStrokePROPID_Stroke = NULL
static a2dPropertyIdUint16PROPID_Layer = NULL

Protected Member Functions

void OnComEvent (a2dComEvent &event)
 default handler for a2dComEvent event
void OnRemoveView (a2dDocumentEvent &event)
 when a view is removed from a document, the tool becomes invalid and will be stopped
void OnDoEvent (a2dCommandProcessorEvent &event)
void OnUndoEvent (a2dCommandProcessorEvent &event)
void OnRedoEvent (a2dCommandProcessorEvent &event)
void OnMouseEvent (wxMouseEvent &event)
 called on mouse events
void OnChar (wxKeyEvent &event)
 called on key events
void OnKeyDown (wxKeyEvent &event)
 called on keydown events
void OnKeyUp (wxKeyEvent &event)
 called on keyup events
virtual void DoStopTool (bool abort)
 to do tool specific stuff to stop a tool. Called from StopTool().

Protected Attributes

wxCursor m_toolcursor
 cursor to use
wxCursor m_toolBusyCursor
 cursor to use when the tool is busy doing something.
a2dToolContrm_controller
 under control of this toolcontroller, to give me events.
bool m_active
 tool is operational
wxUint8 m_bussyStopping
 if > 0, the tool is in the process of stopping, which means it can not be poped yet by controller.
a2dSmrtPtr< a2dEvtHandlerm_eventHandler
 when set called before own event handler
bool m_ignorePendingObjects
 if set ignore all setting for pendingobjects
a2dCorridor m_corridor


Detailed Description

The a2dBaseTool is used to derive tools from that are controlled by.

a a2dToolContr derived class.

The basetool does not implement default behaviour for events in many cases, instead it is possible to set m_eventHandler to take care of action which are the same for a set of tools. a2dBaseTool::ProcessEvent() first redirect incoming events to m_eventHandler, and if not handled there it goes to the tools its own event handler.

See also:
a2dToolContr

Definition at line 352 of file tools.h.


Member Function Documentation

bool a2dBaseTool::ProcessEvent ( wxEvent &  event  )  [virtual]

events recieved from controller processed here

first m_eventHandler is tried, if not set or not processed, try object itself.

Reimplemented from a2dEvtHandler.

Definition at line 695 of file tools.cpp.

bool a2dBaseTool::StartTool ( a2dBaseTool currenttool  )  [virtual]

called to initiate while pushing tool to toolcontroller

It also resets the m_stop flag to false.

Definition at line 671 of file tools.cpp.

virtual bool a2dBaseTool::ZoomSave (  )  [pure virtual]

virtual bool a2dBaseTool::AllowPop (  )  [inline, virtual]

tells if a tool can be poped from the stack.

The controller tests if a tool is allowed to be poped from the stack. When a tool returns false here, that tool will stay on the stack until controller is destructed.

Definition at line 413 of file tools.h.

void a2dBaseTool::StopTool ( bool  abort = false  ) 

call to stop a tool, internal and external.

The stop flag within the tool will be set, triggering deletion of the tool from the outside by the a2dToolContr. Stopping one tool often means activating another which is on the tool stack of the a2dToolContr. Therefore the tools are really stopped and removed from the tool stack from the outside.

After this call the tool must be left in a state that allows the controller to pop the tool.

Override DoStopTool() function, if there is cleaning up to do before stopping a tool. Understand that stopping the tool is something else then (de)activating a tool. A tool can be de-activated, but still in action or at least on the toolstack. Stopping a tools really removes the tool from the stack by the controller.

To prevent poping the tool from the outside before it is really stopped, m_bussyStopping is incremented, when recursive calling this function. GetStopTool() only returns true when all recursive StopTool() calls have returned.

Remarks:
If a tool can not be stopped right now, the function should return false.

Stopping a tools will indirectly lead to the a2dToolContr Popping the tool from the stack, and that action at least de-activates the tool just stopped. So indirectly SetActive( false ) is called on this tool, when it is really stopped.

Parameters:
abort if true the tool is calling AbortBusyMode() instead FinishBusyMode(), the effect is that the tool does directly Undo what it was doing, but not yet did finish.

Definition at line 800 of file tools.cpp.

bool a2dBaseTool::GetStopTool (  ) 

checked by controller to see if the tool needs to be stopped e.g. after a oneshot.

or when wanted. The stop flag is in general set after a tool has received and handled an event which should stop the tool. A tool should not stop itself, since the tool will be deleted. The StopTool() function is called in such a case to trigger the stopping of the tool.

Definition at line 822 of file tools.cpp.

bool a2dBaseTool::GetActive (  )  [inline]

is the tool active?

A tool is "active", when it receives mouse input. Usually this is only the top tool on the tool stack. This is something completely different then "busy". A tool is "busy", when it currently focuses on editing a specific object. Toolstates change like this: 1. Created 2. Pushed on the tool stack -> set active 3. User clicks on an object to edit -> set busy 4. User starts a different tool (e.g. zoom) -> busy but not active (halted) 5. subtool is stopped -> set active again (and busy) 6. User continues editing the object selected in 3. -> still busy 7. User finishes editing the object selected in 3. -> no longer busy, but still active "One-shot" tools are stopped in this situations, other tools continue. 8. User clicks on a different object, repeat step 3..7 -> busy again 9. User stops tool (end tool menu or ESC or 2x double-click ...) -> stopped 10 Tool gets popped from the tool stack

Definition at line 468 of file tools.h.

void a2dBaseTool::SetActive ( bool  active = true  )  [virtual]

set the tool active or inactive.

If the tool needs initializing after it was inactive for a while, override this function to re-initialize the tool. This function can be used to distribute its settings for style etc. to the documents

See also:
a2dCanvasDocument::GetCanvasCommandProcessor(). The default implementation sets fill, stroke to the commandprocessor, but only when m_doSetStyleToCommandProc is true. If you need more complicated behaviour just override.

Reimplemented in a2dObjectEditTool, a2dMultiEditTool, a2dStTool, and a2dDrawWirePolylineLTool.

Definition at line 678 of file tools.cpp.

bool a2dBaseTool::GetBusy (  )  [inline]

Check if the tool is busy editing a distinct object */.

See also:
GetActive for a discription of various tool states

Definition at line 484 of file tools.h.

bool a2dBaseTool::EnterBusyMode (  )  [virtual]

Called when the user selects a distinct object for editing */.

See also:
GetActive for a discription of various tool states You should call the base class (this) version at the END of your function

Reimplemented in a2dObjectEditTool, a2dSimpleEditPolygonTool, a2dStTool, a2dStDrawTool, a2dDragTool, a2dDragNewTool, a2dRotateTool, a2dDrawWirePolylineLTool, a2dDragMultiTool, and a2dFastDragMultiTool.

Definition at line 760 of file tools.cpp.

void a2dBaseTool::FinishBusyMode ( bool  closeCommandGroup = true  )  [virtual]

Called when the user finishes editing a distinct object */.

See also:
EnterBusyMode,

GetActive You should call the base class (this) version at the END of your function

Reimplemented in a2dStTool, a2dStDrawTool, a2dDragTool, a2dDragNewTool, a2dRotateTool, a2dDrawWirePolylineLTool, and a2dDragMultiTool.

Definition at line 770 of file tools.cpp.

void a2dBaseTool::AbortBusyMode (  )  [virtual]

Called when the user aborts editing a distinct object */.

See also:
EnterBusyMode This is supposed to undo aeverything the tool did since entering busy mode

Reimplemented in a2dObjectEditTool, a2dSimpleEditPolygonTool, a2dStTool, a2dStDrawTool, a2dDragTool, a2dRotateTool, a2dDrawWirePolylineLTool, a2dDragMultiTool, and a2dFastDragMultiTool.

Definition at line 785 of file tools.cpp.

const a2dFill& a2dBaseTool::GetFill (  )  const [inline]

get the current fill

Return the current fill

Definition at line 511 of file tools.h.

const a2dStroke& a2dBaseTool::GetStroke (  )  const [inline]

get the current stroke

Return the current stroke

Definition at line 520 of file tools.h.

void a2dBaseTool::SetShowAnotation ( bool  show  )  [inline]

when true anotation will be shown, if used inside a tool

tools can show text when in action (e.g radius of the circle that is drawn) This is called anotation. The flag set by this function can be used to enable or disable the anotation.

Definition at line 533 of file tools.h.

void a2dBaseTool::SetCursorType ( const wxCursor &  cursor  )  [inline]

Sets cursor which the tool should use when started.

You may change the predefined cursor which the tool uses when it becomes active.

Remarks:
Many tools are using more than one cursor. These cursors indicate the status of the tool (busy etc.) and only the busy cursor can be changed currently. This cursor only indicate that the tool is active.
Parameters:
cursor the tool cursor

Definition at line 551 of file tools.h.

void a2dBaseTool::SetBusyCursorType ( const wxCursor &  cursor  )  [inline]

Sets cursor which the tool should use when busy.

You may change the predefined cursor which the tool uses when it becomes busy.

Parameters:
cursor the tool cursor

Definition at line 560 of file tools.h.

virtual void a2dBaseTool::SetMode ( int  mode  )  [inline, virtual]

general integer to set operation modes for a tool (e.g the way it draws)

tools most check the mode and handle in accordance In general Tab should be used to tab/switch/circle between modes understood by a tool.

Reimplemented in a2dObjectEditTool, a2dDrawCircleTool, a2dDrawEllipseTool, a2dDrawEllipticArcTool, a2dDrawArcTool, a2dDrawPolygonLTool, a2dDrawVPathTool, a2dFastDragMultiTool, a2dDrawCircleToolFast, and a2dDrawPolygonLToolFast.

Definition at line 573 of file tools.h.

int a2dBaseTool::GetMode (  )  [inline]

can be used to modify the behaviour of the derived tool.

Tools may have several ways of doing the same or simular things. This integer can be used to set this mode, it depends on the implementation what happens.

Definition at line 581 of file tools.h.

virtual void a2dBaseTool::Render (  )  [inline, virtual]

render the tool chain

A tool chain gets rendered when a2dCanvasView is updating areas that are changed in a document.

Reimplemented in a2dObjectEditTool, a2dMasterDrawZoomFirst, a2dStTool, a2dDragTool, a2dDragMultiTool, a2dStDrawToolFast, a2dZoomFast, a2dFastSelect, and a2dFastDragMultiTool.

Definition at line 593 of file tools.h.

void a2dBaseTool::OpenCommandGroup ( bool  restart  )  [virtual]

called when starting an editing operation (e.g. on mouse down)

Parameters:
restart add a hint to the command group name, that this tool was restarted

Definition at line 867 of file tools.cpp.

wxString a2dBaseTool::GetCommandGroupName (  )  [virtual]

wxMenu* a2dBaseTool::GetMousePopupMenu (  )  [inline]

to get the current mouse menu of the tool

see also RightMouseClick() /return NULL if no menu is set, else the menu.

Definition at line 633 of file tools.h.

void a2dBaseTool::SetMousePopupMenu ( wxMenu *  mousemenu  ) 

to set the current mouse menu of the tool

see also RightMouseClick() NULL sets the menu to non.

Definition at line 664 of file tools.cpp.

a2dCanvasObject* a2dBaseTool::GetParentObject (  )  [inline]

parent object relative to which the actions take place.

Tools can do there work on child objects of some parent a2dCanvasObject. In such cases the context of the tool is set with SetCorridor(), and the last object in the corridor is the m_parentobject.

Definition at line 647 of file tools.h.

void a2dBaseTool::AddDecorationObject ( a2dCanvasObject object  ) 

Add a decoration object to be rendered by the tool.

Decoration object are rendered by the tool in the style they have. They are used to add extra drawings to the actual tool object to clarify editing and drawing.

Definition at line 946 of file tools.cpp.

void a2dBaseTool::SetIgnorePendingObjects ( bool  onoff  ) 

Switches ignorance of pending objects on and off.

If set to true pending objects won't be updated. This method is used by several tools (i.e. a2dDragTool) to avoid updates while the tool is working.

See also:
GetUpdatesPending()
Parameters:
onoff true to ignore pending objects, else false

Definition at line 658 of file tools.cpp.

void a2dBaseTool::OnComEvent ( a2dComEvent event  )  [protected]

default handler for a2dComEvent event

Event id a2dCanvasView::sm_changedShowObject makes the tools corridor change to keep the tool active. In derived tools one can implement different behaviour if needed.

Reimplemented in a2dObjectEditTool, a2dRecursiveEditTool, a2dMultiEditTool, a2dStTool, a2dDragNewTool, a2dDrawRectangleToolFast, and a2dDrawCircleToolFast.

Definition at line 706 of file tools.cpp.


Member Data Documentation

const wxEventType a2dBaseTool::sm_toolBeforePush [static]

sent to current firsttool so it can pop itself based on the tool to push. Allows the current first tool to react on a the pushing of the new tool.

Definition at line 362 of file tools.h.

when set called before own event handler

To be able to change the behaviour in a central location for all tools, one can set this event handler. The default handler is the tool itself.

Definition at line 739 of file tools.h.

used in tools that can do nested editing/drawing. the corridor is a copy of the a2dCanvasObject in the a2dDocument that form the corridor path. re-activating a tool, this list can be used to re-instantiate the corridor path for the tool.

Definition at line 747 of file tools.h.

set when tool needs an redraw (after a a2dCanvas Repaint etc.)

this result in redrawing the tool ( e.g after a change )

Definition at line 761 of file tools.h.

used to save the a2dCanvas mouse event setting.

when tool is destroyed the original mouse event setting is set for a2dCanvas.

Definition at line 783 of file tools.h.


The documentation for this class was generated from the following files:
a2dBaseTool Class Reference -- Tue Aug 31 18:12:01 2010 -- 31 Aug 2010 -- 1.5.5 -- wxArt2D -- . -- Main Page Reference Documentation