37 EVT_MOUSE_EVENTS( a2dMasterTagGroups ::OnMouseEvent )
38 EVT_CHAR( a2dMasterTagGroups ::OnChar )
39 EVT_KEY_DOWN( a2dMasterTagGroups ::OnKeyDown )
40 EVT_KEY_UP( a2dMasterTagGroups ::OnKeyUp )
50 a2dMasterTagGroups ::~a2dMasterTagGroups ()
78 case mode_cntrlselect:
90 void a2dMasterTagGroups::OnChar( wxKeyEvent& event )
107 case mode_cntrlselect:
120 void a2dMasterTagGroups ::OnKeyDown( wxKeyEvent& event )
128 switch( event.GetKeyCode() )
133 m_drawWire = !m_drawWire;
134 SetToolMode( event.m_controlDown, event.m_shiftDown );
138 if ( event.m_controlDown || event.m_shiftDown )
139 SetToolMode( event.m_controlDown, event.m_shiftDown );
144 void a2dMasterTagGroups ::OnKeyUp( wxKeyEvent& event )
152 switch( event.GetKeyCode() )
157 SetToolMode( event.m_controlDown, event.m_shiftDown );
161 if ( !event.m_controlDown || !event.m_shiftDown )
162 SetToolMode( event.m_controlDown, event.m_shiftDown );
171 float minDist = FLT_MAX;
172 for( i = 0; i < hitinfo.
m_extended.size(); i++ )
175 if( wire2 && hitinfo.
m_extended[i].GetHitType().m_distance < minDist && hitinfo.
m_extended[i].GetHitType().IsStrokeHit() )
189 m_modehitinfo = how2;
190 switch( how2.m_stroke2 )
192 case a2dHit::stroke2_vertex:
194 m_mode = mode_editwire_vertex;
196 case a2dHit::stroke2_edgehor:
198 m_mode = mode_editwire_segmenthorizontal;
200 case a2dHit::stroke2_edgevert:
202 m_mode = mode_editwire_segmentvertical;
204 case a2dHit::stroke2_edgeother:
206 m_mode = mode_editwire_segmentinsert;
216 void a2dMasterTagGroups::SetToolMode(
bool ctrl,
bool shift )
220 ic.SetLayer( wxLAYER_ALL );
234 if ( !ctrl && shift )
246 m_mode = mode_select;
261 SetWireCursor( wire, hitinfo );
265 if ( m_drawWire || ( !m_drawWire && ctrl ) )
282 if ( !pin->
IsTemporaryPin() && !( m_drawWire || ( !m_drawWire && ctrl ) ) &&
287 m_mode = mode_move_pin;
299 m_mode = mode_drawwire;
302 else if ( m_drawWire || ( !m_drawWire && ctrl ) )
306 m_mode = mode_drawwire;
312 if ( m_drawWire || ( !m_drawWire && ctrl ) )
316 m_mode = mode_drawwire;
324 SetWireCursor( wire, hitinfo );
351 m_mode = mode_select;
360 if ( !shift && !ctrl )
383 m_mode = mode_drawwire;
395 m_mode = mode_copymulti;
400 m_mode = mode_dragmulti;
407 m_mode = mode_select;
414 m_mode = mode_select;
423 m_mode = mode_select;
429 void a2dMasterTagGroups::OnMouseEvent( wxMouseEvent& event )
443 if ( event.LeftDClick() && !m_toolBusy && !(
event.ControlDown() ||
event.ShiftDown() ) )
445 m_hadDoubleClick =
true;
452 if ( (wire && wire->
GetSelected() ) || (wire && !m_drawWire ) || !wire )
457 PushEditTool( m_modehit );
468 if ( !pin && event.ControlDown() && !
event.ShiftDown() )
471 m_mode = mode_cntrlselect;
474 else if ( !event.ControlDown() &&
event.ShiftDown() )
477 m_mode = mode_select;
487 if( pin && !pin->
IsTemporaryPin() && ( !m_drawWire ||
event.ControlDown() ) )
493 m_mode = mode_move_pin;
497 else if ( event.ControlDown() &&
event.ShiftDown() )
500 m_mode = mode_copymulti;
505 m_mode = mode_dragmulti;
512 if( pin && !pin->
IsTemporaryPin() && ( !m_drawWire ||
event.ControlDown() ) )
518 m_mode = mode_move_pin;
547 else if( pin && !pin->
IsTemporaryPin() && ( !m_drawWire ||
event.ControlDown() ) )
554 m_mode = mode_move_pin;
565 m_mode = mode_select;
571 m_mode = mode_select;
579 PushMovePinTool( m_modehit );
582 case mode_cntrlselect:
591 PushDragMultiTool( m_modehit );
597 PushCopyMultiTool( m_modehit );
603 PushDragTool( m_modehit );
609 PushCopyTool( m_modehit );
613 case mode_editwire_vertex:
615 PushEditWireVertexTool( m_modehit, m_modehitinfo.
m_index );
616 wxMouseEvent mouseevent( wxEVT_LEFT_DOWN );
622 case mode_editwire_segmenthorizontal:
624 PushEditWireSegmentHorizontalTool( m_modehit, m_modehitinfo.
m_index );
625 wxMouseEvent mouseevent( wxEVT_LEFT_DOWN );
631 case mode_editwire_segmentvertical:
633 PushEditWireSegmentVerticalTool( m_modehit, m_modehitinfo.
m_index );
634 wxMouseEvent mouseevent( wxEVT_LEFT_DOWN );
640 case mode_editwire_segmentinsert:
642 PushEditWireSegmentInsertTool( m_modehit, m_modehitinfo.
m_index );
643 wxMouseEvent mouseevent( wxEVT_LEFT_DOWN );
649 case mode_editwire_segment:
651 PushEditSegmentTool( m_modehit, m_modehitinfo.
m_index );
652 wxMouseEvent mouseevent( wxEVT_LEFT_DOWN );
667 else if ( event.Moving() && !m_toolBusy )
669 SetToolMode( event.ControlDown(),
event.ShiftDown() );
672 else if( event.LeftDown() && !m_toolBusy )
683 m_mode = mode_select;
691 case mode_cntrlselect:
709 else if ( event.LeftUp() && m_hadDoubleClick )
711 m_hadDoubleClick =
false;
720 else if( event.LeftUp() && m_toolBusy )
727 m_modehitLastSelectState =
false;
729 m_modehitLastSelectState = m_modehit->
GetSelected();
731 if ( !event.ControlDown() && !
event.ShiftDown() || ( !m_drawWire &&
event.ControlDown() ) )
739 m_modehit->
SetSelected( !m_modehitLastSelectState );
744 if ( wire && m_drawWire )
758 m_mode = mode_drawwire;
760 PushDrawWireTool( m_modehit );
761 wxMouseEvent mouseevent( wxEVT_LEFT_DOWN );
767 else if ( event.ShiftDown() )
807 SetToolMode( event.ControlDown(),
event.ShiftDown() );
810 else if( event.RightDown() && !
GetBusy() )
a2dPin * FindNonWirePin(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
unsigned int m_index
For edge/vertex hits the index of the edge / vertex.
bool GetEditable() const
get if the object may be edited
virtual void DoStopTool(bool abort)
to do tool specific stuff to stop a tool. Called from StopTool().
a2dPin is used in a2dCanvasObject to add pins to it.
generate pins, given Connect/wire pinclass
void Render()
implement rendering
float m_distance
For margin hits, the distance from the stroke center in fractions of the margin.
a2dCanvasObject is the base class for Canvas Objects.
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
void DoStopTool(bool abort)
to do tool specific stuff to stop a tool. Called from StopTool().
bool GetSelected() const
is the object selected flag set
void SetSelected(bool selected)
Set the object selected flag if allowed.
a2dWirePolylineL is a polyline that adjusts itself when the objects it connects move ...
bool m_xyRelToChildren
is set, m_x and m_y are supplied relative to the child objects ( object matrix m_world already applie...
wxUint32 m_option
the way to hit/traverse the document.
a2dExtendedResult m_extended
extended result information with e.g path to lead to the nested object hit
static const a2dCanvasObjectFlagsMask SELECTABLE
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
if set, respect layer order, hit testing is done per layer from the top.
static const a2dCanvasObjectFlagsMask SELECTED
bool IsSelected() const
Is the object selected flag set.
void RemovePins(bool NotConnected=false, bool onlyTemporary=false, bool now=false)
Remove all a2dPin children.
void AbortBusyMode()
Called when the user aborts editing a distinct object */.
a2dCanvasObject * ChildIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent, bool filterSelectableLayers=false)
Do hittest on children.
bool IsTemporaryPin() const
return true if this pin is a temporary pin
void InitMouseEvent(wxMouseEvent &eventnew, int x, int y, wxMouseEvent &event)
common stuff for several master tools
while iterating a a2dCanvasDocument, this holds the context.
struct for how a single object on one layer was hit
a2dConnectionGenerator * GetConnectionGenerator() const
Get class for generating new connection objects between object and pins.
static const a2dCanvasObjectFlagsMask VISIBLE
a2dCanvasObject * Find(a2dCanvasObject *obj) const
return the object if it is part of the list
bool GetSelectable() const
is the object selectable flag set
virtual void SetPinsToBeginState(a2dCanvasObject *root, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
set begin state of pins, before a tools starts asking feedback or after tool is finsihed ...
Master tool for objects graphics slecting and dragging.
static a2dPinClass * Any
used to ask for a new default pin on an object.
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
all headers of the canvas module
filter on this layer and mask.
a2dCanvasObject * GetParent() const
get parent object of the pin
virtual bool IsConnect() const
return true, if this object is used to connect other object's using rubberband like structures...
bool GetDraggable() const
get if the object can be dragged
structure to give as parameter to member functions of a2dCanvasObject