24 #include "wx/filename.h"
29 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
30 #include <wx/msw/msvcrt.h>
33 #define CDRAWER2D GetDrawingPart()->GetDrawer2D()
69 const
a2dCommandId a2dDrawRectangleTool::COMID_PushTool_DrawRectangle( wxT( "PushTool_DrawRectangle" ) );
70 const
a2dCommandId a2dZoomTool::COMID_PushTool_Zoom( wxT( "PushTool_Zoom" ) );
71 const
a2dCommandId a2dSelectTool::COMID_PushTool_Select( wxT( "PushTool_Select" ) );
72 const
a2dCommandId a2dImageTool::COMID_PushTool_Image( wxT( "PushTool_Image" ) );
73 const
a2dCommandId a2dDragTool::COMID_PushTool_Drag( wxT( "PushTool_Drag" ) );
74 const
a2dCommandId a2dDragOrgTool::COMID_PushTool_DragOrg( wxT( "PushTool_DragOrg" ) );
75 const
a2dCommandId a2dDragNewTool::COMID_PushTool_DragNew( wxT( "PushTool_DragNew" ) );
76 const
a2dCommandId a2dCopyTool::COMID_PushTool_Copy( wxT( "PushTool_Copy" ) );
77 const
a2dCommandId a2dRotateTool::COMID_PushTool_Rotate( wxT( "PushTool_Rotate" ) );
78 const
a2dCommandId a2dDeleteTool::COMID_PushTool_Delete( wxT( "PushTool_Delete" ) );
79 const
a2dCommandId a2dDrawCircleTool::COMID_PushTool_DrawCircle( wxT( "PushTool_DrawCircle" ) );
80 const
a2dCommandId a2dDrawLineTool::COMID_PushTool_DrawLine( wxT( "PushTool_DrawLine" ) );
81 const
a2dCommandId a2dDrawLineTool::COMID_PushTool_DrawLineScaledArrow( wxT( "PushTool_DrawLineScaledArrow" ) );
82 const
a2dCommandId a2dDrawEllipseTool::COMID_PushTool_DrawEllipse( wxT( "PushTool_DrawEllipse" ) );
83 const
a2dCommandId a2dDrawEllipticArcTool::COMID_PushTool_DrawEllipticArc( wxT( "PushTool_EllipticArc" ) );
84 const
a2dCommandId a2dDrawEllipticArcTool::COMID_PushTool_DrawEllipticArc_Chord( wxT( "PushTool_EllipticArcChord" ) );
85 const
a2dCommandId a2dDrawArcTool::COMID_PushTool_DrawArc( wxT( "PushTool_DrawArc" ) );
86 const
a2dCommandId a2dDrawArcTool::COMID_PushTool_DrawArc_Chord( wxT( "PushTool_DrawArcChord" ) );
87 const
a2dCommandId a2dDrawPolygonLTool::COMID_PushTool_DrawPolygonL( wxT( "PushTool_DrawPolygonL" ) );
88 const
a2dCommandId a2dDrawPolygonLTool::COMID_PushTool_DrawPolygonL_Splined( wxT( "PushTool_DrawPolygonL_Splined" ) );
89 const
a2dCommandId a2dDrawPolylineLTool::COMID_PushTool_DrawPolylineL( wxT( "PushTool_DrawPolylineL" ) );
90 const
a2dCommandId a2dDrawPolylineLTool::COMID_PushTool_DrawPolylineL_Splined( wxT( "PushTool_DrawPolylineL_Splined" ) );
91 const
a2dCommandId a2dDrawWirePolylineLTool::COMID_PushTool_DrawWirePolylineL( wxT( "PushTool_DrawWirePolylineL" ) );
92 const
a2dCommandId a2dDragMultiTool::COMID_PushTool_DragMulti( wxT( "PushTool_DragMulti" ) );
93 const
a2dCommandId a2dCopyMultiTool::COMID_PushTool_CopyMulti( wxT( "PushTool_CopyMulti" ) );
94 const
a2dCommandId a2dDrawTextTool::COMID_PushTool_DrawText( wxT( "PushTool_DrawText" ) );
95 const
a2dCommandId a2dPropertyTool::COMID_PushTool_Property( wxT( "PushTool_Property" ) );
96 const
a2dCommandId a2dDrawVPathTool::COMID_PushTool_DrawVPath( wxT( "PushTool_DrawVPath" ) );
97 const
a2dCommandId a2dFollowLink::COMID_PushTool_FollowLink( wxT( "PushTool_FollowLink" ) );
99 WX_DEFINE_LIST( wxZoomList );
101 extern const
long TC_UNDO = wxNewId();
102 extern const
long TC_REDO = wxNewId();
103 extern const
long TC_ENDTOOL = wxNewId();
104 extern const
long TC_ZOOMIN = wxNewId();
105 extern const
long TC_ZOOMOUT = wxNewId();
106 extern const
long TC_ZOOMBACK = wxNewId();
107 extern const
long TC_ZOOMOUT2 = wxNewId();
108 extern const
long TC_ZOOMIN2 = wxNewId();
109 extern const
long TC_ZOOMPANXY = wxNewId();
110 extern const
long TC_PROPERTY_XY = wxNewId();
112 #define DEFAULTOpacityFactor 125 ;
120 EVT_MOUSE_EVENTS( a2dStToolContr::OnMouseEvent )
121 EVT_CHAR( a2dStToolContr::OnChar )
122 EVT_KEY_DOWN( a2dStToolContr::OnKeyDown )
123 EVT_KEY_UP( a2dStToolContr::OnKeyUp )
124 EVT_MENU(
TC_UNDO , a2dStToolContr::Undo )
125 EVT_MENU( TC_REDO , a2dStToolContr::Redo )
126 EVT_MENU( TC_ENDTOOL , a2dStToolContr::EndTool )
127 EVT_MENU( TC_ZOOMIN , a2dStToolContr::ZoomWindowMenu )
128 EVT_MENU( TC_ZOOMBACK , a2dStToolContr::ZoomUndoMenu )
129 EVT_MENU( TC_ZOOMOUT , a2dStToolContr::ZoomoutMenu )
130 EVT_MENU( TC_ZOOMPANXY , a2dStToolContr::ZoomPanMenu )
131 EVT_MENU( TC_ZOOMOUT2 , a2dStToolContr::Zoomout2Menu )
132 EVT_MENU( TC_ZOOMIN2 , a2dStToolContr::Zoomin2Menu )
133 EVT_MENU( TC_PROPERTY_XY , a2dStToolContr::EditProperties )
141 m_selectionStateUndo =
false;
142 m_selectedAtEnd =
false;
147 m_noStatusEvent = noStatusEvent;
148 m_format = wxT(
"%6.1f" );
149 m_statusStrings.push_back(
"" );
150 m_statusStrings.push_back(
"" );
151 m_statusStrings.push_back(
"" );
152 m_statusStrings.push_back(
"" );
153 m_statusStrings.push_back(
"" );
154 m_statusStrings.push_back(
"" );
155 m_statusStrings.push_back(
"" );
156 m_statusStrings.push_back(
"" );
157 m_statusStrings.push_back(
"" );
158 m_statusStrings.push_back(
"" );
159 m_statusStrings.push_back(
"" );
160 m_statusStrings.push_back(
"" );
161 m_statusStrings.push_back(
"" );
162 m_statusStrings.push_back(
"" );
163 m_statusStrings.push_back(
"" );
164 m_statusStrings.push_back(
"" );
165 m_statusStrings.push_back(
"" );
166 m_statusStrings.push_back(
"" );
167 m_statusStrings.push_back(
"" );
168 m_statusStrings.push_back(
"" );
169 m_statusStrings.push_back(
"" );
172 m_useEditOpaque =
false;
173 m_editOpacityFactor = DEFAULTOpacityFactor;
174 m_zoomoutCentered =
true;
175 m_draggingCanvas =
false;
176 m_draggingCanvasOption =
true;
179 m_mouse_x = m_mouse_y = 0;
188 m_toolForZoom =
new a2dZoomTool(
this );
193 m_mousemenu =
new wxMenu( _(
"ZOOM" ), (
long )0 );
194 m_mousemenu->Append( TC_ENDTOOL, _(
"end tool" ) );
195 m_mousemenu->AppendSeparator();
196 m_mousemenu->Append( TC_UNDO, _(
"undo" ) );
197 m_mousemenu->Append( TC_REDO, _(
"redo" ) );
198 m_mousemenu->AppendSeparator();
199 m_mousemenu->Append( TC_ZOOMIN, _(
"Zoom Window" ) );
200 m_mousemenu->Append( TC_ZOOMBACK, _(
"Zoom Undo" ) );
201 m_mousemenu->Append( TC_ZOOMOUT, _(
"Zoom out" ) );
202 m_mousemenu->Append( TC_ZOOMOUT2, _(
"Zoom out 2X" ) );
203 m_mousemenu->Append( TC_ZOOMIN2, _(
"Zoom in 2X" ) );
204 m_mousemenu->Append( TC_ZOOMPANXY, _(
"Pan to XY" ) );
205 m_mousemenu->Append( TC_PROPERTY_XY, _(
"Edit Properties" ) );
265 a2dPropertyTool* propedit =
new a2dPropertyTool(
this );
311 wxASSERT_MSG(
wxDynamicCast( toolForZoom, a2dStTool ) != 0, wxT(
"Only a2dStTool can be pushed into a2dStToolContr, and not NULL" ) );
354 double mouse_worldx, mouse_worldy;
356 mouse_worldx -= CDRAWER2D->GetVisibleWidth() / 2;
357 mouse_worldy -= CDRAWER2D->GetVisibleHeight() / 2;
359 Zoom( mouse_worldx, mouse_worldy, CDRAWER2D->GetUppX(), CDRAWER2D->GetUppY() );
370 wxZoomList::compatibility_iterator node =
m_zoomstack.GetFirst();
371 zoom = *node->GetData();
372 delete node->GetData();
391 wxASSERT_MSG( 0, wxT(
"not implemented for this type of canvas" ) );
398 m_drawingPart->GetDisplayWindow()->GetClientSize( &dx, &dy );
399 if ( dy > dx ) dx = dy;
401 Zoom( CDRAWER2D->GetVisibleMinX() - CDRAWER2D->GetUppX()*dx / 2,
402 CDRAWER2D->GetVisibleMinY() - CDRAWER2D->GetUppY()*dy / 2,
403 CDRAWER2D->GetUppX() * 2, CDRAWER2D->GetUppY() * 2 );
409 m_drawingPart->GetDisplayWindow()->GetClientSize( &dx, &dy );
410 if ( dy > dx ) dx = dy;
412 Zoom( CDRAWER2D->GetVisibleMinX() + CDRAWER2D->GetUppX()*dx / 4,
413 CDRAWER2D->GetVisibleMinY() + CDRAWER2D->GetUppY()*dy / 4,
414 CDRAWER2D->GetUppX() * 0.5, CDRAWER2D->GetUppY() * 0.5 );
420 m_drawingPart->GetDisplayWindow()->GetClientSize( &dx, &dy );
421 if ( dy > dx ) dx = dy;
423 double mouse_worldx, mouse_worldy;
425 mouse_worldx -= CDRAWER2D->GetUppX() * dx / 2;
426 mouse_worldy -= CDRAWER2D->GetUppY() * dy / 2;
428 Zoom( mouse_worldx, mouse_worldy, CDRAWER2D->GetUppX() * 2, CDRAWER2D->GetUppY() * 2 );
434 m_drawingPart->GetDisplayWindow()->GetClientSize( &dx, &dy );
435 if ( dy > dx ) dx = dy;
437 double mouse_worldx, mouse_worldy;
439 mouse_worldx -= CDRAWER2D->GetUppX() * dx / 4;
440 mouse_worldy -= CDRAWER2D->GetUppY() * dy / 4;
442 Zoom( mouse_worldx, mouse_worldy, CDRAWER2D->GetUppX() * 0.5, CDRAWER2D->GetUppY() * 0.5 );
445 void a2dStToolContr::Zoom(
double x,
double y,
double uppx,
double uppy )
447 CDRAWER2D->SetMappingUpp( x, y, uppx, uppy );
448 a2dGeneralGlobals->RecordF(
this, _T(
"zoom %f %f %f %f upp" ), x, y, uppx, uppy );
454 wxASSERT_MSG(
wxDynamicCast( tool, a2dStTool ) != 0, wxT(
"Only a2dStTool can be pushed into a2dStToolContr" ) );
518 corridor.
Push( newtop );
566 switch( event.GetKeyCode() )
576 a2dDragTool* drag =
new a2dDragTool(
this );
615 if ( event.m_controlDown && event.m_shiftDown )
617 else if ( event.m_controlDown )
631 if ( event.m_controlDown )
649 case WXK_NUMPAD_ENTER:
656 if ( event.m_controlDown )
662 case WXK_NUMPAD_SUBTRACT:
664 if ( event.m_controlDown )
673 if ( event.GetKeyCode() == m_noSnapkey )
675 if ( restrictEngine )
695 switch( event.GetKeyCode() )
726 if ( event.GetKeyCode() == m_noSnapkey )
728 if ( restrictEngine )
744 std::vector<wxString>::iterator it;
745 it = m_statusStrings.end();
746 for ( it= m_statusStrings.begin(); it != m_statusStrings.end(); ++it)
755 m_statusStrings[ field ] = message;
761 m_statusStrings[ STAT_Xd_Yd ] = str;
764 double mouse_worldx, mouse_worldy;
771 wxString form = GetFormat() +
" : " + GetFormat();
773 str.Printf( form, mouse_worldx, mouse_worldy );
774 m_statusStrings[ STAT_Xw_Yw ] = str;
782 m_statusStrings[ STAT_ToolString ] = str;
791 str = m_statusStrings[ STAT_Xd_Yd ];
792 str = str + _T(
" : " ) + m_statusStrings[ STAT_Xw_Yw ];
793 str = str + _T(
" : " ) + m_statusStrings[ STAT_ToolString ];
803 m_where->GetEventHandler()->ProcessEvent( event );
811 wxPoint pos =
event.GetPosition();
820 if ( event.LeftDown() && !
m_drawingPart->GetDisplayWindow()->HasFocus() )
874 if ( event.LeftDown() && wxWindow::FindFocus() !=
m_drawingPart->GetDisplayWindow() )
880 if ( event.RightDown() && !
GetDrawingPart()->GetDisplayWindow()->GetCapture() )
906 a2dDragTool* drag =
new a2dDragTool(
this );
971 EVT_KEY_DOWN( a2dStTool::OnKeyDown )
972 EVT_KEY_UP( a2dStTool::OnKeyUp )
973 EVT_CHAR( a2dStTool::OnChar )
974 EVT_MOUSE_EVENTS( a2dStTool::OnMouseEvent )
976 EVT_PAINT( a2dStTool::OnPaint )
977 EVT_IDLE( a2dStTool::OnIdle )
978 EVT_DO( a2dStTool::OnDoEvent )
984 m_eventHandler = controller->GetDefaultToolEventHandler();
986 m_useEditOpaque = a2dOpaqueMode_Controller;
987 m_editOpacityFactor = DEFAULTOpacityFactor;
996 m_stcontroller = controller;
997 m_connectionGenerator = GetDrawing()->GetHabitat()->GetConnectionGenerator();
998 m_xanotation = m_yanotation = 0;
1001 m_dragStarted =
false;
1018 AdjustRenderOptions();
1047 void a2dStTool::SetStateString(
const wxString& message,
size_t field )
1066 return object->GetAbsoluteArea( ic );
1073 dc.GetTextExtent(
string, w, h, descent, externalLeading );
1195 void a2dStTool::DeselectAll()
1205 wxPoint pos =
event.GetPosition();
1270 a2dCanvasObjectList::value_type obj = *iter;
1272 bool release =
false;
1279 if( original && obj->GetEditingRender() )
1293 setp.SetSkipNotRenderedInDrawing(
true );
1302 obj->SetRelease(
true );
1303 obj->SetPending(
true );
1362 wxCoord w, h, descent, external;
1399 bool renderingtool =
false;
1405 renderingtool =
true;
1475 renderingtool =
false;
1499 if ( GetEvtHandlerEnabled() )
1517 if ( event.GetKeyCode() == WXK_SHIFT )
1519 if ( restrictEngine )
1555 if ( event.GetKeyCode() == WXK_SHIFT )
1557 if ( restrictEngine )
1584 switch( event.GetKeyCode() )
1628 cworld.
TransformPoint( xWorldLocal, yWorldLocal, xWorldLocal, yWorldLocal );
1669 a2dCanvasObjectList::value_type obj = *iter;
1673 a2dTag tag = tagsp->Last();
1680 void a2dStTool::PrepareForRewire(
a2dCanvasObjectList& dragList,
bool walkWires,
bool selected,
bool stopAtSelectedWire,
bool CreateExtraWires,
a2dRefMap* refs )
1692 BEGIN_EVENT_TABLE( a2dStDrawTool, a2dStTool )
1693 EVT_KEY_DOWN( a2dStDrawTool::OnKeyDown )
1694 EVT_KEY_UP( a2dStDrawTool::OnKeyUp )
1695 EVT_CHAR( a2dStDrawTool::OnChar )
1704 m_AllowModifyTemplate =
true;
1773 switch( event.GetKeyCode() )
1816 BEGIN_EVENT_TABLE( a2dDrawRectangleTool, a2dStDrawTool )
1817 EVT_CHAR( a2dDrawRectangleTool::OnChar )
1818 EVT_MOUSE_EVENTS( a2dDrawRectangleTool::OnMouseEvent )
1821 a2dDrawRectangleTool::a2dDrawRectangleTool(
a2dStToolContr* controller ): a2dStDrawTool( controller )
1828 a2dDrawRectangleTool::~a2dDrawRectangleTool()
1840 wxCoord w, h, descent, external;
1849 void a2dDrawRectangleTool::OnMouseEvent( wxMouseEvent& event )
1870 if ( event.LeftDown() && !
GetBusy() )
1883 state.Printf( form, rec->
GetPosX()*unitScale, rec->
GetPosY()*unitScale );
1884 SetStateString( state, 10 );
1887 SetStateString( state, 11 );
1890 else if ( event.LeftDown() &&
GetBusy() )
1900 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
1913 state.Printf( form, rec->
GetPosX()*unitScale, rec->
GetPosY()*unitScale );
1914 SetStateString( state, 10 );
1917 SetStateString( state, 11 );
1929 BEGIN_EVENT_TABLE( a2dZoomTool, a2dStTool )
1930 EVT_CHAR( a2dZoomTool::OnChar )
1931 EVT_MOUSE_EVENTS( a2dZoomTool::OnMouseEvent )
1936 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
1938 m_isEditTool =
false;
1943 if ( GetDrawingPart()->GetDrawer2D()->HasAlpha() || GetDrawingPart()->GetTrippleBuf() )
1945 SetFill(
a2dFill( wxColour( 66, 159, 235, 50 ) ) );
1956 : a2dStTool( other, options, refs )
1988 wxCoord w, h, descent, external;
2001 switch( event.GetKeyCode() )
2021 void a2dZoomTool::OnMouseEvent( wxMouseEvent& event )
2037 if ( event.LeftDClick() && !
GetBusy() )
2041 else if ( event.LeftDown() && !
GetBusy() )
2063 else if ( event.LeftUp() &&
GetBusy() )
2074 if ( fabs( w ) < 3 && fabs( h ) < 3 )
2109 else if ( ( event.Dragging() &&
GetBusy() ) )
2120 else if( event.RightUp() )
2130 BEGIN_EVENT_TABLE( a2dSelectTool, a2dStTool )
2131 EVT_CHAR( a2dSelectTool::OnChar )
2132 EVT_MOUSE_EVENTS( a2dSelectTool::OnMouseEvent )
2135 a2dSelectTool::a2dSelectTool(
a2dStToolContr* controller ): a2dStTool( controller )
2137 m_storeUndo =
false;
2139 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
2141 m_isEditTool =
false;
2145 m_shift_is_add =
false;
2147 if ( GetDrawingPart()->GetDrawer2D()->HasAlpha() || GetDrawingPart()->GetTrippleBuf() )
2149 SetFill(
a2dFill( wxColour( 233, 15, 23, 20 ) ) );
2159 a2dSelectTool::~a2dSelectTool()
2163 void a2dSelectTool::DeselectAll()
2165 a2dStTool::DeselectAll();
2177 wxCoord w, h, descent, external;
2186 void a2dSelectTool::OnChar( wxKeyEvent& event )
2190 switch( event.GetKeyCode() )
2210 void a2dSelectTool::OnMouseEvent( wxMouseEvent& event )
2222 if ( event.Moving() )
2226 double xWorld, yWorld;
2243 if ( event.LeftDClick() && !
GetBusy() )
2247 else if ( event.LeftDown() && !
GetBusy() )
2257 else if ( event.LeftUp() &&
GetBusy() )
2269 if ( fabs( w ) < 3 && fabs( h ) < 3 )
2277 if ( !event.m_shiftDown )
2320 if ( event.m_shiftDown || hitobject->
GetSelected() )
2343 if ( !event.m_shiftDown )
2373 if ( event.m_shiftDown )
2407 else if ( ( event.Dragging() &&
GetBusy() ) )
2422 EnterBusyModeNoGroup();
2447 BEGIN_EVENT_TABLE( a2dImageTool, a2dStDrawTool )
2448 EVT_CHAR( a2dImageTool::OnChar )
2449 EVT_MOUSE_EVENTS( a2dImageTool::OnMouseEvent )
2452 a2dImageTool::a2dImageTool(
a2dStToolContr* controller ): a2dStDrawTool( controller )
2454 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
2456 m_drawPatternOnTop =
false;
2466 a2dImageTool::~a2dImageTool()
2485 void a2dImageTool::OnChar( wxKeyEvent& event )
2489 switch( event.GetKeyCode() )
2509 void a2dImageTool::OnMouseEvent( wxMouseEvent& event )
2530 if ( event.LeftDClick() && !
GetBusy() )
2534 else if ( event.LeftDown() && !
GetBusy() )
2552 else if ( event.LeftDown() &&
GetBusy() )
2562 static wxString image_dir = _T(
"./" );
2563 static wxString filter = _T(
"All files (*.*)| *.*| BMP files (*.bmp)|*.bmp| GIF files (*.gif)|*.gif| JPEG files (*.jpg)|*.jpg;*.JPG| PNG files (*.png)| *.png" );
2565 wxFileName image_file;
2567 wxFileDialog dialog(
GetDisplayWindow(), _T(
"Select Image File" ), image_dir, image_file.GetFullPath(), filter, wxFD_OPEN );
2569 if ( dialog.ShowModal() != wxID_OK )
2573 image_dir = dialog.GetDirectory();
2574 image_file = dialog.GetFilename();
2576 wxBitmapType type = wxBITMAP_TYPE_ANY;
2578 if ( image_file.GetExt() == _T(
"bmp" ) )
2579 type = wxBITMAP_TYPE_BMP;
2580 else if ( image_file.GetExt() == _T(
"gif" ) )
2581 type = wxBITMAP_TYPE_GIF;
2582 else if ( image_file.GetExt() == _T(
"jpg" ) )
2583 type = wxBITMAP_TYPE_JPEG;
2584 else if ( image_file.GetExt() == _T(
"png" ) )
2585 type = wxBITMAP_TYPE_PNG;
2587 type = wxBITMAP_TYPE_ANY;
2594 const wxChar SEP = wxT(
'\\' );
2596 const wxChar SEP = wxT(
'/' );
2599 wxString image_fullpath = image_dir + SEP + image_file.GetFullPath();
2600 image.LoadFile( image_fullpath, type );
2604 double image_w = fabs( rec->
GetWidth() );
2605 double image_h = fabs( rec->
GetHeight() );
2607 if ( fabs( w ) < 3 && fabs( h ) < 3 )
2609 image_w = image.GetWidth();
2610 image_h = image.GetHeight();
2612 canvas_image =
new a2dImage( image, x1 + image_w / 2 , y1 + image_h / 2, 0, 0 );
2616 canvas_image =
new a2dImage( image, x1 + image_w / 2 , y1 + image_h / 2, image_w, image_h );
2618 canvas_image->
SetFilename( image_fullpath, type,
false );
2633 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
2646 BEGIN_EVENT_TABLE( a2dCopyTool, a2dDragTool )
2647 EVT_MOUSE_EVENTS( a2dCopyTool::OnMouseEvent )
2654 m_mindist = GetDrawing()->GetHabitat()->GetCopyMinDistance();
2666 if ( !m_original->GetDraggable() )
2672 if ( !EnterBusyMode() )
2675 GetDrawingPart()->SetCursor( m_toolcursor );
2681 double dx = xw - m_startMousex;
2682 double dy = yw - m_startMousey;
2683 AdjustShift( &dx, &dy );
2684 DragAbsolute( m_startObjectx + dx, m_startObjecty + dy );
2758 copy->SetAlgoSkip(
true );
2766 copy->SetAlgoSkip(
false );
2774 void a2dCopyTool::OnMouseEvent( wxMouseEvent& event )
2782 int x =
event.GetX();
2783 int y =
event.GetY();
2795 if ( event.Moving() && !
GetBusy() )
2805 if ( event.LeftDown() )
2837 else if ( event.LeftUp() &&
GetBusy() )
2865 if( ( *dx ) * ( *dx ) + ( *dy ) * ( *dy ) < m_mindist )
2867 if( ( *dx ) == 0 && ( *dy ) == 0 )
2869 ( *dx ) = m_mindist * 1.0;
2870 ( *dy ) = m_mindist * 0.5;
2874 double fac = m_mindist / sqrt( ( *dx ) * ( *dx ) + ( *dy ) * ( *dy ) );
2881 BEGIN_EVENT_TABLE( a2dDragTool, a2dStTool )
2882 EVT_MOUSE_EVENTS( a2dDragTool::OnMouseEvent )
2883 EVT_CHAR( a2dDragTool::OnChar )
2888 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
2892 m_mousecaptured =
false;
2893 m_deleteonoutsidedrop =
false;
2894 m_dropAndDrop =
false;
2897 m_lateconnect =
true;
2905 GetDrawingPart()->ToolWorldToMouse( xw, yw, m_x, m_y );
2906 GetDrawing()->GetHabitat()->SetLastXyEntry( xw, yw );
2909 if ( !StartDragging( m_x, m_y, original ) )
2916 m_snapTargetFeatures =
2917 a2dRestrictionEngine::snapToGridPos |
2920 a2dRestrictionEngine::snapToObjectPos |
2931 void a2dDragTool::OnChar( wxKeyEvent& event )
2943 switch( event.GetKeyCode() )
3028 bool a2dDragTool::StartDragging(
int x,
int y,
a2dCanvasObject* original )
3078 if ( event.Moving() && !
GetBusy() )
3089 if ( event.LeftDown() && !
GetBusy() )
3094 if ( m_dropAndDrop && original )
3099 shapeData.Append( clone );
3102 const wxChar *pc = NULL;
3103 switch ( source.DoDragDrop(
true) )
3107 wxLogError(wxT(
"An error occurred during drag and drop operation"));
3111 SetStateString( _(
"No drop happened"), STAT_toolHelp );
3123 SetStateString( _(
"Drag and drop operation cancelled"), STAT_toolHelp );
3129 SetStateString(wxString(wxT(
"Shape successfully ")) + pc, STAT_toolHelp );
3134 else if ( !StartDragging(
m_x,
m_y, original ) )
3138 else if ( event.LeftUp() &&
GetBusy() )
3156 else if ( event.RightDown() )
3173 wxString state, form;
3176 SetStateString( state, 10 );
3179 SetStateString( state, 11 );
3381 PrepareForRewire( dragList,
true,
false,
false,
true, &refs );
3394 BEGIN_EVENT_TABLE( a2dDragOrgTool, a2dStTool )
3395 EVT_MOUSE_EVENTS( a2dDragOrgTool::OnMouseEvent )
3396 EVT_CHAR( a2dDragOrgTool::OnChar )
3399 a2dDragOrgTool::a2dDragOrgTool(
a2dStToolContr* controller ): a2dStTool( controller )
3401 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
3405 m_mousecaptured =
false;
3406 m_deleteonoutsidedrop =
false;
3409 m_lateconnect =
true;
3420 void a2dDragOrgTool::OnChar( wxKeyEvent& event )
3432 switch( event.GetKeyCode() )
3482 bool a2dDragOrgTool::StartDragging(
int x,
int y,
a2dCanvasObject* original )
3530 if ( event.Moving() && !
GetBusy() )
3539 if ( event.LeftDown() && !
GetBusy() )
3547 else if ( event.LeftUp() &&
GetBusy() )
3552 else if ( event.RightDown() )
3698 PrepareForRewire( dragList,
true,
false,
false,
true, &refs );
3712 DEFINE_MENU_ITEMID( CmdMenu_NoDragMenu, wxTRANSLATE(
"Drag the new object"), wxTRANSLATE(
"Drag new object in place") )
3714 BEGIN_EVENT_TABLE( a2dDragNewTool, a2dDragTool )
3715 EVT_ENTER_WINDOW( a2dDragNewTool::OnEnter )
3716 EVT_MOUSE_EVENTS( a2dDragNewTool::OnMouseEvent )
3718 EVT_CHAR( a2dDragNewTool::OnChar )
3722 : a2dDragTool( controller )
3724 m_initiatingMenuId = &initiatingMenuId;
3725 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
3726 m_newObject = newObject;
3727 m_boxCenterDrag =
false;
3730 a2dDragNewTool::~a2dDragNewTool()
3746 m_newObject->SetTransform( matn );
3751 void a2dDragNewTool::OnComEvent(
a2dComEvent& event )
3785 void a2dDragNewTool::OnChar( wxKeyEvent& event )
3789 switch( event.GetKeyCode() )
3855 else if ( event.LeftDown() )
3859 else if ( event.RightDown() )
3863 else if ( event.LeftUp() )
3942 BEGIN_EVENT_TABLE( a2dDeleteTool, a2dStTool )
3943 EVT_CHAR( a2dDeleteTool::OnChar )
3944 EVT_MOUSE_EVENTS( a2dDeleteTool::OnMouseEvent )
3949 a2dStTool( controller )
3951 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
3955 m_whichobjects = whichobjects;
3958 void a2dDeleteTool::OnChar( wxKeyEvent& event )
3962 switch( event.GetKeyCode() )
3986 void a2dDeleteTool::OnMouseEvent( wxMouseEvent& event )
3995 int x =
event.GetX();
3996 int y =
event.GetY();
4002 if ( event.LeftDown() )
4047 BEGIN_EVENT_TABLE( a2dDrawCircleTool, a2dStDrawTool )
4048 EVT_IDLE( a2dDrawCircleTool::OnIdle )
4049 EVT_CHAR( a2dDrawCircleTool::OnChar )
4050 EVT_MOUSE_EVENTS( a2dDrawCircleTool::OnMouseEvent )
4053 a2dDrawCircleTool::a2dDrawCircleTool(
a2dStToolContr* controller ): a2dStDrawTool( controller )
4066 m_anotation.Printf( _T(
"radius %6.3f" ), m_radius );
4068 wxCoord w, h, descent, external;
4078 void a2dDrawCircleTool::OnIdle( wxIdleEvent& event )
4105 void a2dDrawCircleTool::OnChar( wxKeyEvent& event )
4109 switch( event.GetKeyCode() )
4145 dx = (
m_xwprev - m_start_x ) / 2 ;
4146 m_radius = fabs( dx );
4154 dy = (
m_ywprev - m_start_y ) / 2 ;
4155 m_radius = fabs( dy );
4161 cir->
SetPosXY( m_start_x + dx , m_start_y + dy );
4162 cirorg->SetPosXY( m_start_x + dx , m_start_y + dy );
4167 cir->
SetPosXY( m_start_x, m_start_y );
4168 cirorg->SetPosXY( m_start_x, m_start_y );
4175 cirorg->SetPosXY( (
m_xwprev + m_start_x ) / 2, (
m_ywprev + m_start_y ) / 2 );
4176 m_radius = sqrt( pow(
m_xwprev - m_start_x, 2 ) + pow(
m_ywprev - m_start_y, 2 ) ) / 2;
4184 cirorg->SetRadius( m_radius );
4189 state.Printf( form, cir->
GetPosX()*unitScale, cir->
GetPosY()*unitScale );
4190 SetStateString( state, 10 );
4192 state.Printf( form, m_radius*unitScale );
4193 SetStateString( state, 11 );
4198 void a2dDrawCircleTool::OnMouseEvent( wxMouseEvent& event )
4219 if ( event.LeftDown() && !
GetBusy() )
4231 else if ( event.LeftDown() &&
GetBusy() )
4238 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
4246 BEGIN_EVENT_TABLE( a2dDrawPolygonLTool, a2dStDrawTool )
4247 EVT_IDLE( a2dDrawPolygonLTool::OnIdle )
4248 EVT_CHAR( a2dDrawPolygonLTool::OnChar )
4249 EVT_MOUSE_EVENTS( a2dDrawPolygonLTool::OnMouseEvent )
4250 EVT_DO( a2dDrawPolygonLTool::OnDoEvent )
4251 EVT_UNDO( a2dDrawPolygonLTool::OnUndoEvent )
4252 EVT_REDO( a2dDrawPolygonLTool::OnRedoEvent )
4258 m_points->push_front( point );
4260 m_points->push_back( point );
4291 a2dDrawPolygonLTool::~a2dDrawPolygonLTool()
4300 void a2dDrawPolygonLTool::OnIdle( wxIdleEvent& event )
4346 void a2dDrawPolygonLTool::BeginPolygon(
double x,
double y )
4393 void a2dDrawPolygonLTool::AddPoint(
double x,
double y )
4406 if ( abs(
m_x - xd ) >= 3 || abs(
m_y - yd ) >= 3 )
4431 AddPoint( setcursor->GetX(), setcursor->GetY() );
4439 BeginPolygon( setcursor->GetX(), setcursor->GetY() );
4468 OnUndoEvent( event );
4482 void a2dDrawPolygonLTool::OnChar( wxKeyEvent& event )
4490 switch( event.GetKeyCode() )
4526 if ( event.m_controlDown )
4549 void a2dDrawPolygonLTool::OnMouseEvent( wxMouseEvent& event )
4567 if ( event.LeftDown() && !
GetBusy() )
4571 else if ( event.LeftDown() &&
GetBusy() )
4575 else if ( event.Moving() &&
GetBusy() )
4585 updateareas.
Reset();
4594 updateareas.
Reset();
4599 updateareas.
Reset();
4612 state.Printf( form, m_prev_x*unitScale, m_prev_y*unitScale );
4613 SetStateString( state, 10 );
4615 state.Printf( form, dx*unitScale, dy*unitScale );
4616 SetStateString( state, 11 );
4620 else if ( ( event.LeftDClick() ||
event.RightUp() ) &&
GetBusy() )
4632 BEGIN_EVENT_TABLE( a2dDrawPolylineLTool, a2dDrawPolygonLTool )
4633 EVT_MOUSE_EVENTS( a2dDrawPolylineLTool::OnMouseEvent )
4634 EVT_DO( a2dDrawPolylineLTool::OnDoEvent )
4639 a2dDrawPolygonLTool( controller, NULL )
4643 m_AllowModifyTemplate =
true;
4644 m_templatePline = templateObject;
4645 m_templateObject = templateObject;
4646 if ( !m_templatePline )
4649 m_templateObject = (
a2dPolygonL* ) m_templatePline;
4650 m_templatePline->SetEndScaleX( GetDrawing()->GetHabitat()->GetEndScaleX() );
4651 m_templatePline->SetEndScaleY( GetDrawing()->GetHabitat()->GetEndScaleY() );
4652 m_templatePline->SetBegin( GetDrawing()->GetHabitat()->GetLineBegin() );
4653 m_templatePline->SetEnd( GetDrawing()->GetHabitat()->GetLineEnd() );
4654 m_templatePline->SetPathType( GetDrawing()->GetHabitat()->GetPathType() );
4655 m_templatePline->SetContourWidth( GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits() );
4656 m_contourwidth = GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits();
4660 m_layer = m_templatePline->GetLayer();
4661 m_fill = m_templatePline->GetFill();
4662 m_stroke = m_templatePline->GetStroke();
4663 m_contourwidth = m_templatePline->GetContourWidth();
4667 a2dDrawPolylineLTool::~a2dDrawPolylineLTool()
4687 m_templatePline->
SetBegin( begin );
4692 m_templatePline->
SetEnd( end );
4706 void a2dDrawPolylineLTool::OnComEvent(
a2dComEvent& event )
4708 if ( m_AllowModifyTemplate )
4710 if ( event.GetId() == a2dHabitat::sig_SetContourWidth )
4719 else if ( event.GetId() == a2dHabitat::sig_SetPathType )
4745 void a2dDrawPolylineLTool::OnMouseEvent( wxMouseEvent& event )
4762 if ( event.LeftDown() && !
GetBusy() )
4784 line->GetBegin()->
Scale( norm, norm );
4790 line->GetEnd()->
Scale( norm, norm );
4835 BEGIN_EVENT_TABLE( a2dDrawWirePolylineLTool, a2dDrawPolylineLTool )
4836 EVT_MOUSE_EVENTS( a2dDrawWirePolylineLTool::OnMouseEvent )
4837 EVT_KEY_DOWN( a2dDrawWirePolylineLTool::OnKeyDown )
4838 EVT_CHAR( a2dDrawWirePolylineLTool::OnChar )
4839 EVT_UNDO( a2dDrawWirePolylineLTool::OnUndoEvent )
4840 EVT_REDO( a2dDrawWirePolylineLTool::OnRedoEvent )
4841 EVT_IDLE( a2dDrawWirePolylineLTool::OnIdle )
4844 a2dDrawWirePolylineLTool::a2dDrawWirePolylineLTool(
a2dStToolContr* controller )
4845 : a2dDrawPolylineLTool( controller )
4847 m_hadDoubleClick =
false;
4849 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
4851 m_pinClassStartWire = NULL;
4852 m_pinClassEndWire = NULL;
4855 m_toolBusyCursor = *wxSTANDARD_CURSOR;
4856 m_splitAtEnd =
true;
4859 m_manhattan =
false;
4863 m_snapTargetFeatures =
4864 a2dRestrictionEngine::snapToGridPos |
4875 a2dDrawWirePolylineLTool::~a2dDrawWirePolylineLTool()
4907 switch ( m_wiringMode )
4917 case a2d_BasedOnObjectClassRequired:
4921 case a2d_StartGenerateSearchFinish:
5109 void a2dDrawWirePolylineLTool::OnIdle( wxIdleEvent& event )
5119 m_endSegmentMode = mode;
5120 switch ( m_endSegmentMode )
5124 m_manhattan =
false;
5142 m_manhattan =
false;
5198 void a2dDrawWirePolylineLTool::OnKeyDown( wxKeyEvent& event )
5202 switch( event.GetKeyCode() )
5220 if ( abs( m_startWireXdev - endx ) >
GetDrawing()->GetHabitat()->GetHandle()->GetWidth() || abs( m_startWireYdev - endy ) >
GetDrawing()->GetHabitat()->GetHandle()->GetWidth() )
5240 void a2dDrawWirePolylineLTool::OnChar( wxKeyEvent& event )
5248 switch( event.GetKeyCode() )
5253 if ( m_endSegmentMode == WIREEND_STRAIGHT )
5254 m_endSegmentMode = WIREEND_MANHATTAN_X;
5255 else if ( m_endSegmentMode == WIREEND_MANHATTAN_X )
5256 m_endSegmentMode = WIREEND_MANHATTAN_Y;
5257 else if ( m_endSegmentMode == WIREEND_MANHATTAN_Y )
5258 m_endSegmentMode = WIREEND_STRAIGHT;
5290 if ( event.m_controlDown )
5313 void a2dDrawWirePolylineLTool::AtNewVertex()
5355 SearchPinForFinishWire(
GetDrawingPart()->GetShowObject(), drawPin, NULL, hitDistance );
5359 drawPin->
SetPosXY( unRestx, unResty );
5362 SearchPinForFinishWire(
GetDrawingPart()->GetShowObject(), drawPin, NULL, hitDistance );
5367 if ( abs(
m_x - x ) >= 3 || abs(
m_y - y ) >= 3 )
5371 ( void )wxMessageBox( _(
"You cannot connect to this end pin" ), _(
"Connect" ), wxICON_INFORMATION | wxOK );
5461 if ( wireconnected )
5482 void a2dDrawWirePolylineLTool::OnMouseEvent( wxMouseEvent& event )
5510 if ( event.LeftDown() )
5512 m_hadDoubleClick =
false;
5516 else if ( event.LeftUp() && !
GetBusy() && m_hadDoubleClick )
5518 m_hadDoubleClick =
false;
5520 else if ( event.LeftUp() && !
GetBusy() )
5524 ( void )wxMessageBox( _(
"you can not drag a pin" ), _(
"Connect" ), wxICON_INFORMATION | wxOK );
5548 ( void )wxMessageBox( _(
"A connection must start at a pin or another connection" ), _(
"Connect" ), wxICON_INFORMATION | wxOK );
5570 if ( wireconnected )
5587 wxASSERT_MSG(
m_original.Get() != 0, wxT(
"a connection object could not be created for the pin clicked" ) );
5640 m_startWireXdev =
m_x;
5641 m_startWireYdev =
m_y;
5646 else if ( event.LeftUp() &&
GetBusy() )
5650 else if ( event.LeftDClick() &&
GetBusy() )
5652 m_hadDoubleClick =
true;
5664 if ( abs( m_startWireXdev - endx ) >
GetDrawing()->GetHabitat()->GetHandle()->GetWidth() || abs( m_startWireYdev - endy ) >
GetDrawing()->GetHabitat()->GetHandle()->GetWidth() )
5669 else if ( event.RightUp() &&
GetBusy() )
5671 m_hadDoubleClick =
true;
5679 m_point = org->GetFirstPoint();
5705 else if ( ( event.Dragging() ||
event.Moving() ) &&
GetBusy() )
5738 switch ( m_wiringMode )
5747 case a2d_BasedOnObjectClassRequired:
5753 case a2d_StartGenerateSearchFinish:
5761 SetStateString( _(
"Click to end wire at this pin"), STAT_toolHelp );
5763 SetStateString( _(
"Click to add vertex or end wire at other pin or at Double Click"), STAT_toolHelp );
5768 updateareas.
Expand( m_prev_x, m_prev_y );
5771 updateareas.
Reset();
5772 updateareas.
Expand( m_points->front()->GetPoint() );
5780 float dxdev = x -
m_x;
5781 float dydev = y -
m_y;
5782 double lendev = sqrt( dxdev*dxdev + dydev*dydev );
5786 if ( fabs( dx ) < fabs( dy ) )
5813 updateareas.
Reset();
5814 updateareas.
Expand( m_prev_x, m_prev_y );
5818 updateareas.
Reset();
5819 updateareas.
Expand( m_points->front()->GetPoint() );
5829 state.Printf( form, m_prev_x*unitScale, m_prev_y*unitScale );
5830 SetStateString( state, 10 );
5832 state.Printf( form, dx*unitScale, dy*unitScale );
5833 SetStateString( state, 11 );
5835 else if ( event.Moving() && !
GetBusy() )
5850 switch ( m_wiringMode )
5859 case a2d_BasedOnObjectClassRequired:
5865 case a2d_StartGenerateSearchFinish:
5917 m_points->push_back(
m_point );
5939 OnUndoEvent( event );
5942 BEGIN_EVENT_TABLE( a2dDrawEllipseTool, a2dStDrawTool )
5943 EVT_IDLE( a2dDrawEllipseTool::OnIdle )
5944 EVT_CHAR( a2dDrawEllipseTool::OnChar )
5945 EVT_MOUSE_EVENTS( a2dDrawEllipseTool::OnMouseEvent )
5948 a2dDrawEllipseTool::a2dDrawEllipseTool(
a2dStToolContr* controller ): a2dStDrawTool( controller )
5963 wxCoord w, h, descent, external;
5972 void a2dDrawEllipseTool::OnIdle( wxIdleEvent& event )
6014 ellip->
SetPosXY( m_start_x, m_start_y );
6015 elliporg->SetPosXY( m_start_x, m_start_y );
6019 xs = m_xwprev - ellip->
GetPosX();
6024 elliporg->SetWidth( fabs( xs * 2 ) );
6025 elliporg->SetHeight( fabs( ys * 2 ) );
6030 ellip->
SetPosXY( ( m_xwprev + m_start_x ) / 2, (
m_ywprev + m_start_y ) / 2 );
6031 elliporg->SetPosXY( ( m_xwprev + m_start_x ) / 2, (
m_ywprev + m_start_y ) / 2 );
6035 xs = m_xwprev - ellip->
GetPosX();
6040 elliporg->SetWidth( fabs( xs * 2 ) );
6041 elliporg->SetHeight( fabs( ys * 2 ) );
6051 state.Printf( form, ellip->
GetPosX()*unitScale, ellip->
GetPosY()*unitScale );
6052 SetStateString( state, 10 );
6054 state.Printf( form, ellip->
GetWidth()*unitScale, ellip->
GetHeight()*unitScale );
6055 SetStateString( state, 11 );
6061 void a2dDrawEllipseTool::OnChar( wxKeyEvent& event )
6065 switch( event.GetKeyCode() )
6083 void a2dDrawEllipseTool::OnMouseEvent( wxMouseEvent& event )
6104 if ( event.LeftDown() && !
GetBusy() )
6116 else if ( event.LeftDown() &&
GetBusy() )
6123 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
6131 BEGIN_EVENT_TABLE( a2dDrawEllipticArcTool, a2dStDrawTool )
6132 EVT_IDLE( a2dDrawEllipticArcTool::OnIdle )
6133 EVT_CHAR( a2dDrawEllipticArcTool::OnChar )
6134 EVT_MOUSE_EVENTS( a2dDrawEllipticArcTool::OnMouseEvent )
6137 a2dDrawEllipticArcTool::a2dDrawEllipticArcTool(
a2dStToolContr* controller,
a2dEllipticArc* templateobject ): a2dStDrawTool( controller )
6146 m_templateobject = templateobject;
6158 wxCoord w, h, descent, external;
6167 void a2dDrawEllipticArcTool::OnIdle( wxIdleEvent& event )
6214 xs = m_xwprev - ellip->
GetPosX();
6219 elliporg->SetWidth( fabs( xs * 2 ) );
6220 elliporg->SetHeight( fabs( ys * 2 ) );
6230 xs = m_xwprev - ellip->
GetPosX();
6235 elliporg->SetWidth( fabs( xs * 2 ) );
6236 elliporg->SetHeight( fabs( ys * 2 ) );
6246 state.Printf( form, ellip->
GetPosX()*unitScale, ellip->
GetPosY()*unitScale );
6247 SetStateString( state, 10 );
6249 state.Printf( form, ellip->
GetWidth()*unitScale, ellip->
GetHeight()*unitScale );
6250 SetStateString( state, 11 );
6266 void a2dDrawEllipticArcTool::OnChar( wxKeyEvent& event )
6270 switch( event.GetKeyCode() )
6307 void a2dDrawEllipticArcTool::OnMouseEvent( wxMouseEvent& event )
6328 if ( event.LeftDown() && !
GetBusy() )
6353 else if ( event.LeftDown() &&
GetBusy() )
6366 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
6372 xs = m_xwprev - ellip->
GetPosX();
6397 BEGIN_EVENT_TABLE( a2dDrawArcTool, a2dStDrawTool )
6398 EVT_IDLE( a2dDrawArcTool::OnIdle )
6399 EVT_CHAR( a2dDrawArcTool::OnChar )
6400 EVT_MOUSE_EVENTS( a2dDrawArcTool::OnMouseEvent )
6403 a2dDrawArcTool::a2dDrawArcTool(
a2dStToolContr* controller ): a2dStDrawTool( controller )
6422 wxCoord w, h, descent, external;
6431 void a2dDrawArcTool::OnIdle( wxIdleEvent& event )
6458 void a2dDrawArcTool::OnChar( wxKeyEvent& event )
6462 switch( event.GetKeyCode() )
6517 radius = fabs( dx );
6526 radius = fabs( dy );
6555 cirorg->SetRadius( radius );
6560 state.Printf( form, cir->
GetPosX()*unitScale, cir->
GetPosY()*unitScale );
6561 SetStateString( state, 10 );
6563 state.Printf( form, radius*unitScale );
6564 SetStateString( state, 11 );
6583 void a2dDrawArcTool::OnMouseEvent( wxMouseEvent& event )
6604 if ( event.LeftDown() && !
GetBusy() )
6607 double radius = 0.00001;
6617 else if ( event.LeftDown() &&
GetBusy() )
6628 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
6634 xs = m_xwprev - arc->
GetPosX();
6644 arc->
SetX1( cos( atan2( ys, xs ) ) * radius );
6645 arc->
SetY1( sin( atan2( ys, xs ) ) * radius );
6646 arcorg->SetX1( cos( atan2( ys, xs ) ) * radius );
6647 arcorg->SetY1( sin( atan2( ys, xs ) ) * radius );
6654 arcorg->SetX2( xs );
6655 arcorg->SetY2( ys );
6669 BEGIN_EVENT_TABLE( a2dDrawLineTool, a2dStDrawTool )
6670 EVT_CHAR( a2dDrawLineTool::OnChar )
6671 EVT_MOUSE_EVENTS( a2dDrawLineTool::OnMouseEvent )
6672 EVT_DO( a2dDrawLineTool::OnDoEvent )
6675 a2dDrawLineTool::a2dDrawLineTool(
a2dStToolContr* controller,
a2dSLine* templateObject ): a2dStDrawTool( controller )
6680 m_AllowModifyTemplate =
true;
6681 m_templateObject = templateObject;
6682 if ( !m_templateObject )
6685 m_templateObject->SetEndScaleX( GetDrawing()->GetHabitat()->GetEndScaleX() );
6686 m_templateObject->SetEndScaleY( GetDrawing()->GetHabitat()->GetEndScaleY() );
6687 m_templateObject->SetBegin( GetDrawing()->GetHabitat()->GetLineBegin() );
6688 m_templateObject->SetEnd( GetDrawing()->GetHabitat()->GetLineEnd() );
6689 m_templateObject->SetPathType( GetDrawing()->GetHabitat()->GetPathType() );
6690 m_templateObject->SetContourWidth( GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits() );
6691 m_contourwidth = GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits();
6695 m_layer = m_templateObject->GetLayer();
6696 m_fill = m_templateObject->GetFill();
6697 m_stroke = m_templateObject->GetStroke();
6698 m_contourwidth = m_templateObject->GetContourWidth();
6702 a2dDrawLineTool::~a2dDrawLineTool()
6764 void a2dDrawLineTool::OnChar( wxKeyEvent& event )
6768 if ( event.GetKeyCode() == WXK_SPACE )
6770 a2dGeneralGlobals->RecordF(
this, _T(
"line %f %f %f %f" ), m_x1, m_y1, m_x2, m_y2 );
6781 switch( event.GetKeyCode() )
6809 if ( event.m_controlDown )
6835 void a2dDrawLineTool::OnMouseEvent( wxMouseEvent& event )
6856 if ( event.LeftDown() && !
GetBusy() )
6888 else if ( event.LeftDown() &&
GetBusy() )
6893 a2dGeneralGlobals->RecordF(
this, _T(
"line %f %f %f %f" ), m_x1, m_y1, m_x2, m_y2 );
6897 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
6906 lineorg->SetPosXY12( m_x1, m_y1, m_x2, m_y2 );
6915 BEGIN_EVENT_TABLE( a2dRotateTool, a2dStTool )
6916 EVT_CHAR( a2dRotateTool::OnChar )
6917 EVT_MOUSE_EVENTS( a2dRotateTool::OnMouseEvent )
6918 EVT_IDLE( a2dRotateTool::OnIdle )
6919 EVT_KEY_DOWN( a2dRotateTool::OnKeyDown )
6922 a2dRotateTool::a2dRotateTool(
a2dStToolContr* controller ): a2dStTool( controller )
6924 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
6930 a2dRotateTool::~a2dRotateTool()
6954 void a2dRotateTool::OnChar( wxKeyEvent& event )
6960 double dx = m_xwprev - m_xr;
6966 ang = atan2( dy, dx );
6975 switch( event.GetKeyCode() )
7014 restrict->
RestrictPoint( xw, yw, a2dRestrictionEngine::snapToPointAngle );
7023 angn = atan2( dy, dx );
7027 if ( angn <= 0 ) angn += 2.0 *
wxPI;
7028 if ( ang < 0 ) ang += 2.0 *
wxPI;
7056 void a2dRotateTool::OnIdle( wxIdleEvent& event )
7078 void a2dRotateTool::OnMouseEvent( wxMouseEvent& event )
7097 if ( event.Moving() && !
GetBusy() )
7106 if ( event.LeftDown() && !
GetBusy() )
7130 if ( event.m_shiftDown )
7152 else if ( event.LeftUp() &&
GetBusy() )
7166 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
7168 if ( px != m_x || py != m_y )
7176 restrict->
RestrictPoint( xw, yw, a2dRestrictionEngine::snapToPointAngle );
7178 dx = m_xwprev - m_xr;
7185 ang = atan2( dy, dx );
7193 angn = atan2( dy, dx );
7198 if ( angn <= 0 ) angn += 2.0 *
wxPI;
7200 if ( ang < 0 ) ang += 2.0 *
wxPI;
7241 BEGIN_EVENT_TABLE( a2dDrawTextTool, a2dStDrawTool )
7242 EVT_MOUSE_EVENTS( a2dDrawTextTool::OnMouseEvent )
7245 INITIALIZE_PROPERTIES( a2dDrawTextTool, a2dStDrawTool )
7281 a2dDrawTextTool::~a2dDrawTextTool()
7285 void a2dDrawTextTool::OnMouseEvent( wxMouseEvent& event )
7305 if ( event.Moving() )
7311 if ( hitobject && !event.m_shiftDown )
7322 if ( event.LeftDown() && !
GetBusy() )
7327 if ( hitobject && !event.m_shiftDown )
7338 if ( ! ( hitobject && !event.m_shiftDown ) )
7355 BEGIN_EVENT_TABLE( a2dDragMultiTool, a2dStTool )
7356 EVT_KEY_DOWN( a2dDragMultiTool::OnKeyDown )
7357 EVT_KEY_UP( a2dDragMultiTool::OnKeyUp )
7358 EVT_CHAR( a2dDragMultiTool::OnChar )
7359 EVT_MOUSE_EVENTS( a2dDragMultiTool::OnMouseEvent )
7362 a2dDragMultiTool::a2dDragMultiTool(
a2dStToolContr* controller ): a2dStTool( controller )
7364 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
7370 m_snapTargetFeatures =
7371 a2dRestrictionEngine::snapToGridPos |
7374 a2dRestrictionEngine::snapToObjectPos |
7382 a2dDragMultiTool::~a2dDragMultiTool()
7386 void a2dDragMultiTool::OnKeyDown( wxKeyEvent& event )
7417 switch( event.GetKeyCode() )
7444 if ( shiftx || shifty )
7449 DragAbsolute( m_xwprev,
m_ywprev );
7464 switch( event.GetKeyCode() )
7491 if ( shiftx || shifty )
7505 void a2dDragMultiTool::OnKeyUp( wxKeyEvent& event )
7515 switch( event.GetKeyCode() )
7534 void a2dDragMultiTool::OnChar( wxKeyEvent& event )
7538 switch( event.GetKeyCode() )
7552 switch( event.GetKeyCode() )
7565 bool a2dDragMultiTool::StartDragging(
int x,
int y,
a2dCanvasObject* original )
7599 void a2dDragMultiTool::OnMouseEvent( wxMouseEvent& event )
7614 if ( event.Moving() && !
GetBusy() )
7631 if ( event.LeftDown() && !
GetBusy() )
7634 if ( !StartDragging( m_x, m_y, original ) )
7637 else if ( event.LeftUp() &&
GetBusy() )
7668 wxString state, form;
7671 SetStateString( state, 10 );
7674 SetStateString( state, 11 );
7694 for( a2dCanvasObjectList::iterator iter = m_copies.begin(); iter != m_copies.end(); ++iter )
7705 for( a2dCanvasObjectList::iterator iter =
m_objects.begin(); iter !=
m_objects.end(); ++iter )
7714 (*iter)->SetBin2(
false );
7725 for( a2dCanvasObjectList::iterator iter =
m_objects.begin(); iter !=
m_objects.end(); ++iter )
7730 obj->SetAlgoSkip(
true );
7732 ConnectToPinsObject(
GetDrawingPart()->GetShowObject(), obj, hitDistance );
7733 obj->SetAlgoSkip(
false );
7769 void a2dDragMultiTool::DragAbsolute(
double x,
double y )
7774 for( a2dCanvasObjectList::iterator iter = m_copies.begin(); iter != m_copies.end(); ++iter )
7823 double dx = x - oldpos.m_x;
7824 double dy = y - oldpos.m_y;
7825 for( a2dCanvasObjectList::iterator iter = m_copies.begin(); iter != m_copies.end(); ++iter )
7835 wxString state, form;
7837 state.Printf( form, (bbox.
GetMinX()+dx)*unitScale, (bbox.
GetMinY()+dy)*unitScale );
7838 SetStateString( state, 10 );
7841 SetStateString( state, 11 );
7868 a2dCanvasObjectList::iterator iter;
7872 setflags.SetSkipNotRenderedInDrawing(
true );
7886 iter = inBetweenWires.begin();
7887 while( iter != inBetweenWires.end() )
7889 a2dCanvasObjectList::value_type wire = *iter;
7891 iter = inBetweenWires.erase( iter );
7894 wire->SetSelected(
true );
7912 original->
SetBin(
true );
7913 m_copies.push_back( copy );
7921 for( iter = m_copies.begin(); iter != m_copies.end(); ++iter )
7927 PrepareForRewire(
m_objects,
true,
false,
true,
true, &refs );
7969 BEGIN_EVENT_TABLE( a2dDragMultiNewTool, a2dDragMultiTool )
7970 EVT_ENTER_WINDOW( a2dDragMultiNewTool::OnEnter )
7971 EVT_MOUSE_EVENTS( a2dDragMultiNewTool::OnMouseEvent )
7976 : a2dDragMultiTool( controller )
7978 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
7979 m_originals = *originals;
7982 a2dDragMultiNewTool::~a2dDragMultiNewTool()
7984 m_originals.clear();
7988 void a2dDragMultiNewTool::OnComEvent(
a2dComEvent& event )
8022 bool a2dDragMultiNewTool::StartDragging(
int x,
int y )
8032 a2dCanvasObjectList::iterator iter = m_originals.begin();
8033 for( iter = m_originals.begin(); iter != m_originals.end(); ++iter )
8046 iter = m_originals.begin();
8047 for( iter = m_originals.begin(); iter != m_originals.end(); ++iter )
8078 void a2dDragMultiNewTool::OnMouseEvent( wxMouseEvent& event )
8099 StartDragging( m_x, m_y );
8106 else if ( event.LeftDown() )
8110 else if ( event.RightDown() )
8114 else if ( event.LeftUp() )
8116 a2dDragMultiTool::OnMouseEvent( event );
8122 a2dDragMultiTool::OnMouseEvent( event );
8170 for( a2dCanvasObjectList::iterator iter = m_copies.begin(); iter != m_copies.end(); ++iter )
8185 for( a2dCanvasObjectList::iterator iter =
m_objects.begin(); iter !=
m_objects.end(); ++iter )
8194 (*iter)->SetBin2(
false );
8205 for( a2dCanvasObjectList::iterator iter =
m_objects.begin(); iter !=
m_objects.end(); ++iter )
8210 obj->SetAlgoSkip(
true );
8212 ConnectToPinsObject(
GetDrawingPart()->GetShowObject(), obj, hitDistance );
8213 obj->SetAlgoSkip(
false );
8224 BEGIN_EVENT_TABLE( a2dCopyMultiTool, a2dDragMultiTool )
8225 EVT_CHAR( a2dCopyMultiTool::OnChar )
8226 EVT_MOUSE_EVENTS( a2dCopyMultiTool::OnMouseEvent )
8229 a2dCopyMultiTool::a2dCopyMultiTool(
a2dStToolContr* controller ): a2dDragMultiTool( controller )
8231 m_mindist = GetDrawing()->GetHabitat()->GetCopyMinDistance();
8234 void a2dCopyMultiTool::OnChar( wxKeyEvent& event )
8238 switch( event.GetKeyCode() )
8253 bool a2dCopyMultiTool::StartDragging(
int x,
int y,
a2dCanvasObject* original )
8277 bool originalfound =
false;
8278 a2dCanvasObjectList::iterator iter;
8293 originalfound =
true;
8297 wxASSERT( originalfound );
8301 ( *iter )->SetSelected(
true );
8333 void a2dCopyMultiTool::OnMouseEvent( wxMouseEvent& event )
8341 int x =
event.GetX();
8342 int y =
event.GetY();
8353 if ( event.LeftDown() && !
GetBusy() )
8356 if ( !StartDragging( m_x, m_y, original ) )
8359 else if ( event.LeftUp() &&
GetBusy() )
8361 a2dDragMultiTool::OnMouseEvent( event );
8365 a2dDragMultiTool::OnMouseEvent( event );
8375 if( ( *dx ) * ( *dx ) + ( *dy ) * ( *dy ) < m_mindist )
8377 if( ( *dx ) == 0 && ( *dy ) == 0 )
8379 ( *dx ) = m_mindist * 1.0;
8380 ( *dy ) = m_mindist * 0.5;
8384 double fac = m_mindist / sqrt( ( *dx ) * ( *dx ) + ( *dy ) * ( *dy ) );
8391 BEGIN_EVENT_TABLE( a2dPropertyTool, a2dStTool )
8392 EVT_CHAR( a2dPropertyTool::OnChar )
8393 EVT_MOUSE_EVENTS( a2dPropertyTool::OnMouseEvent )
8396 a2dPropertyTool::a2dPropertyTool(
a2dStToolContr* controller ): a2dStTool( controller )
8398 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
8407 void a2dPropertyTool::OnChar( wxKeyEvent& event )
8411 switch( event.GetKeyCode() )
8427 void a2dPropertyTool::OnMouseEvent( wxMouseEvent& event )
8436 int x =
event.GetX();
8437 int y =
event.GetY();
8443 if ( event.LeftDown() )
8479 bool a2dPropertyTool::StartEditing(
double x,
double y )
8484 return StartEditing( mouse_x, mouse_y );
8487 bool a2dPropertyTool::StartEditing(
int x,
int y )
8489 wxMouseEvent event( wxEVT_LEFT_DOWN );
8493 OnMouseEvent( event );
8498 BEGIN_EVENT_TABLE( a2dFollowLink, a2dStTool )
8499 EVT_CHAR( a2dFollowLink::OnChar )
8500 EVT_MOUSE_EVENTS( a2dFollowLink::OnMouseEvent )
8503 a2dFollowLink::a2dFollowLink(
a2dStToolContr* controller ): a2dStTool( controller )
8505 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
8513 void a2dFollowLink::OnChar( wxKeyEvent& event )
8517 switch( event.GetKeyCode() )
8533 void a2dFollowLink::OnMouseEvent( wxMouseEvent& event )
8542 int x =
event.GetX();
8543 int y =
event.GetY();
8549 if ( event.LeftDown() )
8571 bool a2dFollowLink::StartEditing(
double x,
double y )
8576 return StartEditing( mouse_x, mouse_y );
8579 bool a2dFollowLink::StartEditing(
int x,
int y )
8581 wxMouseEvent event( wxEVT_LEFT_DOWN );
8585 OnMouseEvent( event );
8606 m_stcontroller = controller;
8608 m_options = a2dTakeToolstyleFromCmdhOnPop | a2dTakeToolstyleFromCmdhOnPush | a2dTakeToolstyleToNewObject | a2dTakeToolstyleToCentral;
8640 void a2dStToolEvtHandler::OnKeyDown( wxKeyEvent& event )
8643 switch( event.GetKeyCode() )
8648 if ( !first || ( first && !first->
GetBusy() ) )
8650 if ( event.m_controlDown && event.m_shiftDown )
8652 else if ( event.m_controlDown )
8664 if ( !first || ( first && !first->
GetBusy() ) )
8666 if ( event.m_controlDown )
8680 void a2dStToolEvtHandler::OnKeyUp( wxKeyEvent& event )
8685 void a2dStToolEvtHandler::TakeToCmdhFromEditedObject(
a2dObjectEditTool* editTool )
8739 void a2dStToolEvtHandler::OnIdle( wxIdleEvent& event )
8761 a2dSignal comId =
event.GetId();
8782 bool baseContinue =
true;
8788 tool->SetEvtHandlerEnabled(
false );
8789 TakeToCmdhFromEditedObject( tool );
8794 tool->SetEvtHandlerEnabled(
true );
8800 if (
wxDynamicCast( event.GetEventObject(), a2dDrawWirePolylineLTool ) )
8810 baseContinue =
false;
8812 else if (
wxDynamicCast( event.GetEventObject(), a2dDrawPolygonLTool ) )
8814 a2dDrawPolygonLTool* tool =
wxStaticCast( event.GetEventObject(), a2dDrawPolygonLTool );
8818 habitat->SetSpline( tool->
GetSpline() );
8822 habitat->SetSpline( tool->
GetSpline() );
8825 else if (
wxDynamicCast( event.GetEventObject(), a2dDrawPolylineLTool ) )
8829 a2dDrawPolylineLTool* tool =
wxStaticCast( event.GetEventObject(), a2dDrawPolylineLTool );
8832 tool->
SetSpline( habitat->GetSpline() );
8840 a2dDrawPolylineLTool* tool =
wxStaticCast( event.GetEventObject(), a2dDrawPolylineLTool );
8843 habitat->SetSpline( tool->
GetSpline() );
8850 else if (
wxDynamicCast( event.GetEventObject(), a2dDrawLineTool ) )
8854 a2dDrawLineTool* tool =
wxStaticCast( event.GetEventObject(), a2dDrawLineTool );
8864 a2dDrawPolylineLTool* tool =
wxStaticCast( event.GetEventObject(), a2dDrawPolylineLTool );
8873 else if (
wxDynamicCast( event.GetEventObject(), a2dDrawTextTool ) )
8875 a2dDrawTextTool* tool =
wxStaticCast( event.GetEventObject(), a2dDrawTextTool );
8890 baseContinue =
true;
8894 baseContinue =
false;
8898 baseContinue =
false;
8900 else if (
wxDynamicCast( event.GetEventObject(), a2dDragNewTool ) )
8902 baseContinue =
false;
8906 if ( baseContinue &&
8911 a2dStDrawTool* tool =
wxDynamicCast( event.GetEventObject(), a2dStDrawTool );
8913 a2dDrawTextTool* textTool =
wxDynamicCast( tool, a2dDrawTextTool );
8921 habitat->GetTextTemplateObject()->SetFill( tool->
GetFill() );
8922 habitat->GetTextTemplateObject()->SetStroke( tool->
GetStroke() );
8923 habitat->GetTextTemplateObject()->SetLayer( tool->
GetLayer() );
8947 a2dCanvasObject::PROPID_Fill->SetPropertyToObject( obj, tool->
GetFill() );
8956 habitat->SetFill( tool->
GetFill() );
8957 habitat->SetStroke( tool->
GetStroke() );
8958 habitat->SetLayer( tool->
GetLayer() );
8982 a2dCanvasObject::PROPID_Fill->SetPropertyToObject( obj, tool->
GetFill() );
8996 comId == a2dHabitat::sig_changedStroke ||
8997 comId == a2dHabitat::sig_changedLayer ||
8998 comId == a2dHabitat::sig_changedFont ||
8999 comId == a2dHabitat::sig_changedTextFill ||
9000 comId == a2dHabitat::sig_changedTextStroke ||
9001 comId == a2dHabitat::sig_changedTextFont
9007 a2dStDrawTool* drawtool =
wxDynamicCast( tool, a2dStDrawTool );
9008 a2dDrawTextTool* textTool =
wxDynamicCast( tool, a2dDrawTextTool );
9014 if ( editTool && editTool->
GetBusy() )
9047 if ( comId == a2dHabitat::sig_changedStroke && ! tool->
GetStroke().IsSameAs( s ) )
9064 if ( comId == a2dHabitat::sig_changedTextFill && ! tool->
GetFill().IsSameAs( f ) )
9071 if ( comId == a2dHabitat::sig_changedTextStroke && ! tool->
GetStroke().IsSameAs( s ) )
9079 if ( comId == a2dHabitat::sig_changedLayer && tool->
GetLayer() != habitat->
GetLayer() )
9091 if ( comId == a2dHabitat::sig_changedFont )
9093 if ( editTool && editTool->
GetBusy() )
9105 else if ( comId == a2dHabitat::sig_changedTextFont &&
wxDynamicCast( tool, a2dDrawTextTool ) )
9107 a2dDrawTextTool* textTool =
wxDynamicCast( tool, a2dDrawTextTool );
9117 a2dDrawPolylineLTool* toolt =
wxStaticCast( tool, a2dDrawPolylineLTool );
9137 a2dDrawLineTool* toolt =
wxStaticCast( tool, a2dDrawLineTool );
9184 const a2dCommandId* comId =
event.GetCommand()->GetCommandId();
9192 a2dStDrawTool* drawtool =
wxDynamicCast( tool, a2dStDrawTool );
9215 OnUndoEvent( event );
9234 m_stcontroller = controller;
9235 m_takeToolstyleToCmdhOnPush =
false;
9242 void a2dStToolFixedToolStyleEvtHandler::OnKeyDown( wxKeyEvent& event )
9245 switch( event.GetKeyCode() )
9250 if ( !first || ( first && !first->
GetBusy() ) )
9252 if ( event.m_controlDown && event.m_shiftDown )
9254 else if ( event.m_controlDown )
9266 if ( !first || ( first && !first->
GetBusy() ) )
9268 if ( event.m_controlDown )
9282 void a2dStToolFixedToolStyleEvtHandler::OnKeyUp( wxKeyEvent& event )
9287 void a2dStToolFixedToolStyleEvtHandler::OnComEvent(
a2dComEvent& event )
9310 bool baseContinue =
true;
9311 if ( baseContinue &&
wxDynamicCast( event.GetEventObject(), a2dStDrawTool ) )
9315 a2dStDrawTool* tool =
wxDynamicCast( event.GetEventObject(), a2dStDrawTool );
9371 BEGIN_EVENT_TABLE( a2dDrawVPathTool, a2dStDrawTool )
9372 EVT_IDLE( a2dDrawVPathTool::OnIdle )
9373 EVT_CHAR( a2dDrawVPathTool::OnChar )
9374 EVT_MOUSE_EVENTS( a2dDrawVPathTool::OnMouseEvent )
9375 EVT_UNDO( a2dDrawVPathTool::OnUndoEvent )
9376 EVT_REDO( a2dDrawVPathTool::OnRedoEvent )
9382 m_vpath->Add( segment );
9384 m_vpath->Add( segment );
9398 m_controlSet =
false;
9401 m_controlPoints = NULL;
9404 a2dDrawVPathTool::~a2dDrawVPathTool()
9408 void a2dDrawVPathTool::OnIdle( wxIdleEvent& event )
9480 OnUndoEvent( event );
9494 void a2dDrawVPathTool::OnChar( wxKeyEvent& event )
9502 switch( event.GetKeyCode() )
9537 if ( event.m_controlDown )
9560 void a2dDrawVPathTool::OnMouseEvent( wxMouseEvent& event )
9580 if ( event.LeftDown() && !
GetBusy() )
9616 m_vpath->Add( m_segmentPrev );
9629 m_controlSet =
false;
9630 m_endSegment =
false;
9635 else if ( event.LeftDown() &&
GetBusy() )
9638 m_controlSet =
false;
9639 else if ( !m_bezier && !m_endSegment )
9641 m_controlSet =
true;
9646 else if ( event.LeftUp() &&
GetBusy() )
9651 else if ( m_bezier && !m_controlSet )
9653 m_controlSet =
true;
9656 m_endSegment =
true;
9658 else if ( m_bezier && m_controlSet && !m_endSegment )
9660 m_endSegment =
true;
9662 else if ( !m_bezier || ( m_bezier && m_endSegment ) )
9667 if ( abs( m_x - x ) >= 3 || abs( m_y - y ) >= 3 )
9686 m_controlSet =
false;
9687 m_endSegment =
false;
9695 else if ( event.Moving() &&
GetBusy() )
9704 else if ( event.Dragging() &&
GetBusy() )
9707 if ( !m_endSegment )
9712 if ( !m_controlSet )
9719 seg->
m_x2 = m_contrmid_x - dx;
9720 seg->
m_y2 = m_contrmid_y - dy;
9724 seg->
m_x1 = m_xwprev + 1;
9736 else if ( event.LeftDClick() &&
GetBusy() )
9746 BEGIN_EVENT_TABLE( a2dMovePinTool, a2dDragTool )
9747 EVT_MOUSE_EVENTS( a2dMovePinTool::OnMouseEvent )
9748 EVT_CHAR( a2dMovePinTool::OnChar )
9751 a2dMovePinTool::a2dMovePinTool(
a2dStToolContr* controller,
a2dPin* dragPin,
double xw,
double yw,
bool disConnectFirst )
9752 : a2dDragTool( controller )
9754 m_deleteonoutsidedrop =
false;
9755 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
9761 m_snapTargetFeatures =
9762 a2dRestrictionEngine::snapToGridPos |
9766 m_dragPin = dragPin;
9773 if ( disConnectFirst && m_dragPin && m_dragPin->FindNonWirePin() )
9775 OpenCommandGroup(
false );
9776 m_dragPin->GetParent()->DisConnectAt( m_dragPin,
true );
9779 GetDrawingPart()->ToolWorldToMouse( xw, yw, m_x, m_y );
9781 GetDrawing()->GetHabitat()->SetLastXyEntry( xw, yw );
9783 m_dragPinObj =
new a2dRectC( xw, yw, 4*GetHitMargin(), 4*GetHitMargin() );
9784 m_dragPinObj->SetAlgoSkip(
true );
9787 m_dragPinObjPin->SetTemporaryPin(
false );
9788 m_dragPinObjPin->SetPosXY( 0, 0 );
9789 m_dragPinObjPin->SetInternal(
true );
9790 m_dragPinObjPin->SetParent( m_dragPinObj );
9791 m_dragPinObj->Append( m_dragPinObjPin );
9792 m_dragPinObj->HasPins(
true );
9793 m_dragPinObj->SetSelected(
true );
9794 m_dragPinObj->SetFill( m_fill );
9795 m_dragPinObj->SetStroke( m_stroke );
9796 dragPin->DuplicateConnectedToOtherPins(
false );
9797 dragPin->ConnectTo( m_dragPinObjPin );
9798 m_dragPinObjPin->DuplicateConnectedPins( dragPin );
9799 GetDrawingPart()->GetShowObject()->Append( m_dragPinObj );
9801 if ( !StartDragging( m_x, m_y, m_dragPinObj ) )
9816 void a2dMovePinTool::OnMouseEvent( wxMouseEvent& event )
9834 if( event.LeftDown() && !
GetBusy() )
9863 else if ( event.RightDown() )
9867 else if ( event.LeftUp() )
9930 parentObjDragPin->SetAlgoSkip(
true );
9937 SearchPinForFinishWire(
GetDrawingPart()->GetShowObject(), m_dragPin, NULL, hitDistance );
9944 parentObjDragPin->SetAlgoSkip(
false );
Prevent cloning a a2dCameleon reference at a deeper level.
static const a2dCanvasObjectFlagsMask SELECTED2
a2dStroke GetTextStroke() const
get the current text stroke
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
void PushCursor(const wxCursor &cursor)
push a cursor on the cursor stack, and set display cursor to new back being cursor.
int WorldToDeviceXRel(double x) const
convert x relative from world to device coordinates
a2dCircle at x,y, and with radius
perform snapping to boundingbox of objects
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
double GetHeight() const
returns height of the boundingbox
bool GetLastConnectCreationDirection() const
when a wire was created, this return the direction is was created ( first to last pin or visa versa )...
a2dPATH_END_TYPE
defines the way a polyline with a contour width is ended.
static const a2dCanvasObjectFlagsMask BIN
(In) Visible property that can be added to Docview Objects.
double GetAbsY() const
get absolute Y position of the pin ( after applying the parent's matrix and its own matrix ) ...
virtual bool DisConnectWith(a2dCanvasObject *toDisConnect=NULL, const wxString &pinname=wxT(""), bool undo=false)
Do Disconnect from another a2dCanvasObject by pin name.
bool IsEmpty() const
Returns true if the array is empty, false otherwise.
bool SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask whichobjects=a2dCanvasOFlags::ALL, const a2dBoundingBox &bbox=wxNonValidBbox, const a2dAffineMatrix &tworld=a2dIDENTITY_MATRIX)
set all given bit flags at once recursive for all objects in given boundingbox
double GetEndScaleY()
scale begin and end object with this factor in X
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Base class for all types of strokes, understood by a2dDrawer2D classes.
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
wxUint16 GetLayer() const
layer set for new objects.
Prevent cloning a reference at a deeper level.
virtual bool Undo()
Undo one command or command group.
static const a2dSignal sig_toolComEventAddObject
virtual bool GeneratePinsToConnectObject(a2dDrawingPart *part, a2dCanvasObject *root, a2dCanvasObject *connectObject, a2dPinClass *pinClassToConnectTo=NULL, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
Generate pins on objects, and test which can connect to the given object.
virtual bool Redo()
Redo one command or command group.
void SetGeneratePins(bool value)
set the GeneratePins flag
static const a2dSignal sig_changedFill
when active drawing is set, this signal is send to the drawing.
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin or some other objects that needs a parent
static const a2dSignal sm_changedProperty
void Push(a2dCanvasObject *object)
push object onto existing corridor
void SetEndScaleX(double xs)
scaling in X for begin and end objects of lines and polylines
int WorldToDeviceY(double y) const
convert y from world to device coordinates
a2dDrawTextTool(a2dStToolContr *controller, a2dText *templateObject=NULL)
constructor
virtual void SetEndScaleY(double ys)
dummies to be compatible with a2dEndsLine
void SetLayer(wxUint16 layer, bool setStyleOfLayer=false)
a2dCanvasObject * GetLineEnd() const
get current line end object for line and polyline.
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
void SetEndScaleX(double xs)
scale begin and end object with this factor in X
void SetRelease(bool value)
set release flag
if set, set in the clone the PROPID_Original property to the copied object
void SetLineEnd(a2dCanvasObject *end)
set current line end object for line and polyline.
generate pins, given Connect/wire pinclass
class to map references to objects stored in XML, in order to make the connection later on...
const a2dDoMu & GetSnapGridX() const
Get horizontal center snapping distance (zero if disabled)
void SetPosXY12(double x1, double y1, double x2, double y2, bool afterinversion=true)
sets both positions of line
double GetNormalizeScale()
Normalize objects ( defined in coordinates -1 to 1 ranges ) will be multiplied by this factor...
virtual void SetBegin(a2dCanvasObject *begin)
dummies to be compatible with a2dEndsLine
const a2dDoMu & GetContourWidth() const
get the Contour width of shapes in meters
a2dCommand * GetCommand()
the command ( if there was one ) that did it.
void SetRadius(double radius)
set radius
void SetSelected2(bool selected)
Set the object selected2 flag if allowed.
bool Zoom(double x1, double y1, double x2, double y2, bool upp)
Zoom to this rectangle, or Upp at x1, y1.
a2dPin is used in a2dCanvasObject to add pins to it.
no snap to modes specified
polygon defined with list of points.
used to add points to polygon objects
wxFont & GetFont(void)
wxFont in case of a2dFONT_WXDC
static a2dPropertyIdVoidPtr * PROPID_ToolObject
set for objects that act as tool object, when a tool is in action.
bool EliminateMatrix()
reduce matrix to identity without replacing object
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
bool Rotate(double angle)
Rotate clockwise by the given number of degrees:
snap segments of other objects in a2dCanvasObject::RestrictToObject()
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
proptype * GetPropertyListOnly(const a2dObject *obj) const
Get the property from the list in obj ( no members, not cloned )
virtual void SetContourWidth(double width)
set the Contour width of the shape
#define EVT_DO(func)
event sent from a2DocumentCommandProcessor when a command is initially done
void SetNextLineDirection(bool up)
next line is higher in Y if true or lower if false
double GetRadius() const
get radius of the Arc
double GetBboxMinY()
get minimum Y of the boundingbox in world coordinates relative to its parents
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
used to add objects to a a2dCanvasDocument in the current parent
generate pins, given Connect/wire pinclass
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
void SetSpline(bool on)
set to true, the polygon will be drawn as a spline
double DeviceToWorldYRel(double y) const
convert y relative from device to world coordinates
Simple canvas using a whole view for all of the scrolled window.
virtual bool RestrictCanvasObjectAtVertexes(a2dCanvasObject *object, a2dPoint2D &point, double &dx, double &dy, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
return the clossest vertex which can be snapped if any.
double m_y3
control point 2
void SetChord(bool chord)
if true draw as a chord ( no fill end no lines to center )
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
wxString & GetUndoMenuLabel()
by default this is a2dCommandProcessor::GetUndoMenuLabel()
bool EliminateMatrix()
reduce matrix to identity without replacing object
bool IsIdentity(void) const
Is the matrix the identity matrix?
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
double m_x3
control point 2
void SetChord(bool chord)
if true draw as a chord ( no fill end no lines to center )
snap to pins in other objects when not connected
void SetStroke(const a2dStroke &stroke)
used for new objects etc. to set the stroke
if set, clone childs, otherwise ref-copy them
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the line looks like.
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate
a command processor specially designed to work with a a2dCanvasDocument
virtual void SetPending(bool pending)
set this object pending for update
#define EVT_REDO(func)
event sent from a2DocumentCommandProcessor when a command is redone
bool GetYaxis() const
get y axis orientation
void RemoveRedundantPoints(a2dCanvasObject *sendCommandsTo=NULL)
remove all points that are redundant
a2dRectC is a centered rectangle
a2dPin * IsConnectedTo(a2dPin *pin=a2dAnyPin) const
Return the pin to which this pin is connected.
void SetFilename(const wxString filename, wxBitmapType type, bool doread=true)
set filename and type of image for saving.
a2dFont GetTextFont() const
get current font active text font ( like used in text tool ).
double GetWidth() const
return width
double GetBboxMinX()
get minimum X of the boundingbox in world coordinates relative to its parents
a2dCanvasObject * GetEnd()
dummies to be compatible with a2dEndsLine
bool GetFlag(const a2dCanvasObjectFlagsMask which) const
get specific bitflag value
a2dCanvasObject * GetLineBegin() const
get current line begin object for line and polyline.
a2dCanvasObject is the base class for Canvas Objects.
bool GetRouteWhenDrag()
route also while dragging object
double m_y2
control point 1
property to hold a a2dObjectPtr smart pointer type variable to be associated with a a2dObject ...
void SetFixedStyleStroke(const a2dStroke &fixStroke)
set a2dStroke to use when RenderFIX_STYLE is set.
void SetCurrentCanvasObject(a2dCanvasObject *currentcanvasobject, bool takeOverProperties=true)
set the current canvas object, which gets the change in style etc
a2dCanvas * GetCanvas() const
Get the Display window of the a2dView. But casted to a a2dCanvas.
for changing boolean values inside canvas objects
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin
void SetX1(double x1)
Set X1 of arc being begin point of arc.
property to hold a byte integer type vector to be associated with a a2dObject
virtual a2dObject * GetRefObject() const
when a2dProperty, return its value else assert
void SetWidth(double w)
set width of rectangle
a2dPinClass * CanConnectTo(a2dPinClass *other=NULL) const
searches in the connection list for a given pin class
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
vertex list of line and arc segments.
#define EVT_MENUSTRINGS(func)
event sent to a2dCommandProcessorEvents to adjust menu strings (e.g. for current undo/redo command) ...
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
virtual void SetPinsToEndState(a2dCanvasObject *root, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
set end state of pins after tool is finsihed
void SetFill(const a2dFill &fill)
used for new objects etc. to set the fill
static const a2dSignal sig_toolComEventSetEditObject
bool GetSelected() const
is the object selected flag set
void SetSelected(bool selected)
Set the object selected flag if allowed.
bool GetShiftKeyDown() const
some snapping may depend on shift key being down
bool GetSpline() const
certain drawing tools like polygon drawing use this setting
void SetEndScaleY(double ys)
scaling in Y for begin and end objects of lines and polylines
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the line looks like.
double GetBboxWidth()
get width of the boundingbox in world coordinates relative to its parents
double GetStart()
return start angle
void SetBin(bool bin)
general flag use at will.
void ReWireConnected(a2dCanvasObject *parent, bool undo=false)
rewire the object to keep connection or to make connection with other objects
used to change style of canvas objects in a a2dCanvasDocument
void SetContourWidth(double width)
set the Contour width of the shape
a2dSnapToWhatMask GetSnapTargetFeatures() const
a2dFont GetFont() const
get font for text
void RotateRouteMethod()
cycle through routing methods
static a2dPropertyIdRefObject * PROPID_ViewSpecific
void SetContourWidthInDataBaseUnits(double width)
set the Contour width of shapes defined in database units
void SetCaretShow(bool visible=true)
set caret on or off
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
void SetInternal(bool internal)
set when pin is within the border of its parent
void SetMappingShowAll(bool centre=true)
use the boundingbox of the ShowObject to set the mapping such that it will be displayed completely...
a2dNextSeg GetEndSegmentMode()
a2dDrawWirePolylineLTool segment mode initilization
int WorldToDeviceYRel(double y) const
convert y relative from world to device coordinates
void SetHeight(double h)
set height of rectangle
static const a2dCanvasObjectFlagsMask PENDING
a2dWirePolylineL is a polyline that adjusts itself when the objects it connects move ...
If no other snap point was closer, force to grid, even if not within threshold.
snap to other objects its vertexes, which are decided in a2dCanvasObject::RestrictToObject() ...
static const a2dCanvasObjectFlagsMask normalized
a2dText is an abstract base class.
used to change a property on objects
void SetTemporaryPin(bool temporaryPin)
void ConnectTo(a2dPin *connectto)
connect this pin to the given pin
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
double GetMinX() const
get minimum X of the boundingbox
double GetLength() const
Returns length of line.
command on selected objects
void AddPendingUpdateArea(a2dCanvasObject *obj, wxUint8 id=0, bool refsalso=true)
add pending update for the area that is the boundingbox of the given object
static const a2dSignal sig_changedShowObject
void Transform(const a2dAffineMatrix &tworld)
transform the object using the given matrix
void SetFont(const a2dFont &font, double lineSpaceFactor=0.1)
set font for text
const a2dStroke & GetStroke() const
get the current stroke
void SetParentSnapObjects(a2dCanvasObject *obj)
parent object of objects that need to be snapped to
a2dEllipse centered at x,y.
polyline defined with list of points.
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
void SetDrawPatternOnTop(bool drawPatternOnTop)
Sets if the pattern (a rectangle) will be drawn on top of this image.
bool GetSnapTo() const
is snap_to flag set?
void AddOverlayObject(a2dCanvasObject *obj)
add to list of overlay objects (must be children of m_top)
a2dHandle * GetHandle()
get default handle for editing
double GetPosX() const
get x position from affine matrix
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
void SetFixedStyleFill(const a2dFill &fixFill)
set a2dFill to use when RenderFIX_STYLE is set.
bool ScrollWindowConstrained(double dx, double dy)
scroll the window in world coordinates
const a2dCommandId * GetCommandId()
a specific id for this command.
Normal straight line segment in a2dVpath.
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
a2dImage (will scale/rotate image when needed)
double wxRadToDeg(double rad)
conversion from radians to degrees
Normal straight line segment in a2dVertexList and a2dVertexArray.
void SetMappingShowAll(bool centre=true)
use the boundingbox of the ShowObject to set the mapping such that it will be displayed completely...
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
void SetEndScaleY(double ys)
scale begin and end object with this factor in Y
void SetSnapSourceFeatures(wxUint32 snapSourceFeatures)
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
void SetUpdatesPending(bool onoff)
Tells the document that an object has changed.
virtual bool DisConnectAt(a2dPin *pin, bool undo=false)
Do Disconnect from another a2dCanvasObject by pin pointer.
virtual bool Undo()
Undo one command or command group.
de-select objects in a rectangle area
Restriction engine for editing restrictions like snapping.
wxUint16 GetLayer() const
Returns the layer index where this object is drawn upon.
bool FindConnectedWires(a2dCanvasObjectList &result, a2dPin *pin, bool walkWires=true, bool selectedEnds=false, bool stopAtSelectedWire=false, bool addToResult=false)
find wires on pins of this objects.
int WorldToDeviceX(double x) const
convert x from world to device coordinates
Hint to clone enough of the object to do proper dragging in graphics.
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
bool HasPins(bool realcheck=false)
are there a2dPin derived children
bool CheckMask(a2dCanvasObjectFlagsMask mask) const
Compares all flags in object to the given mask and return true is the same.
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 SetBegin(a2dCanvasObject *begin)
set object to draw as begin point
bool CanRedo()
by default this is a2dCommandProcessor::CanRedo()
void RemovePins(bool NotConnected=false, bool onlyTemporary=false, bool now=false)
Remove all a2dPin children.
Remove from property in a hierarchy of a canvas document.
bool GetSpline()
Get the polygon spline setting.
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
virtual a2dCanvasObject * GetEnd()
dummies to be compatible with a2dEndsLine
virtual a2dCanvasObject * CreateConnectObject(a2dCanvasObject *parent, a2dPin *pinThis, a2dPin *pinOther, bool undo=false) const
generates a connection object with pins and all.
Each a2dCommand is given a command id at construction.
used to add object to a a2dCanvasDocument in the current parent
a2dFill GetTextFill() const
get the current text fill
corridor as a direct event path to a a2dCanvasObject
defines common settinsg for a habitat for a set of a2dCameleons.
double m_x2
control point 1
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
double GetContourWidth() const
get the Contour width of the shape
bool IsTemporaryPin() const
return true if this pin is a temporary pin
void SetLastXyEntry(double x, double y)
set last mouse X position in world coordinates, as set by tools.
void SetSnapTo(bool snap)
Sets snap_to flag.
A 2x3 affine matrix class for 2D transformations.
a2dPoint2D GetPosXY() const
get position of object
virtual a2dCanvasObject * GetBegin()
dummies to be compatible with a2dEndsLine
virtual void SetEnd(a2dCanvasObject *end)
dummies to be compatible with a2dEndsLine
bool IsDynamicPin() const
return true if this pin is a dynamic pin
a2dPinClass * GetPinClass() const
return the pin class of this pin
double GetMaxX() const
get maximum X of the boundingbox
bool Start(a2dCanvasObject *object)
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object...
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
bool DoConnect()
if return true, connection with other object on this object its pins is allowed.
a2dPin * HasPinNamed(const wxString pinName, bool NotConnected=false)
are there a2dPin derived children which matches the given pin name?
if set, set in the clone the PROPID_editcopy property to the original object
double GetPosY() const
get y position from affine matrix
void AddPropertyId(a2dPropertyId *id)
add a a2dPropertyId to the list
virtual a2dLineSegment * Clone()
create exact copy
virtual double GetContourWidth() const
get the Contour width of the shape
while iterating a a2dCanvasDocument, this holds the context.
snap segments middle of other objects in a2dCanvasObject::RestrictToObject()
double m_x
x endpoint of line
bool CanUndo()
by default this is a2dCommandProcessor::CanUndo()
a2dCanvasObject * AddCurrent(a2dCanvasObject *objectToAdd, bool withUndo=false, a2dPropertyIdList *setStyles=NULL, a2dCanvasObject *parentObject=NULL)
add the current canvas object to parent as child
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
a2dLineSegment * AddPoint(double x, double y, a2dLineSegmentPtr seg=NULL, bool afterinversion=true)
add point/segment after a segment.
double GetEndScaleY() const
get scaling in Y for begin and end objects of lines and polylines
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
const a2dFill & GetFill() const
get the current fill
a2dConnectionGenerator * GetConnectionGenerator() const
Get class for generating new connection objects between object and pins.
double m_y
y endpoint of line
virtual bool Submit(a2dCommand *command, bool storeIt=true)
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
int TakeOverFrom(a2dCanvasObjectList *total, const wxString &type=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=NULL)
Move objects fitting the given filter from the total list to this list.
void Scale(double scalex, double scaley)
Scale in x and y ( > zero)
used to release object from a a2dCanvasDocument in the current parent
void SetReleaseSnap(bool releaseSnap)
do not snap if set
static const a2dCanvasObjectFlagsMask VISIBLE
void DuplicateConnectedPins(a2dPin *other, bool undo=false)
pins connected to given other pin, will become part of this pin.
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
virtual bool EditProperties(const a2dPropertyId *id, bool withUndo)
edit properties of the object
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
a2dConnectionGenerator * GetConnectionGenerator() const
Get class for generating new connection objects between object and pins.
bool GetRelease() const
get release flag
editing tool for a2dCanvasObject's
Interactive drawing a text object.
double m_y1
y endpoint of line
void SetShiftKeyDown(bool shiftDown)
some snapping may depend on shift key being down
a2dEndsLine with begin and/or end object.
a2dCanvasObject * GetBegin()
dummies to be compatible with a2dEndsLine
const a2dFont & GetFont() const
get current font active font.
bool IsDraggable() const
get if the object can be dragged
double GetMaxY() const
get maximum Y of the boundingbox
double GetWidth() const
returns width of the boundingbox
An object of this class will update a a2dIterC with the required information.
void SetY2(double y2)
Set Y2 of arc being end point of arc.
virtual void DeviceDrawAnnotation(const wxString &text, wxCoord x, wxCoord y, const wxFont &font)
text drawn in device coordinates
virtual void SetEndScaleX(double xs)
dummies to be compatible with a2dEndsLine
select objects in a rectangle area
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
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
void SetFont(const a2dFont &font)
used for to set the font for non Text objects
bool Start(a2dCanvasObject *object, bool setTo)
start removing properties from the object given, and down.
bool Translate(double x, double y)
Translate by dx, dy:
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
void SetLineBegin(a2dCanvasObject *begin)
set current line begin object for line and polyline.
const a2dStroke * a2dTRANSPARENT_STROKE
global a2dStroke stock object for TRANSPARENT stroking
double GetBboxHeight()
get height of the boundingbox in world coordinates relative to its parents
wxString & GetRedoMenuLabel()
by default this is a2dCommandProcessor::GetRedoMenuLabel()
Event sent to a2dCommandProcessor.
virtual bool EliminateMatrix()
reduce matrix to identity
perform snapping to snapping vector path returned by a2dCanvasObject::GetSnapVpath() ...
void Add(a2dVpathSegment *item)
Append a new segment, which is owned by this class now.
void SetToolWantsEventToContinue(bool continueEvent=true)
if tool want an event to be handled by the view, even if already processed.
if set, clone members (e.g. line end styles), otherwise ref-copy them
a2dCanvasObject * Find(a2dCanvasObject *obj) const
return the object if it is part of the list
void RemoveOverlayObject(a2dCanvasObject *obj)
remove from the list of overlay objects (must be children of m_top)
double GetContourWidthInDataBaseUnits() const
get the Contour width of shapes in the document its units
double GetEndScaleX()
scale begin and end object with this factor in X
a2dCanvasObject * IsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
If the position (x,y) is within the object return this.
static const wxEventType sm_showCursor
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
bool Invert(void)
Invert matrix.
void AssertUnique()
Check if all objects are only once in the list.
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 ...
void SetX2(double x2)
Set X2 of arc being end point of arc.
virtual a2dVpathSegment * Clone()
create exact copy
virtual bool RemoveProperty(const a2dPropertyId *id, bool all=true)
This function is called by a2dPropertyId to remove a property from the list.
void SetRouteWhenDrag(bool routeWhenDrag)
route also while dragging object
double GetEnd()
return end angle
double GetMinY() const
get minimum Y of the boundingbox
a2dDrawing * GetDrawing() const
get drawing via top object
void DuplicateConnectedToOtherPins(bool undo=false)
all connections to this pins, will become available in those connected pins too.
bool AddPendingUpdatesOldNew()
adds current and future boundingbox of the objects with pending flag set, to the pendinglist of all a...
double m_x1
x endpoint of line
void SetCaptured(a2dCanvasObject *captured)
set the object that is captured for events in the a2dDrawing.
void SetCaret(int position)
set position of caret (-1 means off)
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
a2dVpath * GetSegments()
modify point at index to x,y
static a2dPinClass * Any
used to ask for a new default pin on an object.
void SetStart(double start)
set start angle
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
virtual bool Redo()
Redo one command or command group.
all headers of the canvas module
#define EVT_UNDO(func)
event sent from a2DocumentCommandProcessor when a command is undone
static a2dPropertyIdBool * PROPID_ToolDecoration
set for objects that act as tool decorations, when a tool is in action.
a2dCanvasObject for a Vector Path
size_t GetNumberOfSegments()
get the number of points in the pointlist
a2dSnapToWhatMask GetSnapSourceFeatures() const
This template class is for property ids with a known data type.
static a2dPropertyIdTagVec * PROPID_Tags
used in tool when grouping using tags
virtual void RenderTopObject(wxUint32 documentDrawStyle, wxUint8 id)
does render the top object in the given style.
int CollectObjects(a2dCanvasObjectList *total, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=0, const a2dBoundingBox &bbox=wxNonValidBbox) const
Copy objects with the right conditions to the total list.
double GetAbsX() const
get absolute X position of the pin ( after applying the parent's matrix and its own matrix ) ...
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
a2dSmrtPtr< a2dText > m_templateObject
object to clone to use as start
double GetHeight() const
return height
a2dCanvasObject * GetParent() const
get parent object of the pin
void PopCursor()
pop a cursor from the cursor stack, and set display cursor to back
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
void SetEnd(a2dCanvasObject *end)
set object to draw as end point
void SetOpacityFactor(wxUint8 OpacityFactor)
when enabling m_useOpacityFactor, this is how transparent
const a2dDoMu & GetSnapGridY() const
Get vertical center snapping distance (zero if disabled)
virtual bool IsConnect() const
return true, if this object is used to connect other object's using rubberband like structures...
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
void SetRestrictPoint(double xSnap, double ySnap)
sets the point for snapping to
for changing boolean select flag values inside canvas objects
void MouseToToolWorld(int x, int y, double &xWorldLocal, double &yWorldLocal)
void SetImageType(wxBitmapType type)
set type of image for saving
void SetY1(double y1)
Set Y1 of arc being begin point of arc.
CloneOptions
options for cloning
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
bool GetDraggable() const
get if the object can be dragged
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Contain one drawing as hierarchical tree of a2dCanvasObject's.
a2dText * GetTemplateObject() const
set template for line object
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
void SetRadius(double radius)
set radius of the Arc
double GetEndScaleX() const
get scaling in X for begin and end objects of lines and polylines
const double wxPI
defines PI
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
a2dEllipticArc centered at x,y
snap to pins in other objects
static void SetIgnoreAllSetpending(bool value=true)
set static IgnoreAllSetpending flag
bool EliminateMatrix()
reduce matrix to identity without replacing object
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
void SetEnd(double end)
set end angle
#define a2dREFOBJECTPTR_KEEPALIVE
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the line looks like.