26 #define ID_LISTBOX 10002
28 #define ID_CLEAR 10004
42 EVT_CLOSE( a2dMeasureDlg::OnCloseWindow )
43 EVT_IDLE( a2dMeasureDlg::OnIdle )
45 EVT_TEXT_ENTER( ID_X, a2dMeasureDlg::OnXEnter )
46 EVT_UPDATE_UI( ID_X, a2dMeasureDlg::OnXUpdate )
48 EVT_TEXT_ENTER( ID_Y, a2dMeasureDlg::OnYEnter )
49 EVT_UPDATE_UI( ID_Y, a2dMeasureDlg::OnYUpdate )
51 EVT_LISTBOX( ID_LISTBOX, a2dMeasureDlg::OnListboxSelected )
52 EVT_UPDATE_UI( ID_LISTBOX, a2dMeasureDlg::OnListboxUpdate )
54 EVT_BUTTON( ID_HIDE, a2dMeasureDlg::OnHideClick )
56 EVT_BUTTON( ID_CLEAR, a2dMeasureDlg::OnClearClick )
58 EVT_UPDATE_UI( ID_SUM, a2dMeasureDlg::OnSumUpdate )
61 EVT_DO( a2dMeasureDlg::OnDoEvent )
70 a2dMeasureDlg::a2dMeasureDlg( )
76 a2dMeasureDlg::~a2dMeasureDlg( )
86 Create( parent,
id, caption, pos, size, style );
93 bool a2dMeasureDlg::Create( wxWindow* parent, wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
102 SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
103 wxDialog::Create( parent,
id, caption, pos, size, style );
106 GetSizer()->Fit(
this );
107 GetSizer()->SetSizeHints(
this );
120 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer( wxVERTICAL );
121 itemDialog1->SetSizer( itemBoxSizer2 );
123 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer( wxHORIZONTAL );
124 itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 1 );
126 m_x =
new wxTextCtrl( itemDialog1, ID_X, _(
"0" ), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
127 m_x->SetHelpText( _(
"X of vertex" ) );
129 m_x->SetToolTip( _(
"X of vertex" ) );
130 itemBoxSizer3->Add( m_x, 1, wxALIGN_CENTER_VERTICAL | wxALL, 1 );
132 m_y =
new wxTextCtrl( itemDialog1, ID_Y, _(
"0" ), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
133 m_y->SetHelpText( _(
"Y of vertex" ) );
135 m_y->SetToolTip( _(
"Y of vertex" ) );
136 itemBoxSizer3->Add( m_y, 1, wxALIGN_CENTER_VERTICAL | wxALL, 1 );
138 wxBoxSizer* itemBoxSizer6 =
new wxBoxSizer( wxHORIZONTAL );
139 itemBoxSizer2->Add( itemBoxSizer6, 1, wxGROW | wxALL, 1 );
141 wxString* m_lbStrings = NULL;
142 m_lb =
new wxListBox( itemDialog1, ID_LISTBOX, wxDefaultPosition, wxDefaultSize, 0, m_lbStrings, wxLB_SINGLE | wxLB_NEEDED_SB );
143 m_lb->SetHelpText( _(
"list of measured points" ) );
145 m_lb->SetToolTip( _(
"list of measured points" ) );
146 itemBoxSizer6->Add( m_lb, 1, wxGROW | wxALL, 1 );
148 wxBoxSizer* itemBoxSizer8 =
new wxBoxSizer( wxHORIZONTAL );
149 itemBoxSizer2->Add( itemBoxSizer8, 0, wxGROW | wxALL, 1 );
151 m_hide =
new wxButton( itemDialog1, ID_HIDE, _(
"Hide" ), wxDefaultPosition, wxDefaultSize, 0 );
152 itemBoxSizer8->Add( m_hide, 0, wxALIGN_CENTER_VERTICAL | wxALL, 1 );
154 m_clear =
new wxButton( itemDialog1, ID_CLEAR, _(
"Clear" ), wxDefaultPosition, wxDefaultSize, 0 );
155 m_clear->SetHelpText( _(
"Clear all measured points" ) );
157 m_clear->SetToolTip( _(
"Clear all measured points" ) );
158 itemBoxSizer8->Add( m_clear, 0, wxALIGN_CENTER_VERTICAL | wxALL, 1 );
160 m_sum =
new wxTextCtrl( itemDialog1, ID_SUM, _(
"0" ), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_PROCESS_ENTER );
161 m_sum->SetHelpText( _(
"Sum of all measured points to rel start" ) );
163 m_sum->SetToolTip( _(
"Sum of all measured points to rel start" ) );
164 itemBoxSizer8->Add( m_sum, 1, wxALIGN_CENTER_VERTICAL | wxALL, 1 );
200 m_x->GetValue().ToDouble( &x );
201 m_y->GetValue().ToDouble( &y );
207 for( a2dVertexList::iterator iter = m_vertexes.begin(); iter != m_vertexes.end(); ++iter )
210 p1 = seg->GetPoint();
211 AppendMeasure( p1.m_x, p1.m_y );
214 tmp.Printf( wxT(
"%lg" ), m_vertexes.
Length() );
215 m_sum->SetValue( tmp );
234 m_x->GetValue().ToDouble( &x );
235 m_y->GetValue().ToDouble( &y );
241 for( a2dVertexList::iterator iter = m_vertexes.begin(); iter != m_vertexes.end(); ++iter )
244 p1 = seg->GetPoint();
245 AppendMeasure( p1.m_x, p1.m_y );
248 tmp.Printf( wxT(
"%lg" ), m_vertexes.
Length() );
249 m_sum->SetValue( tmp );
327 void a2dMeasureDlg::OnComEvent(
a2dComEvent& event )
329 if ( GetEvtHandlerEnabled() )
336 else if ( event.GetId() == a2dCanvasCommandProcessor::sig_SetRelativeStart )
341 coordstr.Printf( wxT(
"%lg" ), x );
342 m_x->SetValue( coordstr );
343 coordstr.Printf( wxT(
"%lg" ), y );
344 m_y->SetValue( coordstr );
346 else if ( event.GetId() == a2dCanvasCommandProcessor::sig_AddMeasurement )
349 m_vertexes.push_back(
new a2dLineSegment( proc->m_meas_x, proc->m_meas_y ) );
351 tmp.Printf( wxT(
"%lg" ), m_vertexes.
Length() );
352 m_sum->SetValue( tmp );
354 AppendMeasure( proc->m_meas_x, proc->m_meas_y );
356 else if ( event.GetId() == a2dCanvasCommandProcessor::sig_ClearMeasurements )
367 if ( GetEvtHandlerEnabled() )
372 void a2dMeasureDlg::AppendMeasure(
double x,
double y )
375 double rel_x, rel_y, length, angle;
376 double start_x = wxAtoi( m_x->GetValue() );
377 double start_y = wxAtoi( m_y->GetValue() );
381 length = sqrt( pow( rel_x, 2 ) + pow( rel_y, 2 ) );
382 if ( rel_x != 0 && rel_y != 0 )
383 angle = asin( rel_y / length ) * 180 / M_PI;
390 wxString unitmeasure = wxT(
"non" );
391 double scaleToMeters = 1;
401 x *= scaleToMeters / multi;
402 y *= scaleToMeters / multi;
408 tmp.Printf( wxT(
"(%lg, %lg) %s dx:%lg dy:%lg l:%lg angle:%lg" ), x, y,
409 unitmeasure.mb_str(), rel_x, rel_y, length, angle );
412 m_lb->SetSelection( m_lb->GetCount() - 1, true );
420 EVT_CHAR( a2dMeasureTool::OnChar )
421 EVT_MOUSE_EVENTS( a2dMeasureTool::OnMouseEvent )
438 a2dMeasureTool::~a2dMeasureTool()
453 wxCoord w, h, descent, external;
466 switch( event.GetKeyCode() )
486 void a2dMeasureTool::OnMouseEvent( wxMouseEvent& event )
508 if ( event.LeftDClick() && !
GetBusy() )
513 if ( event.LeftDClick() &&
GetBusy() )
520 else if ( event.LeftDown() && !
GetBusy() )
537 line->GetBegin()->
Scale( norm, norm );
543 line->GetEnd()->
Scale( norm, norm );
580 else if ( event.LeftDown() &&
GetBusy() )
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
Base class for all types of strokes, understood by a2dDrawer2D classes.
double GetNormalizeScale()
Normalize objects ( defined in coordinates -1 to 1 ranges ) will be multiplied by this factor...
a2dMeasureDlg()
Constructors.
used to add points to polygon objects
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
static bool ShowToolTips()
Should we show tooltips?
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
if set, clone childs, otherwise ref-copy them
bool Create(wxWindow *parent, wxWindowID id=-1, const wxString &caption=SYMBOL_A2DMEASUREDLG_TITLE, const wxPoint &pos=SYMBOL_A2DMEASUREDLG_POSITION, const wxSize &size=SYMBOL_A2DMEASUREDLG_SIZE, long style=SYMBOL_A2DMEASUREDLG_STYLE)
Creation.
a command processor specially designed to work with a a2dCanvasDocument
void OnClearClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR
bool GetFlag(const a2dCanvasObjectFlagsMask which) const
get specific bitflag value
void OnSumUpdate(wxUpdateUIEvent &event)
wxEVT_UPDATE_UI event handler for ID_SUM
void OnCloseWindow(wxCloseEvent &event)
wxEVT_CLOSE_WINDOW event handler for ID_DIALOG
a2dDrawingPart * GetActiveDrawingPart()
return the currently/last active drawing part.
void OnListboxSelected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_LISTBOX
double GetRelativeStartY() const
holds last RelativeStart measurement Y position in world coordinates
static const a2dCanvasObjectFlagsMask normalized
void OnXEnter(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_ENTER event handler for ID_X
static const a2dSignal sig_changedShowObject
polyline defined with list of points.
double GetRelativeStartX() const
holds last RelativeStart measurement X position in world coordinates
void OnYUpdate(wxUpdateUIEvent &event)
wxEVT_UPDATE_UI event handler for ID_Y
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
#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! )
Normal straight line segment in a2dVertexList and a2dVertexArray.
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
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
Restriction engine for editing restrictions like snapping.
static bool GetMultiplierFromString(const wxString &mul, double &multi)
calculate how to get to meters from a multiplier string e.g. um => 1e-6
void CreateControls()
Creates the controls and sizers.
Each a2dCommand is given a command id at construction.
defines common settinsg for a habitat for a set of a2dCameleons.
void OnYEnter(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_ENTER event handler for ID_Y
void SetLastXyEntry(double x, double y)
set last mouse X position in world coordinates, as set by tools.
void OnIdle(wxIdleEvent &event)
wxEVT_IDLE event handler for ID_DIALOG
void SetRelativeStart(double x, double y)
set RelativeStart measurement X and Y position in world coordinates
void OnListboxUpdate(wxUpdateUIEvent &event)
wxEVT_UPDATE_UI event handler for ID_LISTBOX
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.
void Scale(double scalex, double scaley)
Scale in x and y ( > zero)
void OnHideClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_HIDE
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
wxString GetUnits()
this string defines the unit e.g. meters / inch/ etc.
Event sent to a2dCommandProcessor.
virtual bool EliminateMatrix()
reduce matrix to identity
if set, clone members (e.g. line end styles), otherwise ref-copy them
a2dDrawing * GetDrawing() const
get drawing via top object
double Length()
calculate length of path
void OnXUpdate(wxUpdateUIEvent &event)
wxEVT_UPDATE_UI event handler for ID_X
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
all headers of the canvas module
#define EVT_UNDO(func)
event sent from a2DocumentCommandProcessor when a command is undone
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
void SetRestrictPoint(double xSnap, double ySnap)
sets the point for snapping to
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Contain one drawing as hierarchical tree of a2dCanvasObject's.
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
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