qwt_polar_grid.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * QwtPolar Widget Library
3  * Copyright (C) 2008 Uwe Rathmann
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the Qwt License, Version 1.0
7  *****************************************************************************/
8 
9 #include "qwt_polar_grid.h"
10 #include "qwt_painter.h"
11 #include "qwt_text.h"
12 #include "qwt_clipper.h"
13 #include "qwt_scale_map.h"
14 #include "qwt_scale_engine.h"
15 #include "qwt_scale_div.h"
16 #include "qwt_scale_draw.h"
17 #include "qwt_round_scale_draw.h"
18 
19 #include <qpainter.h>
20 #include <qpen.h>
21 #include <float.h>
22 
23 static inline bool isClose( double value1, double value2 )
24 {
25  return qAbs( value1 - value2 ) < DBL_EPSILON;
26 }
27 
28 namespace
29 {
30  class AxisData
31  {
32  public:
33  AxisData()
34  : isVisible( false )
35  , scaleDraw( NULL )
36  {
37  }
38 
39  ~AxisData()
40  {
41  delete scaleDraw;
42  }
43 
44  bool isVisible;
45  mutable QwtAbstractScaleDraw* scaleDraw;
46  QPen pen;
47  QFont font;
48  };
49 
50  class GridData
51  {
52  public:
53  GridData()
54  : isVisible( true )
55  , isMinorVisible( false )
56  {
57  }
58 
59  bool isVisible;
60  bool isMinorVisible;
61  QwtScaleDiv scaleDiv;
62 
63  QPen majorPen;
64  QPen minorPen;
65  };
66 }
67 
69 {
70  public:
73  QwtPolarGrid::DisplayFlags displayFlags;
74  QwtPolarGrid::GridAttributes attributes;
75 };
76 
85  : QwtPolarItem( QwtText( "Grid" ) )
86 {
87  m_data = new PrivateData;
88 
89  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
90  {
91  AxisData& axis = m_data->axisData[axisId];
92  switch( axisId )
93  {
95  {
96  axis.scaleDraw = new QwtRoundScaleDraw;
97  axis.scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 2 );
98  axis.scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 2 );
99  axis.scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 4 );
100  axis.isVisible = true;
101  break;
102  }
103  case QwtPolar::AxisLeft:
104  {
107 
108  axis.scaleDraw = scaleDraw;
109  axis.isVisible = false;
110  break;
111  }
112  case QwtPolar::AxisRight:
113  {
116 
117  axis.scaleDraw = scaleDraw;
118  axis.isVisible = true;
119  break;
120  }
121  case QwtPolar::AxisTop:
122  {
125 
126  axis.scaleDraw = scaleDraw;
127  axis.isVisible = false;
128  break;
129  }
131  {
134 
135  axis.scaleDraw = scaleDraw;
136  axis.isVisible = true;
137  break;
138  }
139  default:;
140  }
141  }
142 
144 
145  m_data->displayFlags = DisplayFlags();
151 
152  setZ( 10.0 );
154 }
155 
158 {
159  delete m_data;
160 }
161 
164 {
166 }
167 
175 {
176  if ( ( ( m_data->displayFlags & flag ) != 0 ) != on )
177  {
178  if ( on )
179  m_data->displayFlags |= flag;
180  else
181  m_data->displayFlags &= ~flag;
182 
183  itemChanged();
184  }
185 }
186 
192 {
193  return ( m_data->displayFlags & flag );
194 }
195 
206 {
207  if ( bool( m_data->attributes & attribute ) == on )
208  return;
209 
210  if ( on )
211  m_data->attributes |= attribute;
212  else
213  m_data->attributes &= ~attribute;
214 
215  itemChanged();
216 }
217 
223 {
224  return m_data->attributes & attribute;
225 }
226 
235 void QwtPolarGrid::setAxisPen( int axisId, const QPen& pen )
236 {
237  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
238  return;
239 
240  AxisData& axisData = m_data->axisData[axisId];
241  if ( axisData.pen != pen )
242  {
243  axisData.pen = pen;
244  itemChanged();
245  }
246 }
247 
254 void QwtPolarGrid::showGrid( int scaleId, bool show )
255 {
256  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
257  return;
258 
259  GridData& grid = m_data->gridData[scaleId];
260  if ( grid.isVisible != show )
261  {
262  grid.isVisible = show;
263  itemChanged();
264  }
265 }
266 
272 bool QwtPolarGrid::isGridVisible( int scaleId ) const
273 {
274  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
275  return false;
276 
277  return m_data->gridData[scaleId].isVisible;
278 }
279 
290 void QwtPolarGrid::showMinorGrid( int scaleId, bool show )
291 {
292  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
293  return;
294 
295  GridData& grid = m_data->gridData[scaleId];
296  if ( grid.isMinorVisible != show )
297  {
298  grid.isMinorVisible = show;
299  itemChanged();
300  }
301 }
302 
308 bool QwtPolarGrid::isMinorGridVisible( int scaleId ) const
309 {
310  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
311  return false;
312 
313  return m_data->gridData[scaleId].isMinorVisible;
314 }
315 
324 void QwtPolarGrid::showAxis( int axisId, bool show )
325 {
326  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
327  return;
328 
329  AxisData& axisData = m_data->axisData[axisId];
330  if ( axisData.isVisible != show )
331  {
332  axisData.isVisible = show;
333  itemChanged();
334  }
335 }
336 
343 bool QwtPolarGrid::isAxisVisible( int axisId ) const
344 {
345  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
346  return false;
347 
348  return m_data->axisData[axisId].isVisible;
349 }
350 
357 void QwtPolarGrid::setPen( const QPen& pen )
358 {
359  bool isChanged = false;
360 
361  for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
362  {
363  GridData& grid = m_data->gridData[scaleId];
364  if ( grid.majorPen != pen || grid.minorPen != pen )
365  {
366  grid.majorPen = pen;
367  grid.minorPen = pen;
368  isChanged = true;
369  }
370  }
371  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
372  {
373  AxisData& axis = m_data->axisData[axisId];
374  if ( axis.pen != pen )
375  {
376  axis.pen = pen;
377  isChanged = true;
378  }
379  }
380  if ( isChanged )
381  itemChanged();
382 }
383 
390 void QwtPolarGrid::setFont( const QFont& font )
391 {
392  bool isChanged = false;
393  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
394  {
395  AxisData& axis = m_data->axisData[axisId];
396  if ( axis.font != font )
397  {
398  axis.font = font;
399  isChanged = true;
400  }
401  }
402  if ( isChanged )
403  itemChanged();
404 }
405 
412 void QwtPolarGrid::setMajorGridPen( const QPen& pen )
413 {
414  bool isChanged = false;
415 
416  for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
417  {
418  GridData& grid = m_data->gridData[scaleId];
419  if ( grid.majorPen != pen )
420  {
421  grid.majorPen = pen;
422  isChanged = true;
423  }
424  }
425  if ( isChanged )
426  itemChanged();
427 }
428 
436 void QwtPolarGrid::setMajorGridPen( int scaleId, const QPen& pen )
437 {
438  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
439  return;
440 
441  GridData& grid = m_data->gridData[scaleId];
442  if ( grid.majorPen != pen )
443  {
444  grid.majorPen = pen;
445  itemChanged();
446  }
447 }
448 
454 QPen QwtPolarGrid::majorGridPen( int scaleId ) const
455 {
456  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
457  return QPen();
458 
459  const GridData& grid = m_data->gridData[scaleId];
460  return grid.majorPen;
461 }
462 
469 void QwtPolarGrid::setMinorGridPen( const QPen& pen )
470 {
471  bool isChanged = false;
472 
473  for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
474  {
475  GridData& grid = m_data->gridData[scaleId];
476  if ( grid.minorPen != pen )
477  {
478  grid.minorPen = pen;
479  isChanged = true;
480  }
481  }
482  if ( isChanged )
483  itemChanged();
484 }
485 
493 void QwtPolarGrid::setMinorGridPen( int scaleId, const QPen& pen )
494 {
495  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
496  return;
497 
498  GridData& grid = m_data->gridData[scaleId];
499  if ( grid.minorPen != pen )
500  {
501  grid.minorPen = pen;
502  itemChanged();
503  }
504 }
505 
510 QPen QwtPolarGrid::minorGridPen( int scaleId ) const
511 {
512  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
513  return QPen();
514 
515  const GridData& grid = m_data->gridData[scaleId];
516  return grid.minorPen;
517 }
518 
525 QPen QwtPolarGrid::axisPen( int axisId ) const
526 {
527  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
528  return QPen();
529 
530  return m_data->axisData[axisId].pen;
531 }
532 
539 void QwtPolarGrid::setAxisFont( int axisId, const QFont& font )
540 {
541  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
542  return;
543 
544  AxisData& axisData = m_data->axisData[axisId];
545  if ( axisData.font != font )
546  {
547  axisData.font = font;
548  itemChanged();
549  }
550 }
551 
556 QFont QwtPolarGrid::axisFont( int axisId ) const
557 {
558  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
559  return QFont();
560 
561  return m_data->axisData[axisId].font;
562 }
563 
574 void QwtPolarGrid::draw( QPainter* painter,
575  const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
576  const QPointF& pole, double radius,
577  const QRectF& canvasRect ) const
578 {
579  updateScaleDraws( azimuthMap, radialMap, pole, radius );
580 
581  painter->save();
582 
584  {
585  QRegion clipRegion( canvasRect.toRect() );
586  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
587  {
588  const AxisData& axis = m_data->axisData[axisId];
589  if ( axisId != QwtPolar::AxisAzimuth && axis.isVisible )
590  {
591  QwtScaleDraw* scaleDraw = static_cast< QwtScaleDraw* >( axis.scaleDraw );
593  {
594  const QList< double >& ticks =
596  for ( int i = 0; i < int( ticks.size() ); i++ )
597  {
598  if ( !scaleDraw->scaleDiv().contains( ticks[i] ) )
599  continue;
600 
601  QRect labelRect =
602  scaleDraw->boundingLabelRect( axis.font, ticks[i] );
603 
604  const int margin = 2;
605  labelRect.adjust( -margin, -margin, margin, margin );
606 
607  if ( labelRect.isValid() )
608  clipRegion -= QRegion( labelRect );
609  }
610  }
611  }
612  }
613  painter->setClipRegion( clipRegion );
614  }
615 
616  // draw radial grid
617 
618  const GridData& radialGrid = m_data->gridData[QwtPolar::Radius];
619  if ( radialGrid.isVisible && radialGrid.isMinorVisible )
620  {
621  painter->setPen( radialGrid.minorPen );
622 
623  drawCircles( painter, canvasRect, pole, radialMap,
624  radialGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) );
625  drawCircles( painter, canvasRect, pole, radialMap,
626  radialGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) );
627  }
628  if ( radialGrid.isVisible )
629  {
630  painter->setPen( radialGrid.majorPen );
631 
632  drawCircles( painter, canvasRect, pole, radialMap,
633  radialGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) );
634  }
635 
636  // draw azimuth grid
637 
638  const GridData& azimuthGrid =
640 
641  if ( azimuthGrid.isVisible && azimuthGrid.isMinorVisible )
642  {
643  painter->setPen( azimuthGrid.minorPen );
644 
645  drawRays( painter, canvasRect, pole, radius, azimuthMap,
646  azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) );
647  drawRays( painter, canvasRect, pole, radius, azimuthMap,
648  azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) );
649  }
650  if ( azimuthGrid.isVisible )
651  {
652  painter->setPen( azimuthGrid.majorPen );
653 
654  drawRays( painter, canvasRect, pole, radius, azimuthMap,
655  azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) );
656  }
657  painter->restore();
658 
659  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
660  {
661  const AxisData& axis = m_data->axisData[axisId];
662  if ( axis.isVisible )
663  {
664  painter->save();
665  drawAxis( painter, axisId );
666  painter->restore();
667  }
668  }
669 }
670 
682  QPainter* painter, const QRectF& canvasRect,
683  const QPointF& pole, double radius,
684  const QwtScaleMap& azimuthMap, const QList< double >& values ) const
685 {
686  for ( int i = 0; i < int( values.size() ); i++ )
687  {
688  double azimuth = azimuthMap.transform( values[i] );
689  azimuth = ::fmod( azimuth, 2 * M_PI );
690 
691  bool skipLine = false;
693  {
696  if ( isClose( azimuth, 0.0 ) )
697  {
698  const AxisData& axis = m_data->axisData[QwtPolar::AxisRight];
699  if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
700  skipLine = true;
701  }
702  else if ( isClose( azimuth, M_PI / 2 ) )
703  {
704  const AxisData& axis = m_data->axisData[QwtPolar::AxisTop];
705  if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
706  skipLine = true;
707  }
708  else if ( isClose( azimuth, M_PI ) )
709  {
710  const AxisData& axis = m_data->axisData[QwtPolar::AxisLeft];
711  if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
712  skipLine = true;
713  }
714  else if ( isClose( azimuth, 3 * M_PI / 2.0 ) )
715  {
716  const AxisData& axis = m_data->axisData[QwtPolar::AxisBottom];
717  if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
718  skipLine = true;
719  }
720  }
721  if ( !skipLine )
722  {
723  const QPointF pos = qwtPolar2Pos( pole, radius, azimuth );
724 
725  /*
726  Qt4 is horrible slow, when painting primitives,
727  with coordinates far outside the visible area.
728  */
729 
730  QPolygonF polygon( 2 );
731  polygon[0] = pole.toPoint();
732  polygon[1] = pos.toPoint();
733 
735  QwtClipper::clipPolygonF( canvasRect, polygon );
736 
737  QwtPainter::drawPolyline( painter, polygon );
738  }
739  }
740 }
741 
752  QPainter* painter, const QRectF& canvasRect,
753  const QPointF& pole, const QwtScaleMap& radialMap,
754  const QList< double >& values ) const
755 {
756  for ( int i = 0; i < int( values.size() ); i++ )
757  {
758  const double val = values[i];
759 
760  const GridData& gridData =
762 
763  bool skipLine = false;
765  {
766  const AxisData& axis = m_data->axisData[QwtPolar::AxisAzimuth];
767  if ( axis.isVisible &&
768  axis.scaleDraw->hasComponent( QwtAbstractScaleDraw::Backbone ) )
769  {
770  if ( isClose( val, gridData.scaleDiv.upperBound() ) )
771  skipLine = true;
772  }
773  }
774 
775  if ( isClose( val, gridData.scaleDiv.lowerBound() ) )
776  skipLine = true;
777 
778  if ( !skipLine )
779  {
780  const double radius = radialMap.transform( val );
781 
782  QRectF outerRect( 0, 0, 2 * radius, 2 * radius );
783  outerRect.moveCenter( pole );
784 
786  {
787  /*
788  Qt4 is horrible slow, when painting primitives,
789  with coordinates far outside the visible area.
790  We need to clip.
791  */
792 
793  const QVector< QwtInterval > angles =
794  QwtClipper::clipCircle( canvasRect, pole, radius );
795 
796  for ( int j = 0; j < angles.size(); j++ )
797  {
798  const QwtInterval intv = angles[j];
799 
800  if ( intv.minValue() == 0 && intv.maxValue() == 2 * M_PI )
801  {
802  QwtPainter::drawEllipse( painter, outerRect );
803  }
804  else
805  {
806  const double from = qwtDegrees( intv.minValue() );
807  const double to = qwtDegrees( intv.maxValue() );
808 
809  double span = to - from;
810  if ( span < 0.0 )
811  span += 360.0;
812 
813  painter->drawArc( outerRect,
814  qRound( from * 16 ), qRound( span * 16 ) );
815  }
816  }
817  }
818  else
819  {
820  QwtPainter::drawEllipse( painter, outerRect );
821  }
822  }
823  }
824 }
825 
832 void QwtPolarGrid::drawAxis( QPainter* painter, int axisId ) const
833 {
834  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
835  return;
836 
837  AxisData& axis = m_data->axisData[axisId];
838 
839  painter->setPen( axis.pen );
840  painter->setFont( axis.font );
841 
842  QPalette pal;
843  pal.setColor( QPalette::WindowText, axis.pen.color() );
844  pal.setColor( QPalette::Text, axis.pen.color() );
845 
846  axis.scaleDraw->draw( painter, pal );
847 }
848 
860  const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
861  const QPointF& pole, double radius ) const
862 {
863  const QPoint p = pole.toPoint();
864 
865  const QwtInterval interval =
866  m_data->gridData[QwtPolar::ScaleRadius].scaleDiv.interval();
867 
868  const int min = radialMap.transform( interval.minValue() );
869  const int max = radialMap.transform( interval.maxValue() );
870  const int l = max - min;
871 
872  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
873  {
874  AxisData& axis = m_data->axisData[axisId];
875 
876  if ( axisId == QwtPolar::AxisAzimuth )
877  {
879  static_cast< QwtRoundScaleDraw* >( axis.scaleDraw );
880 
881  scaleDraw->setRadius( qRound( radius ) );
882  scaleDraw->moveCenter( p );
883 
884  double from = ::fmod( 90.0 - qwtDegrees( azimuthMap.p1() ), 360.0 );
885  if ( from < 0.0 )
886  from += 360.0;
887 
888  scaleDraw->setAngleRange( from, from - 360.0 );
889 
890  const QwtTransform* transform = azimuthMap.transformation();
891  if ( transform )
892  scaleDraw->setTransformation( transform->copy() );
893  else
894  scaleDraw->setTransformation( NULL );
895  }
896  else
897  {
899  static_cast< QwtScaleDraw* >( axis.scaleDraw );
900 
901  switch( axisId )
902  {
903  case QwtPolar::AxisLeft:
904  {
905  scaleDraw->move( p.x() - min, p.y() );
906  scaleDraw->setLength( -l );
907  break;
908  }
909  case QwtPolar::AxisRight:
910  {
911  scaleDraw->move( p.x() + min, p.y() );
912  scaleDraw->setLength( l );
913  break;
914  }
915  case QwtPolar::AxisTop:
916  {
917  scaleDraw->move( p.x(), p.y() - max );
918  scaleDraw->setLength( l );
919  break;
920  }
922  {
923  scaleDraw->move( p.x(), p.y() + max );
924  scaleDraw->setLength( -l );
925  break;
926  }
927  }
928  const QwtTransform* transform = radialMap.transformation();
929  if ( transform )
930  scaleDraw->setTransformation( transform->copy() );
931  else
932  scaleDraw->setTransformation( NULL );
933  }
934  }
935 }
936 
952 void QwtPolarGrid::updateScaleDiv( const QwtScaleDiv& azimuthScaleDiv,
953  const QwtScaleDiv& radialScaleDiv, const QwtInterval& interval )
954 {
955  GridData& radialGrid = m_data->gridData[QwtPolar::Radius];
956 
957  const QwtPolarPlot* plt = plot();
958  if ( plt && testGridAttribute( AutoScaling ) )
959  {
960  const QwtScaleEngine* se = plt->scaleEngine( QwtPolar::Radius );
961  radialGrid.scaleDiv = se->divideScale(
962  interval.minValue(), interval.maxValue(),
964  plt->scaleMaxMinor( QwtPolar::Radius ), 0 );
965  }
966  else
967  {
968  if ( radialGrid.scaleDiv != radialScaleDiv )
969  radialGrid.scaleDiv = radialScaleDiv;
970  }
971 
972  GridData& azimuthGrid = m_data->gridData[QwtPolar::Azimuth];
973  if ( azimuthGrid.scaleDiv != azimuthScaleDiv )
974  {
975  azimuthGrid.scaleDiv = azimuthScaleDiv;
976  }
977 
978  bool hasOrigin = false;
979  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
980  {
981  AxisData& axis = m_data->axisData[axisId];
982  if ( axis.isVisible && axis.scaleDraw )
983  {
984  if ( axisId == QwtPolar::AxisAzimuth )
985  {
986  axis.scaleDraw->setScaleDiv( azimuthGrid.scaleDiv );
988  {
989  axis.scaleDraw->enableComponent(
990  QwtAbstractScaleDraw::Ticks, !azimuthGrid.isVisible );
991  }
992  }
993  else
994  {
995  QwtScaleDiv sd = radialGrid.scaleDiv;
996 
998 
1000  {
1001  bool skipOrigin = hasOrigin;
1002  if ( !skipOrigin )
1003  {
1004  if ( axisId == QwtPolar::AxisLeft
1005  || axisId == QwtPolar::AxisRight )
1006  {
1007  if ( m_data->axisData[QwtPolar::AxisBottom].isVisible )
1008  skipOrigin = true;
1009  }
1010  else
1011  {
1012  if ( m_data->axisData[QwtPolar::AxisLeft].isVisible )
1013  skipOrigin = true;
1014  }
1015  }
1016  if ( ticks.size() > 0 && ticks.first() == sd.lowerBound() )
1017  {
1018  if ( skipOrigin )
1019  ticks.removeFirst();
1020  else
1021  hasOrigin = true;
1022  }
1023  }
1024 
1026  {
1027  if ( ticks.size() > 0 && ticks.last() == sd.upperBound() )
1028  ticks.removeLast();
1029  }
1030 
1031  sd.setTicks( QwtScaleDiv::MajorTick, ticks );
1032  axis.scaleDraw->setScaleDiv( sd );
1033 
1035  {
1036  axis.scaleDraw->enableComponent(
1037  QwtAbstractScaleDraw::Ticks, !radialGrid.isVisible );
1038  }
1039 
1040  }
1041  }
1042  }
1043 }
1044 
1050 {
1051  const AxisData& axis = m_data->axisData[QwtPolar::AxisAzimuth];
1052  if ( axis.isVisible )
1053  {
1054  const int extent = axis.scaleDraw->extent( axis.font );
1055  return extent;
1056  }
1057 
1058  return 0;
1059 }
1060 
1068 const QwtScaleDraw* QwtPolarGrid::scaleDraw( int axisId ) const
1069 {
1070  if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
1071  return static_cast< QwtScaleDraw* >( m_data->axisData[axisId].scaleDraw );
1072 
1073  return NULL;
1074 }
1075 
1084 {
1085  if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
1086  return static_cast< QwtScaleDraw* >( m_data->axisData[axisId].scaleDraw );
1087 
1088  return NULL;
1089 }
1090 
1099 void QwtPolarGrid::setScaleDraw( int axisId, QwtScaleDraw* scaleDraw )
1100 {
1101  if ( axisId < QwtPolar::AxisLeft || axisId > QwtPolar::AxisBottom )
1102  return;
1103 
1104  AxisData& axisData = m_data->axisData[axisId];
1105  if ( axisData.scaleDraw != scaleDraw )
1106  {
1107  delete axisData.scaleDraw;
1108  axisData.scaleDraw = scaleDraw;
1109  itemChanged();
1110  }
1111 }
1112 
1118 {
1119  return static_cast< QwtRoundScaleDraw* >(
1120  m_data->axisData[QwtPolar::AxisAzimuth].scaleDraw );
1121 }
1122 
1128 {
1129  return static_cast< QwtRoundScaleDraw* >(
1130  m_data->axisData[QwtPolar::AxisAzimuth].scaleDraw );
1131 }
1132 
1140 {
1141  AxisData& axisData = m_data->axisData[QwtPolar::AxisAzimuth];
1142  if ( axisData.scaleDraw != scaleDraw )
1143  {
1144  delete axisData.scaleDraw;
1145  axisData.scaleDraw = scaleDraw;
1146  itemChanged();
1147  }
1148 }
QwtRoundScaleDraw
A class for drawing round scales.
Definition: qwt_round_scale_draw.h:31
QwtPolar::AxisRight
@ AxisRight
Right axis.
Definition: qwt_polar.h:61
QwtPolarGrid::rtti
virtual int rtti() const QWT_OVERRIDE
Definition: qwt_polar_grid.cpp:163
QwtPolarGrid::majorGridPen
QPen majorGridPen(int scaleId) const
Definition: qwt_polar_grid.cpp:454
QwtScaleDraw
A class for drawing scales.
Definition: qwt_scale_draw.h:35
QwtPolarGrid::ClipAxisBackground
@ ClipAxisBackground
Definition: qwt_polar_grid.h:72
QwtTransform::copy
virtual QwtTransform * copy() const =0
Virtualized copy operation.
QwtPolarItem::RenderAntialiased
@ RenderAntialiased
Enable antialiasing.
Definition: qwt_polar_item.h:95
QwtPolarPlot
A plotting widget, displaying a polar coordinate system.
Definition: qwt_polar_plot.h:46
QwtAbstractScaleDraw::setTransformation
void setTransformation(QwtTransform *)
Definition: qwt_abstract_scale_draw.cpp:115
QwtPolar::AxisAzimuth
@ AxisAzimuth
Azimuth axis.
Definition: qwt_polar.h:55
QwtPolarGrid::testDisplayFlag
bool testDisplayFlag(DisplayFlag) const
Definition: qwt_polar_grid.cpp:191
QwtPolar::ScaleCount
@ ScaleCount
Number of scales.
Definition: qwt_polar.h:86
QwtPolarGrid::setMinorGridPen
void setMinorGridPen(const QPen &p)
Definition: qwt_polar_grid.cpp:469
QwtAbstractScaleDraw::hasComponent
bool hasComponent(ScaleComponent) const
Definition: qwt_abstract_scale_draw.cpp:95
qwt_scale_div.h
QwtPolarGrid::PrivateData
Definition: qwt_polar_grid.cpp:68
QwtPolarGrid::axisPen
QPen axisPen(int axisId) const
Definition: qwt_polar_grid.cpp:525
QwtPolar::AxisBottom
@ AxisBottom
Bottom axis.
Definition: qwt_polar.h:67
QwtPainter::drawPolyline
static void drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
Definition: qwt_painter.cpp:578
QwtClipper::clipCircle
QWT_EXPORT QVector< QwtInterval > clipCircle(const QRectF &, const QPointF &, double radius)
Definition: qwt_clipper.cpp:477
QwtPolarGrid::isAxisVisible
bool isAxisVisible(int axisId) const
Definition: qwt_polar_grid.cpp:343
QwtScaleDiv::MediumTick
@ MediumTick
Medium ticks.
Definition: qwt_scale_div.h:46
QwtPolarGrid::updateScaleDraws
void updateScaleDraws(const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, const double radius) const
Definition: qwt_polar_grid.cpp:859
QwtScaleDraw::LeftScale
@ LeftScale
The scale is left.
Definition: qwt_scale_draw.h:51
QwtPolarGrid::PrivateData::gridData
GridData gridData[QwtPolar::ScaleCount]
Definition: qwt_polar_grid.cpp:71
QVector
Definition: qwt_clipper.h:23
QwtInterval::minValue
double minValue() const
Definition: qwt_interval.h:192
QwtPolarGrid::PrivateData::axisData
AxisData axisData[QwtPolar::AxesCount]
Definition: qwt_polar_grid.cpp:72
QwtTransform
A transformation between coordinate systems.
Definition: qwt_transform.h:35
QwtAbstractScaleDraw::Ticks
@ Ticks
Ticks.
Definition: qwt_abstract_scale_draw.h:45
QwtPolarGrid::marginHint
virtual int marginHint() const QWT_OVERRIDE
Definition: qwt_polar_grid.cpp:1049
QwtPolarGrid::setFont
void setFont(const QFont &)
Definition: qwt_polar_grid.cpp:390
QwtAbstractScaleDraw::scaleDiv
const QwtScaleDiv & scaleDiv() const
Definition: qwt_abstract_scale_draw.cpp:133
qwtPolar2Pos
QPoint qwtPolar2Pos(const QPoint &pole, double radius, double angle)
Definition: qwt_point_polar.h:137
QwtScaleDiv::lowerBound
double lowerBound() const
Definition: qwt_scale_div.cpp:131
QwtPolar::AxisTop
@ AxisTop
Top axis.
Definition: qwt_polar.h:64
QwtPolarGrid::m_data
PrivateData * m_data
Definition: qwt_polar_grid.h:176
QList< double >
QwtPolarGrid::setAzimuthScaleDraw
void setAzimuthScaleDraw(QwtRoundScaleDraw *)
Set a scale draw for the azimuth scale.
Definition: qwt_polar_grid.cpp:1139
QwtPolarGrid::PrivateData::attributes
QwtPolarGrid::GridAttributes attributes
Definition: qwt_polar_grid.cpp:74
QwtPolarGrid::scaleDraw
const QwtScaleDraw * scaleDraw(int axisId) const
Definition: qwt_polar_grid.cpp:1068
QwtPolarGrid::PrivateData::displayFlags
QwtPolarGrid::DisplayFlags displayFlags
Definition: qwt_polar_grid.cpp:73
QwtPolarGrid::ClipGridLines
@ ClipGridLines
Definition: qwt_polar_grid.h:85
QwtAbstractScaleDraw::Labels
@ Labels
Labels.
Definition: qwt_abstract_scale_draw.h:48
QwtPolarItem::setZ
void setZ(double z)
Set the z value.
Definition: qwt_polar_item.cpp:142
M_PI
#define M_PI
Definition: qwt_math.h:56
QwtScaleDiv::contains
bool contains(double value) const
Definition: qwt_scale_div.cpp:212
qwtDegrees
double qwtDegrees(double degrees)
Translate radians into degrees.
Definition: qwt_math.h:257
QwtScaleDiv::ticks
QList< double > ticks(int tickType) const
Definition: qwt_scale_div.cpp:309
QwtScaleMap::p1
double p1() const
Definition: qwt_scale_map.h:99
QwtScaleDiv::MajorTick
@ MajorTick
Major ticks.
Definition: qwt_scale_div.h:49
qwt_clipper.h
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:22
QwtAbstractScaleDraw::Backbone
@ Backbone
Backbone = the line where the ticks are located.
Definition: qwt_abstract_scale_draw.h:42
qwt_scale_map.h
QwtPolarGrid::draw
virtual void draw(QPainter *p, const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, double radius, const QRectF &rect) const QWT_OVERRIDE
Definition: qwt_polar_grid.cpp:574
QwtAbstractScaleDraw::ScaleComponent
ScaleComponent
Definition: qwt_abstract_scale_draw.h:39
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtPolarGrid::setMajorGridPen
void setMajorGridPen(const QPen &p)
Definition: qwt_polar_grid.cpp:412
QwtPolarItem::itemChanged
virtual void itemChanged()
Definition: qwt_polar_item.cpp:355
QwtPolarGrid::setAxisPen
void setAxisPen(int axisId, const QPen &p)
Definition: qwt_polar_grid.cpp:235
QwtPolarGrid::minorGridPen
QPen minorGridPen(int scaleId) const
Definition: qwt_polar_grid.cpp:510
QwtPolarItem::Rtti_PolarGrid
@ Rtti_PolarGrid
For QwtPolarGrid.
Definition: qwt_polar_item.h:52
QwtScaleDiv::upperBound
double upperBound() const
Definition: qwt_scale_div.cpp:151
QwtPolarGrid::showMinorGrid
void showMinorGrid(int scaleId, bool show=true)
Definition: qwt_polar_grid.cpp:290
qwt_scale_draw.h
QwtPolarItem
Base class for items on a polar plot.
Definition: qwt_polar_item.h:37
QwtScaleDraw::boundingLabelRect
QRect boundingLabelRect(const QFont &, double value) const
Find the bounding rectangle for the label.
Definition: qwt_scale_draw.cpp:794
QwtAbstractScaleDraw
A abstract base class for drawing scales.
Definition: qwt_abstract_scale_draw.h:31
QwtScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
QwtPolarItem::setRenderHint
void setRenderHint(RenderHint, bool on=true)
Definition: qwt_polar_item.cpp:234
QwtScaleDraw::move
void move(double x, double y)
Definition: qwt_scale_draw.h:118
QwtClipper::clipPolygonF
QWT_EXPORT void clipPolygonF(const QRectF &, QPolygonF &, bool closePolygon=false)
Definition: qwt_clipper.cpp:404
QwtPolar::Azimuth
@ Azimuth
Azimuth.
Definition: qwt_polar.h:42
QwtPolarPlot::scaleEngine
QwtScaleEngine * scaleEngine(int scaleId)
Definition: qwt_polar_plot.cpp:499
qwt_polar_grid.h
QwtScaleMap::transform
double transform(double s) const
Definition: qwt_scale_map.h:137
QwtPolarGrid::setGridAttribute
void setGridAttribute(GridAttribute, bool on=true)
Specify an attribute for the grid.
Definition: qwt_polar_grid.cpp:205
QwtPolarGrid::drawAxis
void drawAxis(QPainter *, int axisId) const
Definition: qwt_polar_grid.cpp:832
isClose
static bool isClose(double value1, double value2)
Definition: qwt_polar_grid.cpp:23
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:26
QwtPolarGrid::GridAttribute
GridAttribute
Grid attributes.
Definition: qwt_polar_grid.h:94
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:45
QwtPolarGrid::drawCircles
void drawCircles(QPainter *, const QRectF &, const QPointF &pole, const QwtScaleMap &radialMap, const QList< double > &) const
Definition: qwt_polar_grid.cpp:751
QwtPolarGrid::updateScaleDiv
virtual void updateScaleDiv(const QwtScaleDiv &azimuthMap, const QwtScaleDiv &radialMap, const QwtInterval &) QWT_OVERRIDE
Update the item to changes of the axes scale division.
Definition: qwt_polar_grid.cpp:952
QwtPolarGrid::setAxisFont
void setAxisFont(int axisId, const QFont &p)
Definition: qwt_polar_grid.cpp:539
QwtPolarGrid::SmartOriginLabel
@ SmartOriginLabel
Definition: qwt_polar_grid.h:58
QwtPolarGrid::~QwtPolarGrid
virtual ~QwtPolarGrid()
Destructor.
Definition: qwt_polar_grid.cpp:157
QwtScaleDraw::BottomScale
@ BottomScale
The scale is below.
Definition: qwt_scale_draw.h:45
QwtPolarGrid::setDisplayFlag
void setDisplayFlag(DisplayFlag, bool on=true)
Definition: qwt_polar_grid.cpp:174
udp_client.int
int
Definition: udp_client.py:11
QwtPolarGrid::isGridVisible
bool isGridVisible(int scaleId) const
Definition: qwt_polar_grid.cpp:272
qwt_painter.h
qwt_scale_engine.h
QwtPolarGrid::setScaleDraw
void setScaleDraw(int axisId, QwtScaleDraw *)
Set a scale draw.
Definition: qwt_polar_grid.cpp:1099
QwtPolarGrid::testGridAttribute
bool testGridAttribute(GridAttribute) const
Definition: qwt_polar_grid.cpp:222
QwtPolarGrid::QwtPolarGrid
QwtPolarGrid()
Constructor.
Definition: qwt_polar_grid.cpp:84
QwtScaleDiv::setTicks
void setTicks(int tickType, const QList< double > &)
Definition: qwt_scale_div.cpp:297
QwtPolar::ScaleRadius
@ ScaleRadius
Radial scale.
Definition: qwt_polar.h:83
QwtPolarGrid::DisplayFlag
DisplayFlag
Definition: qwt_polar_grid.h:52
qwt_round_scale_draw.h
QwtPolarPlot::scaleMaxMinor
int scaleMaxMinor(int scaleId) const
Definition: qwt_polar_plot.cpp:423
QwtInterval::maxValue
double maxValue() const
Definition: qwt_interval.h:198
QwtPolarGrid::showAxis
void showAxis(int axisId, bool show=true)
Definition: qwt_polar_grid.cpp:324
QwtPolarGrid::SmartScaleDraw
@ SmartScaleDraw
Definition: qwt_polar_grid.h:78
QwtPolarGrid::AutoScaling
@ AutoScaling
Definition: qwt_polar_grid.h:100
QwtPolarGrid::azimuthScaleDraw
const QwtRoundScaleDraw * azimuthScaleDraw() const
Definition: qwt_polar_grid.cpp:1117
QwtScaleDiv::MinorTick
@ MinorTick
Minor ticks.
Definition: qwt_scale_div.h:43
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:33
QwtPolarGrid::drawRays
void drawRays(QPainter *, const QRectF &, const QPointF &pole, double radius, const QwtScaleMap &azimuthMap, const QList< double > &) const
Definition: qwt_polar_grid.cpp:681
QwtPolarItem::plot
QwtPolarPlot * plot() const
Definition: qwt_polar_item.cpp:118
qwt_text.h
QwtScaleMap::transformation
const QwtTransform * transformation() const
Get the transformation.
Definition: qwt_scale_map.cpp:88
QwtPolarItem::show
void show()
Show the item.
Definition: qwt_polar_item.cpp:314
QwtPolarGrid::setPen
void setPen(const QPen &p)
Definition: qwt_polar_grid.cpp:357
QwtScaleDraw::setAlignment
void setAlignment(Alignment)
Definition: qwt_scale_draw.cpp:322
QwtPolarGrid::axisFont
QFont axisFont(int axisId) const
Definition: qwt_polar_grid.cpp:556
QwtScaleDraw::setLength
void setLength(double length)
Definition: qwt_scale_draw.cpp:732
QwtPolar::AxesCount
@ AxesCount
Number of available axis.
Definition: qwt_polar.h:70
QwtPolarGrid::isMinorGridVisible
bool isMinorGridVisible(int scaleId) const
Definition: qwt_polar_grid.cpp:308
QwtPainter::drawEllipse
static void drawEllipse(QPainter *, const QRectF &)
Wrapper for QPainter::drawEllipse()
Definition: qwt_painter.cpp:426
QwtPolarPlot::scaleMaxMajor
int scaleMaxMajor(int scaleId) const
Definition: qwt_polar_plot.cpp:460
QwtPolarGrid::showGrid
void showGrid(int scaleId, bool show=true)
Definition: qwt_polar_grid.cpp:254
QwtPolar::AxisLeft
@ AxisLeft
Left axis.
Definition: qwt_polar.h:58
QwtPolar::Radius
@ Radius
Radius.
Definition: qwt_polar.h:45
QwtPolarGrid::HideMaxRadiusLabel
@ HideMaxRadiusLabel
Definition: qwt_polar_grid.h:64


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46