00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #pragma warning(disable:4786)
00012
00013 #include "a2dprec.h"
00014
00015 #ifdef __BORLANDC__
00016 #pragma hdrstop
00017 #endif
00018
00019 #ifndef WX_PRECOMP
00020 #include "wx/wx.h"
00021 #endif
00022
00023 #include <wx/wfstream.h>
00024 #include <math.h>
00025
00026 #if wxART2D_USE_CANEXTOBJ
00027 #include "wx/canextobj/eval.h"
00028 #endif //wxART2D_USE_CANEXTOBJ
00029
00030 #include "wx/canvas/canglob.h"
00031 #include "wx/curves/meta.h"
00032
00033 #include "wx/canvas/canobj.h"
00034 #include "wx/canvas/candoc.h"
00035 #include "wx/canvas/drawer.h"
00036 #include "wx/canvas/canvas.h"
00037 #include "wx/canvas/cancom.h"
00038
00039 #if wxART2D_USE_EDITOR
00040 #include "wx/editor/edit.h"
00041 #endif //wxART2D_USE_EDITOR
00042
00043
00044
00045
00046
00047 IMPLEMENT_DYNAMIC_CLASS(a2dBaseMarker, a2dCurveObject)
00048 IMPLEMENT_DYNAMIC_CLASS(a2dAxisMarker, a2dBaseMarker)
00049 IMPLEMENT_DYNAMIC_CLASS(a2dCursorAxisMarker, a2dAxisMarker)
00050 IMPLEMENT_DYNAMIC_CLASS(a2dMarker, a2dBaseMarker)
00051 IMPLEMENT_DYNAMIC_CLASS(a2dBandMarker, a2dMarker)
00052 IMPLEMENT_DYNAMIC_CLASS(a2dMarkerShow, a2dCanvasObject)
00053
00054 #ifdef wxUSE_INTPOINT
00055 #define wxMAX_COORDINATE INT_MAX
00056 #define wxMIN_COORDINATE INT_MIN
00057 #else
00058 #define wxMAX_COORDINATE 100e99
00059 #define wxMIN_COORDINATE 100e-99
00060 #endif
00061
00062
00063
00064
00065
00066 #define fach 0.7
00067 #define facv 1.78
00068
00069 a2dPropertyIdDouble* a2dBaseMarker::PROPID_PositionMarker = NULL;
00070
00071 INITIALIZE_PROPERTIES( a2dBaseMarker, a2dCurveObject )
00072 {
00073 A2D_PROPID_GS( a2dPropertyIdDouble, a2dBaseMarker, PositionMarker, 0, GetPosition, SetPosition );
00074 return true;
00075 }
00076
00077 A2D_BEGIN_EVENT_TABLE(a2dBaseMarker, a2dCurveObject)
00078 A2D_EVT_CANVASOBJECT_ENTER_EVENT( a2dBaseMarker::OnEnterObject )
00079 A2D_EVT_CANVASOBJECT_LEAVE_EVENT( a2dBaseMarker::OnLeaveObject )
00080 A2D_END_EVENT_TABLE()
00081
00082 a2dBaseMarker::a2dBaseMarker( const wxString& format): a2dCurveObject()
00083 {
00084 m_position = 0;
00085 m_l1 = 12;
00086 m_l2 = 10;
00087 m_b = 10;
00088 m_step = 0;
00089 m_spline = false;
00090 m_prompting = false;
00091
00092 m_format = format;
00093 m_textheight = m_l1 /5 ;
00094 m_font = a2dFont( m_textheight, wxSWISS, wxITALIC );
00095
00096 }
00097
00098 a2dBaseMarker::a2dBaseMarker( const wxString& format, double atx, double height): a2dCurveObject()
00099 {
00100 m_position = atx;
00101
00102 m_l1 = 12;
00103 m_l2 = 10;
00104 m_b = 10;
00105 m_step = 0;
00106 m_prompting = false;
00107
00108 m_lworld.Translate(atx,0);
00109
00110 m_spline = false;
00111
00112 m_format = format;
00113 m_textheight = height;
00114 if ( height == 0 )
00115 m_textheight = m_l1 /5 ;
00116
00117 m_font = a2dFont( m_textheight, wxSWISS, wxITALIC );
00118 }
00119
00120 a2dBaseMarker::a2dBaseMarker( const wxString& format, double atx, const a2dFont& font): a2dCurveObject()
00121 {
00122 m_position = atx;
00123
00124 m_l1 = 12;
00125 m_l2 = 10;
00126 m_b = 10;
00127 m_spline = false;
00128
00129 m_lworld.Translate(atx,0);
00130
00131 m_format = format;
00132 m_font = font;
00133 m_textheight = m_font.GetSize();
00134 m_step = 0;
00135 m_prompting = false;
00136 }
00137
00138
00139 a2dBaseMarker::~a2dBaseMarker()
00140 {
00141 }
00142
00143 a2dBaseMarker::a2dBaseMarker( const a2dBaseMarker &other, CloneOptions options )
00144 :a2dCurveObject( other, options )
00145 {
00146 m_format = other.m_format;
00147 m_textheight = other.m_textheight;
00148 m_l1 = other.m_l1;
00149 m_l2 = other.m_l2;
00150 m_b = other.m_b;
00151 m_step = other.m_step;
00152 m_spline = other.m_spline;
00153 m_prompting = other.m_prompting;
00154 m_position = other.m_position;
00155 m_font = other.m_font;
00156 }
00157
00158 a2dObject* a2dBaseMarker::Clone( CloneOptions options ) const
00159 {
00160 return new a2dBaseMarker( *this, options );
00161 };
00162
00163
00164 void a2dBaseMarker::Set(double xt, double yt, double l1, double l2, double b)
00165 {
00166 SetPosXY(xt,yt);
00167 m_l1 = l1;
00168 m_l2 = l2;
00169 m_b = b;
00170
00171 SetPending(true);
00172 }
00173
00174 void a2dBaseMarker::Set( double l1, double l2, double b)
00175 {
00176 m_l1 = l1;
00177 m_l2 = l2;
00178 m_b = b;
00179
00180 SetPending(true);
00181 }
00182
00183 a2dBoundingBox a2dBaseMarker::DoGetUnTransformedBbox( a2dBboxFlags flags ) const
00184 {
00185 a2dBoundingBox bbox;
00186 bbox.Expand( -m_b/2, 0);
00187 bbox.Expand( m_b/2, m_l1 );
00188 bbox.Expand( 0, m_l2 );
00189
00190 if ( !m_format.IsEmpty() && m_textheight )
00191 {
00192 double xc, yc;
00193 m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
00194 wxString form;
00195 form.Printf(m_format, xc, yc );
00196
00197 a2dBoundingBox bboxtext = m_font.GetTextExtent( form, UNKNOWN_YAXIS );
00198 bboxtext.Translate( -m_b/2 , m_l1 + m_textheight *2.5 );
00199 bbox.Expand( bboxtext );
00200 }
00201 return bbox;
00202 }
00203
00204 #if wxART2D_USE_CVGIO
00205
00206 void a2dBaseMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00207 {
00208 a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
00209 if ( xmlparts == a2dXmlSer_attrib )
00210 {
00211 out.WriteAttribute( wxT("l1") , m_l1 );
00212 out.WriteAttribute( wxT("l2") , m_l2 );
00213 out.WriteAttribute( wxT("b") , m_b );
00214 }
00215 else
00216 {
00217 }
00218 }
00219
00220 void a2dBaseMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00221 {
00222 a2dCanvasObject::DoLoad( parent, parser, xmlparts );
00223 if ( xmlparts == a2dXmlSer_attrib )
00224 {
00225 m_l1 = parser.RequireAttributeValueDouble( wxT("l1") );
00226 m_l2 = parser.RequireAttributeValueDouble( wxT("l2") );
00227 m_b = parser.RequireAttributeValueDouble( wxT("b") );
00228 }
00229 else
00230 {
00231 }
00232
00233
00234 }
00235 #endif //wxART2D_USE_CVGIO
00236
00237 bool a2dBaseMarker::DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent )
00238 {
00239 a2dVertexArray points;
00240 points.push_back( new a2dLineSegment( 0, 0 ) );
00241 points.push_back( new a2dLineSegment( m_b/2.0, m_l1 ) );
00242 points.push_back( new a2dLineSegment( 0, m_l2 ) );
00243 points.push_back( new a2dLineSegment( -m_b/2.0, m_l1 ) );
00244
00245 a2dPoint2D P = a2dPoint2D(hitEvent.m_relx, hitEvent.m_rely);
00246 double pw = ic.GetWorldStrokeExtend();
00247 double margin = ic.GetTransformedHitMargin();
00248
00249 hitEvent.m_how = points.HitTestPolygon( P, pw+margin );
00250
00251 return hitEvent.m_how.IsHit();
00252 }
00253
00254
00255 bool a2dBaseMarker::DoStartEdit( wxUint16 WXUNUSED(editmode), wxEditStyle WXUNUSED(editstyle) )
00256 {
00257 if ( m_flags.m_editable )
00258 {
00259
00260
00261 Update( updatemask_force );
00262
00263 SetPending( true );
00264 return true;
00265 }
00266
00267 return false;
00268 }
00269
00270 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
00271
00272 void a2dBaseMarker::DoRender( a2dIterC& ic, OVERLAP WXUNUSED(clipparent) )
00273 {
00274 a2dVertexArray cpoints;
00275
00276
00277
00278
00279
00280 if ( m_flags.m_editingCopy )
00281 ic.GetDrawer2D()->SetDrawerFill(*a2dBLACK_FILL);
00282
00283 cpoints.push_back( new a2dLineSegment( 0, 0 ));
00284 cpoints.push_back( new a2dLineSegment( m_b/2.0, m_l1 ));
00285 if(m_l1 != m_l2)
00286 {
00287 cpoints.push_back( new a2dLineSegment( 0, m_l2 ));
00288 }
00289 cpoints.push_back( new a2dLineSegment( -m_b/2.0, m_l1 ));
00290
00291 ic.GetDrawer2D()->DrawPolygon( &cpoints, m_spline, wxWINDING_RULE);
00292
00293 cpoints.clear();
00294
00295 if(!m_format.IsEmpty())
00296 {
00297 double xc, yc;
00298 m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
00299 wxString form;
00300 form.Printf(m_format, xc, yc );
00301
00302 ic.GetDrawer2D()->SetFont( m_font );
00303 ic.GetDrawer2D()->SetDrawerFill(*a2dTRANSPARENT_FILL);
00304
00305 ic.GetDrawer2D()->DrawText( form, -m_b/2, m_l1 + m_textheight *2.5 );
00306
00307 ic.GetDrawer2D()->SetFont( *a2dNullFONT );
00308 }
00309 }
00310
00311 const wxString& a2dBaseMarker::GetMarkerString()
00312 {
00313 if(!m_promptFormat.IsEmpty())
00314 {
00315 double xc, yc;
00316 m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
00317 wxString form;
00318 m_promptString.Printf(m_promptFormat, xc, yc);
00319 }
00320 else
00321 m_promptString = wxT("BaseMarker");
00322 return m_promptString;
00323 }
00324
00325 void a2dBaseMarker::OnEnterObject(a2dCanvasObjectMouseEvent &event)
00326 {
00327 return;
00328 a2dIterC* ic = event.GetIterC();
00329
00330 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
00331 m_prompting = true;
00332 if(m_promptText)
00333 {
00334
00335 m_promptText->SetText(GetMarkerString());
00336 m_promptText->SetPosXY(m_b/2,m_l1);
00337 m_promptText->SetVisible(true);
00338 }
00339 SetPending( true );
00340 event.Skip();
00341 }
00342
00343 void a2dBaseMarker::OnLeaveObject(a2dCanvasObjectMouseEvent &event)
00344 {
00345 return;
00346 event.Skip();
00347 m_prompting = false;
00348 if(m_promptText)
00349 m_promptText->SetVisible(false);
00350 SetPending( true );
00351 }
00352
00353 void a2dBaseMarker::SetPrompt( a2dText* prompttext)
00354 {
00355 if(m_promptText)
00356 ReleaseChild(m_promptText);
00357 m_promptText = prompttext;
00358 prompttext->SetVisible(false);
00359 Append(prompttext);
00360 SetPending(true);
00361 }
00362
00363
00364
00365
00366 #define fach 0.7
00367 #define facv 1.78
00368
00369 a2dPropertyIdCanvasObject* a2dAxisMarker::PROPID_axis = NULL;
00370
00371 INITIALIZE_PROPERTIES( a2dAxisMarker, a2dBaseMarker )
00372 {
00373 A2D_PROPID_D( a2dPropertyIdCanvasObject, axis, 0 );
00374 return true;
00375 }
00376
00377 void a2dAxisMarker::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
00378 {
00379 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
00380
00381 a2dBaseMarker::DoWalker( this, handler );
00382
00383
00384
00385 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
00386 }
00387
00388 A2D_BEGIN_EVENT_TABLE(a2dAxisMarker,a2dBaseMarker)
00389 A2D_EVT_CANVASOBJECT_MOUSE_EVENT( a2dAxisMarker::OnCanvasObjectMouseEvent )
00390 A2D_END_EVENT_TABLE()
00391
00392 void a2dAxisMarker::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
00393 {
00394 a2dIterC* ic = event.GetIterC();
00395
00396 if ( m_flags.m_editingCopy )
00397 {
00398 a2dAxisMarker* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dAxisMarker );
00399
00400 static double xprev;
00401 static double yprev;
00402
00403 double xw,yw;
00404 xw = event.GetX();
00405 yw = event.GetY();
00406
00407 a2dAffineMatrix atWorld = ic->GetTransform();
00408 a2dAffineMatrix inverse = ic->GetInverseTransform();
00409
00410 double xh,yh;
00411 inverse.TransformPoint(xw, yw, xh, yh);
00412
00413 if (event.GetMouseEvent().LeftDown())
00414 {
00415 ic->SetCorridorPath( true, this );
00416 xprev = xh;
00417 yprev = yh;
00418 }
00419 else if ( event.GetMouseEvent().LeftUp() )
00420 {
00421 ic->SetCorridorPath( false );
00422 ic->GetCanvasView()->SetCaptured(NULL);
00423 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
00424
00425 if ( m_lworld != original->GetTransformMatrix() )
00426 m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( original, PROPID_TransformMatrix, m_lworld ) );
00427 }
00428 else if ( event.GetMouseEvent().Dragging() )
00429 {
00430 if(m_axis->IsYAxis())
00431 {
00432 double xy = m_axis->ConvertWorld2Axis(yh);
00433 if ( m_axis->GetAxisMin() < xy && m_axis->GetAxisMax() > xy )
00434 {
00435 double x,y;
00436 x = xh - (xprev-GetPosX());
00437 y = yh - (yprev-GetPosY());
00438
00439 SetPosXY( 0, y );
00440 original->SetPending( true );
00441 original->SetPosXY( 0, y );
00442 }
00443 else if ( m_axis->GetAxisMin() > xy )
00444 {
00445 double y = 0;
00446 if ( m_axis->GetAxisMin() != m_axis->GetBoundaryMin() )
00447 y = m_axis->GetLength();
00448
00449 SetPosXY( 0, y );
00450
00451
00452
00453
00454 original->SetPending( true );
00455 original->SetPosXY( 0, y );
00456 }
00457 else if ( m_axis->GetAxisMax() < xy )
00458 {
00459 double y = 0;
00460 if ( m_axis->GetAxisMin() == m_axis->GetBoundaryMin() )
00461 y = m_axis->GetLength();
00462
00463 SetPosXY( 0, y );
00464
00465
00466
00467
00468 original->SetPending( true );
00469 original->SetPosXY( 0, y );
00470 }
00471 }
00472 else
00473 {
00474 double xy = m_axis->ConvertWorld2Axis(xh);
00475 if ( m_axis->GetAxisMin() < xy && m_axis->GetAxisMax() > xy )
00476 {
00477 double x,y;
00478 x = xh - (xprev-GetPosX());
00479 y = yh - (yprev-GetPosY());
00480
00481 SetPosXY( x, 0 );
00482 original->SetPending( true );
00483 original->SetPosXY( x, 0 );
00484 }
00485 else if ( m_axis->GetAxisMin() > xy )
00486 {
00487 double x = 0;
00488 if ( m_axis->GetAxisMin() != m_axis->GetBoundaryMin() )
00489 x = m_axis->GetLength();
00490
00491 SetPosXY( x, 0 );
00492
00493
00494
00495
00496 original->SetPending( true );
00497 original->SetPosXY( x, 0 );
00498 }
00499 else if ( m_axis->GetAxisMax() < xy )
00500 {
00501 double x = 0;
00502 if ( m_axis->GetAxisMin() == m_axis->GetBoundaryMin() )
00503 x = m_axis->GetLength();
00504
00505 SetPosXY( x, 0 );
00506
00507
00508
00509
00510 original->SetPending( true );
00511 original->SetPosXY( x, 0 );
00512 }
00513 }
00514 xprev = xh;
00515 yprev = yh;
00516 }
00517 else
00518 {
00519 event.Skip();
00520 }
00521 }
00522 else
00523 {
00524 event.Skip();
00525 }
00526 }
00527
00528 a2dAxisMarker::a2dAxisMarker( const wxString& format, a2dCurveAxis* axis)
00529 : a2dBaseMarker( format )
00530 {
00531 m_axis = axis;
00532 }
00533
00534 a2dAxisMarker::a2dAxisMarker( const wxString& format, a2dCurveAxis* axis , double atx, double height)
00535 : a2dBaseMarker(format, atx, height)
00536 {
00537 m_axis = axis;
00538 }
00539
00540 a2dAxisMarker::a2dAxisMarker( const wxString& format, a2dCurveAxis* axis , double atx, const a2dFont& font )
00541 : a2dBaseMarker(format, atx, font)
00542 {
00543 m_axis = axis;
00544 }
00545
00546
00547 a2dAxisMarker::~a2dAxisMarker()
00548 {
00549 }
00550
00551 a2dAxisMarker::a2dAxisMarker( const a2dAxisMarker &other, CloneOptions options )
00552 :a2dBaseMarker( other, options )
00553 {
00554 m_axis = other.m_axis;
00555 }
00556
00557 a2dObject* a2dAxisMarker::Clone( CloneOptions options ) const
00558 {
00559 return new a2dAxisMarker( *this, options );
00560 };
00561
00562 void a2dAxisMarker::DoAddPending( a2dIterC& WXUNUSED(ic) )
00563 {
00564
00565
00566 }
00567
00568 void a2dAxisMarker::DependencyPending( a2dWalkerIOHandler* WXUNUSED(handler) )
00569 {
00570 if ( !m_flags.m_pending && m_axis->GetPending() )
00571 {
00572
00573 SetPending(true);
00574 }
00575 }
00576
00577 bool a2dAxisMarker::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
00578 {
00579 if ( m_axis && !m_bbox.GetValid() )
00580 {
00581 double worldPos = m_axis->ConvertAxis2World(m_position);
00582 if(m_axis->IsYAxis())
00583 SetPosXY( 0, worldPos );
00584 else
00585 SetPosXY( worldPos, 0 );
00586
00587 m_untransbbox = m_bbox = DoGetUnTransformedBbox();
00588 m_bbox.MapBbox(m_lworld);
00589 return true;
00590 }
00591 return false;
00592 }
00593
00594 #if wxART2D_USE_CVGIO
00595
00596 void a2dAxisMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00597 {
00598 a2dBaseMarker::DoSave( parent, out, xmlparts, towrite );
00599 if ( xmlparts == a2dXmlSer_attrib )
00600 {
00601 if ( m_axis )
00602 {
00603 out.WriteAttribute( wxT("axisname") , m_axis->GetName() );
00604 out.WriteAttribute( wxT("axis"), m_axis->GetUniqueSerializationId() );
00605 }
00606 }
00607 else
00608 {
00609 }
00610 }
00611
00612 void a2dAxisMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00613 {
00614 a2dBaseMarker::DoLoad( parent, parser, xmlparts );
00615 if ( xmlparts == a2dXmlSer_attrib )
00616 {
00617 if ( parser.HasAttribute( wxT("axis") ) )
00618 {
00619 parser.ResolveOrAdd( (a2dSmrtPtr<class a2dObject>*) &m_axis, parser.GetAttributeValue( wxT("axis") ) );
00620 }
00621 }
00622 else
00623 {
00624 }
00625
00626
00627 }
00628 #endif //wxART2D_USE_CVGIO
00629
00630 const wxString& a2dAxisMarker::GetMarkerString()
00631 {
00632 double val;
00633 if(!m_promptFormat.IsEmpty() && m_axis->GetLevelValue(GetName(),val))
00634 {
00635 m_promptString.Printf(m_promptFormat, val);
00636 }
00637 else if(!GetName().IsEmpty())
00638 m_promptString = GetName();
00639 else
00640 m_promptString = wxT("AxisMarker");
00641 return m_promptString;
00642 }
00643
00644
00645
00646
00647
00648 a2dPropertyIdCanvasObject* a2dCursorAxisMarker::PROPID_cursor = NULL;
00649
00650 INITIALIZE_PROPERTIES( a2dCursorAxisMarker, a2dAxisMarker )
00651 {
00652 A2D_PROPID_D( a2dPropertyIdCanvasObject, cursor, 0 );
00653 return true;
00654 }
00655
00656 a2dCursorAxisMarker::a2dCursorAxisMarker( const wxString& format, a2dCurveAxis* axis, a2dCursor* cursor)
00657 : a2dAxisMarker( format, axis )
00658 {
00659 m_cursor = cursor;
00660 m_positionY = 0;
00661 }
00662
00663 a2dCursorAxisMarker::a2dCursorAxisMarker( const wxString& format, a2dCurveAxis* axis , a2dCursor* cursor, double atx, double aty, double height)
00664 : a2dAxisMarker(format, axis, atx, height)
00665 {
00666 m_cursor = cursor;
00667 m_positionY = aty;
00668 }
00669
00670 a2dCursorAxisMarker::a2dCursorAxisMarker( const wxString& format, a2dCurveAxis* axis , a2dCursor* cursor, double atx, double aty, const a2dFont& font)
00671 : a2dAxisMarker(format, axis, atx, font)
00672 {
00673 m_cursor = cursor;
00674 m_positionY = aty;
00675 }
00676
00677
00678 a2dCursorAxisMarker::~a2dCursorAxisMarker()
00679 {
00680 }
00681
00682 a2dCursorAxisMarker::a2dCursorAxisMarker( const a2dCursorAxisMarker &other, CloneOptions options )
00683 :a2dAxisMarker( other, options )
00684 {
00685 m_cursor = other.m_cursor;
00686 m_positionY = other.m_positionY;
00687 }
00688
00689 a2dObject* a2dCursorAxisMarker::Clone( CloneOptions options ) const
00690 {
00691 return new a2dCursorAxisMarker( *this, options );
00692 };
00693
00694 void a2dCursorAxisMarker::DependencyPending( a2dWalkerIOHandler* WXUNUSED(handler) )
00695 {
00696 if ( !m_flags.m_pending && (m_axis && m_axis->GetPending() || m_cursor && m_cursor->GetPending()))
00697 {
00698
00699 SetPending(true);
00700 }
00701 }
00702
00703 bool a2dCursorAxisMarker::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
00704 {
00705 if ( m_axis && !m_bbox.GetValid() )
00706 {
00707 double worldPosY = 0.;
00708 if(m_cursor)
00709 worldPosY = m_cursor->ConvertAxis2World(m_positionY);
00710 double worldPos = m_axis->ConvertAxis2World(m_position);
00711 if(m_axis->IsYAxis())
00712 SetPosXY( worldPosY, worldPos );
00713 else
00714 SetPosXY( worldPos, worldPosY );
00715
00716 m_untransbbox = m_bbox = DoGetUnTransformedBbox();
00717 m_bbox.MapBbox(m_lworld);
00718 return true;
00719 }
00720 return false;
00721 }
00722
00723 #if wxART2D_USE_CVGIO
00724
00725 void a2dCursorAxisMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00726 {
00727 a2dAxisMarker::DoSave( parent, out, xmlparts, towrite );
00728 if ( xmlparts == a2dXmlSer_attrib )
00729 {
00730 if ( m_cursor )
00731 {
00732 out.WriteAttribute( wxT("cursor"), m_cursor->GetUniqueSerializationId() );
00733 }
00734
00735 }
00736 else
00737 {
00738 }
00739 }
00740
00741 void a2dCursorAxisMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00742 {
00743 a2dAxisMarker::DoLoad( parent, parser, xmlparts );
00744 if ( xmlparts == a2dXmlSer_attrib )
00745 {
00746 if ( parser.HasAttribute( wxT("cursor") ) )
00747 {
00748 parser.ResolveOrAdd( (a2dSmrtPtr<class a2dObject>*) &m_cursor, parser.GetAttributeValue( wxT("cursor") ) );
00749 }
00750 }
00751 else
00752 {
00753 }
00754
00755
00756 }
00757 #endif //wxART2D_USE_CVGIO
00758
00759
00760
00761
00762 #define fach 0.7
00763 #define facv 1.78
00764
00765 a2dPropertyIdCanvasObject* a2dMarker::PROPID_curve = NULL;
00766
00767 INITIALIZE_PROPERTIES( a2dMarker, a2dBaseMarker )
00768 {
00769 A2D_PROPID_D( a2dPropertyIdCanvasObject, curve, 0 );
00770 return true;
00771 }
00772
00773 void a2dMarker::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
00774 {
00775 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
00776 a2dBaseMarker::DoWalker( parent, handler );
00777
00778 if (m_curve)
00779 m_curve->Walker( this, handler );
00780
00781 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
00782 }
00783
00784
00785 A2D_BEGIN_EVENT_TABLE(a2dMarker,a2dBaseMarker)
00786 A2D_EVT_CANVASOBJECT_MOUSE_EVENT( a2dMarker::OnCanvasObjectMouseEvent )
00787 A2D_EVT_CHAR( a2dMarker::OnChar )
00788 A2D_END_EVENT_TABLE()
00789
00790 void a2dMarker::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
00791 {
00792 a2dIterC* ic = event.GetIterC();
00793
00794 if ( m_flags.m_editingCopy )
00795 {
00796 a2dMarker* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dMarker );
00797
00798 static double xprev;
00799 static double yprev;
00800
00801 double xw,yw;
00802 xw = event.GetX();
00803 yw = event.GetY();
00804
00805 a2dAffineMatrix atWorld = ic->GetTransform();
00806 a2dAffineMatrix inverse = ic->GetInverseTransform();
00807
00808 double xh,yh;
00809 inverse.TransformPoint(xw, yw, xh, yh);
00810
00811 double xcurve, ycurve;
00812 m_curvesArea->World2Curve( xh, yh, xcurve, ycurve );
00813
00814 if (event.GetMouseEvent().LeftDown())
00815 {
00816 ic->SetCorridorPath( true, this );
00817 xprev = xh;
00818 yprev = yh;
00819 }
00820 else if ( event.GetMouseEvent().LeftUp() )
00821 {
00822 ic->SetCorridorPath( false );
00823 ic->GetCanvasView()->SetCaptured(NULL);
00824 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
00825
00826
00827 m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( original, PROPID_PositionMarker, m_position ) );
00828 }
00829 else if ( event.GetMouseEvent().Dragging() )
00830 {
00831 a2dBoundingBox curvebox = m_curve->GetClippedCurveBoundaries();
00832 if(curvebox.GetValid())
00833 {
00834 if ( curvebox.GetMinX() < xcurve && curvebox.GetMaxX() > xcurve )
00835 {
00836 double x,y;
00837 x = xh - (xprev-GetPosX());
00838 y = yh - (yprev-GetPosY());
00839
00840 m_position = xcurve;
00841 CalculatePositionMarker( x, y );
00842 SetPosXY( x, y );
00843
00844
00845
00846
00847 original->SetPosition( m_position );
00848 }
00849 else if ( curvebox.GetMinX() > xcurve )
00850 {
00851 double x,y ;
00852 m_position = curvebox.GetMinX();
00853 CalculatePositionMarker( x, y );
00854 SetPosXY( x, y );
00855
00856
00857
00858
00859 original->SetPosition( m_position );
00860 }
00861 else if ( curvebox.GetMaxX() < xcurve )
00862 {
00863 double x,y ;
00864 m_position = curvebox.GetMaxX();
00865 CalculatePositionMarker( x, y );
00866 SetPosXY( x, y );
00867
00868
00869
00870
00871 original->SetPosition( m_position );
00872 }
00873 }
00874 xprev = xh;
00875 yprev = yh;
00876 }
00877 else
00878 {
00879 event.Skip();
00880 }
00881 }
00882 else
00883 {
00884 event.Skip();
00885 }
00886 }
00887
00888 void a2dMarker::OnChar(wxKeyEvent& event)
00889 {
00890 if ( m_flags.m_editingCopy )
00891 {
00892 a2dBoundingBox curvebox = m_curve->GetClippedCurveBoundaries();
00893 if(!curvebox.GetValid())
00894 {
00895 return;
00896 }
00897
00898 a2dMarker* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dMarker );
00899
00900 double x;
00901 x = m_position;
00902
00903 double step = (curvebox.GetMaxX() - curvebox.GetMinX())/100;
00904 if ( m_step )
00905 step = m_step;
00906
00907 switch(event.GetKeyCode())
00908 {
00909 case WXK_LEFT:
00910 x = x - step;
00911 break;
00912
00913 case WXK_RIGHT:
00914 x = x + step;
00915 break;
00916
00917
00918 case WXK_PAGEUP:
00919 x = x + step*10;
00920 break;
00921
00922
00923 case WXK_PAGEDOWN:
00924 x = x - step*10;
00925 break;
00926
00927 case WXK_HOME:
00928 x = curvebox.GetMinX();
00929 break;
00930
00931 case WXK_END:
00932 x = curvebox.GetMaxX();
00933 break;
00934
00935 break;
00936 default:
00937 event.Skip();
00938 return;
00939 }
00940
00941 if ( curvebox.GetMinX() <= x && curvebox.GetMaxX() >= x )
00942 {
00943 double yw,xw;
00944 m_position = x;
00945 CalculatePositionMarker( yw,xw );
00946
00947 SetPosXY( yw,xw );
00948
00949
00950
00951
00952 original->SetPosition( m_position );
00953 }
00954 else if ( curvebox.GetMinX() > x )
00955 {
00956 double yw,xw;
00957 m_position = curvebox.GetMinX();
00958 CalculatePositionMarker( yw,xw );
00959 SetPosXY( yw,xw );
00960
00961
00962
00963
00964 original->SetPosition( m_position );
00965 }
00966 else if ( curvebox.GetMaxX() < x )
00967 {
00968 double yw,xw;
00969 m_position = curvebox.GetMaxX();
00970 CalculatePositionMarker( yw,xw);
00971 SetPosXY( yw,xw);
00972
00973
00974
00975
00976 original->SetPosition( m_position );
00977 }
00978
00979 }
00980 else
00981 event.Skip();
00982 }
00983
00984 a2dMarker::a2dMarker( const wxString& format, a2dCurve* curve)
00985 : a2dBaseMarker( format )
00986 {
00987 m_curve = curve;
00988 }
00989
00990 a2dMarker::a2dMarker( const wxString& format, a2dCurve* curve , double atx, double height)
00991 : a2dBaseMarker(format, atx, height)
00992 {
00993 m_curve = curve;
00994 }
00995
00996 a2dMarker::a2dMarker( const wxString& format, a2dCurve* curve , double atx, const a2dFont& font)
00997 : a2dBaseMarker(format, atx, font)
00998 {
00999 m_curve = curve;
01000 }
01001
01002
01003 a2dMarker::~a2dMarker()
01004 {
01005 }
01006
01007 a2dMarker::a2dMarker( const a2dMarker &other, CloneOptions options )
01008 :a2dBaseMarker( other, options )
01009 {
01010 m_curve = other.m_curve;
01011 }
01012
01013 a2dObject* a2dMarker::Clone( CloneOptions options ) const
01014 {
01015 return new a2dMarker( *this, options );
01016 };
01017
01018 void a2dMarker::CalculatePositionMarker( double& xw, double& yw )
01019 {
01020 if ( m_curve )
01021 {
01022 a2dPoint2D point;
01023 m_curve->GetXyAtSweep( m_position, point );
01024 m_position = point.m_x;
01025 m_curvesArea->Curve2World( point.m_x, point.m_y, xw, yw );
01026 }
01027 else
01028 {
01029 xw = 0;
01030 yw = 0;
01031 m_position = 0;
01032 }
01033 }
01034
01035 bool a2dMarker::GetPositionCurvePoint( a2dPoint2D& point )
01036 {
01037 if ( m_curve )
01038 {
01039 return m_curve->GetXyAtSweep( m_position, point );
01040 }
01041 else
01042 {
01043 point.m_x = 0;
01044 point.m_y = 0;
01045 return false;
01046 }
01047 }
01048
01049 void a2dMarker::DoAddPending( a2dIterC& WXUNUSED(ic) )
01050 {
01051
01052
01053 }
01054
01055 void a2dMarker::DependencyPending( a2dWalkerIOHandler* WXUNUSED(handler) )
01056 {
01057 if ( !m_flags.m_pending && m_curve->GetPending() )
01058 {
01059
01060 SetPending(true);
01061 }
01062 }
01063
01064 bool a2dMarker::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
01065 {
01066 if ( m_curve && !m_bbox.GetValid() )
01067 {
01068 double x, y;
01069 CalculatePositionMarker( x, y );
01070 SetPosXY( x, y );
01071
01072
01073
01074 m_untransbbox = m_bbox = DoGetUnTransformedBbox();
01075 m_bbox.MapBbox(m_lworld);
01076 return true;
01077 }
01078 return false;
01079 }
01080
01081 #if wxART2D_USE_CVGIO
01082
01083 void a2dMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01084 {
01085 a2dBaseMarker::DoSave( parent, out, xmlparts, towrite );
01086 if ( xmlparts == a2dXmlSer_attrib )
01087 {
01088 if ( m_curve )
01089 {
01090 out.WriteAttribute( wxT("curvename") , m_curve->GetName() );
01091 out.WriteAttribute( wxT("curve"), m_curve->GetUniqueSerializationId() );
01092 }
01093 }
01094 else
01095 {
01096 }
01097 }
01098
01099 void a2dMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01100 {
01101 a2dBaseMarker::DoLoad( parent, parser, xmlparts );
01102 if ( xmlparts == a2dXmlSer_attrib )
01103 {
01104 if ( parser.HasAttribute( wxT("curve") ) )
01105 {
01106 parser.ResolveOrAdd( (a2dSmrtPtr<class a2dObject>*) &m_curve, parser.GetAttributeValue( wxT("curve") ) );
01107 }
01108 }
01109 else
01110 {
01111 }
01112
01113
01114 }
01115 #endif //wxART2D_USE_CVGIO
01116
01117 const wxString& a2dMarker::GetMarkerString()
01118 {
01119 if(!m_promptFormat.IsEmpty())
01120 {
01121 double xc, yc;
01122 m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
01123 wxString form;
01124 m_promptString.Printf(m_promptFormat, xc, yc);
01125 }
01126 else if(!GetName().IsEmpty())
01127 m_promptString = GetName();
01128 else
01129 m_promptString = wxT("CurveMarker");
01130 return m_promptString;
01131 }
01132
01133
01134
01135
01136
01137 a2dBandMarker::a2dBandMarker( const wxString& format, a2dBandCurve* curve)
01138 : a2dMarker( format, curve )
01139 {
01140 m_markerUpLow = true;
01141 m_curveBand = curve;
01142 m_curveBand->SetMarkerUpLow( m_markerUpLow );
01143 }
01144
01145 a2dBandMarker::a2dBandMarker( const wxString& format, a2dBandCurve* curve , double atx, double height)
01146 : a2dMarker(format, curve, atx, height)
01147 {
01148 m_markerUpLow = true;
01149 m_curveBand = curve;
01150 m_curveBand->SetMarkerUpLow( m_markerUpLow );
01151 }
01152
01153 a2dBandMarker::a2dBandMarker( const wxString& format, a2dBandCurve* curve , double atx, const a2dFont& font)
01154 : a2dMarker(format, curve, atx, font)
01155 {
01156 m_markerUpLow = true;
01157 m_curveBand = curve;
01158 m_curveBand->SetMarkerUpLow( m_markerUpLow );
01159 }
01160
01161 a2dBandMarker::~a2dBandMarker()
01162 {
01163 }
01164
01165 a2dBandMarker::a2dBandMarker( const a2dBandMarker &other, CloneOptions options )
01166 :a2dMarker( other, options )
01167 {
01168 m_markerUpLow = other.m_markerUpLow;
01169 m_curveBand = other.m_curveBand;
01170 }
01171
01172 a2dObject* a2dBandMarker::Clone( CloneOptions options ) const
01173 {
01174 return new a2dBandMarker( *this, options );
01175 };
01176
01177 void a2dBandMarker::CalculatePositionMarker( double& xw, double& yw )
01178 {
01179 if ( m_curve )
01180 {
01181 m_curveBand->SetMarkerUpLow( m_markerUpLow );
01182 a2dMarker::CalculatePositionMarker( xw, yw );
01183 }
01184 else
01185 {
01186 xw = 0;
01187 yw = 0;
01188 m_position = 0;
01189 }
01190 }
01191
01192 bool a2dBandMarker::GetPositionCurvePoint( a2dPoint2D& point )
01193 {
01194 if ( m_curve )
01195 {
01196 m_curveBand->SetMarkerUpLow( m_markerUpLow );
01197 a2dMarker::GetPositionCurvePoint( point );
01198 return true;
01199 }
01200 else
01201 {
01202 point.m_x = 0;
01203 point.m_y = 0;
01204 return false;
01205 }
01206 }
01207
01208 #if wxART2D_USE_CVGIO
01209
01210 void a2dBandMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01211 {
01212 a2dMarker::DoSave( parent, out, xmlparts, towrite );
01213 if ( xmlparts == a2dXmlSer_attrib )
01214 {
01215 out.WriteAttribute( wxT("uplow") , m_markerUpLow );
01216 }
01217 else
01218 {
01219 }
01220 }
01221
01222 void a2dBandMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01223 {
01224 a2dMarker::DoLoad( parent, parser, xmlparts );
01225 if ( xmlparts == a2dXmlSer_attrib )
01226 {
01227 m_markerUpLow = parser.GetAttributeValueBool( wxT("spline"), false );
01228 }
01229 else
01230 {
01231 }
01232 }
01233 #endif //wxART2D_USE_CVGIO
01234
01235 void a2dBandMarker::DoRender( a2dIterC& ic, OVERLAP WXUNUSED(clipparent) )
01236 {
01237 a2dVertexArray cpoints;
01238
01239 if ( m_flags.m_editingCopy )
01240 ic.GetDrawer2D()->SetDrawerFill(*a2dBLACK_FILL);
01241
01242 cpoints.push_back( new a2dLineSegment( 0, 0 ));
01243 cpoints.push_back( new a2dLineSegment( m_b/2.0, m_l1 ));
01244 if(m_l1 != m_l2)
01245 {
01246 cpoints.push_back( new a2dLineSegment( 0, m_l2 ));
01247 }
01248 cpoints.push_back( new a2dLineSegment( -m_b/2.0, m_l1 ));
01249
01250 double xw,yw,yw2;
01251 CalculatePositionMarker( xw, yw2 );
01252 m_markerUpLow = !m_markerUpLow;
01253 CalculatePositionMarker( xw, yw );
01254 m_markerUpLow = !m_markerUpLow;
01255 m_curveBand->SetMarkerUpLow( m_markerUpLow );
01256
01257 ic.GetDrawer2D()->DrawPolygon( &cpoints, m_spline, wxWINDING_RULE);
01258
01259 ic.GetDrawer2D()->DrawLine( 0,0, 0, yw-yw2 );
01260
01261 cpoints.clear();
01262
01263 if(!m_format.IsEmpty())
01264 {
01265 double xc, yc;
01266 m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
01267 wxString form;
01268 form.Printf(m_format, xc, yc );
01269
01270 ic.GetDrawer2D()->SetFont( m_font );
01271 ic.GetDrawer2D()->SetDrawerFill(*a2dTRANSPARENT_FILL);
01272
01273 ic.GetDrawer2D()->DrawText( form, -m_b/2, m_l1 + m_textheight *2.5 );
01274
01275 ic.GetDrawer2D()->SetFont( *a2dNullFONT );
01276 }
01277 }
01278
01279
01280
01281
01282 #define fach 0.7
01283 #define facv 1.78
01284
01285 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_marker = NULL;
01286 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_xText = NULL;
01287 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_yText = NULL;
01288 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_Xlabel = NULL;
01289 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_Ylabel = NULL;
01290
01291 INITIALIZE_PROPERTIES( a2dMarkerShow, a2dCanvasObject )
01292 {
01293 A2D_PROPID_D( a2dPropertyIdCanvasObject, marker, 0 );
01294 A2D_PROPID_D( a2dPropertyIdCanvasObject, xText, 0 );
01295 A2D_PROPID_D( a2dPropertyIdCanvasObject, yText, 0 );
01296 A2D_PROPID_D( a2dPropertyIdCanvasObject, Xlabel, 0 );
01297 A2D_PROPID_D( a2dPropertyIdCanvasObject, Ylabel, 0 );
01298 return true;
01299 }
01300
01301 void a2dMarkerShow::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
01302 {
01303 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
01304 a2dCanvasObject::DoWalker( parent, handler );
01305 if (m_marker)
01306 m_marker->Walker( this, handler );
01307 if (m_xText)
01308 m_xText->Walker( this, handler );
01309 if (m_yText)
01310 m_yText->Walker( this, handler );
01311 if (m_Xlabel)
01312 m_Xlabel->Walker( this, handler );
01313 if (m_Ylabel)
01314 m_Ylabel->Walker( this, handler );
01315
01316 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
01317 }
01318
01319 A2D_BEGIN_EVENT_TABLE(a2dMarkerShow,a2dCanvasObject)
01320 A2D_EVT_CANVASOBJECT_MOUSE_EVENT( a2dMarkerShow::OnCanvasObjectMouseEvent )
01321 A2D_END_EVENT_TABLE()
01322
01323 a2dMarkerShow::a2dMarkerShow( double x, double y,
01324 const wxString& XLabel, const wxString& YLabel,
01325 const wxString& XValueformat, const wxString& YValueformat,
01326 a2dMarker* marker, double height)
01327 :a2dCanvasObject( x, y )
01328 {
01329 m_marker = marker;
01330
01331 m_XValueformat = XValueformat;
01332 m_YValueformat = YValueformat;
01333
01334 m_textheight = height;
01335 if ( height == 0 )
01336 m_textheight = 5 ;
01337
01338 m_Xlabel = new a2dText(XLabel, 0,0, a2dFont(m_textheight, wxSWISS) );
01339 Append(m_Xlabel);
01340 m_Xlabel->SetName( wxT("__XLABEL__") );
01341 m_Xlabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01342
01343 m_Ylabel = new a2dText(YLabel, 0,-1.2*m_textheight, a2dFont(m_textheight, wxSWISS) );
01344 Append(m_Ylabel);
01345 m_Ylabel->SetName( wxT("__YLABEL__") );
01346 m_Ylabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01347
01348 m_xText = new a2dText( wxT(""), 0,0, a2dFont(m_textheight, wxSWISS) );
01349 Append(m_xText);
01350 m_xText->SetName( wxT("__XTEXT__") );
01351 m_xText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01352
01353 m_yText = new a2dText( wxT(""), 0,-1.2*m_textheight, a2dFont(m_textheight, wxSWISS) );
01354 Append(m_yText);
01355 m_yText->SetName( wxT("__YTEXT__") );
01356 m_yText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01357 }
01358
01359 a2dMarkerShow::~a2dMarkerShow()
01360 {
01361 }
01362
01363 a2dMarkerShow::a2dMarkerShow( const a2dMarkerShow &other, CloneOptions options )
01364 :a2dCanvasObject( other, options )
01365 {
01366 m_marker = other.m_marker;
01367 m_XValueformat = other.m_XValueformat;
01368 m_YValueformat = other.m_YValueformat;
01369 m_textheight = other.m_textheight;
01370
01371 m_xText = (a2dText*) Find( wxT("__XTEXT__") );
01372 m_xText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01373 m_yText = (a2dText*) Find( wxT("__YTEXT__") );
01374 m_yText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01375 m_Xlabel = (a2dText*) Find( wxT("__XLABEL__") );
01376 m_Xlabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01377 m_Ylabel = (a2dText*) Find( wxT("__YLABEL__") );
01378 m_Ylabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
01379 }
01380
01381 a2dObject* a2dMarkerShow::Clone( CloneOptions options ) const
01382 {
01383 return new a2dMarkerShow( *this, options );
01384 };
01385
01386 a2dBoundingBox a2dMarkerShow::DoGetUnTransformedBbox( a2dBboxFlags flags ) const
01387 {
01388 a2dBoundingBox bbox;
01389
01390 m_Xlabel->SetPosXY( 0.0, 0.0 );
01391 a2dBoundingBox Xlabelbox = m_Xlabel->GetFont().GetTextExtent( m_Xlabel->GetText(), UNKNOWN_YAXIS, m_Xlabel->GetAlignment() );
01392 Xlabelbox.Translate( m_Xlabel->GetPosX(), m_Xlabel->GetPosY() );
01393 bbox.Expand( Xlabelbox );
01394 m_Xlabel->Update( updatemask_normal );
01395
01396 m_Ylabel->SetPosXY( 0.0, -1.2 * Xlabelbox.GetHeight() );
01397 a2dBoundingBox Ylabelbox = m_Ylabel->GetFont().GetTextExtent( m_Ylabel->GetText(), UNKNOWN_YAXIS, m_Ylabel->GetAlignment() );
01398 Ylabelbox.Translate( m_Ylabel->GetPosX(), m_Ylabel->GetPosY() );
01399 bbox.Expand( Ylabelbox );
01400 m_Ylabel->Update( updatemask_normal );
01401
01402 double labelw = bbox.GetMaxX();
01403
01404 m_xText->SetPosXY( labelw, 0.0 );
01405 a2dBoundingBox Xtextbox = m_xText->GetFont().GetTextExtent( m_xText->GetText(), UNKNOWN_YAXIS, m_xText->GetAlignment() );
01406 Xtextbox.Translate( m_xText->GetPosX(), m_xText->GetPosY() );
01407 bbox.Expand( Xtextbox );
01408 m_xText->Update( updatemask_normal );
01409
01410 m_yText->SetPosXY( labelw, m_Ylabel->GetPosY() );
01411 a2dBoundingBox Ytextbox = m_yText->GetFont().GetTextExtent( m_yText->GetText(), UNKNOWN_YAXIS, m_yText->GetAlignment() );
01412 Ytextbox.Translate( m_yText->GetPosX(), m_yText->GetPosY() );
01413 bbox.Expand( Ytextbox );
01414 m_yText->Update( updatemask_normal );
01415
01416 return bbox;
01417 }
01418
01419 void a2dMarkerShow::DependencyPending( a2dWalkerIOHandler* WXUNUSED(handler) )
01420 {
01421 if ( !m_flags.m_pending )
01422 {
01423
01424 if ( m_marker && m_marker->GetPending() )
01425 {
01426
01427 SetPending(true);
01428 }
01429
01430 else if ( ( m_xText->GetPending() || m_yText->GetPending() ) )
01431 {
01432
01433 double x;
01434 m_xText->GetText().ToDouble( &x );
01435 if ( m_marker )
01436 m_marker->SetPosition( x );
01437 }
01438 }
01439 }
01440
01441 void a2dMarkerShow::OnPropertyChanged( const a2dPropertyId* id)
01442 {
01443 a2dCanvasObject::OnPropertyChanged(id);
01444 if(id == PROPID_Stroke)
01445 {
01446 a2dStroke stroke = GetStroke();
01447 m_xText->SetStroke( stroke );
01448 m_Xlabel->SetStroke( stroke );
01449 m_yText->SetStroke( stroke );
01450 m_Ylabel->SetStroke( stroke );
01451 }
01452 else if(id == PROPID_Fill)
01453 {
01454 a2dFill fill = GetFill();
01455 m_xText->SetFill( fill );
01456 m_Xlabel->SetFill( fill );
01457 m_yText->SetFill( fill );
01458 m_Ylabel->SetFill( fill );
01459 }
01460 }
01461
01462 bool a2dMarkerShow::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
01463 {
01464 if ( !m_bbox.GetValid() )
01465 {
01466 wxString formX;
01467 wxString formY;
01468 if ( m_marker )
01469 {
01470 a2dPoint2D point;
01471 m_marker->GetPositionCurvePoint( point );
01472 formX.Printf( m_XValueformat, point.m_x );
01473 formY.Printf( m_YValueformat, point.m_y );
01474 }
01475 else
01476 {
01477 formX.Printf( m_XValueformat, 0.0 );
01478 formY.Printf( m_YValueformat, 0.0 );
01479 }
01480 m_xText->SetText( formX );
01481 m_yText->SetText( formY );
01482 m_xText->SetStroke( GetStroke() );
01483 m_xText->SetFill( GetFill() );
01484 m_Xlabel->SetStroke( GetStroke() );
01485 m_Xlabel->SetFill( GetFill() );
01486 m_yText->SetStroke( GetStroke() );
01487 m_yText->SetFill( GetFill() );
01488 m_Ylabel->SetStroke( GetStroke() );
01489 m_Ylabel->SetFill( GetFill() );
01490
01491 m_xText->SetPending( false );
01492 m_yText->SetPending( false );
01493
01494 m_bbox = DoGetUnTransformedBbox();
01495 m_bbox.MapBbox(m_lworld);
01496 return true;
01497 }
01498
01499 return false;
01500 }
01501
01502 void a2dMarkerShow::DoRender( a2dIterC& ic, OVERLAP WXUNUSED(clipparent) )
01503 {
01504
01505
01506 wxString formX;
01507 wxString formY;
01508 if ( m_marker )
01509 {
01510 a2dPoint2D point;
01511 m_marker->GetPositionCurvePoint( point );
01512 formX.Printf( m_XValueformat, point.m_x );
01513 formY.Printf( m_YValueformat, point.m_y );
01514 }
01515 else
01516 {
01517 formX.Printf( m_XValueformat, 0.0 );
01518 formY.Printf( m_YValueformat, 0.0 );
01519 }
01520
01521 m_xText->SetText( formX );
01522 m_yText->SetText( formY );
01523 m_xText->SetPending( false );
01524 m_yText->SetPending( false );
01525
01526 a2dBoundingBox bbox;
01527
01528 m_Xlabel->SetPosXY( 0.0, 0.0 );
01529 a2dBoundingBox Xlabelbox = m_Xlabel->GetFont().GetTextExtent( m_Xlabel->GetText(), ic.GetDrawer2D()->GetYaxis(), m_Xlabel->GetAlignment() );
01530 Xlabelbox.Translate( m_Xlabel->GetPosX(), m_Xlabel->GetPosY() );
01531 bbox.Expand( Xlabelbox );
01532
01533 m_Ylabel->SetPosXY( 0.0, -1.2 * m_Xlabel->GetLineHeight() );
01534 a2dBoundingBox Ylabelbox = m_Ylabel->GetFont().GetTextExtent( m_Ylabel->GetText(), ic.GetDrawer2D()->GetYaxis(), m_Ylabel->GetAlignment() );
01535 Ylabelbox.Translate( m_Ylabel->GetPosX(), m_Ylabel->GetPosY() );
01536 bbox.Expand( Ylabelbox );
01537
01538 double labelw = bbox.GetMaxX();
01539
01540 m_xText->SetPosXY( labelw, 0.0 );
01541 a2dBoundingBox Xtextbox = m_xText->GetFont().GetTextExtent( m_xText->GetText(), ic.GetDrawer2D()->GetYaxis(), m_xText->GetAlignment() );
01542 Xtextbox.Translate( m_xText->GetPosX(), m_xText->GetPosY() );
01543 bbox.Expand( Xtextbox );
01544
01545 m_yText->SetPosXY( labelw, m_Ylabel->GetPosY() );
01546 a2dBoundingBox Ytextbox = m_yText->GetFont().GetTextExtent( m_yText->GetText(), ic.GetDrawer2D()->GetYaxis(), m_yText->GetAlignment() );
01547 Ytextbox.Translate( m_yText->GetPosX(), m_yText->GetPosY() );
01548 bbox.Expand( Ytextbox );
01549
01550 bbox.Enlarge( bbox.GetWidth() / 80.0 );
01551 ic.GetDrawer2D()->DrawRoundedRectangle( bbox.GetMinX(), bbox.GetMinY(), bbox.GetWidth() ,bbox.GetHeight(), 0);
01552 }
01553
01554 #if wxART2D_USE_CVGIO
01555 void a2dMarkerShow::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01556 {
01557 a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
01558 if ( xmlparts == a2dXmlSer_attrib )
01559 {
01560 }
01561 else
01562 {
01563 }
01564 }
01565
01566 void a2dMarkerShow::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01567 {
01568 a2dCanvasObject::DoLoad( parent, parser, xmlparts );
01569 if ( xmlparts == a2dXmlSer_attrib )
01570 {
01571 m_xText = (a2dText*) Find( wxT("__XTEXT__") );
01572 m_yText = (a2dText*) Find( wxT("__YTEXT__") );
01573 m_Xlabel = (a2dText*) Find( wxT("__XLABEL__") );
01574 m_Ylabel = (a2dText*) Find( wxT("__YLABEL__") );
01575 }
01576 else
01577 {
01578 }
01579 }
01580 #endif //wxART2D_USE_CVGIO
01581
01582 bool a2dMarkerShow::DoIsHitWorld( a2dIterC& WXUNUSED(ic), a2dHitEvent& hitEvent )
01583 {
01584 return true;
01585 }
01586
01587
01588 bool a2dMarkerShow::DoStartEdit( wxUint16 WXUNUSED(editmode), wxEditStyle WXUNUSED(editstyle) )
01589 {
01590 if ( m_flags.m_editable )
01591 {
01592
01593
01594 Update( updatemask_force );
01595
01596 SetPending( true );
01597 return true;
01598 }
01599
01600 return false;
01601 }
01602
01603 void a2dMarkerShow::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
01604 {
01605 a2dIterC* ic = event.GetIterC();
01606 if ( m_flags.m_editingCopy )
01607 {
01608
01609 double xw,yw;
01610 xw = event.GetX();
01611 yw = event.GetY();
01612
01613 a2dAffineMatrix atWorld = ic->GetTransform();
01614
01615 if ( event.GetMouseEvent().LeftDown() )
01616 {
01617 a2dMarkerShow* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dMarkerShow );;
01618
01619 a2dHitEvent hitevent = a2dHitEvent(xw, yw, false);
01620 if ( IsHitWorld( *ic, hitevent ) )
01621 {
01622 a2dHitEvent hitinfo( xw, yw, false );
01623 hitinfo.m_xyRelToChildren = true;
01624 a2dCanvasObject* text = original->IsHitWorld( *ic, hitinfo );
01625 if ( text && text->GetEditable() )
01626 {
01627 #if wxART2D_USE_EDITOR
01628 a2dIterCU cu( *ic, original );
01629 a2dStToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dStToolContr ) ;
01630
01631 ic->SetCorridorPath( true, NULL );
01632 controller->StartEditingObject( text, *ic );
01633 #else //wxART2D_USE_EDITOR
01634 wxMessageBox( wxT("Need editor module enabled for this") );
01635 #endif //wxART2D_USE_EDITOR
01636
01637 SetPending( true );
01638 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
01639 }
01640 else
01641 event.Skip();
01642 }
01643 else
01644 EndEdit();
01645 }
01646 else if ( event.GetMouseEvent().LeftDClick() )
01647 {
01648 EndEdit();
01649 }
01650 else if ( event.GetMouseEvent().Moving() )
01651 {
01652 event.Skip();
01653 }
01654 else
01655 event.Skip();
01656 }
01657 else
01658 event.Skip();
01659 }
01660
01661
01662
01663
01664
01665 a2dCursorMarkerList::a2dCursorMarkerList()
01666 {
01667 }
01668
01669 a2dCursorMarkerList::~a2dCursorMarkerList()
01670 {
01671 }
01672
01673 a2dCursorMarkerList* a2dCursorMarkerList::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01674 {
01675 wxASSERT(0);
01676 return NULL;
01677 }
01678
01679
01680
01681
01682 IMPLEMENT_DYNAMIC_CLASS(a2dCursor, a2dCanvasObject)
01683
01684 A2D_BEGIN_EVENT_TABLE(a2dCursor,a2dCanvasObject)
01685
01686 A2D_END_EVENT_TABLE()
01687
01688 a2dCursor::a2dCursor( double csize )
01689 : a2dCanvasObject()
01690 {
01691 m_csize = csize;
01692 m_hsize = 0;
01693 m_wsize = 0;
01694 m_posx = 0;
01695 m_posy = 0;
01696 m_onlyIntPosX = false;
01697 m_onlyIntPosY = false;
01698 }
01699
01700 a2dCursor::~a2dCursor()
01701 {
01702 }
01703
01704 a2dCursor::a2dCursor( const a2dCursor &other, CloneOptions options )
01705 :a2dCanvasObject( other, options )
01706 {
01707 m_hsize = other.m_hsize;
01708 m_wsize = other.m_wsize;
01709 m_csize = other.m_csize;
01710 m_posx = other.m_posx;
01711 m_posy = other.m_posy;
01712 m_onlyIntPosX = other.m_onlyIntPosX;
01713 m_onlyIntPosY = other.m_onlyIntPosY;
01714 }
01715
01716 a2dObject* a2dCursor::Clone( CloneOptions options ) const
01717 {
01718 return new a2dCursor( *this, options );
01719 };
01720
01721 void a2dCursor::DoUpdateViewDependentTransform( a2dIterC& ic )
01722 {
01723
01724 a2dCanvasObject::DoUpdateViewDependentTransform(ic);
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735 }
01736
01737 a2dBoundingBox a2dCursor::DoGetUnTransformedBbox(a2dBboxFlags flags)
01738 {
01739 a2dBoundingBox bbox;
01740
01741 double scalex = 1;
01742 const a2dMatrixProperty * propSpec = PROPID_IntViewDependTransform->GetPropertyListOnly( this );
01743 if ( propSpec )
01744 {
01745 a2dMatrixProperty* propMatrix = wxStaticCast(propSpec, a2dMatrixProperty);
01746 scalex = propMatrix->GetValue().Get_scaleX();
01747 }
01748
01749 bbox.Expand(0,0);
01750 bbox.Expand(m_csize*scalex,m_hsize);
01751
01752 m_untransbbox = bbox;
01753 return bbox;
01754 }
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769 return true;
01770 }
01771 return false;
01772 }
01773 */
01774 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
01775
01776 void a2dCursor::DoRender( a2dIterC& ic, OVERLAP WXUNUSED(clipparent) )
01777 {
01778
01779
01780
01781
01782 double scalex = 1.;
01783 const a2dMatrixProperty * propSpec = PROPID_IntViewDependTransform->GetPropertyListOnly( this );
01784 if ( propSpec )
01785 {
01786 a2dMatrixProperty* propMatrix = wxStaticCast(propSpec, a2dMatrixProperty);
01787 scalex = propMatrix->GetValue().Get_scaleX();
01788 }
01789 ic.GetDrawer2D()->DrawRoundedRectangle( 0, 0, m_csize*scalex, m_hsize, 0);
01790 }
01791
01792 void a2dCursor::AddMarker(a2dBaseMarker* marker )
01793 {
01794 m_markers.push_back(marker);
01795 }
01796
01797 void a2dCursor::RemoveMarker(a2dBaseMarker* marker )
01798 {
01799 m_markers.ReleaseObject(marker);
01800 }
01801
01802 void a2dCursor::RemoveMarkers()
01803 {
01804 m_markers.clear();
01805 }
01806
01807 void a2dCursor::SetPosition(double posx, double posy, const a2dAffineMatrix& mat )
01808 {
01809 m_posx = m_onlyIntPosX ? int(posx+0.5) : posx;
01810 m_posy = m_onlyIntPosY ? int(posy+0.5) : posy;
01811 forEachIn( a2dCursorMarkerList, &m_markers )
01812 {
01813 a2dBaseMarker *marker = *iter;
01814 marker->SetPosition( m_posx );
01815 }
01816
01817 double xw, yw;
01818 mat.TransformPoint(m_posx, m_posy, xw, yw);
01819
01820 SetPosXY(xw,yw);
01821 }
01822
01823 bool a2dCursor::GetPosition(double& posx, double& posy)
01824 {
01825 posx = m_posx;
01826 posy = m_posy;
01827 return true;
01828 }
01829
01830 bool a2dCursor::CheckPosition(double posx)
01831 {
01832 bool retCode = false;
01833 forEachIn( a2dCursorMarkerList, &m_markers )
01834 {
01835 a2dBaseMarker *baseMarker = *iter;
01836 a2dMarker *marker = wxDynamicCast(baseMarker,a2dMarker);
01837 if(marker && marker->GetCurve())
01838 {
01839 a2dPoint2D apoint;
01840 if(marker->GetCurve()->GetXyAtSweep(posx,apoint))
01841 return true;
01842 }
01843 }
01844 return retCode;
01845 }
01846
01847 void a2dCursor::UpdatePosition(double WXUNUSED(minx), double miny, const a2dAffineMatrix& mat )
01848 {
01849 double xw, yw;
01850 mat.TransformPoint(m_posx, m_posy, xw, yw);
01851 SetPosXY(xw, miny);
01852 }
01853
01854 void a2dCursor::SetPending( bool pending )
01855 {
01856 a2dCanvasObject::SetPending(pending);
01857 if(pending)
01858 {
01859 forEachIn( a2dCursorMarkerList, &m_markers )
01860 {
01861 a2dBaseMarker *marker = *iter;
01862 marker->SetPending(pending);
01863 }
01864 }
01865 }
01866
01867 double a2dCursor::ConvertAxis2World( double percentValue )
01868 {
01869 return percentValue/100.*m_hsize;
01870 }
01871