wxArt2D
axis.cpp
Go to the documentation of this file.
1 /*! \file curves/src/axis.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: axis.cpp,v 1.23 2009/07/24 16:35:01 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include <wx/wfstream.h>
22 #include <math.h>
23 
24 #include "wx/canvas/eval.h"
25 
26 #include "wx/curves/meta.h"
27 
28 #include "wx/canvas/canobj.h"
29 #include "wx/canvas/drawer.h"
30 #include "wx/canvas/canvas.h"
31 
32 #if wxART2D_USE_EDITOR
33 #include "wx/canvas/edit.h"
34 #endif //wxART2D_USE_EDITOR
35 
36 //----------------------------------------------------------------------------
37 // globals
38 //----------------------------------------------------------------------------
39 
40 IMPLEMENT_DYNAMIC_CLASS( a2dTicFormatter, a2dCanvasObject )
41 IMPLEMENT_DYNAMIC_CLASS( a2dTimeTicFormatter, a2dTicFormatter )
42 IMPLEMENT_DYNAMIC_CLASS( a2dCurveAxis, a2dCanvasObject )
43 IMPLEMENT_DYNAMIC_CLASS( a2dCurveAxisLin, a2dCurveAxis )
44 #if 0
45 IMPLEMENT_DYNAMIC_CLASS( a2dCurveAxisArea, a2dCurveObject )
46 #endif
47 
48 //----------------------------------------------------------------------------
49 // a2dTicFormatter
50 //----------------------------------------------------------------------------
51 
53  : a2dCanvasObject()
54 {
55  m_format = _T( "%3.0f" );
56 }
57 
59 {
60 }
61 
62 a2dTicFormatter::a2dTicFormatter( const a2dTicFormatter& other, CloneOptions options, a2dRefMap* refs )
63  : a2dCanvasObject( other, options, refs )
64 {
65  m_format = other.m_format;
66 }
67 
69 {
70  return new a2dTicFormatter( *this, options, refs );
71 }
72 
73 
74 wxString a2dTicFormatter::GetTicText( double dTicValue ) const
75 {
76  wxString strTicText;
77 
78  strTicText.Printf( m_format, dTicValue );
79  return strTicText;
80 }
81 
82 
84  : a2dTicFormatter()
85 {
86  m_format.empty();
87 }
88 
90 {
91 }
92 
93 void a2dTimeTicFormatter::SetTicFormat( const wxString& format )
94 {
95  wxASSERT_MSG( format.IsEmpty(), wxT( "format string not supported" ) );
96 }
97 
98 wxString a2dTimeTicFormatter::GetTicText( double dTicValue )
99 {
100  wxString strTicText;
101  wxString str;
102  wxChar cSeparator = _T( '\0' );
103  int i, nDivisor[] = { 60, 60, 24 };
104  int i0 = 0;
105  wxUint32 ulTic = ( wxUint32 ) dTicValue;
106 
107  // converts dTicValue, which is the elapsed time in seconds, to a
108  // d:mm:hh:ss formatted string. the implementation is iterative and
109  // runs from ss to d (right to left).
110 
111  // no seconds please!
112  i0 = 1, ulTic /= nDivisor[0];
113 
114  strTicText.empty();
115  // ss, mm, hh
116  for ( i = i0; i < 3; i++ )
117  {
118  str.Printf( _T( "%02lu%c" ), ulTic % nDivisor[i], cSeparator );
119  strTicText = str + strTicText;
120  ulTic /= nDivisor[i];
121  cSeparator = _T( ':' );
122  }
123  // d (days) - optional
124  if ( ulTic > 0 )
125  {
126  str.Printf( _T( "%lu%c" ), ulTic, cSeparator );
127  strTicText = str + strTicText;
128  }
129  return strTicText;
130 }
131 
132 
133 
134 //----------------------------------------------------------------------------
135 // a2dCurveAxis
136 //----------------------------------------------------------------------------
137 /*
138 const a2dPropertyIdRefObject a2dCurveAxis::PROPID_stroketic( CLASSNAME( a2dCurveAxis ), wxT("stroketic"), a2dPropertyId::flag_none, 0 );
139 const a2dPropertyIdRefObject a2dCurveAxis::PROPID_stroketictext( CLASSNAME( a2dCurveAxis ), wxT("stroketictext"), a2dPropertyId::flag_none, 0 );
140 const a2dPropertyIdRefObject a2dCurveAxis::PROPID_strokeaxis( CLASSNAME( a2dCurveAxis ), wxT("strokeaxis"), a2dPropertyId::flag_none, 0 );
141 */
142 
143 a2dCurveAxis::a2dCurveAxis( double length, bool yaxis )
144  : a2dCurveObject()
145 {
146  m_length = length;
147  m_yaxis = yaxis;
148  m_showtics = true;
149  m_tic = 0;
150  m_ticheight = 0;
151  m_stroketic = *a2dBLACK_STROKE;
152  m_stroketictext = *a2dBLACK_STROKE;
153  m_strokeunits = *a2dBLACK_STROKE;
154 
156 
157  m_sidetic = true;//false;
158  m_inverttic = false;
159  m_autosizedtic = false;
160 
161  m_min = 0;
162  m_max = 1000;
163  m_ticmin = m_min;
164  m_ticmax = m_max;
165  m_position = 0;
166 
167  m_pTicFormatter = new a2dTicFormatter();
168  m_pTicFormatter->SetAxis( this );
169 
170  m_font = a2dFont( 6, wxSWISS, wxITALIC );
171 }
172 
173 a2dCurveAxis::~a2dCurveAxis()
174 {
175 }
176 
178 {
179  return new a2dCurveAxis( *this, options, refs );
180 };
181 
182 a2dCurveAxis::a2dCurveAxis( const a2dCurveAxis& other, CloneOptions options, a2dRefMap* refs )
183  : a2dCurveObject( other, options, refs )
184 {
185  m_showtics = other.m_showtics;
186  m_tic = other.m_tic;
187  m_ticheight = other.m_ticheight;
188  if( options & clone_members )
189  {
190  m_stroketic = other.m_stroketic;
191  m_stroketictext = other.m_stroketictext;
192  m_strokeunits = other.m_strokeunits;
193  m_pTicFormatter = ( a2dTicFormatter* ) other.m_pTicFormatter->Clone( CloneOptions( options & ~ clone_seteditcopy ) );
194  m_font = other.m_font;
195  }
196  else
197  {
198  m_stroketic = other.m_stroketic;
199  m_stroketictext = other.m_stroketictext;
200  m_strokeunits = other.m_strokeunits;
201  m_pTicFormatter = other.m_pTicFormatter;
202  m_font = other.m_font;
203  }
204  m_units = other.m_units;
205  m_length = other.m_length;
206  m_min = other.m_min;
207  m_max = other.m_max;
208  m_ticmin = other.m_ticmin;
209  m_ticmax = other.m_ticmax;
210  m_yaxis = other.m_yaxis;
211 
212  m_sidetic = other.m_sidetic;
213  m_inverttic = other.m_inverttic;
214  m_position = other.m_position;
215  m_autosizedtic = other.m_autosizedtic;
216  m_commonTicFormat = other.m_commonTicFormat;
217 
218 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
219  //klion: it is because the CurrentSmartPointerOwner can change in property->TClone()
220  CurrentSmartPointerOwner = this;
221 #endif
222 
223 }
224 
225 void a2dCurveAxis::SetBoundaries( double min, double max )
226 {
227  if( m_min != min || m_max != max )
228  {
230  {
232  {
233  a2dCanvasObject* obj = *iter;
234  double curlength = m_length != 0 ? m_length : 1.;
235  if( m_yaxis )
236  {
237  obj->SetPosXY( 0, obj->GetPosY() / curlength * ( m_max - m_min ) + m_min );
238  double val = obj->GetPosY();
239  if( val < wxMin( min, max ) || val > wxMax( min, max ) )
240  obj->SetVisible( false );
241  else
242  obj->SetVisible( true );
243  obj->SetPosXY( 0, ( obj->GetPosY() - min ) / ( max - min )*curlength );
244  }
245  else
246  {
247  obj->SetPosXY( obj->GetPosX() / curlength * ( m_max - m_min ) + m_min, 0 );
248  double val = obj->GetPosX();
249  if( val < wxMin( min, max ) || val > wxMax( min, max ) )
250  obj->SetVisible( false );
251  else
252  obj->SetVisible( true );
253  obj->SetPosXY( ( obj->GetPosX() - min ) / ( max - min )*curlength, 0 );
254  }
255  }
256  }
257  if( m_min == m_ticmin && m_max == m_ticmax )
258  {
259  m_ticmin = min;
260  m_ticmax = max;
261  }
262  m_min = min;
263  m_max = max;
264  SetPending( true );
265  }
266 }
267 
268 void a2dCurveAxis::SetTicBoundaries( double min, double max )
269 {
270  if ( m_ticmin != min || m_ticmax != max )
271  {
272  m_ticmin = min;
273  m_ticmax = max;
274  SetPending( true );
275  }
276 }
277 
278 void a2dCurveAxis::SetLength( double length )
279 {
280  if ( m_length != length )
281  {
283  {
285  {
286  a2dCanvasObject* obj = *iter;
287  double curlength = m_length != 0 ? m_length : 1.;
288  double newlength = length != 0 ? length : 1.;
289  if ( m_yaxis )
290  {
291  obj->SetPosXY( 0, obj->GetPosY() / curlength * ( m_max - m_min ) + m_min );
292  obj->SetPosXY( 0, ( obj->GetPosY() - m_min ) / ( m_max - m_min )*newlength );
293  }
294  else
295  {
296  obj->SetPosXY( obj->GetPosX() / curlength * ( m_max - m_min ) + m_min, 0 );
297  obj->SetPosXY( ( obj->GetPosX() - m_min ) / ( m_max - m_min )*newlength, 0 );
298  }
299  }
300  }
301  m_length = length;
302  SetPending( true );
303  }
304 }
305 
306 #if wxART2D_USE_CVGIO
307 void a2dCurveAxis::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
308 {
309  a2dCurveObject::DoSave( parent, out, xmlparts, towrite );
310  if ( xmlparts == a2dXmlSer_attrib )
311  {
312  out.WriteAttribute( wxT( "min" ) , m_min );
313  out.WriteAttribute( wxT( "max" ) , m_max );
314  out.WriteAttribute( wxT( "ticmin" ) , m_ticmin );
315  out.WriteAttribute( wxT( "ticmax" ) , m_ticmax );
316  out.WriteAttribute( wxT( "yaxis" ) , m_yaxis );
317  out.WriteAttribute( wxT( "showtics" ) , m_showtics );
318  out.WriteNewLine();
319  out.WriteAttribute( wxT( "font" ), m_font.CreateString() );
320  out.WriteNewLine();
321 
322  out.WriteAttribute( wxT( "tic" ) , m_tic );
323  out.WriteAttribute( wxT( "ticheight" ) , m_ticheight );
324  out.WriteAttribute( wxT( "sidetic" ) , m_sidetic );
325  out.WriteNewLine();
326  out.WriteAttribute( wxT( "position" ) , m_position );
327  out.WriteAttribute( wxT( "inverttic" ) , m_inverttic );
328  out.WriteAttribute( wxT( "autosizedtic" ) , m_autosizedtic );
329  out.WriteNewLine();
330  out.WriteAttribute( wxT( "units" ) , m_units );
331  out.WriteAttribute( wxT( "commonFormat" ), m_commonTicFormat );
332 
333  out.WriteNewLine();
334  }
335  else
336  {
337  out.WriteStartElement( wxT( "derived" ) );
338 
339  m_stroketic.Save( this, out, towrite );
340  m_stroketictext.Save( this, out, towrite );
341  m_strokeunits.Save( this, out, towrite );
342 
343  m_pTicFormatter->Save( this, out, towrite );
344 
345  out.WriteEndElement();
346  }
347 }
348 
349 void a2dCurveAxis::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
350 {
351  a2dCurveObject::DoLoad( parent, parser, xmlparts );
352  if ( xmlparts == a2dXmlSer_attrib )
353  {
354  m_min = parser.RequireAttributeValueDouble( wxT( "min" ) );
355  m_max = parser.RequireAttributeValueDouble( wxT( "max" ) );
356  m_ticmin = parser.RequireAttributeValueDouble( wxT( "ticmin" ) );
357  m_ticmax = parser.RequireAttributeValueDouble( wxT( "ticmax" ) );
358  m_yaxis = parser.RequireAttributeValueBool( wxT( "yaxis" ) );
359  m_showtics = parser.RequireAttributeValueBool( wxT( "showtics" ) );
360  a2dFontInfo fontinfo;
361  fontinfo.ParseString( parser.RequireAttributeValue( wxT( "font" ) ) );
362  m_font = a2dFont::CreateFont( fontinfo );
363 
364  m_tic = parser.RequireAttributeValueDouble( _T( "tic" ) );
365  m_ticheight = parser.RequireAttributeValueDouble( wxT( "ticheight" ) );
366  m_sidetic = parser.RequireAttributeValueBool( wxT( "sidetic" ) );
367  m_position = parser.GetAttributeValueDouble( wxT( "position" ) );
368  m_inverttic = parser.GetAttributeValueBool( wxT( "inverttic" ) );
369  m_autosizedtic = parser.GetAttributeValueBool( wxT( "autosizedtic" ) );
370 
371  m_units = parser.GetAttributeValue( wxT( "units" ) );
372  m_commonTicFormat = parser.GetAttributeValue( wxT( "commonTicFormat" ) );
373  }
374  else
375  {
376  parser.Require( START_TAG, wxT( "derived" ) );
377  parser.Next();
378 
379  // new strokes, since the current ones might be shared by other objects too.
380  m_stroketic.UnRef();
381  m_stroketictext.UnRef();
382  m_strokeunits.UnRef();
383 
384  m_stroketic.Load( parent, parser );
385  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_stroketic );
386  m_stroketictext.Load( parent, parser );
387  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_stroketictext );
388  m_strokeunits.Load( parent, parser );
389  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_strokeunits );
390 
391  m_pTicFormatter->Load( parent, parser );
392  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_pTicFormatter );
393 
394  parser.Require( END_TAG, wxT( "derived" ) );
395  parser.Next();
396  }
397 }
398 #endif //wxART2D_USE_CVGIO
399 
401 {
402  m_stroketic = stroke;
403  SetPending( true );
404 }
405 
407 {
408  m_stroketictext = stroke;
409  SetPending( true );
410 }
411 
412 void a2dCurveAxis::SetUnitsStroke( const a2dStroke& stroke )
413 {
414  m_strokeunits = stroke;
415  SetPending( true );
416 }
417 
418 void a2dCurveAxis::SetUnitsStroke( const wxColour& color, double width, a2dStrokeStyle style )
419 {
420  m_strokeunits = a2dStroke( color, width, style );
421  SetPending( true );
422 }
423 
425 {
427  if( m_autosizedtic )
428  {
430  if ( propSpec )
431  {
432  int clientw, clienth;
433  ic.GetDrawingPart()->GetCanvas()->GetClientSize( &clientw, &clienth );
434 
435  if ( clientw == 0 ) clientw = 10;
436  if ( clienth == 0 ) clienth = 10;
437 
438  double w = fabs( ic.GetDrawer2D()->DeviceToWorldXRel( clientw ) );
439  double h = fabs( ic.GetDrawer2D()->DeviceToWorldYRel( clienth ) );
440  double relw = ic.GetInverseTransform().TransformDistance( w );
441  double relh = ic.GetInverseTransform().TransformDistance( h );
442  /* another way
443  double worldtic;
444  if(m_yaxis)
445  {
446  if ( clienth == 0 ) clienth = 10;
447  double h = fabs(ic.GetDrawer2D()->DeviceToWorldYRel(clienth));
448  double relh = h*ic.GetInverseTransform().Get_scaleY();
449  worldtic = relh/m_length*15;
450  }
451  else
452  {
453  if ( clientw == 0 ) clientw = 10;
454  double w = fabs(ic.GetDrawer2D()->DeviceToWorldXRel(clientw));
455  double relw = w*ic.GetInverseTransform().Get_scaleX();
456  worldtic = relw/m_length*15;
457  }
458  */
459 
460  double worldtic = wxMin( relw, relh ) / m_length * 15;
461  double tic = worldtic / m_length * ( m_max - m_min );
462  if( tic > 10 ) tic = int( tic + 0.5 );
463 
464  if( m_tic != tic )
465  {
466  m_tic = tic;
467  SetPending( true );
468  }
469  }
470  }
471 }
472 
473 bool a2dCurveAxis::HasLevelMarkers() const
474 {
475  a2dCanvasObject* pObject = NULL;
476  a2dAxisMarker* pMarker = NULL;
477 
479  {
480  pObject = *iter;
481  pMarker = wxDynamicCast( pObject, a2dAxisMarker );
482  if ( pMarker )
483  return TRUE;
484  }
485  return FALSE;
486 }
487 
489 {
490  a2dBoundingBox bbox;
491 
492 #if 0
493  // tictextheightX and tictextheigtY are not longer used.
494  // this may be an error since the scaling is not respected.
495  // should be investigated! FIXME
496  double tictextheight = GetTicTextHeight();
497  double tictextheightX = tictextheight;
498  double tictextheightY = tictextheight;
499 
500  a2dNamedProperty* propSpec = PROPID_intViewDependTransform->GetPropertyListOnly( this );
501  if ( propSpec )
502  {
503  a2dMatrixProperty* propMatrix = wxStaticCast( propSpec, a2dMatrixProperty );
504  double scalex = propMatrix->GetValue().Get_scaleX();
505  double scaley = propMatrix->GetValue().Get_scaleY();
506  tictextheightX = tictextheightX * scalex;
507  tictextheightY = tictextheightY * scaley;
508 // maybe it is bad for different scale by X and by Y.
509 // tictextheight = propMatrix->GetValue().TransformDistance(tictextheight);
510  }
511 #endif
512 
513  a2dAffineMatrix internalTransform;
515  if ( propSpec )
516  {
517  a2dMatrixProperty* propMatrix = wxStaticCast( propSpec, a2dMatrixProperty );
518  internalTransform = propMatrix->GetValue();
519  }
520  double length = GetLength();
521 
522  double sizeticstroke = m_stroketic.GetWidth();
523  double ticheight = GetTicHeight();
524  int hasLevels = HasLevelMarkers() ? 1 : 0;
525 
526  if( !internalTransform.IsIdentity() )
527  {
528  double scalex = internalTransform.Get_scaleX();
529  double scaley = internalTransform.Get_scaleY();
530  if ( m_yaxis )
531  {
532  length = length / scaley;
533  sizeticstroke = sizeticstroke / scaley;
534 // hasLevels = (int) (hasLevels / scalex);
535  }
536  else
537  {
538  length = length / scalex;
539  sizeticstroke = sizeticstroke / scalex;
540 // hasLevels = (int) (hasLevels / scaley);
541  }
542  }
543 
544  if( m_showtics )
545  {
546  wxString ticstr = m_commonTicFormat.IsEmpty() ?
547  m_pTicFormatter->GetTicText( - wxMax( fabs( m_min ), fabs( m_max ) ) )
548  : wxString::Format( m_commonTicFormat.c_str(), - wxMax( fabs( m_min ), fabs( m_max ) ) );
549  // bboxtext alignment depends on axis direction and flags! See below!
550 
551 // int hasLevels = HasLevelMarkers() ? 1 : 0;
552 
553  // Strategy: we calculate a complete tic-bbox, consisting of line and text
554  // at xy = 0 and expand bbox. Then we translate the tic-bbox to m_length and
555  // expand bbox again.
556  double xy = 0;
557  double transX = 0, transY = 0;
558 // double sizeticstroke = m_stroketic->GetWidth();
559 
560  a2dBoundingBox bboxtic;
561  a2dBoundingBox bboxunits;
562 
563  a2dBoundingBox bboxtext;
564  a2dBoundingBox bboxline;
565 
566  if ( m_sidetic )
567  {
568  // Line 1:1 (or 2:1 with markers) on both axis sides.
569  // Text center on tic
570  double ticsize = ticheight * ( 1.1 + hasLevels );
571  double textticpos = ticheight * ( 1.2 + hasLevels );
572  if ( m_yaxis )
573  {
574  bboxtext = m_font.GetTextExtent( ticstr, wxMIDY | ( m_inverttic ? wxMINX : wxMAXX ) );
575  if ( m_inverttic )
576  {
577  bboxline = a2dBoundingBox( -ticheight, xy, ticsize, xy );
578  bboxtext.Translate( textticpos, xy );
579  }
580  else
581  {
582  bboxline = a2dBoundingBox( -ticsize, xy, ticheight, xy );
583  bboxtext.Translate( -textticpos, xy );
584  }
585  transX = 0, transY = length;
586  }
587  else
588  {
589  bboxtext = m_font.GetTextExtent( ticstr, wxMIDX | ( m_inverttic ? wxMINY : wxMAXY ) );
590  if ( m_inverttic )
591  {
592  bboxline = a2dBoundingBox( xy, -ticheight, xy, ticsize );
593  bboxtext.Translate( xy, textticpos );
594  }
595  else
596  {
597  bboxline = a2dBoundingBox( xy, -ticsize, xy, ticheight );
598  bboxtext.Translate( xy, -textticpos );
599  }
600  transX = length, transY = 0;
601  }
602  bboxtic.Expand( bboxline );
603  bboxtic.Expand( bboxtext );
604 
605  if ( !m_units.IsEmpty() )
606  {
607  if ( m_yaxis )
608  {
609  bboxunits = m_font.GetTextExtent( m_units, ( m_inverttic ? wxMINX : wxMAXX ) );
610  if ( m_inverttic )
611  bboxunits.Translate( textticpos, m_max > m_min ? length : 0 );
612  else
613  bboxunits.Translate( -textticpos, m_max > m_min ? length : 0 );
614  }
615  else
616  {
617  bboxunits = m_font.GetTextExtent( m_units, ( m_inverttic ? wxMINY : wxMAXY ) | ( m_max > m_min ? wxMINX : wxMAXX ) );
618  if ( m_inverttic )
619  bboxunits.Translate( m_max > m_min ? length : 0, textticpos );
620  else
621  bboxunits.Translate( m_max > m_min ? length : 0, -textticpos );
622  }
623  }
624 
625  }
626  else // ==> !m_sidetic
627  {
628  // Line on one side of the axis.
629  // Text above the tic for Y-axis and beside for X-Axis. Not sure about this but sample look like that.
630  // we use sizeticstroke+1 to get a better separation of line and text
631  double ticsize = ticheight * ( 2 + hasLevels );
632  double textticpos = ticheight * ( 0.5 + hasLevels );
633  if ( m_yaxis )
634  {
635  bboxtext = m_font.GetTextExtent( ticstr, wxMINY | ( m_inverttic ? wxMINX : wxMAXX ) );
636  if ( m_inverttic )
637  {
638  bboxline = a2dBoundingBox( 0, xy, ticsize, xy );
639  bboxtext.Translate( textticpos, xy + sizeticstroke ); //klion +1
640  }
641  else
642  {
643  bboxline = a2dBoundingBox( -ticsize, xy, 0, xy );
644  bboxtext.Translate( -textticpos, xy + sizeticstroke ); //klion +1
645  }
646  transX = 0, transY = length;
647  if( !m_units.IsEmpty() )
648  transY -= bboxtext.GetHeight();
649  }
650  else
651  {
652  bboxtext = m_font.GetTextExtent( ticstr, wxMINX | ( m_inverttic ? wxMINY : wxMAXY ) );
653  if ( m_inverttic )
654  {
655  bboxline = a2dBoundingBox( xy, ticsize, xy, 0 );
656  bboxtext.Translate( xy + sizeticstroke, textticpos ); //klion +1
657  }
658  else
659  {
660  bboxline = a2dBoundingBox( xy, -ticsize, xy, 0 );
661  bboxtext.Translate( xy + sizeticstroke, -textticpos ); //klion +1
662  }
663  transX = length, transY = 0;
664  if( !m_units.IsEmpty() )
665  transX -= bboxtext.GetWidth();
666  }
667  bboxtic.Expand( bboxline );
668  bboxtic.Expand( bboxtext );
669 
670  if ( !m_units.IsEmpty() )
671  {
672  if ( m_yaxis )
673  {
674  bboxunits = m_font.GetTextExtent( m_units, wxMINY | ( m_inverttic ? wxMINX : wxMAXX ) );
675  if ( m_inverttic )
676  bboxunits.Translate( textticpos, ( m_max > m_min ? length : 0 ) + sizeticstroke );
677  else
678  bboxunits.Translate( -textticpos, ( m_max > m_min ? length : 0 ) + sizeticstroke );
679  }
680  else
681  {
682  bboxunits = m_font.GetTextExtent( m_units, ( m_max > m_min ? wxMINX : wxMAXX ) | ( m_inverttic ? wxMINY : wxMAXY ) );
683  if ( m_inverttic )
684  bboxunits.Translate( ( m_max > m_min ? length : 0 ) - sizeticstroke, textticpos );
685  else
686  bboxunits.Translate( ( m_max > m_min ? length : 0 ) - sizeticstroke, -textticpos );
687  }
688  }
689 
690  }
691 
692  m_untransbboxtictext = bboxtext;
693  bbox.Expand( bboxtic );
694  bboxtic.Translate( transX, transY );
695  bbox.Expand( bboxtic );
696  bbox.Expand( bboxunits );
697 
698  }
699  else
700  {
701  bbox.Expand( 0, 0 );
702  if ( m_yaxis )
703  bbox.Expand( 0, length );
704  else
705  bbox.Expand( length, 0 );
706  }
707 
708  if( !internalTransform.IsIdentity() )
709  {
710  bbox.MapBbox( internalTransform );
711  }
712 
713  return bbox;
714 }
715 
716 double a2dCurveAxis::ConvertWorld2Axis( double RelativeWorldValue )
717 {
718  double curlength = m_length != 0 ? m_length : 1.;
719  return RelativeWorldValue / curlength * ( m_max - m_min ) + m_min;
720 }
721 
722 double a2dCurveAxis::ConvertAxis2World( double AxisValue )
723 {
724  double curlength = m_length != 0 ? m_length : 1.;
725  return ( AxisValue - m_min ) / ( m_max - m_min ) * curlength;
726 }
727 
728 void a2dCurveAxis::AddLevel( const wxString& levelName, double val, a2dCanvasObject* object )
729 {
730  if ( !levelName.IsEmpty() )
731  object->SetName( levelName );
732  if ( m_inverttic )
733  {
734  object->Mirror( !m_yaxis, m_yaxis );
735  a2dBaseMarker* aMarker = wxDynamicCast( object, a2dBaseMarker );
736  if ( aMarker )
737  {
738  a2dText* aText = aMarker->GetPrompt();
739  if ( aText )
740  aText->Mirror(); //aText->Mirror(m_yaxis,!m_yaxis);
741  }
742  }
743  Append( object );
744  a2dBaseMarker* aMarker = wxDynamicCast( object, a2dBaseMarker );
745  if( aMarker )
746  aMarker->SetPosition( val );
747 
748  if ( val < wxMin( m_min, m_max ) || val > wxMax( m_min, m_max ) )
749  object->SetVisible( false );
750  else
751  object->SetVisible( true );
752  if ( m_yaxis )
753  object->SetPosXY( 0, ConvertAxis2World( val ) );
754  else
755  object->SetPosXY( ConvertAxis2World( val ), 0 );
756  SetPending( true );
757 }
758 
759 a2dCanvasObject* a2dCurveAxis::GetLevel( const wxString& levelName )
760 {
761  a2dCanvasObjectList::iterator iter = GetChildObjectList()->begin();
762  while( iter != GetChildObjectList()->end() )
763  {
764  if ( ( *iter )->GetName() == levelName )
765  return ( a2dCanvasObject* ) ( *iter ).Get();
766  ++iter;
767  }
768  return NULL;
769 }
770 
771 bool a2dCurveAxis::GetLevelValue( const wxString& levelName, double& val )
772 {
773  a2dCanvasObjectList::iterator iter = GetChildObjectList()->begin();
774  while( iter != GetChildObjectList()->end() )
775  {
776  if ( ( *iter )->GetName() == levelName )
777  {
778  a2dCanvasObject* obj = ( ( a2dCanvasObject* ) ( *iter ).Get() );
779  if ( m_yaxis )
780  val = ConvertWorld2Axis( obj->GetPosY() );
781  else
782  val = ConvertWorld2Axis( obj->GetPosX() );
783  return true;
784  }
785  ++iter;
786  }
787  return false;
788 }
789 
790 void a2dCurveAxis::SetInvertTic( bool inverttic )
791 {
792  if( m_inverttic != inverttic )
793  {
794  MirrorLevels();
795  m_inverttic = inverttic;
796  SetPending( true );
797  }
798 }
799 
800 void a2dCurveAxis::MirrorLevels()
801 {
803  {
805  {
806  a2dCanvasObject* obj = *iter;
807  obj->Mirror( !m_yaxis, m_yaxis );
808  a2dBaseMarker* aMarker = wxDynamicCast( obj, a2dBaseMarker );
809  if ( aMarker )
810  {
811  a2dText* aPrompt = aMarker->GetPrompt();
812  if ( aPrompt )
813  aPrompt->Mirror(); // aPrompt->Mirror(m_yaxis,!m_yaxis);
814  }
815  }
816  }
817 }
818 
820 {
821  m_pTicFormatter = pFormatter;
822  m_pTicFormatter->SetAxis( this );
823  SetPending( TRUE );
824 }
825 
826 double a2dCurveAxis::GetTicStart() const
827 {
828  double tic = GetTic();
829  double ticstart = floor( m_min / tic + 0.5 ) * tic;
830  if ( ( tic > 0. && ticstart <= m_min ) || ( tic < 0. && ticstart >= m_min ) )
831  ticstart += tic;
832  return ticstart;
833 }
834 
835 
836 
837 //----------------------------------------------------------------------------
838 // a2dCurveAxisLin
839 //----------------------------------------------------------------------------
840 
841 a2dCurveAxisLin::a2dCurveAxisLin( double length, bool yaxis )
842  : a2dCurveAxis( length, yaxis )
843 {
844 }
845 
846 a2dCurveAxisLin::~a2dCurveAxisLin()
847 {
848 }
849 
850 a2dCurveAxisLin::a2dCurveAxisLin( const a2dCurveAxisLin& other, CloneOptions options, a2dRefMap* refs )
851  : a2dCurveAxis( other, options, refs )
852 {
853 }
854 
856 {
857  return new a2dCurveAxisLin( *this, options, refs );
858 }
859 
860 #if wxART2D_USE_CVGIO
861 void a2dCurveAxisLin::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
862 {
863  a2dCurveAxis::DoSave( parent, out, xmlparts, towrite );
864  if ( xmlparts == a2dXmlSer_attrib )
865  {
866  }
867  else
868  {
869  }
870 }
871 
872 void a2dCurveAxisLin::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
873 {
874  a2dCurveAxis::DoLoad( parent, parser, xmlparts );
875  if ( xmlparts == a2dXmlSer_attrib )
876  {
877  }
878  else
879  {
880  }
881 }
882 #endif //wxART2D_USE_CVGIO
883 
884 //! expand a2dBoundingBox to x,y,w,h
885 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
886 
887 void a2dCurveAxisLin::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
888 {
889  double tic;
890  double ticheight;
891  double tictextheight;
892  double length;
893  a2dAffineMatrix internalTransform;
894 
895  // For debugging
896 // ic.GetDrawer2D()->SetDrawerFill(a2dWHITE_FILL);
897 // ic.GetDrawer2D()->DrawRoundedRectangle(BBOX2XYWH(m_untransbbox), 0);
898 
899  double tictextsize = m_yaxis ? m_untransbboxtictext.GetHeight() : m_untransbboxtictext.GetWidth();
900  tic = GetTic();
901  ticheight = GetTicHeight();
902  tictextheight = m_font.GetSize();
903  length = GetLength();
904 
905  double sizeticstroke = m_stroketic.GetWidth();
906 
908  if ( propSpec )
909  {
910  a2dMatrixProperty* propMatrix = wxStaticCast( propSpec, a2dMatrixProperty );
911  internalTransform = propMatrix->GetValue();
912  }
913  /*
914  if (!internalTransform.IsIdentity())
915  {
916  ticheight = internalTransform.TransformDistance(ticheight);
917  tictextheight = internalTransform.TransformDistance(tictextheight);
918  }
919  */
920 
921  double x;
922 
923  if ( m_yaxis )
924  ic.GetDrawer2D()->DrawLine( 0, 0, 0, m_length );
925  else
926  ic.GetDrawer2D()->DrawLine( 0, 0, m_length, 0 );
927 
928  if ( m_showtics )
929  {
930  int hasLevels = HasLevelMarkers() ? 1 : 0;
931 
932  // it is better then tictextheight and ticheight transforming.
933  // it is better for different scale by X and by Y
934  if ( !internalTransform.IsIdentity() )
935  {
936  double scalex = internalTransform.Get_scaleX();
937  double scaley = internalTransform.Get_scaleY();
938  if ( m_yaxis )
939  {
940  length = length / scaley;
941  sizeticstroke = sizeticstroke / scaley;
942  }
943  else
944  {
945  length = length / scalex;
946  sizeticstroke = sizeticstroke / scalex;
947  }
948  }
949  a2dIterCU cu( ic, internalTransform );
950 
951  double ticstart;
952  ic.GetDrawer2D()->SetDrawerStroke( m_stroketictext );
954 
955  ticstart = floor( m_min / tic + 0.5 ) * tic;
956  if ( ( tic > 0 && ticstart < m_min ) || ( tic < 0 && ticstart > m_min ) )
957  ticstart += tic;
958 
959  ic.GetDrawer2D()->SetFont( m_font );
960  if ( m_sidetic )
961  {
962  //add tics
963  double textticpos = ticheight * ( 1.2 + hasLevels );
964  double textmax = m_max; //m_units.IsEmpty() ? m_max : m_max - tic;
965  for ( x = ticstart; ( tic > 0 && x <= textmax ) || ( tic < 0 && x >= textmax ); x = x + tic )
966  {
967  double dTicValue;
968  if ( m_max != m_ticmax || m_min != m_ticmin )
969  dTicValue = ( x - m_min ) / ( m_max - m_min ) * ( m_ticmax - m_ticmin ) + m_ticmin;
970  else
971  dTicValue = x;
972 
973  double xy = ( x - m_min ) / ( m_max - m_min ) * length;
974 
975  wxString ticstr = m_pTicFormatter->GetTicText( dTicValue );
976 
977  if ( m_yaxis )
978  {
979  if ( m_inverttic )
980  ic.GetDrawer2D()->DrawText( ticstr, textticpos, xy, wxMINX );
981  else
982  ic.GetDrawer2D()->DrawText( ticstr, -textticpos, xy, wxMAXX );
983  }
984  else
985  {
986  if ( m_inverttic )
987  ic.GetDrawer2D()->DrawText( ticstr, xy, textticpos, wxMINY );
988  else
989  ic.GetDrawer2D()->DrawText( ticstr, xy, -textticpos, wxMAXY );
990  }
991  }
992  if ( !m_units.IsEmpty() )
993  {
994  ic.GetDrawer2D()->SetDrawerStroke( m_strokeunits );
995  if ( m_yaxis )
996  {
997  if ( m_inverttic )
998  ic.GetDrawer2D()->DrawText( m_units, textticpos, m_max > m_min ? length : 0, wxMINX );
999  else
1000  ic.GetDrawer2D()->DrawText( m_units, -textticpos, m_max > m_min ? length : 0, wxMAXX );
1001  }
1002  else
1003  {
1004  if( m_inverttic )
1005  ic.GetDrawer2D()->DrawText( m_units, m_max > m_min ? length : 0, textticpos, wxMINY | ( m_max > m_min ? wxMINX : wxMAXX ) );
1006  else
1007  ic.GetDrawer2D()->DrawText( m_units, m_max > m_min ? length : 0, -textticpos, wxMAXY | ( m_max > m_min ? wxMINX : wxMAXX ) );
1008  }
1009  }
1010 
1011  ic.GetDrawer2D()->SetDrawerStroke( m_stroketic );
1012 
1013  //add tics
1014  double ticsize = ticheight * ( 1.1 + hasLevels );
1015  for ( x = ticstart; ( tic > 0 && x <= m_max ) || ( tic < 0 && x >= m_max ); x = x + tic )
1016  {
1017  double xy = ( x - m_min ) / ( m_max - m_min ) * length;
1018  if ( m_yaxis )
1019  {
1020  if ( m_inverttic )
1021  ic.GetDrawer2D()->DrawLine( -ticheight, xy, ticsize, xy );
1022  else
1023  ic.GetDrawer2D()->DrawLine( -ticsize, xy, ticheight, xy );
1024  }
1025  else
1026  {
1027  if ( m_inverttic )
1028  ic.GetDrawer2D()->DrawLine( xy, -ticheight, xy, ticsize );
1029  else
1030  ic.GetDrawer2D()->DrawLine( xy, -ticsize, xy, ticheight );
1031  }
1032  }
1033  }
1034  else
1035  {
1036  double textticpos = ticheight * ( 0.5 + hasLevels );
1037  double textmax = m_max; //m_units.IsEmpty() ? m_max : m_max - tic;
1038  double transformedTic = fabs( tic ) / fabs( m_max - m_min ) * length;
1039  bool enDrawLastTic = transformedTic > ( 2 * tictextsize + 3 * sizeticstroke );
1040  //add tics
1041  for ( x = ticstart; ( tic > 0 && x <= textmax ) || ( tic < 0 && x >= textmax ); x = x + tic )
1042  {
1043  double dTicValue;
1044  if ( m_max != m_ticmax || m_min != m_ticmin )
1045  dTicValue = ( x - m_min ) / ( m_max - m_min ) * ( m_ticmax - m_ticmin ) + m_ticmin;
1046  else
1047  dTicValue = x;
1048 
1049  double xy = ( x - m_min ) / ( m_max - m_min ) * length;
1050 
1051  wxString ticstr = m_pTicFormatter->GetTicText( dTicValue );
1052 
1053  bool notLastTic = fabs( xy - length ) > tictextsize; //fabs(x - textmax) > tictextsize; // fabs(tic/2);
1054  if ( m_yaxis )
1055  {
1056  if ( m_units.IsEmpty() || notLastTic )
1057  {
1058  if ( m_inverttic )
1059  ic.GetDrawer2D()->DrawText( ticstr, textticpos, xy + sizeticstroke, wxMINY | wxMINX );
1060  else
1061  ic.GetDrawer2D()->DrawText( ticstr, - textticpos, xy + sizeticstroke, wxMINY | wxMAXX );
1062  }
1063  else if( enDrawLastTic )
1064  {
1065  if ( m_inverttic )
1066  ic.GetDrawer2D()->DrawText( ticstr, textticpos, xy - sizeticstroke, wxMAXY | wxMINX );
1067  else
1068  ic.GetDrawer2D()->DrawText( ticstr, - textticpos, xy - sizeticstroke, wxMAXY | wxMAXX );
1069  }
1070  }
1071  else
1072  {
1073  if( m_units.IsEmpty() || notLastTic )
1074  {
1075  if ( m_inverttic )
1076  ic.GetDrawer2D()->DrawText( ticstr, xy + sizeticstroke, textticpos, wxMINX | wxMINY );
1077  else
1078  ic.GetDrawer2D()->DrawText( ticstr, xy + sizeticstroke, -textticpos, wxMINX | wxMAXY );
1079  }
1080  else if( enDrawLastTic )
1081  {
1082  if ( m_inverttic )
1083  ic.GetDrawer2D()->DrawText( ticstr, xy - sizeticstroke, textticpos, wxMAXX | wxMINY );
1084  else
1085  ic.GetDrawer2D()->DrawText( ticstr, xy - sizeticstroke, -textticpos, wxMAXX | wxMAXY );
1086  }
1087  }
1088  }
1089  if ( !m_units.IsEmpty() )
1090  {
1091  ic.GetDrawer2D()->SetDrawerStroke( m_strokeunits );
1092  if ( m_yaxis )
1093  {
1094  if ( m_inverttic )
1095  ic.GetDrawer2D()->DrawText( m_units, textticpos, ( m_max > m_min ? length : 0 ) + sizeticstroke , wxMINY | wxMINX );
1096  else
1097  ic.GetDrawer2D()->DrawText( m_units, -textticpos, ( m_max > m_min ? length : 0 ) + sizeticstroke , wxMINY | wxMAXX );
1098  }
1099  else
1100  {
1101  if ( m_inverttic )
1102  ic.GetDrawer2D()->DrawText( m_units, ( m_max > m_min ? length : 0 ) - sizeticstroke, textticpos, ( m_max > m_min ? wxMINX : wxMAXX ) | wxMINY );
1103  else
1104  ic.GetDrawer2D()->DrawText( m_units, ( m_max > m_min ? length : 0 ) - sizeticstroke, -textticpos, ( m_max > m_min ? wxMINX : wxMAXX ) | wxMAXY );
1105  }
1106  }
1107 
1108  ic.GetDrawer2D()->SetDrawerStroke( m_stroketic );
1109 
1110  //add tics
1111  double ticsize = ticheight * ( 2 + hasLevels );
1112  for ( x = ticstart; ( tic > 0 && x <= m_max ) || ( tic < 0 && x >= m_max ); x = x + tic )
1113  {
1114  double xy = ( x - m_min ) / ( m_max - m_min ) * length;
1115  if ( m_yaxis )
1116  {
1117  if ( m_inverttic )
1118  ic.GetDrawer2D()->DrawLine( 0, xy, ticsize, xy );
1119  else
1120  ic.GetDrawer2D()->DrawLine( -ticsize, xy, 0, xy );
1121  }
1122  else
1123  {
1124  if ( m_inverttic )
1125  ic.GetDrawer2D()->DrawLine( xy, ticsize, xy, 0 );
1126  else
1127  ic.GetDrawer2D()->DrawLine( xy, -ticsize, xy, 0 );
1128  }
1129  }
1130  }
1131  }
1132 }
1133 
1134 
1135 
1136 #if 0
1137 //----------------------------------------------------------------------------
1138 // a2dCurveAxisArea
1139 //----------------------------------------------------------------------------
1140 
1141 a2dCurveAxisArea::a2dCurveAxisArea()
1142  : a2dCurveObject()
1143 {
1144 }
1145 
1146 a2dCurveAxisArea::~a2dCurveAxisArea()
1147 {
1148 }
1149 
1150 a2dObject* a2dCurveAxisArea::Clone( CloneOptions options ) const
1151 {
1152  return new a2dCurveAxisArea( *this, options );
1153 }
1154 
1155 a2dCurveAxisArea::a2dCurveAxisArea( const a2dCurveAxisArea& other, CloneOptions options )
1156  : a2dCurveObject( other, options )
1157 {
1158 }
1159 
1160 a2dCurveAxis* a2dCurveAxisArea::GetAxis( const wxString axisname )
1161 {
1162  a2dCanvasObjectList::iterator iter = GetChildObjectList()->begin();
1163  while( iter != GetChildObjectList()->end() )
1164  {
1165  if ( ( *iter )->GetName() == axisname )
1166  return ( a2dCurveAxis* ) ( *iter ).Get();
1167  ++iter;
1168  }
1169  return NULL;
1170 }
1171 
1172 a2dCurveAxis* a2dCurveAxisArea::GetAxis( int nIndex )
1173 {
1174  a2dCanvasObjectList::iterator iter = GetChildObjectList()->begin();
1175  int i = 0;
1176  while( ( i <= nIndex ) && ( iter != GetChildObjectList()->end() ) )
1177  {
1178  if ( i == nIndex )
1179  return ( a2dCurveAxis* ) ( *iter ).Get();
1180  ++iter;
1181  }
1182  return NULL;
1183 }
1184 
1185 bool a2dCurveAxisArea::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )//WXUNUSED(mode) )
1186 {
1187  a2dCurveAxis* pAxis;
1188  bool calc = FALSE;
1189  double dXPos = 0;
1190  double dYPos = 0;
1191  a2dPoint2D point;
1192  a2dBoundingBox bbox;
1193 
1194  forEachIn( a2dCanvasObjectList, GetChildObjectList() )
1195  {
1196  a2dCanvasObject* pObject = *iter;
1197  pAxis = wxDynamicCast( pObject, a2dCurveAxis );
1198  if ( pAxis )
1199  {
1200  point = pAxis->GetPosXY();
1201 // if ((dXPos != point.m_x) || (dYPos != point.m_y)) {
1202  pAxis->SetPosXY( dXPos, dYPos );
1203  calc = TRUE;
1204 // }
1205 // bbox = pAxis->GetBbox(); // Debug
1206  if ( pAxis->IsYAxis() )
1207  dXPos -= pAxis->GetBbox().GetWidth();
1208  else
1209  dYPos -= pAxis->GetBbox().GetHeight();
1210  }
1211  }
1212 
1213  if ( !m_bbox.GetValid() || calc )
1214  {
1215  m_bbox = DoGetUnTransformedBbox();
1216  m_bbox.MapBbox( m_lworld );
1217 
1218  return true;
1219  }
1220 
1221  return false;
1222 }
1223 
1224 a2dBoundingBox a2dCurveAxisArea::DoGetUnTransformedBbox( a2dBboxFlags flags ) const
1225 {
1226  a2dCurveAxis* pAxis;
1227  a2dBoundingBox bbox;
1228 
1229  forEachIn( a2dCanvasObjectList, GetChildObjectList() )
1230  {
1231  a2dCanvasObject* pObject = *iter;
1232  pAxis = wxDynamicCast( pObject, a2dCurveAxis );
1233  if ( pAxis )
1234  bbox.Expand( pAxis->GetBbox() );
1235  }
1236 
1237  if ( !bbox.GetValid() ) //no child or empty childlist secure
1238  {
1239  //no objects, therefore make the bounding box the x,y of this object
1240  bbox.Expand( 0, 0 );
1241  }
1242 
1243  return bbox;
1244 }
1245 
1246 void a2dCurveAxisArea::DoRender( a2dIterC& ic, OVERLAP clipparent )
1247 {
1248  bool bShowBbox = TRUE;
1249  a2dCurveAxis* pAxis = NULL;
1250 
1251  a2dCurveObject::DoRender( ic, clipparent );
1252 
1253  if ( bShowBbox )
1254  {
1255  ic.GetDrawer2D()->SetDrawerStroke( a2dStroke( wxColour( 0xff0000 ), 2, a2dSTROKE_SOLID ) );
1257  forEachIn( a2dCanvasObjectList, GetChildObjectList() )
1258  {
1259  a2dCanvasObject* pObject = *iter;
1260  pAxis = wxDynamicCast( pObject, a2dCurveAxis );
1261  if ( pAxis )
1262  {
1263  wxRect absareadev = pAxis->GetAbsoluteArea( ic );
1265  ic.GetDrawer2D()->DrawRoundedRectangle( absareadev.x, absareadev.y, absareadev.width, absareadev.height, 0 );
1266  ic.GetDrawer2D()->PopTransform();
1267  }
1268  }
1269  }
1270 }
1271 
1272 void a2dCurveAxisArea::SetLength( double length )
1273 {
1274  a2dCurveAxis* pAxis;
1275 
1276  if ( m_length != length )
1277  {
1278  forEachIn( a2dCanvasObjectList, GetChildObjectList() )
1279  {
1280  a2dCanvasObject* pObject = *iter;
1281  pAxis = wxDynamicCast( pObject, a2dCurveAxis );
1282  if ( pAxis )
1283  pAxis->SetLength( length );
1284  }
1285  m_length = length;
1286  SetPending( true );
1287  }
1288 }
1289 #endif
1290 
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 GetHeight() const
returns height of the boundingbox
Definition: bbox.cpp:334
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
double GetSize() const
Get the font size.
Definition: stylebase.cpp:2917
double m_max
maximum on axis (internal boundaries)
Definition: axis.h:274
#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
classes for plotting curve and pie data, and editing them.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: axis.cpp:872
void SetFormatter(a2dTicFormatter *pFormatter)
Replace current tic formatter.
Definition: axis.cpp:819
property to hold a a2dAffineMatrix
Definition: afmatrix.h:410
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
Font info class, used as a single element for enumerating fonts.
Definition: stylebase.h:686
virtual void PopTransform(void)
Recall the previously saved user-to-world transform off the matrix stack.
Definition: drawer2d.cpp:480
XMLeventType Next()
Walks to next element and returns event type.
Definition: genxmlpars.cpp:422
bool RequireAttributeValueBool(const wxString &attrib)
Forces an attribute and returns its boolean value.
Definition: genxmlpars.cpp:551
void ParseString(wxString string)
Fill this class from a string.
Definition: stylebase.cpp:120
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
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: axis.cpp:855
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: axis.cpp:68
const a2dAffineMatrix & GetInverseTransform() const
Inverse of GetTransform()
Definition: canobj.cpp:699
Ref Counted base object.
Definition: gen.h:1045
void SetTicTextStroke(const a2dStroke &stroke)
Set a stroke for tics text.
Definition: axis.cpp:406
proptype * GetPropertyListOnly(const a2dObject *obj) const
Get the property from the list in obj ( no members, not cloned )
Definition: id.inl:318
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
double m_ticmin
tic scale minimum on axis
Definition: axis.h:277
double DeviceToWorldYRel(double y) const
convert y relative from device to world coordinates
Definition: drawer2d.h:449
wxString CreateString()
Create a string description of the font.
Definition: stylebase.cpp:2887
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Definition: drawer2d.cpp:565
bool IsIdentity(void) const
Is the matrix the identity matrix?
Definition: afmatrix.h:147
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 SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
double GetTic() const
get distance of tic lines in X/Y (curve coords)
Definition: axis.h:181
double m_length
length in parent world coordinates
Definition: axis.h:269
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: axis.cpp:488
double m_ticmax
tic scale maximum on axis
Definition: axis.h:279
The base class for all drawable objects in a a2dCanvasDocument.
void SetTicBoundaries(double min, double max)
Definition: axis.cpp:268
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
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dCanvas * GetCanvas() const
Get the Display window of the a2dView. But casted to a a2dCanvas.
Definition: drawer.h:525
double m_position
position of axis
Definition: axis.h:282
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
a2dCanvas uses a2dCanvasView for displaying a view on a a2dCanvasDocument.
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
double TransformDistance(double distance) const
Transform a distance.
Definition: afmatrix.cpp:616
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
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
Definition: gen.cpp:1305
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
Definition: genxmlpars.cpp:862
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
This is here so that this class cannot be used directly.
Definition: axis.cpp:177
a2dCurveObject for objects needing to know its parent a2dCurvesArea.
Definition: curve.h:42
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
Definition: drawer2d.cpp:621
bool IsYAxis() const
return true is this axis is Yaxis
Definition: axis.h:163
void WriteNewLine()
Writes a new line and takes care of indentation.
Definition: genxmlpars.cpp:890
a2dText is an abstract base class.
Definition: cantext.h:93
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
Definition: objlist.cpp:53
void Mirror(bool x=true, bool y=false)
Mirrors this object in x or y orientation.
Definition: canobj.cpp:2639
a2dTicFormatter()
default constructor
Definition: axis.cpp:52
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
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
a2dCanvasObjectList * m_childobjects
holds child objects
Definition: canobj.h:2562
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
virtual void DoUpdateViewDependentObjects(a2dIterC &ic)
update derived objects
Definition: canobj.cpp:4657
virtual ~a2dTimeTicFormatter()
destructor
Definition: axis.cpp:89
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
base class for axis in a2dCanvasXYDisplayGroup
Definition: axis.h:340
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
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: axis.cpp:349
static a2dFont CreateFont(const a2dFontInfo &info, bool force=false)
Create the font from a fontinfo description.
Definition: stylebase.cpp:3163
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
void SetLength(double length)
set length in world coordinates ( not axis coordinates )
Definition: axis.cpp:278
void SetAxis(a2dCurveAxis *axis)
Set the parent axis that owns this formatter. Used by a2dCurveAxis::SetFormatter() ...
Definition: axis.h:44
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
void SetTicStroke(const a2dStroke &stroke)
Set a stroke for tics.
Definition: axis.cpp:400
virtual wxString GetTicText(double dTicValue) const
Default implementation. Returns printf(m_format, dTicValue)
Definition: axis.cpp:74
wxString RequireAttributeValue(const wxString &attrib)
Forces an attribute and returns its string value.
Definition: genxmlpars.cpp:461
virtual ~a2dTicFormatter()
destructor
Definition: axis.cpp:58
bool m_yaxis
is this an Y axis
Definition: axis.h:285
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: axis.cpp:307
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
bool m_showtics
if true tics are displayed
Definition: axis.h:288
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
a2dPoint2D GetPosXY() const
get position of object
Definition: canobj.h:533
double GetAttributeValueDouble(const wxString &attrib, double defaultv=0)
Returns the double value of an attribute.
Definition: genxmlpars.cpp:474
double GetLength() const
get length in world coordinates.
Definition: axis.h:160
if set, set in the clone the PROPID_editcopy property to the original object
Definition: gen.h:1215
double GetPosY() const
get y position from affine matrix
Definition: canobj.h:530
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: axis.cpp:861
void MapBbox(const a2dAffineMatrix &matrix)
Definition: bbox.cpp:445
double Get_scaleX() const
return scaling in X
Definition: afmatrix.cpp:755
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
virtual void Load(wxObject *parent, a2dIOHandlerXmlSerIn &parser)
load object from CVG file
Definition: gen.cpp:1396
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
Definition: genxmlpars.cpp:450
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: axis.cpp:887
void SetBoundaries(double min, double max)
define which part is displayed on this axis
Definition: axis.cpp:225
editing tool for a2dCanvasObject&#39;s
double GetWidth() const
returns width of the boundingbox
Definition: bbox.cpp:328
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
Definition: genxmlpars.cpp:390
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
Definition: canobj.cpp:1624
if set, clone members (e.g. line end styles), otherwise ref-copy them
Definition: gen.h:1203
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
void DoUpdateViewDependentObjects(a2dIterC &ic)
update derived objects
Definition: axis.cpp:424
double m_min
minimum on axis (internal boundaries)
Definition: axis.h:272
a2dFont m_font
tic font
Definition: axis.h:306
float GetWidth() const
Definition: stylebase.cpp:6281
double Get_scaleY() const
return scaling in Y
Definition: afmatrix.cpp:777
#define const_forEachIn(listtype, list)
easy const iteration for a2dlist
Definition: a2dlist.h:118
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.
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
Definition: gen.cpp:1343
a2dDrawingPart * GetDrawingPart() const
get current a2dDrawingPart
Definition: canobj.cpp:631
double RequireAttributeValueDouble(const wxString &attrib)
Forces an attribute and returns its double value.
Definition: genxmlpars.cpp:487
wxRect GetAbsoluteArea(a2dIterC &ic, int inflate=2)
Get absolute occupied area in the device coordinates.
Definition: canobj.cpp:3199
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
a2dStrokeStyle
stroke styles for a2dStroke
Definition: stylebase.h:298
For Markers on an Axis.
Definition: marker.h:181
a2dTimeTicFormatter()
default constructor
Definition: axis.cpp:83
list of a2dObject&#39;s
Definition: gen.h:3157
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
base class for axis tic formatter
Definition: axis.h:31
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
Definition: drawer2d.h:444
CloneOptions
options for cloning
Definition: gen.h:1200
void SetTicFormat(const wxString &format)
Set how tic text is formated/displayed.
Definition: axis.cpp:93
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
virtual void PushIdentityTransform()
push no transform, to draw directly in device coordinates
Definition: drawer2d.cpp:469
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
void WriteStartElement(const wxString &name, bool newLine=true)
Writes start tag which has no attributes.
Definition: genxmlpars.cpp:738
double GetTicTextHeight() const
return size of font
Definition: axis.h:194
axis.cpp Source File -- Sun Oct 12 2014 17:04:12 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation