wxArt2D
marker.cpp
Go to the documentation of this file.
1 /*! \file curves/src/marker.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: marker.cpp,v 1.39 2008/10/31 22:43:43 titato Exp $
9 */
10 
11 #pragma warning(disable:4786)
12 
13 #include "a2dprec.h"
14 
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18 
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22 
23 #include <wx/wfstream.h>
24 #include <math.h>
25 
26 #include "wx/canvas/eval.h"
27 #include "wx/canvas/canglob.h"
28 #include "wx/curves/meta.h"
29 
30 #include "wx/canvas/canobj.h"
31 #include "wx/canvas/drawer.h"
32 #include "wx/canvas/canvas.h"
33 
34 #if wxART2D_USE_EDITOR
35 #include "wx/canvas/edit.h"
36 #endif //wxART2D_USE_EDITOR
37 
38 //----------------------------------------------------------------------------
39 // globals
40 //----------------------------------------------------------------------------
41 
42 IMPLEMENT_DYNAMIC_CLASS( a2dBaseMarker, a2dCurveObject )
43 IMPLEMENT_DYNAMIC_CLASS( a2dAxisMarker, a2dBaseMarker )
44 IMPLEMENT_DYNAMIC_CLASS( a2dCursorAxisMarker, a2dAxisMarker )
45 IMPLEMENT_DYNAMIC_CLASS( a2dMarker, a2dBaseMarker )
46 IMPLEMENT_DYNAMIC_CLASS( a2dBandMarker, a2dMarker )
47 IMPLEMENT_DYNAMIC_CLASS( a2dMarkerShow, a2dCanvasObject )
48 
49 #ifdef wxUSE_INTPOINT
50 #define wxMAX_COORDINATE INT_MAX
51 #define wxMIN_COORDINATE INT_MIN
52 #else
53 #define wxMAX_COORDINATE 100e99
54 #define wxMIN_COORDINATE 100e-99
55 #endif
56 
57 
58 //----------------------------------------------------------------------------
59 // a2dBaseMarker
60 //----------------------------------------------------------------------------
61 #define fach 0.7
62 #define facv 1.78
63 
64 a2dPropertyIdDouble* a2dBaseMarker::PROPID_PositionMarker = NULL;
65 
66 INITIALIZE_PROPERTIES( a2dBaseMarker, a2dCurveObject )
67 {
68  A2D_PROPID_GS( a2dPropertyIdDouble, a2dBaseMarker, PositionMarker, 0, GetPosition, SetPosition );
69  return true;
70 }
71 
72 BEGIN_EVENT_TABLE( a2dBaseMarker, a2dCurveObject )
75 END_EVENT_TABLE()
76 
77 a2dBaseMarker::a2dBaseMarker( const wxString& format ): a2dCurveObject()
78 {
79  m_position = 0;
80  m_l1 = 12;
81  m_l2 = 10;
82  m_b = 10;
83  m_step = 0;
84  m_spline = false;
85  m_prompting = false;
86 
87  m_format = format;
88  m_textheight = m_l1 / 5 ;
89  m_font = a2dFont( m_textheight, wxSWISS, wxITALIC );
90 
91 }
92 
93 a2dBaseMarker::a2dBaseMarker( const wxString& format, double atx, double height ): a2dCurveObject()
94 {
95  m_position = atx;
96 
97  m_l1 = 12;
98  m_l2 = 10;
99  m_b = 10;
100  m_step = 0;
101  m_prompting = false;
102 
103  m_lworld.Translate( atx, 0 );
104 
105  m_spline = false;
106 
107  m_format = format;
108  m_textheight = height;
109  if ( height == 0 )
110  m_textheight = m_l1 / 5 ;
111 
112  m_font = a2dFont( m_textheight, wxSWISS, wxITALIC );
113 }
114 
115 a2dBaseMarker::a2dBaseMarker( const wxString& format, double atx, const a2dFont& font ): a2dCurveObject()
116 {
117  m_position = atx;
118 
119  m_l1 = 12;
120  m_l2 = 10;
121  m_b = 10;
122  m_spline = false;
123 
124  m_lworld.Translate( atx, 0 );
125 
126  m_format = format;
127  m_font = font;
128  m_textheight = m_font.GetSize();
129  m_step = 0;
130  m_prompting = false;
131 }
132 
133 
134 a2dBaseMarker::~a2dBaseMarker()
135 {
136 }
137 
138 a2dBaseMarker::a2dBaseMarker( const a2dBaseMarker& other, CloneOptions options, a2dRefMap* refs )
139  : a2dCurveObject( other, options, refs )
140 {
141  m_format = other.m_format;
142  m_textheight = other.m_textheight;
143  m_l1 = other.m_l1;
144  m_l2 = other.m_l2;
145  m_b = other.m_b;
146  m_step = other.m_step;
147  m_spline = other.m_spline;
148  m_prompting = other.m_prompting;
149  m_position = other.m_position;
150  m_font = other.m_font;
151 }
152 
154 {
155  return new a2dBaseMarker( *this, options, refs );
156 };
157 
158 
159 void a2dBaseMarker::Set( double xt, double yt, double l1, double l2, double b )
160 {
161  SetPosXY( xt, yt );
162  m_l1 = l1;
163  m_l2 = l2;
164  m_b = b;
165 
166  SetPending( true );
167 }
168 
169 void a2dBaseMarker::Set( double l1, double l2, double b )
170 {
171  m_l1 = l1;
172  m_l2 = l2;
173  m_b = b;
174 
175  SetPending( true );
176 }
177 
179 {
180  a2dBoundingBox bbox;
181  bbox.Expand( -m_b / 2, 0 );
182  bbox.Expand( m_b / 2, m_l1 );
183  bbox.Expand( 0, m_l2 );
184 
185  if ( !m_format.IsEmpty() && m_textheight )
186  {
187  double xc, yc;
188  m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
189  wxString form;
190  form.Printf( m_format, xc, yc );
191 
192  a2dBoundingBox bboxtext = m_font.GetTextExtent( form );
193  bboxtext.Translate( -m_b / 2 , m_l1 + m_textheight * 2.5 );
194  bbox.Expand( bboxtext );
195  }
196  return bbox;
197 }
198 
199 #if wxART2D_USE_CVGIO
200 
201 void a2dBaseMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
202 {
203  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
204  if ( xmlparts == a2dXmlSer_attrib )
205  {
206  out.WriteAttribute( wxT( "l1" ) , m_l1 );
207  out.WriteAttribute( wxT( "l2" ) , m_l2 );
208  out.WriteAttribute( wxT( "b" ) , m_b );
209  }
210  else
211  {
212  }
213 }
214 
215 void a2dBaseMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
216 {
217  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
218  if ( xmlparts == a2dXmlSer_attrib )
219  {
220  m_l1 = parser.RequireAttributeValueDouble( wxT( "l1" ) );
221  m_l2 = parser.RequireAttributeValueDouble( wxT( "l2" ) );
222  m_b = parser.RequireAttributeValueDouble( wxT( "b" ) );
223  }
224  else
225  {
226  }
227 
228  //m_curve = ;
229 }
230 #endif //wxART2D_USE_CVGIO
231 
233 {
234  a2dVertexArray points;
235  points.push_back( new a2dLineSegment( 0, 0 ) );
236  points.push_back( new a2dLineSegment( m_b / 2.0, m_l1 ) );
237  points.push_back( new a2dLineSegment( 0, m_l2 ) );
238  points.push_back( new a2dLineSegment( -m_b / 2.0, m_l1 ) );
239 
240  a2dPoint2D P = a2dPoint2D( hitEvent.m_relx, hitEvent.m_rely );
241  double pw = ic.GetWorldStrokeExtend();
242  double margin = ic.GetTransformedHitMargin();
243 
244  hitEvent.m_how = points.HitTestPolygon( P, pw + margin );
245 
246  return hitEvent.m_how.IsHit();
247 }
248 
249 
250 bool a2dBaseMarker::DoStartEdit( wxUint16 WXUNUSED( editmode ), wxEditStyle WXUNUSED( editstyle ) )
251 {
252  if ( m_flags.m_editable )
253  {
254  //calculate bbox's else mouse events may take place when first, and idle event is not yet
255  //processed to do this calculation.
257  //still set it pending to do the redraw ( in place )
258  SetPending( true );
259  return true;
260  }
261 
262  return false;
263 }
264 
265 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
266 
267 void a2dBaseMarker::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
268 {
269  a2dVertexArray cpoints;
270 
271  // For debugging
272 // ic.GetDrawer2D()->SetDrawerFill(a2dWHITE_FILL);
273 // ic.GetDrawer2D()->DrawRoundedRectangle(BBOX2XYWH(m_untransbbox), 0);
274 
275  if ( m_flags.m_editingCopy )
277 
278  cpoints.push_back( new a2dLineSegment( 0, 0 ) );
279  cpoints.push_back( new a2dLineSegment( m_b / 2.0, m_l1 ) );
280  if( m_l1 != m_l2 )
281  {
282  cpoints.push_back( new a2dLineSegment( 0, m_l2 ) );
283  }
284  cpoints.push_back( new a2dLineSegment( -m_b / 2.0, m_l1 ) );
285 
286  ic.GetDrawer2D()->DrawPolygon( &cpoints, m_spline, wxWINDING_RULE );
287 
288  cpoints.clear();
289 
290  if( !m_format.IsEmpty() )
291  {
292  double xc, yc;
293  m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
294  wxString form;
295  form.Printf( m_format, xc, yc );
296 
297  ic.GetDrawer2D()->SetFont( m_font );
299 
300  ic.GetDrawer2D()->DrawText( form, -m_b / 2, m_l1 + m_textheight * 2.5 );
301  //ic.GetDrawer2D()->DrawText( form, 0, 0 );
302  ic.GetDrawer2D()->SetFont( *a2dNullFONT );
303  }
304 }
305 
306 const wxString& a2dBaseMarker::GetMarkerString()
307 {
308  if( !m_promptFormat.IsEmpty() )
309  {
310  double xc, yc;
311  m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
312  wxString form;
313  m_promptString.Printf( m_promptFormat, xc, yc );
314  }
315  else
316  m_promptString = wxT( "BaseMarker" );
317  return m_promptString;
318 }
319 
320 void a2dBaseMarker::OnEnterObject( a2dCanvasObjectMouseEvent& event )
321 {
322  return;
323  a2dIterC* ic = event.GetIterC();
324 
325  ic->GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
326  m_prompting = true;
327  if( m_promptText )
328  {
329 // ic->GetTransform().TransformPoint(GetPosX(),GetPosY());
330  m_promptText->SetText( GetMarkerString() );
331  m_promptText->SetPosXY( m_b / 2, m_l1 );
332  m_promptText->SetVisible( true );
333  }
334  SetPending( true );
335  event.Skip();
336 }
337 
338 void a2dBaseMarker::OnLeaveObject( a2dCanvasObjectMouseEvent& event )
339 {
340  return;
341  event.Skip();
342  m_prompting = false;
343  if( m_promptText )
344  m_promptText->SetVisible( false );
345  SetPending( true );
346 }
347 
348 void a2dBaseMarker::SetPrompt( a2dText* prompttext )
349 {
350  if( m_promptText )
351  ReleaseChild( m_promptText );
352  m_promptText = prompttext;
353  prompttext->SetVisible( false );
354  Append( prompttext );
355  SetPending( true );
356 }
357 
358 //----------------------------------------------------------------------------
359 // a2dAxisMarker
360 //----------------------------------------------------------------------------
361 #define fach 0.7
362 #define facv 1.78
363 
364 a2dPropertyIdCanvasObject* a2dAxisMarker::PROPID_axis = NULL;
365 
366 INITIALIZE_PROPERTIES( a2dAxisMarker, a2dBaseMarker )
367 {
368  A2D_PROPID_D( a2dPropertyIdCanvasObject, axis, 0 );
369  return true;
370 }
371 
372 void a2dAxisMarker::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
373 {
374  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
375 
376  a2dBaseMarker::DoWalker( this, handler );
377 
378  // the m_axis is just a pointer of which this object is part, so do not walk
379 
380  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
381 }
382 
383 BEGIN_EVENT_TABLE( a2dAxisMarker, a2dBaseMarker )
384  EVT_CANVASOBJECT_MOUSE_EVENT( a2dAxisMarker::OnCanvasObjectMouseEvent )
385 END_EVENT_TABLE()
386 
387 void a2dAxisMarker::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
388 {
389  a2dIterC* ic = event.GetIterC();
390 
391  if ( m_flags.m_editingCopy )
392  {
393  a2dAxisMarker* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dAxisMarker );
394 
395  static double xprev;
396  static double yprev;
397 
398  double xw, yw;
399  xw = event.GetX();
400  yw = event.GetY();
401 
402  a2dAffineMatrix atWorld = ic->GetTransform();
403  a2dAffineMatrix inverse = ic->GetInverseTransform();
404 
405  double xh, yh;
406  inverse.TransformPoint( xw, yw, xh, yh );
407 
408  if ( event.GetMouseEvent().LeftDown() )
409  {
410  ic->SetCorridorPath( true, this );
411  xprev = xh;
412  yprev = yh;
413  }
414  else if ( event.GetMouseEvent().LeftUp() )
415  {
416  ic->SetCorridorPath( false );
417  ic->GetDrawingPart()->SetCaptured( NULL );
418  ic->GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
419 
420  if ( m_lworld != original->GetTransformMatrix() )
421  m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( original, PROPID_TransformMatrix, m_lworld ) );
422  }
423  else if ( event.GetMouseEvent().Dragging() )
424  {
425  if( m_axis->IsYAxis() )
426  {
427  double xy = m_axis->ConvertWorld2Axis( yh );
428  if ( m_axis->GetAxisMin() < xy && m_axis->GetAxisMax() > xy )
429  {
430  double x, y;
431  x = xh - ( xprev - GetPosX() );
432  y = yh - ( yprev - GetPosY() );
433 
434  SetPosXY( 0, y );
435  original->SetPending( true );
436  original->SetPosXY( 0, y );
437  }
438  else if ( m_axis->GetAxisMin() > xy )
439  {
440  double y = 0;
441  if ( m_axis->GetAxisMin() != m_axis->GetBoundaryMin() )
442  y = m_axis->GetLength();
443 
444  SetPosXY( 0, y );
445 
446  //the next takes care of imediate updating of
447  // the original a2dMarker AND a2dMarkerShow Objects
448  //The are dependency checking the original object.
449  original->SetPending( true );
450  original->SetPosXY( 0, y );
451  }
452  else if ( m_axis->GetAxisMax() < xy )
453  {
454  double y = 0;
455  if ( m_axis->GetAxisMin() == m_axis->GetBoundaryMin() )
456  y = m_axis->GetLength();
457 
458  SetPosXY( 0, y );
459 
460  //the next takes care of imediate updating of
461  // the original a2dMarker AND a2dMarkerShow Objects
462  //The are dependency checking the original object.
463  original->SetPending( true );
464  original->SetPosXY( 0, y );
465  }
466  }
467  else
468  {
469  double xy = m_axis->ConvertWorld2Axis( xh );
470  if ( m_axis->GetAxisMin() < xy && m_axis->GetAxisMax() > xy )
471  {
472  double x, y;
473  x = xh - ( xprev - GetPosX() );
474  y = yh - ( yprev - GetPosY() );
475 
476  SetPosXY( x, 0 );
477  original->SetPending( true );
478  original->SetPosXY( x, 0 );
479  }
480  else if ( m_axis->GetAxisMin() > xy )
481  {
482  double x = 0;
483  if ( m_axis->GetAxisMin() != m_axis->GetBoundaryMin() )
484  x = m_axis->GetLength();
485 
486  SetPosXY( x, 0 );
487 
488  //the next takes care of imediate updating of
489  // the original a2dMarker AND a2dMarkerShow Objects
490  //The are dependency checking the original object.
491  original->SetPending( true );
492  original->SetPosXY( x, 0 );
493  }
494  else if ( m_axis->GetAxisMax() < xy )
495  {
496  double x = 0;
497  if ( m_axis->GetAxisMin() == m_axis->GetBoundaryMin() )
498  x = m_axis->GetLength();
499 
500  SetPosXY( x, 0 );
501 
502  //the next takes care of imediate updating of
503  // the original a2dMarker AND a2dMarkerShow Objects
504  //The are dependency checking the original object.
505  original->SetPending( true );
506  original->SetPosXY( x, 0 );
507  }
508  }
509  xprev = xh;
510  yprev = yh;
511  }
512  else
513  {
514  event.Skip();
515  }
516  }
517  else
518  {
519  event.Skip();
520  }
521 }
522 
523 a2dAxisMarker::a2dAxisMarker( const wxString& format, a2dCurveAxis* axis )
524  : a2dBaseMarker( format )
525 {
526  m_axis = axis;
527 }
528 
529 a2dAxisMarker::a2dAxisMarker( const wxString& format, a2dCurveAxis* axis , double atx, double height )
530  : a2dBaseMarker( format, atx, height )
531 {
532  m_axis = axis;
533 }
534 
535 a2dAxisMarker::a2dAxisMarker( const wxString& format, a2dCurveAxis* axis , double atx, const a2dFont& font )
536  : a2dBaseMarker( format, atx, font )
537 {
538  m_axis = axis;
539 }
540 
541 
542 a2dAxisMarker::~a2dAxisMarker()
543 {
544 }
545 
546 a2dAxisMarker::a2dAxisMarker( const a2dAxisMarker& other, CloneOptions options, a2dRefMap* refs )
547  : a2dBaseMarker( other, options, refs )
548 {
549  m_axis = other.m_axis;
550 }
551 
553 {
554  return new a2dAxisMarker( *this, options, refs );
555 };
556 
557 void a2dAxisMarker::DoAddPending( a2dIterC& WXUNUSED( ic ) )
558 {
559  //klion 27.05.2005 if ( m_flags.m_pending )
560  // SetPending(true);
561 }
562 
564 {
565  if ( !m_flags.m_pending && m_axis->GetPending() )
566  {
567  //wxLogDebug( "marker");
568  SetPending( true );
569  }
570 }
571 
572 bool a2dAxisMarker::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
573 {
574  if ( m_axis && !m_bbox.GetValid() )
575  {
576  double worldPos = m_axis->ConvertAxis2World( m_position );
577  if( m_axis->IsYAxis() )
578  SetPosXY( 0, worldPos );
579  else
580  SetPosXY( worldPos, 0 );
581 
584  return true;
585  }
586  return false;
587 }
588 
589 #if wxART2D_USE_CVGIO
590 
591 void a2dAxisMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
592 {
593  a2dBaseMarker::DoSave( parent, out, xmlparts, towrite );
594  if ( xmlparts == a2dXmlSer_attrib )
595  {
596  if ( m_axis )
597  {
598  out.WriteAttribute( wxT( "axisname" ) , m_axis->GetName() );
599  out.WriteAttribute( wxT( "axis" ), m_axis->GetUniqueSerializationId() );
600  }
601  }
602  else
603  {
604  }
605 }
606 
607 void a2dAxisMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
608 {
609  a2dBaseMarker::DoLoad( parent, parser, xmlparts );
610  if ( xmlparts == a2dXmlSer_attrib )
611  {
612  if ( parser.HasAttribute( wxT( "axis" ) ) )
613  {
614  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_axis, parser.GetAttributeValue( wxT( "axis" ) ) );
615  }
616  }
617  else
618  {
619  }
620 
621  //m_curve = ;
622 }
623 #endif //wxART2D_USE_CVGIO
624 
625 const wxString& a2dAxisMarker::GetMarkerString()
626 {
627  double val;
628  if( !m_promptFormat.IsEmpty() && m_axis->GetLevelValue( GetName(), val ) )
629  {
630  m_promptString.Printf( m_promptFormat, val );
631  }
632  else if( !GetName().IsEmpty() )
633  m_promptString = GetName();
634  else
635  m_promptString = wxT( "AxisMarker" );
636  return m_promptString;
637 }
638 
639 //----------------------------------------------------------------------------
640 // a2dCursorAxisMarker
641 //----------------------------------------------------------------------------
642 
643 a2dPropertyIdCanvasObject* a2dCursorAxisMarker::PROPID_cursor = NULL;
644 
645 INITIALIZE_PROPERTIES( a2dCursorAxisMarker, a2dAxisMarker )
646 {
647  A2D_PROPID_D( a2dPropertyIdCanvasObject, cursor, 0 );
648  return true;
649 }
650 
651 a2dCursorAxisMarker::a2dCursorAxisMarker( const wxString& format, a2dCurveAxis* axis, a2dCursor* cursor )
652  : a2dAxisMarker( format, axis )
653 {
654  m_cursor = cursor;
655  m_positionY = 0;
656 }
657 
658 a2dCursorAxisMarker::a2dCursorAxisMarker( const wxString& format, a2dCurveAxis* axis , a2dCursor* cursor, double atx, double aty, double height )
659  : a2dAxisMarker( format, axis, atx, height )
660 {
661  m_cursor = cursor;
662  m_positionY = aty;
663 }
664 
665 a2dCursorAxisMarker::a2dCursorAxisMarker( const wxString& format, a2dCurveAxis* axis , a2dCursor* cursor, double atx, double aty, const a2dFont& font )
666  : a2dAxisMarker( format, axis, atx, font )
667 {
668  m_cursor = cursor;
669  m_positionY = aty;
670 }
671 
672 
673 a2dCursorAxisMarker::~a2dCursorAxisMarker()
674 {
675 }
676 
677 a2dCursorAxisMarker::a2dCursorAxisMarker( const a2dCursorAxisMarker& other, CloneOptions options, a2dRefMap* refs )
678  : a2dAxisMarker( other, options, refs )
679 {
680  m_cursor = other.m_cursor;
681  m_positionY = other.m_positionY;
682 }
683 
685 {
686  return new a2dCursorAxisMarker( *this, options, refs );
687 };
688 
690 {
691  if ( !m_flags.m_pending && ( m_axis && m_axis->GetPending() || m_cursor && m_cursor->GetPending() ) )
692  {
693  //wxLogDebug( "marker");
694  SetPending( true );
695  }
696 }
697 
698 bool a2dCursorAxisMarker::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
699 {
700  if ( m_axis && !m_bbox.GetValid() )
701  {
702  double worldPosY = 0.;
703  if( m_cursor )
704  worldPosY = m_cursor->ConvertAxis2World( m_positionY );
705  double worldPos = m_axis->ConvertAxis2World( m_position );
706  if( m_axis->IsYAxis() )
707  SetPosXY( worldPosY, worldPos );
708  else
709  SetPosXY( worldPos, worldPosY );
710 
713  return true;
714  }
715  return false;
716 }
717 
718 #if wxART2D_USE_CVGIO
719 
720 void a2dCursorAxisMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
721 {
722  a2dAxisMarker::DoSave( parent, out, xmlparts, towrite );
723  if ( xmlparts == a2dXmlSer_attrib )
724  {
725  if ( m_cursor )
726  {
727  out.WriteAttribute( wxT( "cursor" ), m_cursor->GetUniqueSerializationId() );
728  }
729 // out.WriteAttribute( wxT("positionY"), m_positionY );
730  }
731  else
732  {
733  }
734 }
735 
736 void a2dCursorAxisMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
737 {
738  a2dAxisMarker::DoLoad( parent, parser, xmlparts );
739  if ( xmlparts == a2dXmlSer_attrib )
740  {
741  if ( parser.HasAttribute( wxT( "cursor" ) ) )
742  {
743  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_cursor, parser.GetAttributeValue( wxT( "cursor" ) ) );
744  }
745  }
746  else
747  {
748  }
749 
750  //m_curve = ;
751 }
752 #endif //wxART2D_USE_CVGIO
753 
754 //----------------------------------------------------------------------------
755 // a2dMarker
756 //----------------------------------------------------------------------------
757 #define fach 0.7
758 #define facv 1.78
759 
760 a2dPropertyIdCanvasObject* a2dMarker::PROPID_curve = NULL;
761 
762 INITIALIZE_PROPERTIES( a2dMarker, a2dBaseMarker )
763 {
764  A2D_PROPID_D( a2dPropertyIdCanvasObject, curve, 0 );
765  return true;
766 }
767 
768 void a2dMarker::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
769 {
770  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
771  a2dBaseMarker::DoWalker( parent, handler );
772 
773  if ( m_curve )
774  m_curve->Walker( this, handler );
775 
776  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
777 }
778 
779 
780 BEGIN_EVENT_TABLE( a2dMarker, a2dBaseMarker )
781  EVT_CANVASOBJECT_MOUSE_EVENT( a2dMarker::OnCanvasObjectMouseEvent )
782  EVT_CHAR( a2dMarker::OnChar )
783 END_EVENT_TABLE()
784 
785 void a2dMarker::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
786 {
787  a2dIterC* ic = event.GetIterC();
788 
789  if ( m_flags.m_editingCopy )
790  {
791  a2dMarker* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dMarker );
792 
793  static double xprev;
794  static double yprev;
795 
796  double xw, yw;
797  xw = event.GetX();
798  yw = event.GetY();
799 
800  a2dAffineMatrix atWorld = ic->GetTransform();
801  a2dAffineMatrix inverse = ic->GetInverseTransform();
802 
803  double xh, yh;
804  inverse.TransformPoint( xw, yw, xh, yh );
805 
806  double xcurve, ycurve;
807  m_curvesArea->World2Curve( xh, yh, xcurve, ycurve );
808 
809  if ( event.GetMouseEvent().LeftDown() )
810  {
811  ic->SetCorridorPath( true, this );
812  xprev = xh;
813  yprev = yh;
814  }
815  else if ( event.GetMouseEvent().LeftUp() )
816  {
817  ic->SetCorridorPath( false );
818  ic->GetDrawingPart()->SetCaptured( NULL );
819  ic->GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
820 
821  //if ( original->GetPosition() != m_position )
822  m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( original, PROPID_PositionMarker, m_position ) );
823  }
824  else if ( event.GetMouseEvent().Dragging() )
825  {
826  a2dBoundingBox curvebox = m_curve->GetClippedCurveBoundaries();
827  if( curvebox.GetValid() )
828  {
829  if ( curvebox.GetMinX() < xcurve && curvebox.GetMaxX() > xcurve )
830  {
831  double x, y;
832  x = xh - ( xprev - GetPosX() );
833  y = yh - ( yprev - GetPosY() );
834 
835  m_position = xcurve;
836  CalculatePositionMarker( x, y );
837  SetPosXY( x, y );
838 
839  //the next takes care of imediate updating of
840  // the original a2dMarker AND a2dMarkerShow Objects
841  //The are dependency checking the original object.
842  original->SetPosition( m_position );
843  }
844  else if ( curvebox.GetMinX() > xcurve )
845  {
846  double x, y ;
847  m_position = curvebox.GetMinX();
848  CalculatePositionMarker( x, y );
849  SetPosXY( x, y );
850 
851  //the next takes care of imediate updating of
852  // the original a2dMarker AND a2dMarkerShow Objects
853  //The are dependency checking the original object.
854  original->SetPosition( m_position );
855  }
856  else if ( curvebox.GetMaxX() < xcurve )
857  {
858  double x, y ;
859  m_position = curvebox.GetMaxX();
860  CalculatePositionMarker( x, y );
861  SetPosXY( x, y );
862 
863  //the next takes care of imediate updating of
864  // the original a2dMarker AND a2dMarkerShow Objects
865  //The are dependency checking the original object.
866  original->SetPosition( m_position );
867  }
868  }
869  xprev = xh;
870  yprev = yh;
871  }
872  else
873  {
874  event.Skip();
875  }
876  }
877  else
878  {
879  event.Skip();
880  }
881 }
882 
883 void a2dMarker::OnChar( wxKeyEvent& event )
884 {
885  if ( m_flags.m_editingCopy )
886  {
887  a2dBoundingBox curvebox = m_curve->GetClippedCurveBoundaries();
888  if( !curvebox.GetValid() )
889  {
890  return;
891  }
892 
893  a2dMarker* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dMarker );
894 
895  double x;
896  x = m_position; //GetPosX();
897 
898  double step = ( curvebox.GetMaxX() - curvebox.GetMinX() ) / 100;
899  if ( m_step )
900  step = m_step;
901 
902  switch( event.GetKeyCode() )
903  {
904  case WXK_LEFT:
905  x = x - step;
906  break;
907 
908  case WXK_RIGHT:
909  x = x + step;
910  break;
911 
912  //case WXK_PAGEUP:
913  case WXK_PAGEUP:
914  x = x + step * 10;
915  break;
916 
917  //case WXK_PAGEDOWN:
918  case WXK_PAGEDOWN:
919  x = x - step * 10;
920  break;
921 
922  case WXK_HOME:
923  x = curvebox.GetMinX();
924  break;
925 
926  case WXK_END:
927  x = curvebox.GetMaxX();
928  break;
929 
930  break;
931  default:
932  event.Skip();
933  return;
934  }
935 
936  if ( curvebox.GetMinX() <= x && curvebox.GetMaxX() >= x )
937  {
938  double yw, xw;
939  m_position = x;
940  CalculatePositionMarker( yw, xw );
941 
942  SetPosXY( yw, xw );
943 
944  //the next takes care of imediate updating of
945  // the original a2dMarker AND a2dMarkerShow Objects
946  //They are dependency checking the original object.
947  original->SetPosition( m_position );
948  }
949  else if ( curvebox.GetMinX() > x )
950  {
951  double yw, xw;
952  m_position = curvebox.GetMinX();
953  CalculatePositionMarker( yw, xw );
954  SetPosXY( yw, xw );
955 
956  //the next takes care of imediate updating of
957  // the original a2dMarker AND a2dMarkerShow Objects
958  //They are dependency checking the original object.
959  original->SetPosition( m_position );
960  }
961  else if ( curvebox.GetMaxX() < x )
962  {
963  double yw, xw;
964  m_position = curvebox.GetMaxX();
965  CalculatePositionMarker( yw, xw );
966  SetPosXY( yw, xw );
967 
968  //the next takes care of imediate updating of
969  // the original a2dMarker AND a2dMarkerShow Objects
970  //They are dependency checking the original object.
971  original->SetPosition( m_position );
972  }
973 
974  }
975  else
976  event.Skip();
977 }
978 
979 a2dMarker::a2dMarker( const wxString& format, a2dCurve* curve )
980  : a2dBaseMarker( format )
981 {
982  m_curve = curve;
983 }
984 
985 a2dMarker::a2dMarker( const wxString& format, a2dCurve* curve , double atx, double height )
986  : a2dBaseMarker( format, atx, height )
987 {
988  m_curve = curve;
989 }
990 
991 a2dMarker::a2dMarker( const wxString& format, a2dCurve* curve , double atx, const a2dFont& font )
992  : a2dBaseMarker( format, atx, font )
993 {
994  m_curve = curve;
995 }
996 
997 
998 a2dMarker::~a2dMarker()
999 {
1000 }
1001 
1002 a2dMarker::a2dMarker( const a2dMarker& other, CloneOptions options, a2dRefMap* refs )
1003  : a2dBaseMarker( other, options, refs )
1004 {
1005  m_curve = other.m_curve;
1006 }
1007 
1009 {
1010  return new a2dMarker( *this, options, refs );
1011 };
1012 
1013 void a2dMarker::CalculatePositionMarker( double& xw, double& yw )
1014 {
1015  if ( m_curve )
1016  {
1017  a2dPoint2D point;
1018  m_curve->GetXyAtSweep( m_position, point );
1019  m_position = point.m_x;
1020  m_curvesArea->Curve2World( point.m_x, point.m_y, xw, yw );
1021  }
1022  else
1023  {
1024  xw = 0;
1025  yw = 0;
1026  m_position = 0;
1027  }
1028 }
1029 
1031 {
1032  if ( m_curve )
1033  {
1034  return m_curve->GetXyAtSweep( m_position, point );
1035  }
1036  else
1037  {
1038  point.m_x = 0;
1039  point.m_y = 0;
1040  return false;
1041  }
1042 }
1043 
1044 void a2dMarker::DoAddPending( a2dIterC& WXUNUSED( ic ) )
1045 {
1046 //klion 27.05.2005 if ( m_flags.m_pending )
1047 // SetPending(true);
1048 }
1049 
1051 {
1052  if ( !m_flags.m_pending && m_curve->GetPending() )
1053  {
1054  //wxLogDebug( "marker");
1055  SetPending( true );
1056  }
1057 }
1058 
1059 bool a2dMarker::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1060 {
1061  if ( m_curve && !m_bbox.GetValid() )
1062  {
1063  double x, y;
1064  CalculatePositionMarker( x, y );
1065  SetPosXY( x, y );
1066 
1067  //wxLogDebug( "on update marker %d %f %f ", GetUniqueSerializationId(), x, y );
1068 
1070  m_bbox.MapBbox( m_lworld );
1071  return true;
1072  }
1073  return false;
1074 }
1075 
1076 #if wxART2D_USE_CVGIO
1077 
1078 void a2dMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1079 {
1080  a2dBaseMarker::DoSave( parent, out, xmlparts, towrite );
1081  if ( xmlparts == a2dXmlSer_attrib )
1082  {
1083  if ( m_curve )
1084  {
1085  out.WriteAttribute( wxT( "curvename" ) , m_curve->GetName() );
1086  out.WriteAttribute( wxT( "curve" ), m_curve->GetUniqueSerializationId() );
1087  }
1088  }
1089  else
1090  {
1091  }
1092 }
1093 
1094 void a2dMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1095 {
1096  a2dBaseMarker::DoLoad( parent, parser, xmlparts );
1097  if ( xmlparts == a2dXmlSer_attrib )
1098  {
1099  if ( parser.HasAttribute( wxT( "curve" ) ) )
1100  {
1101  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_curve, parser.GetAttributeValue( wxT( "curve" ) ) );
1102  }
1103  }
1104  else
1105  {
1106  }
1107 
1108  //m_curve = ;
1109 }
1110 #endif //wxART2D_USE_CVGIO
1111 
1113 {
1114  if( !m_promptFormat.IsEmpty() )
1115  {
1116  double xc, yc;
1117  m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
1118  wxString form;
1119  m_promptString.Printf( m_promptFormat, xc, yc );
1120  }
1121  else if( !GetName().IsEmpty() )
1122  m_promptString = GetName();
1123  else
1124  m_promptString = wxT( "CurveMarker" );
1125  return m_promptString;
1126 }
1127 
1128 //----------------------------------------------------------------------------
1129 // a2dBandMarker
1130 //----------------------------------------------------------------------------
1131 
1132 a2dBandMarker::a2dBandMarker( const wxString& format, a2dBandCurve* curve )
1133  : a2dMarker( format, curve )
1134 {
1135  m_markerUpLow = true;
1136  m_curveBand = curve;
1137  m_curveBand->SetMarkerUpLow( m_markerUpLow );
1138 }
1139 
1140 a2dBandMarker::a2dBandMarker( const wxString& format, a2dBandCurve* curve , double atx, double height )
1141  : a2dMarker( format, curve, atx, height )
1142 {
1143  m_markerUpLow = true;
1144  m_curveBand = curve;
1145  m_curveBand->SetMarkerUpLow( m_markerUpLow );
1146 }
1147 
1148 a2dBandMarker::a2dBandMarker( const wxString& format, a2dBandCurve* curve , double atx, const a2dFont& font )
1149  : a2dMarker( format, curve, atx, font )
1150 {
1151  m_markerUpLow = true;
1152  m_curveBand = curve;
1153  m_curveBand->SetMarkerUpLow( m_markerUpLow );
1154 }
1155 
1156 a2dBandMarker::~a2dBandMarker()
1157 {
1158 }
1159 
1160 a2dBandMarker::a2dBandMarker( const a2dBandMarker& other, CloneOptions options, a2dRefMap* refs )
1161  : a2dMarker( other, options, refs )
1162 {
1163  m_markerUpLow = other.m_markerUpLow;
1164  m_curveBand = other.m_curveBand;
1165 }
1166 
1168 {
1169  return new a2dBandMarker( *this, options, refs );
1170 };
1171 
1172 void a2dBandMarker::CalculatePositionMarker( double& xw, double& yw )
1173 {
1174  if ( m_curve )
1175  {
1176  m_curveBand->SetMarkerUpLow( m_markerUpLow );
1177  a2dMarker::CalculatePositionMarker( xw, yw );
1178  }
1179  else
1180  {
1181  xw = 0;
1182  yw = 0;
1183  m_position = 0;
1184  }
1185 }
1186 
1188 {
1189  if ( m_curve )
1190  {
1191  m_curveBand->SetMarkerUpLow( m_markerUpLow );
1193  return true;
1194  }
1195  else
1196  {
1197  point.m_x = 0;
1198  point.m_y = 0;
1199  return false;
1200  }
1201 }
1202 
1203 #if wxART2D_USE_CVGIO
1204 
1205 void a2dBandMarker::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1206 {
1207  a2dMarker::DoSave( parent, out, xmlparts, towrite );
1208  if ( xmlparts == a2dXmlSer_attrib )
1209  {
1210  out.WriteAttribute( wxT( "uplow" ) , m_markerUpLow );
1211  }
1212  else
1213  {
1214  }
1215 }
1216 
1217 void a2dBandMarker::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1218 {
1219  a2dMarker::DoLoad( parent, parser, xmlparts );
1220  if ( xmlparts == a2dXmlSer_attrib )
1221  {
1222  m_markerUpLow = parser.GetAttributeValueBool( wxT( "spline" ), false );
1223  }
1224  else
1225  {
1226  }
1227 }
1228 #endif //wxART2D_USE_CVGIO
1229 
1230 void a2dBandMarker::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
1231 {
1232  a2dVertexArray cpoints;
1233 
1234  if ( m_flags.m_editingCopy )
1236 
1237  cpoints.push_back( new a2dLineSegment( 0, 0 ) );
1238  cpoints.push_back( new a2dLineSegment( m_b / 2.0, m_l1 ) );
1239  if( m_l1 != m_l2 )
1240  {
1241  cpoints.push_back( new a2dLineSegment( 0, m_l2 ) );
1242  }
1243  cpoints.push_back( new a2dLineSegment( -m_b / 2.0, m_l1 ) );
1244 
1245  double xw, yw, yw2;
1246  CalculatePositionMarker( xw, yw2 );
1247  m_markerUpLow = !m_markerUpLow;
1248  CalculatePositionMarker( xw, yw );
1249  m_markerUpLow = !m_markerUpLow;
1250  m_curveBand->SetMarkerUpLow( m_markerUpLow );
1251 
1252  ic.GetDrawer2D()->DrawPolygon( &cpoints, m_spline, wxWINDING_RULE );
1253 
1254  ic.GetDrawer2D()->DrawLine( 0, 0, 0, yw - yw2 );
1255 
1256  cpoints.clear();
1257 
1258  if( !m_format.IsEmpty() )
1259  {
1260  double xc, yc;
1261  m_curvesArea->World2Curve( GetPosX(), GetPosY(), xc, yc );
1262  wxString form;
1263  form.Printf( m_format, xc, yc );
1264 
1265  ic.GetDrawer2D()->SetFont( m_font );
1267 
1268  ic.GetDrawer2D()->DrawText( form, -m_b / 2, m_l1 + m_textheight * 2.5 );
1269  //ic.GetDrawer2D()->DrawText( form, 0, 0 );
1270  ic.GetDrawer2D()->SetFont( *a2dNullFONT );
1271  }
1272 }
1273 
1274 //----------------------------------------------------------------------------
1275 // a2dMarkerShow
1276 //----------------------------------------------------------------------------
1277 #define fach 0.7
1278 #define facv 1.78
1279 
1280 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_marker = NULL;
1281 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_xText = NULL;
1282 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_yText = NULL;
1283 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_Xlabel = NULL;
1284 a2dPropertyIdCanvasObject* a2dMarkerShow::PROPID_Ylabel = NULL;
1285 
1286 INITIALIZE_PROPERTIES( a2dMarkerShow, a2dCanvasObject )
1287 {
1288  A2D_PROPID_D( a2dPropertyIdCanvasObject, marker, 0 );
1289  A2D_PROPID_D( a2dPropertyIdCanvasObject, xText, 0 );
1290  A2D_PROPID_D( a2dPropertyIdCanvasObject, yText, 0 );
1291  A2D_PROPID_D( a2dPropertyIdCanvasObject, Xlabel, 0 );
1292  A2D_PROPID_D( a2dPropertyIdCanvasObject, Ylabel, 0 );
1293  return true;
1294 }
1295 
1296 void a2dMarkerShow::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
1297 {
1298  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
1299  a2dCanvasObject::DoWalker( parent, handler );
1300  if ( m_marker )
1301  m_marker->Walker( this, handler );
1302  if ( m_xText )
1303  m_xText->Walker( this, handler );
1304  if ( m_yText )
1305  m_yText->Walker( this, handler );
1306  if ( m_Xlabel )
1307  m_Xlabel->Walker( this, handler );
1308  if ( m_Ylabel )
1309  m_Ylabel->Walker( this, handler );
1310 
1311  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
1312 }
1313 
1314 BEGIN_EVENT_TABLE( a2dMarkerShow, a2dCanvasObject )
1315  EVT_CANVASOBJECT_MOUSE_EVENT( a2dMarkerShow::OnCanvasObjectMouseEvent )
1316  EVT_COM_EVENT( a2dMarkerShow::OnPropertyChanged )
1317 END_EVENT_TABLE()
1318 
1319 a2dMarkerShow::a2dMarkerShow( double x, double y,
1320  const wxString& XLabel, const wxString& YLabel,
1321  const wxString& XValueformat, const wxString& YValueformat,
1322  a2dMarker* marker, double height )
1323  : a2dCanvasObject( x, y )
1324 {
1325  m_marker = marker;
1326 
1327  m_XValueformat = XValueformat;
1328  m_YValueformat = YValueformat;
1329 
1330  m_textheight = height;
1331  if ( height == 0 )
1332  m_textheight = 5 ;
1333 
1334  m_Xlabel = new a2dText( XLabel, 0, 0, a2dFont( m_textheight, wxSWISS ) );
1335  Append( m_Xlabel );
1336  m_Xlabel->SetName( wxT( "__XLABEL__" ) );
1337  m_Xlabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1338 
1339  m_Ylabel = new a2dText( YLabel, 0, -1.2 * m_textheight, a2dFont( m_textheight, wxSWISS ) );
1340  Append( m_Ylabel );
1341  m_Ylabel->SetName( wxT( "__YLABEL__" ) );
1342  m_Ylabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1343 
1344  m_xText = new a2dText( wxT( "" ), 0, 0, a2dFont( m_textheight, wxSWISS ) );
1345  Append( m_xText );
1346  m_xText->SetName( wxT( "__XTEXT__" ) );
1347  m_xText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1348 
1349  m_yText = new a2dText( wxT( "" ), 0, -1.2 * m_textheight, a2dFont( m_textheight, wxSWISS ) );
1350  Append( m_yText );
1351  m_yText->SetName( wxT( "__YTEXT__" ) );
1352  m_yText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1353 }
1354 
1355 a2dMarkerShow::~a2dMarkerShow()
1356 {
1357 }
1358 
1359 a2dMarkerShow::a2dMarkerShow( const a2dMarkerShow& other, CloneOptions options, a2dRefMap* refs )
1360  : a2dCanvasObject( other, options, refs )
1361 {
1362  m_marker = other.m_marker;
1363  m_XValueformat = other.m_XValueformat;
1364  m_YValueformat = other.m_YValueformat;
1365  m_textheight = other.m_textheight;
1366  // the next are just quick access pointers, no cloning on those
1367  m_xText = ( a2dText* ) Find( wxT( "__XTEXT__" ) );
1368  m_xText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1369  m_yText = ( a2dText* ) Find( wxT( "__YTEXT__" ) );
1370  m_yText->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1371  m_Xlabel = ( a2dText* ) Find( wxT( "__XLABEL__" ) );
1372  m_Xlabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1373  m_Ylabel = ( a2dText* ) Find( wxT( "__YLABEL__" ) );
1374  m_Ylabel->SetSpecificFlags( false, a2dCanvasOFlags::DRAGGABLE );
1375 }
1376 
1378 {
1379  return new a2dMarkerShow( *this, options, refs );
1380 };
1381 
1383 {
1384  a2dBoundingBox bbox;
1385 
1386  m_Xlabel->SetPosXY( 0.0, 0.0 );
1387  a2dBoundingBox Xlabelbox = m_Xlabel->GetFont().GetTextExtent( m_Xlabel->GetText(), m_Xlabel->GetAlignment() );
1388  Xlabelbox.Translate( m_Xlabel->GetPosX(), m_Xlabel->GetPosY() );
1389  bbox.Expand( Xlabelbox );
1390  m_Xlabel->Update( updatemask_normal );
1391 
1392  m_Ylabel->SetPosXY( 0.0, -1.2 * Xlabelbox.GetHeight() );
1393  a2dBoundingBox Ylabelbox = m_Ylabel->GetFont().GetTextExtent( m_Ylabel->GetText(), m_Ylabel->GetAlignment() );
1394  Ylabelbox.Translate( m_Ylabel->GetPosX(), m_Ylabel->GetPosY() );
1395  bbox.Expand( Ylabelbox );
1396  m_Ylabel->Update( updatemask_normal );
1397 
1398  double labelw = bbox.GetMaxX();
1399 
1400  m_xText->SetPosXY( labelw, 0.0 );
1401  a2dBoundingBox Xtextbox = m_xText->GetFont().GetTextExtent( m_xText->GetText(), m_xText->GetAlignment() );
1402  Xtextbox.Translate( m_xText->GetPosX(), m_xText->GetPosY() );
1403  bbox.Expand( Xtextbox );
1404  m_xText->Update( updatemask_normal );
1405 
1406  m_yText->SetPosXY( labelw, m_Ylabel->GetPosY() );
1407  a2dBoundingBox Ytextbox = m_yText->GetFont().GetTextExtent( m_yText->GetText(), m_yText->GetAlignment() );
1408  Ytextbox.Translate( m_yText->GetPosX(), m_yText->GetPosY() );
1409  bbox.Expand( Ytextbox );
1410  m_yText->Update( updatemask_normal );
1411 
1412  return bbox;
1413 }
1414 
1416 {
1417  if ( !m_flags.m_pending )
1418  {
1419  //if marker was dragged, the show marker is to be updated
1420  if ( m_marker && m_marker->GetPending() )
1421  {
1422  //wxLogDebug( "onmarker" );
1423  SetPending( true );
1424  }
1425  //if text of show marker was edited, the marker will be updated too.
1426  else if ( ( m_xText->GetPending() || m_yText->GetPending() ) )
1427  {
1428  //wxLogDebug( "ontext" );
1429  double x;
1430  m_xText->GetText().ToDouble( &x );
1431  if ( m_marker )
1432  m_marker->SetPosition( x );
1433  }
1434  }
1435 }
1436 
1437 void a2dMarkerShow::OnPropertyChanged( a2dComEvent& event )
1438 {
1440  if( event.GetPropertyId() == PROPID_Stroke )
1441  {
1442  a2dStroke stroke = GetStroke();
1443  m_xText->SetStroke( stroke );
1444  m_Xlabel->SetStroke( stroke );
1445  m_yText->SetStroke( stroke );
1446  m_Ylabel->SetStroke( stroke );
1447  }
1448  else if( event.GetPropertyId() == PROPID_Fill )
1449  {
1450  a2dFill fill = GetFill();
1451  m_xText->SetFill( fill );
1452  m_Xlabel->SetFill( fill );
1453  m_yText->SetFill( fill );
1454  m_Ylabel->SetFill( fill );
1455  }
1456 }
1457 
1458 bool a2dMarkerShow::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1459 {
1460  if ( !m_bbox.GetValid() )
1461  {
1462  wxString formX;
1463  wxString formY;
1464  if ( m_marker )
1465  {
1466  a2dPoint2D point;
1467  m_marker->GetPositionCurvePoint( point );
1468  formX.Printf( m_XValueformat, point.m_x );
1469  formY.Printf( m_YValueformat, point.m_y );
1470  }
1471  else
1472  {
1473  formX.Printf( m_XValueformat, 0.0 );
1474  formY.Printf( m_YValueformat, 0.0 );
1475  }
1476  m_xText->SetText( formX );
1477  m_yText->SetText( formY );
1478  m_xText->SetStroke( GetStroke() );
1479  m_xText->SetFill( GetFill() );
1480  m_Xlabel->SetStroke( GetStroke() );
1481  m_Xlabel->SetFill( GetFill() );
1482  m_yText->SetStroke( GetStroke() );
1483  m_yText->SetFill( GetFill() );
1484  m_Ylabel->SetStroke( GetStroke() );
1485  m_Ylabel->SetFill( GetFill() );
1486 
1487  m_xText->SetPending( false );
1488  m_yText->SetPending( false );
1489 
1491  m_bbox.MapBbox( m_lworld );
1492  return true;
1493  }
1494 
1495  return false;
1496 }
1497 
1498 void a2dMarkerShow::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
1499 {
1500  // This first part is basically a copy of the DoGetUnTransformedBbox method.
1501  // It is copied here, because proper DC-font information is now known.
1502  wxString formX;
1503  wxString formY;
1504  if ( m_marker )
1505  {
1506  a2dPoint2D point;
1507  m_marker->GetPositionCurvePoint( point );
1508  formX.Printf( m_XValueformat, point.m_x );
1509  formY.Printf( m_YValueformat, point.m_y );
1510  }
1511  else
1512  {
1513  formX.Printf( m_XValueformat, 0.0 );
1514  formY.Printf( m_YValueformat, 0.0 );
1515  }
1516 
1517  m_xText->SetText( formX );
1518  m_yText->SetText( formY );
1519  m_xText->SetPending( false );
1520  m_yText->SetPending( false );
1521 
1522  a2dBoundingBox bbox;
1523 
1524  m_Xlabel->SetPosXY( 0.0, 0.0 );
1525  a2dBoundingBox Xlabelbox = m_Xlabel->GetFont().GetTextExtent( m_Xlabel->GetText(), m_Xlabel->GetAlignment() );
1526  Xlabelbox.Translate( m_Xlabel->GetPosX(), m_Xlabel->GetPosY() );
1527  bbox.Expand( Xlabelbox );
1528 
1529  m_Ylabel->SetPosXY( 0.0, -1.2 * m_Xlabel->GetLineHeight() );
1530  a2dBoundingBox Ylabelbox = m_Ylabel->GetFont().GetTextExtent( m_Ylabel->GetText(), m_Ylabel->GetAlignment() );
1531  Ylabelbox.Translate( m_Ylabel->GetPosX(), m_Ylabel->GetPosY() );
1532  bbox.Expand( Ylabelbox );
1533 
1534  double labelw = bbox.GetMaxX();
1535 
1536  m_xText->SetPosXY( labelw, 0.0 );
1537  a2dBoundingBox Xtextbox = m_xText->GetFont().GetTextExtent( m_xText->GetText(), m_xText->GetAlignment() );
1538  Xtextbox.Translate( m_xText->GetPosX(), m_xText->GetPosY() );
1539  bbox.Expand( Xtextbox );
1540 
1541  m_yText->SetPosXY( labelw, m_Ylabel->GetPosY() );
1542  a2dBoundingBox Ytextbox = m_yText->GetFont().GetTextExtent( m_yText->GetText(), m_yText->GetAlignment() );
1543  Ytextbox.Translate( m_yText->GetPosX(), m_yText->GetPosY() );
1544  bbox.Expand( Ytextbox );
1545 
1546  bbox.Enlarge( bbox.GetWidth() / 80.0 );
1547  ic.GetDrawer2D()->DrawRoundedRectangle( bbox.GetMinX(), bbox.GetMinY(), bbox.GetWidth() , bbox.GetHeight(), 0 );
1548 }
1549 
1550 #if wxART2D_USE_CVGIO
1551 void a2dMarkerShow::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1552 {
1553  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
1554  if ( xmlparts == a2dXmlSer_attrib )
1555  {
1556  }
1557  else
1558  {
1559  }
1560 }
1561 
1562 void a2dMarkerShow::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1563 {
1564  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
1565  if ( xmlparts == a2dXmlSer_attrib )
1566  {
1567  m_xText = ( a2dText* ) Find( wxT( "__XTEXT__" ) );
1568  m_yText = ( a2dText* ) Find( wxT( "__YTEXT__" ) );
1569  m_Xlabel = ( a2dText* ) Find( wxT( "__XLABEL__" ) );
1570  m_Ylabel = ( a2dText* ) Find( wxT( "__YLABEL__" ) );
1571  }
1572  else
1573  {
1574  }
1575 }
1576 #endif //wxART2D_USE_CVGIO
1577 
1578 bool a2dMarkerShow::DoIsHitWorld( a2dIterC& WXUNUSED( ic ), a2dHitEvent& hitEvent )
1579 {
1580  return true;
1581 }
1582 
1583 
1584 bool a2dMarkerShow::DoStartEdit( wxUint16 WXUNUSED( editmode ), wxEditStyle WXUNUSED( editstyle ) )
1585 {
1586  if ( m_flags.m_editable )
1587  {
1588  //calculate bbox's else mouse events may take place when first, and idle event is not yet
1589  //processed to do this calculation.
1591  //still set it pending to do the redraw ( in place )
1592  SetPending( true );
1593  return true;
1594  }
1595 
1596  return false;
1597 }
1598 
1599 void a2dMarkerShow::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
1600 {
1601  a2dIterC* ic = event.GetIterC();
1602  if ( m_flags.m_editingCopy )
1603  {
1604  //to world group coordinates to do hit test in world group coordinates
1605  double xw, yw;
1606  xw = event.GetX();
1607  yw = event.GetY();
1608 
1609  a2dAffineMatrix atWorld = ic->GetTransform();
1610 
1611  if ( event.GetMouseEvent().LeftDown() )
1612  {
1613  a2dMarkerShow* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dMarkerShow );;
1614 
1615  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false );
1616  if ( IsHitWorld( *ic, hitevent ) )
1617  {
1618  a2dHitEvent hitinfo( xw, yw, false );
1619  hitinfo.m_xyRelToChildren = true;
1620  a2dCanvasObject* text = original->IsHitWorld( *ic, hitinfo );//ChildIsHitWorld( *ic, hitinfo );
1621  if ( text && text->GetEditable() )
1622  {
1623 #if wxART2D_USE_EDITOR
1624  a2dIterCU cu( *ic, original );
1625  a2dStToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dStToolContr ) ;
1626 
1627  ic->SetCorridorPath( true, NULL );
1628  controller->StartEditingObject( text, *ic );
1629 #else //wxART2D_USE_EDITOR
1630  wxMessageBox( wxT( "Need editor module enabled for this" ) );
1631 #endif //wxART2D_USE_EDITOR
1632 
1633  SetPending( true );
1634  ic->GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
1635  }
1636  else
1637  event.Skip();
1638  }
1639  else
1640  EndEdit();
1641  }
1642  else if ( event.GetMouseEvent().LeftDClick() )
1643  {
1644  EndEdit();
1645  }
1646  else if ( event.GetMouseEvent().Moving() )
1647  {
1648  event.Skip();
1649  }
1650  else
1651  event.Skip();
1652  }
1653  else
1654  event.Skip();
1655 }
1656 
1657 //----------------------------------------------------------------------------
1658 // a2dCursorMarkerList
1659 //----------------------------------------------------------------------------
1660 
1661 a2dCursorMarkerList::a2dCursorMarkerList()
1662 {
1663 }
1664 
1665 a2dCursorMarkerList::~a2dCursorMarkerList()
1666 {
1667 }
1668 
1669 a2dCursorMarkerList* a2dCursorMarkerList::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
1670 {
1671  wxASSERT( 0 );
1672  return NULL;
1673 }
1674 
1675 //----------------------------------------------------------------------------
1676 // a2dCursor
1677 //----------------------------------------------------------------------------
1678 IMPLEMENT_DYNAMIC_CLASS( a2dCursor, a2dCanvasObject )
1679 
1680 BEGIN_EVENT_TABLE( a2dCursor, a2dCanvasObject )
1681 // EVT_CANVASOBJECT_MOUSE_EVENT( a2dCursorMarker::OnCanvasObjectMouseEvent )
1682 END_EVENT_TABLE()
1683 
1684 a2dCursor::a2dCursor( double csize )
1685  : a2dCanvasObject()
1686 {
1687  m_csize = csize;
1688  m_hsize = 0;
1689  m_wsize = 0;
1690  m_posx = 0;
1691  m_posy = 0;
1692  m_onlyIntPosX = false;
1693  m_onlyIntPosY = false;
1694 }
1695 
1696 a2dCursor::~a2dCursor()
1697 {
1698 }
1699 
1700 a2dCursor::a2dCursor( const a2dCursor& other, CloneOptions options, a2dRefMap* refs )
1701  : a2dCanvasObject( other, options, refs )
1702 {
1703  m_hsize = other.m_hsize;
1704  m_wsize = other.m_wsize;
1705  m_csize = other.m_csize;
1706  m_posx = other.m_posx;
1707  m_posy = other.m_posy;
1708  m_onlyIntPosX = other.m_onlyIntPosX;
1709  m_onlyIntPosY = other.m_onlyIntPosY;
1710 }
1711 
1713 {
1714  return new a2dCursor( *this, options, refs );
1715 };
1716 
1718 {
1719  // a2dAffineMatrix oldTransf = m_lworld;
1721  /*
1722  if(oldTransf != m_lworld)
1723  {
1724  double tempwsize, oldhsize;
1725  oldTransf.TransformPoint(0, m_hsize, tempwsize, oldhsize);
1726  a2dAffineMatrix newInverseTransf = m_lworld;
1727  newInverseTransf.Invert();
1728  newInverseTransf.TransformPoint(0, oldhsize, tempwsize, m_hsize);
1729  }
1730  */
1731 }
1732 
1733 a2dBoundingBox a2dCursor::DoGetUnTransformedBbox( a2dBboxFlags flags )
1734 {
1735  a2dBoundingBox bbox;
1736 
1737  double scalex = 1;
1739  if ( propSpec )
1740  {
1741  a2dMatrixProperty* propMatrix = wxStaticCast( propSpec, a2dMatrixProperty );
1742  scalex = propMatrix->GetValue().Get_scaleX();
1743  }
1744 
1745  bbox.Expand( 0, 0 );
1746  bbox.Expand( m_csize * scalex, m_hsize );
1747 
1748  m_untransbbox = bbox;
1749  return bbox;
1750 }
1751 
1752 /*
1753 bool a2dCursor::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1754 {
1755 if ( m_curve && !m_bbox.GetValid() )
1756 {
1757 
1758 //// double y;
1759 //// m_curve->CalculateYatX( GetPosX() , y );
1760 //// SetPosXY( GetPosX(), y );
1761 
1762 //// m_bbox=DoGetUnTransformedBbox();
1763 //// m_bbox.MapBbox(m_lworld);
1764 
1765 return true;
1766 }
1767 return false;
1768 }
1769 */
1770 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
1771 
1772 void a2dCursor::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
1773 {
1774  // For debugging
1775 // ic.GetDrawer2D()->SetDrawerFill(a2dWHITE_FILL);
1776 // ic.GetDrawer2D()->DrawRoundedRectangle(BBOX2XYWH(m_untransbbox), 0);
1777 
1778  double scalex = 1.;
1780  if ( propSpec )
1781  {
1782  a2dMatrixProperty* propMatrix = wxStaticCast( propSpec, a2dMatrixProperty );
1783  scalex = propMatrix->GetValue().Get_scaleX();
1784  }
1785  ic.GetDrawer2D()->DrawRoundedRectangle( 0, 0, m_csize * scalex, m_hsize, 0 ); //, true);
1786 }
1787 
1788 void a2dCursor::AddMarker( a2dBaseMarker* marker )
1789 {
1790  m_markers.push_back( marker );
1791 }
1792 
1793 void a2dCursor::RemoveMarker( a2dBaseMarker* marker )
1794 {
1795  m_markers.ReleaseObject( marker );
1796 }
1797 
1798 void a2dCursor::RemoveMarkers()
1799 {
1800  m_markers.clear();
1801 }
1802 
1803 void a2dCursor::SetPosition( double posx, double posy, const a2dAffineMatrix& mat )
1804 {
1805  m_posx = m_onlyIntPosX ? int( posx + 0.5 ) : posx;
1806  m_posy = m_onlyIntPosY ? int( posy + 0.5 ) : posy;
1808  {
1809  a2dBaseMarker* marker = *iter;
1810  marker->SetPosition( m_posx );
1811  }
1812 
1813  double xw, yw;
1814  mat.TransformPoint( m_posx, m_posy, xw, yw );
1815 
1816  SetPosXY( xw, yw );
1817 }
1818 
1819 bool a2dCursor::GetPosition( double& posx, double& posy )
1820 {
1821  posx = m_posx;
1822  posy = m_posy;
1823  return true;
1824 }
1825 
1826 bool a2dCursor::CheckPosition( double posx )
1827 {
1828  bool retCode = false;
1830  {
1831  a2dBaseMarker* baseMarker = *iter;
1832  a2dMarker* marker = wxDynamicCast( baseMarker, a2dMarker );
1833  if( marker && marker->GetCurve() )
1834  {
1835  a2dPoint2D apoint;
1836  if( marker->GetCurve()->GetXyAtSweep( posx, apoint ) )
1837  return true;
1838  }
1839  }
1840  return retCode;
1841 }
1842 
1843 void a2dCursor::UpdatePosition( double WXUNUSED( minx ), double miny, const a2dAffineMatrix& mat )
1844 {
1845  double xw, yw;
1846  mat.TransformPoint( m_posx, m_posy, xw, yw );
1847  SetPosXY( xw, miny );
1848 }
1849 
1850 void a2dCursor::SetPending( bool pending )
1851 {
1852  a2dCanvasObject::SetPending( pending );
1853  if( pending )
1854  {
1856  {
1857  a2dBaseMarker* marker = *iter;
1858  marker->SetPending( pending );
1859  }
1860  }
1861 }
1862 
1863 double a2dCursor::ConvertAxis2World( double percentValue )
1864 {
1865  return percentValue / 100.*m_hsize;
1866 }
1867 
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
Definition: canobj.h:301
cursor on curve plot as a vertical line with markers
Definition: marker.h:512
bool GetAttributeValueBool(const wxString &attrib, bool defaultv=false)
Returns the boolean value of an attribute.
Definition: genxmlpars.cpp:537
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
Definition: canobj.h:289
double GetHeight() const
returns height of the boundingbox
Definition: bbox.cpp:334
double GetSize() const
Get the font size.
Definition: stylebase.cpp:2917
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
void DependencyPending(a2dWalkerIOHandler *handler)
called by to check if this object becomes pending as a result of other objects
Definition: marker.cpp:1415
classes for plotting curve and pie data, and editing them.
bool HasAttribute(const wxString &attrib)
Does the current tag have this attribute?
Definition: genxmlpars.cpp:560
property to hold a a2dAffineMatrix
Definition: afmatrix.h:410
bool GetEditable() const
get if the object may be edited
Definition: canobj.h:1584
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
a2dBoundingBox m_untransbbox
Untransformed bounding box.
Definition: curve.h:93
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
Definition: gen.cpp:1310
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
Definition: canobj.h:500
double m_step
step to move when dragging/moving marker
Definition: marker.h:142
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: marker.cpp:1377
For Markers on a Curve.
Definition: marker.h:248
bool ResolveOrAdd(a2dSmrtPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
try to resolve the object that is in storedHere when it is a reference.
Definition: gen.cpp:4760
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: marker.cpp:250
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: marker.cpp:607
virtual const wxString & GetMarkerString()
string for maker, as is rendered when entering marker with cursor.
Definition: marker.cpp:1112
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
const a2dAffineMatrix & GetInverseTransform() const
Inverse of GetTransform()
Definition: canobj.cpp:699
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: marker.cpp:591
#define EVT_CANVASOBJECT_ENTER_EVENT(func)
static event table macro for a2dCanvasObject mouse enter event
Definition: canglob.h:314
const a2dFill * a2dBLACK_FILL
global a2dFill stock object for BLACK filling
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: marker.cpp:736
Ref Counted base object.
Definition: gen.h:1045
bool GetPending() const
is this object pending for update?
Definition: canobj.h:1162
void Enlarge(const double Marge)
enlarge with the given amount
Definition: bbox.cpp:162
proptype * GetPropertyListOnly(const a2dObject *obj) const
Get the property from the list in obj ( no members, not cloned )
Definition: id.inl:318
bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: marker.cpp:1584
bool m_pending
set when a2dCanvasObject needs an update (redraw).
Definition: candefs.h:277
a2dBoundingBox GetClippedCurveBoundaries()
get clipped boundary box of plot boundary in curve coordinates
Definition: curve.cpp:524
bool IsHit() const
true if this is a hit
Definition: polyver.h:107
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
double m_l2
length from top of arrow to inside point in X
Definition: marker.h:130
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
virtual void DrawPolygon(a2dVertexArray *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
Draw polygon in world coordinates using pointarray.
Definition: drawer2d.cpp:1889
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
a2dCurve * GetCurve() const
return curve of the marker
Definition: marker.h:294
void World2Curve(double xw, double yw, double &xcurve, double &ycurve)
used by a2dCurve to transform its own curve coordinates to the curve plotting area ...
Definition: curvegroup.cpp:164
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
bool GetPositionCurvePoint(a2dPoint2D &point)
get point at position of marker.
Definition: marker.cpp:1187
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
bool m_prompting
prompting when OnEnterObject
Definition: marker.h:145
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: marker.cpp:768
The base class for all drawable objects in a a2dCanvasDocument.
double GetTransformedHitMargin()
transformed to object its coordinate system
Definition: canobj.cpp:616
For Showing Marker position of Markers on a Curve.
Definition: marker.h:408
void SetFont(const a2dFont &font)
set font to use for drawing text
Definition: drawer2d.cpp:722
base class for axis in a2dCanvasXYDisplayGroup
Definition: axis.h:102
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: marker.cpp:1059
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
vertex array of line and arc segments.
Definition: polyver.h:494
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: marker.cpp:1712
double m_b
base of arrow
Definition: marker.h:133
void DoAddPending(a2dIterC &ic)
called by addPending
Definition: marker.cpp:557
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dCanvas uses a2dCanvasView for displaying a view on a a2dCanvasDocument.
void DependencyPending(a2dWalkerIOHandler *handler)
called by to check if this object becomes pending as a result of other objects
Definition: marker.cpp:689
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
Definition: afmatrix.cpp:559
virtual void EndEdit()
cleanup an editcopy object
Definition: canobj.cpp:1828
List of markers.
Definition: marker.h:498
a2dBoundingBox GetTextExtent(const wxString &string, int alignment=wxMINX|wxMINY, double *w=NULL, double *h=NULL, double *descent=NULL, double *externalLeading=NULL) const
Get the dimensions in world coordinates of the string.
Definition: stylebase.cpp:3044
void Curve2World(double xcurve, double ycurve, double &xw, double &yw)
used by a2dCurve to transform its own curve coordinates to the curve plotting area ...
Definition: curvegroup.cpp:171
a2dFont GetFont() const
get font for text
Definition: cantext.h:251
a2dCurveObject for objects needing to know its parent a2dCurvesArea.
Definition: curve.h:42
int ReleaseChild(a2dCanvasObject *obj, bool backwards=false, bool all=false, bool now=false, bool undoCommands=false)
remove the given object from the childobjects
Definition: canobj.cpp:6260
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
Definition: canobj.h:2559
marker for two value in one curve, called a a2dBandCurve.
Definition: marker.h:350
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
Definition: drawer2d.cpp:621
void Set(double xt, double yt, double l1, double l2, double b)
Definition: marker.cpp:159
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: marker.cpp:1205
void OnPropertyChanged(a2dComEvent &event)
Definition: canobj.cpp:2762
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: marker.cpp:720
bool IsYAxis() const
return true is this axis is Yaxis
Definition: axis.h:163
a2dText is an abstract base class.
Definition: cantext.h:93
void DependencyPending(a2dWalkerIOHandler *handler)
called by to check if this object becomes pending as a result of other objects
Definition: marker.cpp:1050
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: marker.cpp:232
used to change a property on objects
Definition: drawing.h:2244
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: marker.cpp:1217
void SetMarkerUpLow(bool markerUpLow)
return of GetXyAtSweep() is upper side of curve if true, else low
Definition: curve.h:727
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
Definition: bbox.cpp:299
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
Definition: bbox.cpp:155
const a2dBoundingBox & Translate(a2dPoint2D &)
translate with given vector
Definition: bbox.cpp:370
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
Definition: drawer2d.cpp:2048
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
bool m_spline
draw splined?
Definition: marker.h:136
const a2dFont * a2dNullFONT
global a2dFont stock object for NO font
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: marker.cpp:1498
The a2dStToolContr is a Tool Controller specialized for working with a2dCanvasView.
Definition: sttool.h:485
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
Definition: gen.cpp:1473
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
Definition: gen.h:564
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: marker.cpp:698
a2dMarker(const wxString &format=_T("%f %f"), a2dCurve *curve=0)
marker formatted
Definition: marker.cpp:979
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
Definition: canobj.cpp:636
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: marker.cpp:1382
bool m_editable
object can be edited
Definition: candefs.h:295
Normal straight line segment in a2dVertexList and a2dVertexArray.
Definition: polyver.h:163
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
Definition: canobj.cpp:2645
#define EVT_CANVASOBJECT_MOUSE_EVENT(func)
static event table macro for a2dCanvasObject mouse event
Definition: canglob.h:312
void DoUpdateViewDependentTransform(a2dIterC &ic)
update transform matrix klion: I&#39;m not sure that this function necessary as virtual ...
Definition: marker.cpp:1717
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: marker.cpp:572
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
bool m_onlyIntPosY
position is rounded to whole number
Definition: marker.h:591
double GetLineHeight() const
Height in world coordinates of one line.
Definition: cantext.h:179
a2dBoundingBox m_untransbbox
Untransformed bounding box.
Definition: marker.h:597
virtual void SetPending(bool pending)
set this object pending for update
Definition: marker.cpp:1850
bool m_onlyIntPosX
position is rounded to whole number
Definition: marker.h:589
virtual void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
Definition: drawer2d.cpp:2167
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: marker.cpp:1551
void DoAddPending(a2dIterC &ic)
called by addPending
Definition: marker.cpp:1044
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: marker.cpp:201
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: marker.cpp:153
For Markers on a Plot.
Definition: marker.h:31
virtual void DrawText(const wxString &text, double x, double y, int alignment=wxMINX|wxMINY, bool Background=true)
Draw text in user coordinates.
Definition: drawer2d.cpp:2329
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
Definition: canobj.h:1303
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
static a2dPropertyIdMatrix * PROPID_IntViewDependTransform
used for objects with* PROPID_viewDependent but only for internal area
Definition: canobj.h:2705
wxMouseEvent & GetMouseEvent()
return the original mouse event that was redirected to the a2dCanvasObject
Definition: canglob.h:243
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: marker.cpp:1772
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: marker.cpp:1296
Base class for curves.
Definition: curve.h:107
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: marker.cpp:1578
double GetMaxX() const
get maximum X of the boundingbox
Definition: bbox.cpp:316
virtual bool GetXyAtSweep(double sweepValue, a2dPoint2D &point) const =0
return Points in plot at the value of sweep parameter.
static const a2dCanvasObjectFlagsMask DRAGGABLE
Definition: candefs.h:187
double GetPosY() const
get y position from affine matrix
Definition: canobj.h:530
double GetWorldStrokeExtend()
Definition: canobj.h:3403
bool GetPositionCurvePoint(a2dPoint2D &point)
get point at position of marker.
Definition: marker.cpp:1030
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
void MapBbox(const a2dAffineMatrix &matrix)
Definition: bbox.cpp:445
double Get_scaleX() const
return scaling in X
Definition: afmatrix.cpp:755
#define EVT_CANVASOBJECT_LEAVE_EVENT(func)
static event table macro for a2dCanvasObject mouse leave event
Definition: canglob.h:316
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.
Definition: canobj.cpp:2924
#define A2D_PROPID_GS(type, classname, propname, defaultval, fget, fset)
to define a get set property more easily
Definition: id.h:710
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: marker.cpp:215
a2dHit HitTestPolygon(const a2dPoint2D &ptest, double margin)
extensive hittesting on vertex list seen as polygon.
Definition: polyver.cpp:1254
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
Definition: genxmlpars.cpp:450
void SetText(const wxString &text)
set the text for the object &#39; &#39; in string means new line
Definition: cantext.h:165
editing tool for a2dCanvasObject&#39;s
a2dCurvesArea * m_curvesArea
parent of curve
Definition: curve.h:90
double GetWidth() const
returns width of the boundingbox
Definition: bbox.cpp:328
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: marker.cpp:372
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
bool ReleaseObject(T *object)
release a certain object from the list
Definition: smrtptr.inl:118
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
Definition: canobj.cpp:1624
bool m_editingCopy
true if the object needs to be rendered in edit mode.
Definition: candefs.h:304
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: marker.cpp:267
see a2dComEvent
Definition: gen.h:371
void DependencyPending(a2dWalkerIOHandler *handler)
called by to check if this object becomes pending as a result of other objects
Definition: marker.cpp:563
Curve represented by a number of vertexes.
Definition: curve.h:703
a2dCanvasObject * IsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
If the position (x,y) is within the object return this.
Definition: canobj.cpp:3415
virtual void DoUpdateViewDependentTransform(a2dIterC &ic)
update transform matrix klion: I&#39;m not sure that this function necessary as virtual ...
Definition: canobj.cpp:4637
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: marker.cpp:1167
double m_position
the current X where the marker is located
Definition: marker.h:148
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dObject&#39;s and derived classes
Definition: gen.cpp:5265
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
a2dCursorMarkerList m_markers
list of markers on cursor line
Definition: marker.h:594
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
void SetCaptured(a2dCanvasObject *captured)
set the object that is captured for events in the a2dDrawing.
Definition: drawer.h:638
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: marker.cpp:1562
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
Definition: id.inl:325
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
a2dFont m_font
marker font
Definition: marker.h:139
virtual bool StartEditingObject(a2dCanvasObject *objectToEdit)
start editing this object
Definition: sttool.cpp:926
a2dDrawingPart * GetDrawingPart() const
get current a2dDrawingPart
Definition: canobj.cpp:631
int GetAlignment() const
Get the position of the anchor point w.r.t the text.
Definition: cantext.h:304
This template class is for property ids with a known data type.
Definition: id.h:477
a2dBoundingBox m_bbox
boundingbox in world coordinates
Definition: canobj.h:2539
double RequireAttributeValueDouble(const wxString &attrib)
Forces an attribute and returns its double value.
Definition: genxmlpars.cpp:487
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: marker.cpp:178
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: marker.cpp:1094
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: marker.cpp:1458
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: marker.cpp:1008
a2dCanvasObject * Find(const wxString &objectname, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *propid=NULL, const wxString &valueAsString=wxT(""), wxUint32 id=0) const
return the object which fits the filter.
Definition: canobj.cpp:4505
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
Definition: canobj.cpp:663
wxString GetText() const
get the text of the object &#39; &#39; in string means new line
Definition: cantext.h:168
For Markers on an Axis.
Definition: marker.h:181
list of a2dObject&#39;s
Definition: gen.h:3157
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
Definition: canobj.h:291
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: marker.cpp:1078
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
CloneOptions
options for cloning
Definition: gen.h:1200
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: marker.cpp:552
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: marker.cpp:684
void SetCorridorPath(bool OnOff, a2dCanvasObject *captureObject=NULL)
to set corridor path ( also to captured object), its a2dCanvasOFlags::IsOnCorridorPath flag is set on...
Definition: canobj.cpp:739
double m_l1
length from top of arrow to outside points in X
Definition: marker.h:127
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
wxInt64 GetUniqueSerializationId() const
return a unique id for this object
Definition: gen.cpp:1450
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: canobj.cpp:5504
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
general canvas module declarations and classes
wxEditStyle
Definition: canobj.h:109
marker.cpp Source File -- Sun Oct 12 2014 17:04:22 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation