qwt_plot.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_plot.h"
11 #include "qwt_plot_dict.h"
12 #include "qwt_plot_layout.h"
13 #include "qwt_scale_widget.h"
14 #include "qwt_scale_engine.h"
15 #include "qwt_text_label.h"
16 #include "qwt_legend.h"
17 #include "qwt_legend_data.h"
18 #include "qwt_plot_canvas.h"
19 #include <qmath.h>
20 #include <qpainter.h>
21 #include <qpointer.h>
22 #include <qpaintengine.h>
23 #include <qapplication.h>
24 #include <qevent.h>
25 
26 static inline void qwtEnableLegendItems( QwtPlot *plot, bool on )
27 {
28  if ( on )
29  {
30  QObject::connect(
31  plot, SIGNAL( legendDataChanged(
32  const QVariant &, const QList<QwtLegendData> & ) ),
33  plot, SLOT( updateLegendItems(
34  const QVariant &, const QList<QwtLegendData> & ) ) );
35  }
36  else
37  {
38  QObject::disconnect(
39  plot, SIGNAL( legendDataChanged(
40  const QVariant &, const QList<QwtLegendData> & ) ),
41  plot, SLOT( updateLegendItems(
42  const QVariant &, const QList<QwtLegendData> & ) ) );
43  }
44 }
45 
46 static void qwtSetTabOrder(
47  QWidget *first, QWidget *second, bool withChildren )
48 {
49  QList<QWidget *> tabChain;
50  tabChain += first;
51  tabChain += second;
52 
53  if ( withChildren )
54  {
55  QList<QWidget *> children = second->findChildren<QWidget *>();
56 
57  QWidget *w = second->nextInFocusChain();
58  while ( children.contains( w ) )
59  {
60  children.removeAll( w );
61 
62  tabChain += w;
63  w = w->nextInFocusChain();
64  }
65  }
66 
67  for ( int i = 0; i < tabChain.size() - 1; i++ )
68  {
69  QWidget *from = tabChain[i];
70  QWidget *to = tabChain[i+1];
71 
72  const Qt::FocusPolicy policy1 = from->focusPolicy();
73  const Qt::FocusPolicy policy2 = to->focusPolicy();
74 
75  QWidget *proxy1 = from->focusProxy();
76  QWidget *proxy2 = to->focusProxy();
77 
78  from->setFocusPolicy( Qt::TabFocus );
79  from->setFocusProxy( NULL);
80 
81  to->setFocusPolicy( Qt::TabFocus );
82  to->setFocusProxy( NULL);
83 
84  QWidget::setTabOrder( from, to );
85 
86  from->setFocusPolicy( policy1 );
87  from->setFocusProxy( proxy1);
88 
89  to->setFocusPolicy( policy2 );
90  to->setFocusProxy( proxy2 );
91  }
92 }
93 
95 {
96 public:
97  QPointer<QwtTextLabel> titleLabel;
98  QPointer<QwtTextLabel> footerLabel;
99  QPointer<QWidget> canvas;
100  QPointer<QwtAbstractLegend> legend;
102 
104 };
105 
110 QwtPlot::QwtPlot( QWidget *parent ):
111  QFrame( parent )
112 {
113  initPlot( QwtText() );
114 }
115 
121 QwtPlot::QwtPlot( const QwtText &title, QWidget *parent ):
122  QFrame( parent )
123 {
124  initPlot( title );
125 }
126 
129 {
130  setAutoReplot( false );
132 
133  delete d_data->layout;
134  deleteAxesData();
135  delete d_data;
136 }
137 
143 {
144  d_data = new PrivateData;
145 
146  d_data->layout = new QwtPlotLayout;
147  d_data->autoReplot = false;
148 
149  // title
150  d_data->titleLabel = new QwtTextLabel( this );
151  d_data->titleLabel->setObjectName( "QwtPlotTitle" );
152  d_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
153 
154  QwtText text( title );
155  text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
156  d_data->titleLabel->setText( text );
157 
158  // footer
159  d_data->footerLabel = new QwtTextLabel( this );
160  d_data->footerLabel->setObjectName( "QwtPlotFooter" );
161 
162  QwtText footer;
163  footer.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
164  d_data->footerLabel->setText( footer );
165 
166  // legend
167  d_data->legend = NULL;
168 
169  // axis
170  initAxesData();
171 
172  // canvas
173  d_data->canvas = new QwtPlotCanvas( this );
174  d_data->canvas->setObjectName( "QwtPlotCanvas" );
175  d_data->canvas->installEventFilter( this );
176 
177  setSizePolicy( QSizePolicy::MinimumExpanding,
178  QSizePolicy::MinimumExpanding );
179 
180  resize( 200, 200 );
181 
182  QList<QWidget *> focusChain;
183  focusChain << this << d_data->titleLabel << axisWidget( xTop )
186 
187  for ( int i = 0; i < focusChain.size() - 1; i++ )
188  qwtSetTabOrder( focusChain[i], focusChain[i+1], false );
189 
190  qwtEnableLegendItems( this, true );
191 }
192 
217 void QwtPlot::setCanvas( QWidget *canvas )
218 {
219  if ( canvas == d_data->canvas )
220  return;
221 
222  delete d_data->canvas;
223  d_data->canvas = canvas;
224 
225  if ( canvas )
226  {
227  canvas->setParent( this );
228  canvas->installEventFilter( this );
229 
230  if ( isVisible() )
231  canvas->show();
232  }
233 }
234 
241 bool QwtPlot::event( QEvent *event )
242 {
243  bool ok = QFrame::event( event );
244  switch ( event->type() )
245  {
246  case QEvent::LayoutRequest:
247  updateLayout();
248  break;
249  case QEvent::PolishRequest:
250  replot();
251  break;
252  default:;
253  }
254  return ok;
255 }
256 
275 bool QwtPlot::eventFilter( QObject *object, QEvent *event )
276 {
277  if ( object == d_data->canvas )
278  {
279  if ( event->type() == QEvent::Resize )
280  {
282  }
283  else if ( event->type() == QEvent::ContentsRectChange )
284  {
285  updateLayout();
286  }
287  }
288 
289  return QFrame::eventFilter( object, event );
290 }
291 
294 {
295  if ( d_data->autoReplot )
296  replot();
297 }
298 
315 {
316  d_data->autoReplot = tf;
317 }
318 
323 bool QwtPlot::autoReplot() const
324 {
325  return d_data->autoReplot;
326 }
327 
332 void QwtPlot::setTitle( const QString &title )
333 {
334  if ( title != d_data->titleLabel->text().text() )
335  {
336  d_data->titleLabel->setText( title );
337  updateLayout();
338  }
339 }
340 
346 {
347  if ( title != d_data->titleLabel->text() )
348  {
349  d_data->titleLabel->setText( title );
350  updateLayout();
351  }
352 }
353 
356 {
357  return d_data->titleLabel->text();
358 }
359 
362 {
363  return d_data->titleLabel;
364 }
365 
368 {
369  return d_data->titleLabel;
370 }
371 
376 void QwtPlot::setFooter( const QString &text )
377 {
378  if ( text != d_data->footerLabel->text().text() )
379  {
380  d_data->footerLabel->setText( text );
381  updateLayout();
382  }
383 }
384 
389 void QwtPlot::setFooter( const QwtText &text )
390 {
391  if ( text != d_data->footerLabel->text() )
392  {
393  d_data->footerLabel->setText( text );
394  updateLayout();
395  }
396 }
397 
400 {
401  return d_data->footerLabel->text();
402 }
403 
406 {
407  return d_data->footerLabel;
408 }
409 
412 {
413  return d_data->footerLabel;
414 }
415 
423 {
424  if ( layout != d_data->layout )
425  {
426  delete d_data->layout;
427  d_data->layout = layout;
428 
429  updateLayout();
430  }
431 }
432 
435 {
436  return d_data->layout;
437 }
438 
441 {
442  return d_data->layout;
443 }
444 
450 {
451  return d_data->legend;
452 }
453 
459 {
460  return d_data->legend;
461 }
462 
463 
467 QWidget *QwtPlot::canvas()
468 {
469  return d_data->canvas;
470 }
471 
475 const QWidget *QwtPlot::canvas() const
476 {
477  return d_data->canvas;
478 }
479 
484 QSize QwtPlot::sizeHint() const
485 {
486  int dw = 0;
487  int dh = 0;
488  for ( int axisId = 0; axisId < axisCnt; axisId++ )
489  {
490  if ( axisEnabled( axisId ) )
491  {
492  const int niceDist = 40;
493  const QwtScaleWidget *scaleWidget = axisWidget( axisId );
494  const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv();
495  const int majCnt = scaleDiv.ticks( QwtScaleDiv::MajorTick ).count();
496 
497  if ( axisId == yLeft || axisId == yRight )
498  {
499  int hDiff = ( majCnt - 1 ) * niceDist
500  - scaleWidget->minimumSizeHint().height();
501  if ( hDiff > dh )
502  dh = hDiff;
503  }
504  else
505  {
506  int wDiff = ( majCnt - 1 ) * niceDist
507  - scaleWidget->minimumSizeHint().width();
508  if ( wDiff > dw )
509  dw = wDiff;
510  }
511  }
512  }
513  return minimumSizeHint() + QSize( dw, dh );
514 }
515 
520 {
521  QSize hint = d_data->layout->minimumSizeHint( this );
522  hint += QSize( 2 * frameWidth(), 2 * frameWidth() );
523 
524  return hint;
525 }
526 
531 void QwtPlot::resizeEvent( QResizeEvent *e )
532 {
533  QFrame::resizeEvent( e );
534  updateLayout();
535 }
536 
547 {
548  bool doAutoReplot = autoReplot();
549  setAutoReplot( false );
550 
551  updateAxes();
552 
553  /*
554  Maybe the layout needs to be updated, because of changed
555  axes labels. We need to process them here before painting
556  to avoid that scales and canvas get out of sync.
557  */
558  QApplication::sendPostedEvents( this, QEvent::LayoutRequest );
559 
560  if ( d_data->canvas )
561  {
562  const bool ok = QMetaObject::invokeMethod(
563  d_data->canvas, "replot", Qt::DirectConnection );
564  if ( !ok )
565  {
566  // fallback, when canvas has no a replot method
567  d_data->canvas->update( d_data->canvas->contentsRect() );
568  }
569  }
570 
571  setAutoReplot( doAutoReplot );
572 }
573 
579 {
580  d_data->layout->activate( this, contentsRect() );
581 
582  QRect titleRect = d_data->layout->titleRect().toRect();
583  QRect footerRect = d_data->layout->footerRect().toRect();
584  QRect scaleRect[QwtPlot::axisCnt];
585  for ( int axisId = 0; axisId < axisCnt; axisId++ )
586  scaleRect[axisId] = d_data->layout->scaleRect( axisId ).toRect();
587  QRect legendRect = d_data->layout->legendRect().toRect();
588  QRect canvasRect = d_data->layout->canvasRect().toRect();
589 
590  // resize and show the visible widgets
591 
592  if ( !d_data->titleLabel->text().isEmpty() )
593  {
594  d_data->titleLabel->setGeometry( titleRect );
595  if ( !d_data->titleLabel->isVisibleTo( this ) )
596  d_data->titleLabel->show();
597  }
598  else
599  d_data->titleLabel->hide();
600 
601  if ( !d_data->footerLabel->text().isEmpty() )
602  {
603  d_data->footerLabel->setGeometry( footerRect );
604  if ( !d_data->footerLabel->isVisibleTo( this ) )
605  d_data->footerLabel->show();
606  }
607  else
608  {
609  d_data->footerLabel->hide();
610  }
611 
612  for ( int axisId = 0; axisId < axisCnt; axisId++ )
613  {
614  QwtScaleWidget* scaleWidget = axisWidget( axisId );
615 
616  if ( axisEnabled( axisId ) )
617  {
618  if ( scaleRect[axisId] != scaleWidget->geometry() )
619  {
620  scaleWidget->setGeometry( scaleRect[axisId] );
621 
622  int startDist, endDist;
623  scaleWidget->getBorderDistHint( startDist, endDist );
624  scaleWidget->setBorderDist( startDist, endDist );
625  }
626 
627  if ( !scaleWidget->isVisibleTo( this ) )
628  scaleWidget->show();
629  }
630  else
631  {
632  scaleWidget->hide();
633  }
634  }
635 
636  if ( d_data->legend )
637  {
638  if ( d_data->legend->isEmpty() )
639  {
640  d_data->legend->hide();
641  }
642  else
643  {
644  d_data->legend->setGeometry( legendRect );
645  d_data->legend->show();
646  }
647  }
648 
649  d_data->canvas->setGeometry( canvasRect );
650 }
651 
668  const QwtScaleMap maps[], const QRectF &canvasRect,
669  double &left, double &top, double &right, double &bottom) const
670 {
671  left = top = right = bottom = -1.0;
672 
673  const QwtPlotItemList& itmList = itemList();
674  for ( QwtPlotItemIterator it = itmList.begin();
675  it != itmList.end(); ++it )
676  {
677  const QwtPlotItem *item = *it;
679  {
680  double m[ QwtPlot::axisCnt ];
681  item->getCanvasMarginHint(
682  maps[ item->xAxis() ], maps[ item->yAxis() ],
683  canvasRect, m[yLeft], m[xTop], m[yRight], m[xBottom] );
684 
685  left = qMax( left, m[yLeft] );
686  top = qMax( top, m[xTop] );
687  right = qMax( right, m[yRight] );
688  bottom = qMax( bottom, m[xBottom] );
689  }
690  }
691 }
692 
702 {
703  QwtScaleMap maps[axisCnt];
704  for ( int axisId = 0; axisId < axisCnt; axisId++ )
705  maps[axisId] = canvasMap( axisId );
706 
707  double margins[axisCnt];
708  getCanvasMarginsHint( maps, canvas()->contentsRect(),
709  margins[yLeft], margins[xTop], margins[yRight], margins[xBottom] );
710 
711  bool doUpdate = false;
712  for ( int axisId = 0; axisId < axisCnt; axisId++ )
713  {
714  if ( margins[axisId] >= 0.0 )
715  {
716  const int m = qCeil( margins[axisId] );
717  plotLayout()->setCanvasMargin( m, axisId);
718  doUpdate = true;
719  }
720  }
721 
722  if ( doUpdate )
723  updateLayout();
724 }
725 
735 void QwtPlot::drawCanvas( QPainter *painter )
736 {
737  QwtScaleMap maps[axisCnt];
738  for ( int axisId = 0; axisId < axisCnt; axisId++ )
739  maps[axisId] = canvasMap( axisId );
740 
741  drawItems( painter, d_data->canvas->contentsRect(), maps );
742 }
743 
757 void QwtPlot::drawItems( QPainter *painter, const QRectF &canvasRect,
758  const QwtScaleMap maps[axisCnt] ) const
759 {
760  const QwtPlotItemList& itmList = itemList();
761  for ( QwtPlotItemIterator it = itmList.begin();
762  it != itmList.end(); ++it )
763  {
764  QwtPlotItem *item = *it;
765  if ( item && item->isVisible() )
766  {
767  painter->save();
768 
769  painter->setRenderHint( QPainter::Antialiasing,
771  painter->setRenderHint( QPainter::HighQualityAntialiasing,
773 
774  item->draw( painter,
775  maps[item->xAxis()], maps[item->yAxis()],
776  canvasRect );
777 
778  painter->restore();
779  }
780  }
781 }
782 
790 QwtScaleMap QwtPlot::canvasMap( int axisId ) const
791 {
792  QwtScaleMap map;
793  if ( !d_data->canvas )
794  return map;
795 
796  map.setTransformation( axisScaleEngine( axisId )->transformation() );
797 
798  const QwtScaleDiv &sd = axisScaleDiv( axisId );
799  map.setScaleInterval( sd.lowerBound(), sd.upperBound() );
800 
801  if ( axisEnabled( axisId ) )
802  {
803  const QwtScaleWidget *s = axisWidget( axisId );
804  if ( axisId == yLeft || axisId == yRight )
805  {
806  double y = s->y() + s->startBorderDist() - d_data->canvas->y();
807  double h = s->height() - s->startBorderDist() - s->endBorderDist();
808  map.setPaintInterval( y + h, y );
809  }
810  else
811  {
812  double x = s->x() + s->startBorderDist() - d_data->canvas->x();
813  double w = s->width() - s->startBorderDist() - s->endBorderDist();
814  map.setPaintInterval( x, x + w );
815  }
816  }
817  else
818  {
819  const QRect &canvasRect = d_data->canvas->contentsRect();
820  if ( axisId == yLeft || axisId == yRight )
821  {
822  int top = 0;
823  if ( !plotLayout()->alignCanvasToScale( xTop ) )
824  top = plotLayout()->canvasMargin( xTop );
825 
826  int bottom = 0;
827  if ( !plotLayout()->alignCanvasToScale( xBottom ) )
828  bottom = plotLayout()->canvasMargin( xBottom );
829 
830  map.setPaintInterval( canvasRect.bottom() - bottom,
831  canvasRect.top() + top );
832  }
833  else
834  {
835  int left = 0;
836  if ( !plotLayout()->alignCanvasToScale( yLeft ) )
837  left = plotLayout()->canvasMargin( yLeft );
838 
839  int right = 0;
840  if ( !plotLayout()->alignCanvasToScale( yRight ) )
841  right = plotLayout()->canvasMargin( yRight );
842 
843  map.setPaintInterval( canvasRect.left() + left,
844  canvasRect.right() - right );
845  }
846  }
847 
848  return map;
849 }
850 
861 void QwtPlot::setCanvasBackground( const QBrush &brush )
862 {
863  QPalette pal = d_data->canvas->palette();
864  pal.setBrush( QPalette::Window, brush );
865 
866  canvas()->setPalette( pal );
867 }
868 
876 QBrush QwtPlot::canvasBackground() const
877 {
878  return canvas()->palette().brush(
879  QPalette::Normal, QPalette::Window );
880 }
881 
886 bool QwtPlot::axisValid( int axisId )
887 {
888  return ( ( axisId >= QwtPlot::yLeft ) && ( axisId < QwtPlot::axisCnt ) );
889 }
890 
925  QwtPlot::LegendPosition pos, double ratio )
926 {
927  d_data->layout->setLegendPosition( pos, ratio );
928 
929  if ( legend != d_data->legend )
930  {
931  if ( d_data->legend && d_data->legend->parent() == this )
932  delete d_data->legend;
933 
934  d_data->legend = legend;
935 
936  if ( d_data->legend )
937  {
938  connect( this,
939  SIGNAL( legendDataChanged(
940  const QVariant &, const QList<QwtLegendData> & ) ),
941  d_data->legend,
942  SLOT( updateLegend(
943  const QVariant &, const QList<QwtLegendData> & ) )
944  );
945 
946  if ( d_data->legend->parent() != this )
947  d_data->legend->setParent( this );
948 
949  qwtEnableLegendItems( this, false );
950  updateLegend();
951  qwtEnableLegendItems( this, true );
952 
953  QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
954  if ( lgd )
955  {
956  switch ( d_data->layout->legendPosition() )
957  {
958  case LeftLegend:
959  case RightLegend:
960  {
961  if ( lgd->maxColumns() == 0 )
962  lgd->setMaxColumns( 1 ); // 1 column: align vertical
963  break;
964  }
965  case TopLegend:
966  case BottomLegend:
967  {
968  lgd->setMaxColumns( 0 ); // unlimited
969  break;
970  }
971  default:
972  break;
973  }
974  }
975 
976  QWidget *previousInChain = NULL;
977  switch ( d_data->layout->legendPosition() )
978  {
979  case LeftLegend:
980  {
981  previousInChain = axisWidget( QwtPlot::xTop );
982  break;
983  }
984  case TopLegend:
985  {
986  previousInChain = this;
987  break;
988  }
989  case RightLegend:
990  {
991  previousInChain = axisWidget( QwtPlot::yRight );
992  break;
993  }
994  case BottomLegend:
995  {
996  previousInChain = footerLabel();
997  break;
998  }
999  }
1000 
1001  if ( previousInChain )
1002  qwtSetTabOrder( previousInChain, legend, true );
1003  }
1004  }
1005 
1006  updateLayout();
1007 }
1008 
1015 {
1016  const QwtPlotItemList& itmList = itemList();
1017  for ( QwtPlotItemIterator it = itmList.begin();
1018  it != itmList.end(); ++it )
1019  {
1020  updateLegend( *it );
1021  }
1022 }
1023 
1030 void QwtPlot::updateLegend( const QwtPlotItem *plotItem )
1031 {
1032  if ( plotItem == NULL )
1033  return;
1034 
1035  QList<QwtLegendData> legendData;
1036 
1037  if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
1038  legendData = plotItem->legendData();
1039 
1040  const QVariant itemInfo = itemToInfo( const_cast< QwtPlotItem *>( plotItem) );
1041  Q_EMIT legendDataChanged( itemInfo, legendData );
1042 }
1043 
1056 void QwtPlot::updateLegendItems( const QVariant &itemInfo,
1057  const QList<QwtLegendData> &legendData )
1058 {
1059  QwtPlotItem *plotItem = infoToItem( itemInfo );
1060  if ( plotItem )
1061  {
1062  const QwtPlotItemList& itmList = itemList();
1063  for ( QwtPlotItemIterator it = itmList.begin();
1064  it != itmList.end(); ++it )
1065  {
1066  QwtPlotItem *item = *it;
1068  item->updateLegend( plotItem, legendData );
1069  }
1070  }
1071 }
1072 
1079 void QwtPlot::attachItem( QwtPlotItem *plotItem, bool on )
1080 {
1081  if ( plotItem->testItemInterest( QwtPlotItem::LegendInterest ) )
1082  {
1083  // plotItem is some sort of legend
1084 
1085  const QwtPlotItemList& itmList = itemList();
1086  for ( QwtPlotItemIterator it = itmList.begin();
1087  it != itmList.end(); ++it )
1088  {
1089  QwtPlotItem *item = *it;
1090 
1091  QList<QwtLegendData> legendData;
1092  if ( on && item->testItemAttribute( QwtPlotItem::Legend ) )
1093  {
1094  legendData = item->legendData();
1095  plotItem->updateLegend( item, legendData );
1096  }
1097  }
1098  }
1099 
1100  if ( on )
1101  insertItem( plotItem );
1102  else
1103  removeItem( plotItem );
1104 
1105  Q_EMIT itemAttached( plotItem, on );
1106 
1107  if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
1108  {
1109  // the item wants to be represented on the legend
1110 
1111  if ( on )
1112  {
1113  updateLegend( plotItem );
1114  }
1115  else
1116  {
1117  const QVariant itemInfo = itemToInfo( plotItem );
1118  Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() );
1119  }
1120  }
1121 
1122  autoRefresh();
1123 }
1124 
1142 QVariant QwtPlot::itemToInfo( QwtPlotItem *plotItem ) const
1143 {
1144  QVariant itemInfo;
1145  qVariantSetValue( itemInfo, plotItem );
1146 
1147  return itemInfo;
1148 }
1149 
1165 QwtPlotItem *QwtPlot::infoToItem( const QVariant &itemInfo ) const
1166 {
1167  if ( itemInfo.canConvert<QwtPlotItem *>() )
1168  return qvariant_cast<QwtPlotItem *>( itemInfo );
1169 
1170  return NULL;
1171 }
1172 
1173 
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
void setTitle(const QString &)
Definition: qwt_plot.cpp:332
const QwtScaleDiv & axisScaleDiv(int axisId) const
Return the scale division of a specified axis.
virtual QSize minimumSizeHint() const
Return a minimum size hint.
Definition: qwt_plot.cpp:519
virtual QwtPlotItem * infoToItem(const QVariant &) const
Identify the plot item according to an item info object, that has bee generated from itemToInfo()...
Definition: qwt_plot.cpp:1165
Enable antialiasing.
LegendPosition
Definition: qwt_plot.h:116
X axis above the canvas.
Definition: qwt_plot.h:105
virtual void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const =0
Draw the item.
void insertItem(QwtPlotItem *)
void setCanvasBackground(const QBrush &)
Change the background of the plotting area.
Definition: qwt_plot.cpp:861
bool isVisible() const
A Widget which displays a QwtText.
QRectF legendRect() const
QwtTextLabel * titleLabel()
Definition: qwt_plot.cpp:361
virtual void getCanvasMarginsHint(const QwtScaleMap maps[], const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
Calculate the canvas margins.
Definition: qwt_plot.cpp:667
Number of axes.
Definition: qwt_plot.h:108
virtual void drawItems(QPainter *, const QRectF &, const QwtScaleMap maps[axisCnt]) const
Definition: qwt_plot.cpp:757
int xAxis() const
Return xAxis.
QList< QwtPlotItem * > QwtPlotItemList
See QT 4.x assistant documentation for QList.
Definition: qwt_plot_dict.h:20
QRectF footerRect() const
XmlRpcServer s
void setCanvas(QWidget *)
Set the drawing canvas of the plot widget.
Definition: qwt_plot.cpp:217
virtual QVariant itemToInfo(QwtPlotItem *) const
Build an information, that can be used to identify a plot item on the legend.
Definition: qwt_plot.cpp:1142
QPointer< QWidget > canvas
Definition: qwt_plot.cpp:99
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
void setAutoReplot(bool=true)
Set or reset the autoReplot option.
Definition: qwt_plot.cpp:314
void deleteAxesData()
QwtPlot::LegendPosition legendPosition() const
QPointer< QwtTextLabel > footerLabel
Definition: qwt_plot.cpp:98
void updateLegendItems(const QVariant &itemInfo, const QList< QwtLegendData > &data)
Update all plot items interested in legend attributes.
Definition: qwt_plot.cpp:1056
void autoRefresh()
Replots the plot if autoReplot() is true.
Definition: qwt_plot.cpp:293
Y axis right of the canvas.
Definition: qwt_plot.h:99
virtual void replot()
Redraw the plot.
Definition: qwt_plot.cpp:546
QwtPlotLayout * layout
Definition: qwt_plot.cpp:101
A class representing a scale division.
Definition: qwt_scale_div.h:36
void setCanvasMargin(int margin, int axis=-1)
QwtTextLabel * footerLabel()
Definition: qwt_plot.cpp:405
void updateCanvasMargins()
Update the canvas margins.
Definition: qwt_plot.cpp:701
virtual QSize minimumSizeHint(const QwtPlot *) const
bool axisEnabled(int axisId) const
Canvas of a QwtPlot.
void setScaleInterval(double s1, double s2)
Specify the borders of the scale interval.
A 2-D plotting widget.
Definition: qwt_plot.h:74
static void qwtSetTabOrder(QWidget *first, QWidget *second, bool withChildren)
Definition: qwt_plot.cpp:46
const QwtScaleDraw * scaleDraw() const
TFSIMD_FORCE_INLINE const tfScalar & y() const
QPointer< QwtAbstractLegend > legend
Definition: qwt_plot.cpp:100
Y axis left of the canvas.
Definition: qwt_plot.h:96
QList< QwtPlotItem * >::ConstIterator QwtPlotItemIterator
Definition: qwt_plot_dict.h:21
static bool axisValid(int axisId)
Definition: qwt_plot.cpp:886
double upperBound() const
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
virtual bool event(QEvent *)
Adds handling of layout requests.
Definition: qwt_plot.cpp:241
const QwtScaleWidget * axisWidget(int axisId) const
QwtAbstractLegend * legend()
Definition: qwt_plot.cpp:449
The item is represented on the legend.
QBrush canvasBackground() const
The legend will be below the footer.
Definition: qwt_plot.h:125
QRectF titleRect() const
uint maxColumns() const
Definition: qwt_legend.cpp:304
bool testItemAttribute(ItemAttribute) const
void setPlotLayout(QwtPlotLayout *)
Assign a new plot layout.
Definition: qwt_plot.cpp:422
int startBorderDist() const
bool autoDelete() const
QRectF scaleRect(int axis) const
QwtPlot(QWidget *=NULL)
Constructor.
Definition: qwt_plot.cpp:110
void setBorderDist(int start, int end)
void setRenderFlags(int flags)
Change the render flags.
Definition: qwt_text.cpp:271
virtual void updateLayout()
Adjust plot content to its current size.
Definition: qwt_plot.cpp:578
bool testRenderHint(RenderHint) const
int canvasMargin(int axis) const
virtual void activate(const QwtPlot *, const QRectF &rect, Options options=0x00)
Recalculate the geometry of all components.
A Widget which contains a scale.
void detachItems(int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true)
void setLegendPosition(QwtPlot::LegendPosition pos, double ratio)
Specify the position of the legend.
size_t to
virtual void drawCanvas(QPainter *)
Definition: qwt_plot.cpp:735
const QwtScaleDiv & scaleDiv() const
double lowerBound() const
void setTransformation(QwtTransform *)
void initAxesData()
Initialize axes.
void setPaintInterval(double p1, double p2)
Specify the borders of the paint device interval.
virtual ~QwtPlot()
Destructor.
Definition: qwt_plot.cpp:128
virtual QSize minimumSizeHint() const
A class representing a text.
Definition: qwt_text.h:51
bool autoReplot() const
virtual QwtScaleMap canvasMap(int axisId) const
Definition: qwt_plot.cpp:790
virtual QSize sizeHint() const
Definition: qwt_plot.cpp:484
void attachItem(QwtPlotItem *, bool)
Attach/Detach a plot item.
Definition: qwt_plot.cpp:1079
The legend will be right from the QwtPlot::yRight axis.
Definition: qwt_plot.h:122
void setFooter(const QString &)
Definition: qwt_plot.cpp:376
int yAxis() const
Return yAxis.
The legend will be left from the QwtPlot::yLeft axis.
Definition: qwt_plot.h:119
TFSIMD_FORCE_INLINE const tfScalar & x() const
QRectF canvasRect() const
A scale map.
Definition: qwt_scale_map.h:30
QPointer< QwtTextLabel > titleLabel
Definition: qwt_plot.cpp:97
static void qwtEnableLegendItems(QwtPlot *plot, bool on)
Definition: qwt_plot.cpp:26
int endBorderDist() const
TFSIMD_FORCE_INLINE const tfScalar & w() const
bool testItemInterest(ItemInterest) const
QwtText title() const
Definition: qwt_plot.cpp:355
Abstract base class for legend widgets.
QWidget * canvas()
Definition: qwt_plot.cpp:467
bool alignCanvasToScale(int axisId) const
The legend widget.
Definition: qwt_legend.h:29
void updateLegend()
Definition: qwt_plot.cpp:1014
Layout engine for QwtPlot.
void initPlot(const QwtText &title)
Initializes a QwtPlot instance.
Definition: qwt_plot.cpp:142
void insertLegend(QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
Insert a legend.
Definition: qwt_plot.cpp:924
void getBorderDistHint(int &start, int &end) const
Calculate a hint for the border distances.
QwtScaleEngine * axisScaleEngine(int axisId)
void setRenderHint(RenderHint, bool on=true)
void setMaxColumns(uint numColums)
Set the maximum number of entries in a row.
Definition: qwt_legend.cpp:292
virtual void updateLegend(const QwtPlotItem *, const QList< QwtLegendData > &)
Update the item to changes of the legend info.
The legend will be above the title.
Definition: qwt_plot.h:128
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:64
PrivateData * d_data
Definition: qwt_plot.h:308
int i
virtual void resizeEvent(QResizeEvent *e)
Definition: qwt_plot.cpp:531
size_t from
QList< double > ticks(int tickType) const
virtual bool eventFilter(QObject *, QEvent *)
Event filter.
Definition: qwt_plot.cpp:275
virtual void getCanvasMarginHint(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasSize, double &left, double &top, double &right, double &bottom) const
Calculate a hint for the canvas margin.
void updateAxes()
Rebuild the axes scales.
void removeItem(QwtPlotItem *)
void itemAttached(QwtPlotItem *plotItem, bool on)
Unspecific value, that can be used, when it doesn&#39;t matter.
Definition: qwt_plot_item.h:76
X axis below the canvas.
Definition: qwt_plot.h:102
QwtPlotLayout * plotLayout()
Definition: qwt_plot.cpp:434
QwtText footer() const
Definition: qwt_plot.cpp:399


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17