27 #include "wx/editor/recurdoc.h"
28 #include "wx/filename.h"
32 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
33 #include <wx/msw/msvcrt.h>
41 EVT_CHAR( a2dLinkTool::OnChar )
42 EVT_MOUSE_EVENTS( a2dLinkTool::OnMouseEvent )
47 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
59 a2dLinkTool::~a2dLinkTool()
78 void a2dLinkTool::OnChar( wxKeyEvent& event )
82 switch( event.GetKeyCode() )
102 void a2dLinkTool::OnMouseEvent( wxMouseEvent& event )
123 if ( event.LeftDClick() && !
GetBusy() )
127 else if ( event.LeftDown() && !
GetBusy() )
145 else if ( event.LeftDown() &&
GetBusy() )
155 static wxString link_dir = *(
a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT(
"APPLICATION_DATA" ) ) );
157 static wxString filter = _T(
"All files (*.*)| *.*| CVG files (*.cvg)| *.cvg" );
159 wxFileName link_file;
161 wxFileDialog dialog(
GetDisplayWindow(), _T(
"Select Image File" ), link_dir, link_file.GetFullPath(), filter, wxFD_OPEN );
163 if ( dialog.ShowModal() != wxID_OK )
167 link_dir = dialog.GetPath();
168 link_file = dialog.GetFilename();
170 wxFileName link_dirf = wxFileName( link_dir );
171 link_dir = link_dirf.GetVolume() + link_dirf.GetVolumeSeparator() + link_dirf.GetPathWithSep( wxPATH_UNIX );
175 wxString link_fullpath = link_dir + link_file.GetFullName();
179 double link_w = fabs( rec->
GetWidth() );
180 double link_h = fabs( rec->
GetHeight() );
187 if ( fabs( w ) < 3 && fabs( h ) < 3 )
220 else if ( ( event.Dragging() &&
GetBusy() ) || ( event.Moving() &&
GetBusy() ) )
241 EVT_CHAR( a2dFollowLinkDocDrawCam::OnChar )
242 EVT_MOUSE_EVENTS( a2dFollowLinkDocDrawCam::OnMouseEvent )
247 m_eventHandler = controller->GetDefaultToolEventHandlerFixedStyle();
253 void a2dFollowLinkDocDrawCam::OnChar( wxKeyEvent& event )
257 switch( event.GetKeyCode() )
273 void a2dFollowLinkDocDrawCam::OnMouseEvent( wxMouseEvent& event )
282 int x =
event.GetX();
283 int y =
event.GetY();
289 if ( event.LeftDown() )
303 wxString link = uri.BuildURI();
304 if ( !link.IsEmpty() )
306 wxString file = link;
307 wxString scheme = uri.GetScheme();
308 if ( scheme == wxT(
"file" ) )
310 wxRegEx reVolume( wxT(
"^\\/[a-fA-F].*$") );
311 file = uri.GetPath();
312 if ( reVolume.Matches( file ) )
313 file = file.Mid( 1 );
315 if ( !::wxFileExists( file ) )
317 wxFileName fileo = wxFileName( file, wxPATH_UNIX );
318 file = *(
a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT(
"APPLICATION_DATA" ) ) ) + wxFileName::GetPathSeparator(wxPATH_UNIX) + fileo.GetFullName();
319 if ( !::wxFileExists( file ) )
346 bool a2dFollowLinkDocDrawCam::StartFollowHere(
double x,
double y )
351 return StartFollowHere( mouse_x, mouse_y );
354 bool a2dFollowLinkDocDrawCam::StartFollowHere(
int x,
int y )
356 wxMouseEvent event( wxEVT_LEFT_DOWN );
360 OnMouseEvent( event );
374 a2dMasterTagGroups3Link ::a2dMasterTagGroups3Link (
a2dStToolContr* controller ):
383 a2dMasterTagGroups3Link::~a2dMasterTagGroups3Link ()
387 wxString a2dMasterTagGroups3Link::GetToolString()
const
389 wxString str =
"Edit";
391 return str +
" Wires";
413 SelectHitObject( hit );
431 SelectHitObject( hit );
432 tool->StartFollowHere(
m_x,
m_y );
435 void a2dMasterTagGroups3Link::EditDlgOrHandles(
a2dCanvasObject* hit,
bool modifier,
bool noHandleEditForWire )
439 if ( m_dlgOrEdit && !modifier )
449 else if ( !m_dlgOrEditModal )
461 bool withFill =
false;
468 if ( nrst + nrfi == 0 )
476 withFill = 0 != nrfi;
481 dlg.SetUnitsScale(
GetDrawing()->GetUnitsScale() );
483 dlg.SetExtStroke(eSt);
486 if ( wxID_OK == dlg.ShowModal() )
488 eSt = dlg.GetExtStroke();
489 eFi = dlg.GetExtFill();
493 hit->
SetFill( eFi.Get( hit->GetFill() ) );
494 hit->
SetStroke( eSt.Get( hit->GetStroke() ) );
509 if ( (wire && wire->
GetSelected() ) || (wire && !noHandleEditForWire ) || !wire )
int WorldToDeviceXRel(double x) const
convert x relative from world to device coordinates
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
#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.
int WorldToDeviceY(double y) const
convert y from world to device coordinates
void SetFilename(const wxFileName &filename, bool notifyViews=false)
Sets the filename for this document. Usually called by the framework.
static const a2dCanvasObjectFlagsMask BIN2
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate
virtual void SetPending(bool pending)
set this object pending for update
bool GetYaxis() const
get y axis orientation
double GetWidth() const
return width
a2dError FileNew(a2dDocumentPtr &doc, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE)
Creates a document from a list of templates (if more than one template).
a2dCanvasObject is the base class for Canvas Objects.
void SetSize(double size)
Set the font size.
Docview framework its controlling class.
void SetWidth(double w)
set width of rectangle
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
bool GetSelected() const
is the object selected flag set
void SetSelected(bool selected)
Set the object selected flag if allowed.
int WorldToDeviceYRel(double y) const
convert y relative from world to device coordinates
void SetHeight(double h)
set height of rectangle
a2dWirePolylineL is a polyline that adjusts itself when the objects it connects move ...
double GetMinX() const
get minimum X of the boundingbox
double GetPosX() const
get x position from affine matrix
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
objects which fit the mask are given a new fill and stroke style
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Restriction engine for editing restrictions like snapping.
int WorldToDeviceX(double x) const
convert x from world to device coordinates
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
if set, respect layer order, hit testing is done per layer from the top.
static const a2dCanvasObjectFlagsMask SELECTED
a2dError FileOpenCheck(a2dDocumentPtr &doc, const wxFileName &file, bool checkModification)
Return existing document, or open it from file.
wxURI GetURI() const
quick way to get to PROPID_URI property
Each a2dCommand is given a command id at construction.
Master tool for objects graphics slecting and dragging.
void SetLastXyEntry(double x, double y)
set last mouse X position in world coordinates, as set by tools.
bool ShowDlgStyle(bool onOff)
show style dialog or not, return true of changed from previous state
double GetPosY() const
get y position from affine matrix
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
virtual bool Submit(a2dCommand *command, bool storeIt=true)
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
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.
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
double GetMaxY() const
get maximum Y of the boundingbox
to display a2dCanvasObject references
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
Master tool for objects graphics slecting and dragging.
const a2dStroke * a2dTRANSPARENT_STROKE
global a2dStroke stock object for TRANSPARENT stroking
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
void SetTitle(const wxString &title, bool notifyViews=false)
Sets the title for this document.
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
all headers of the canvas module
double GetHeight() const
return height
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
#define a2dREFOBJECTPTR_KEEPALIVE