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_scale_map.h"
16 #include "qwt_text_label.h"
17 #include "qwt_legend.h"
18 #include "qwt_legend_data.h"
19 #include "qwt_plot_canvas.h"
20 #include "qwt_math.h"
21 
22 #include <qpainter.h>
23 #include <qpointer.h>
24 #include <qapplication.h>
25 #include <qcoreevent.h>
26 
27 static inline void qwtEnableLegendItems( QwtPlot *plot, bool on )
28 {
29  // gcc seems to have problems with const char sig[] in combination with certain options
30  const char* sig = SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>));
31  const char* slot = SLOT(updateLegendItems(QVariant,QList<QwtLegendData>));
32 
33  if ( on )
34  QObject::connect( plot, sig, plot, slot );
35  else
36  QObject::disconnect( plot, sig, plot, slot );
37 }
38 
39 static void qwtSetTabOrder(
40  QWidget *first, QWidget *second, bool withChildren )
41 {
42  QList<QWidget *> tabChain;
43  tabChain += first;
44  tabChain += second;
45 
46  if ( withChildren )
47  {
48  QList<QWidget *> children = second->findChildren<QWidget *>();
49 
50  QWidget *w = second->nextInFocusChain();
51  while ( children.contains( w ) )
52  {
53  children.removeAll( w );
54 
55  tabChain += w;
56  w = w->nextInFocusChain();
57  }
58  }
59 
60  for ( int i = 0; i < tabChain.size() - 1; i++ )
61  {
62  QWidget *from = tabChain[i];
63  QWidget *to = tabChain[i+1];
64 
65  const Qt::FocusPolicy policy1 = from->focusPolicy();
66  const Qt::FocusPolicy policy2 = to->focusPolicy();
67 
68  QWidget *proxy1 = from->focusProxy();
69  QWidget *proxy2 = to->focusProxy();
70 
71  from->setFocusPolicy( Qt::TabFocus );
72  from->setFocusProxy( NULL);
73 
74  to->setFocusPolicy( Qt::TabFocus );
75  to->setFocusProxy( NULL);
76 
77  QWidget::setTabOrder( from, to );
78 
79  from->setFocusPolicy( policy1 );
80  from->setFocusProxy( proxy1);
81 
82  to->setFocusPolicy( policy2 );
83  to->setFocusProxy( proxy2 );
84  }
85 }
86 
88 {
89 public:
90  QPointer<QwtTextLabel> titleLabel;
91  QPointer<QwtTextLabel> footerLabel;
92  QPointer<QWidget> canvas;
93  QPointer<QwtAbstractLegend> legend;
95 
96  bool autoReplot;
97 };
98 
103 QwtPlot::QwtPlot( QWidget *parent ):
104  QFrame( parent )
105 {
106  initPlot( QwtText() );
107 }
108 
114 QwtPlot::QwtPlot( const QwtText &title, QWidget *parent ):
115  QFrame( parent )
116 {
117  initPlot( title );
118 }
119 
122 {
123  setAutoReplot( false );
125 
126  delete d_data->layout;
127  deleteAxesData();
128  delete d_data;
129 }
130 
136 {
137  d_data = new PrivateData;
138 
139  d_data->layout = new QwtPlotLayout;
140  d_data->autoReplot = false;
141 
142  // title
143  d_data->titleLabel = new QwtTextLabel( this );
144  d_data->titleLabel->setObjectName( "QwtPlotTitle" );
145  d_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
146 
147  QwtText text( title );
148  text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
149  d_data->titleLabel->setText( text );
150 
151  // footer
152  d_data->footerLabel = new QwtTextLabel( this );
153  d_data->footerLabel->setObjectName( "QwtPlotFooter" );
154 
155  QwtText footer;
156  footer.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
157  d_data->footerLabel->setText( footer );
158 
159  // legend
160  d_data->legend = NULL;
161 
162  // axis
163  initAxesData();
164 
165  // canvas
166  d_data->canvas = new QwtPlotCanvas( this );
167  d_data->canvas->setObjectName( "QwtPlotCanvas" );
168  d_data->canvas->installEventFilter( this );
169 
170  setSizePolicy( QSizePolicy::MinimumExpanding,
171  QSizePolicy::MinimumExpanding );
172 
173  resize( 200, 200 );
174 
175  QList<QWidget *> focusChain;
176  focusChain << this << d_data->titleLabel << axisWidget( xTop )
179 
180  for ( int i = 0; i < focusChain.size() - 1; i++ )
181  qwtSetTabOrder( focusChain[i], focusChain[i+1], false );
182 
183  qwtEnableLegendItems( this, true );
184 }
185 
210 void QwtPlot::setCanvas( QWidget *canvas )
211 {
212  if ( canvas == d_data->canvas )
213  return;
214 
215  delete d_data->canvas;
216  d_data->canvas = canvas;
217 
218  if ( canvas )
219  {
220  canvas->setParent( this );
221  canvas->installEventFilter( this );
222 
223  if ( isVisible() )
224  canvas->show();
225  }
226 }
227 
234 bool QwtPlot::event( QEvent *event )
235 {
236  bool ok = QFrame::event( event );
237  switch ( event->type() )
238  {
239  case QEvent::LayoutRequest:
240  updateLayout();
241  break;
242  case QEvent::PolishRequest:
243  replot();
244  break;
245  default:;
246  }
247  return ok;
248 }
249 
268 bool QwtPlot::eventFilter( QObject *object, QEvent *event )
269 {
270  if ( object == d_data->canvas )
271  {
272  if ( event->type() == QEvent::Resize )
273  {
275  }
276  else if ( event->type() == QEvent::ContentsRectChange )
277  {
278  updateLayout();
279  }
280  }
281 
282  return QFrame::eventFilter( object, event );
283 }
284 
287 {
288  if ( d_data->autoReplot )
289  replot();
290 }
291 
307 void QwtPlot::setAutoReplot( bool tf )
308 {
309  d_data->autoReplot = tf;
310 }
311 
316 bool QwtPlot::autoReplot() const
317 {
318  return d_data->autoReplot;
319 }
320 
325 void QwtPlot::setTitle( const QString &title )
326 {
327  if ( title != d_data->titleLabel->text().text() )
328  {
329  d_data->titleLabel->setText( title );
330  updateLayout();
331  }
332 }
333 
339 {
340  if ( title != d_data->titleLabel->text() )
341  {
342  d_data->titleLabel->setText( title );
343  updateLayout();
344  }
345 }
346 
349 {
350  return d_data->titleLabel->text();
351 }
352 
355 {
356  return d_data->titleLabel;
357 }
358 
361 {
362  return d_data->titleLabel;
363 }
364 
369 void QwtPlot::setFooter( const QString &text )
370 {
371  if ( text != d_data->footerLabel->text().text() )
372  {
373  d_data->footerLabel->setText( text );
374  updateLayout();
375  }
376 }
377 
382 void QwtPlot::setFooter( const QwtText &text )
383 {
384  if ( text != d_data->footerLabel->text() )
385  {
386  d_data->footerLabel->setText( text );
387  updateLayout();
388  }
389 }
390 
393 {
394  return d_data->footerLabel->text();
395 }
396 
399 {
400  return d_data->footerLabel;
401 }
402 
405 {
406  return d_data->footerLabel;
407 }
408 
416 {
417  if ( layout != d_data->layout )
418  {
419  delete d_data->layout;
420  d_data->layout = layout;
421 
422  updateLayout();
423  }
424 }
425 
428 {
429  return d_data->layout;
430 }
431 
434 {
435  return d_data->layout;
436 }
437 
443 {
444  return d_data->legend;
445 }
446 
452 {
453  return d_data->legend;
454 }
455 
456 
460 QWidget *QwtPlot::canvas()
461 {
462  return d_data->canvas;
463 }
464 
468 const QWidget *QwtPlot::canvas() const
469 {
470  return d_data->canvas;
471 }
472 
477 QSize QwtPlot::sizeHint() const
478 {
479  int dw = 0;
480  int dh = 0;
481  for ( int axisId = 0; axisId < axisCnt; axisId++ )
482  {
483  if ( axisEnabled( axisId ) )
484  {
485  const int niceDist = 40;
486  const QwtScaleWidget *scaleWidget = axisWidget( axisId );
487  const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv();
488  const int majCnt = scaleDiv.ticks( QwtScaleDiv::MajorTick ).count();
489 
490  if ( axisId == yLeft || axisId == yRight )
491  {
492  int hDiff = ( majCnt - 1 ) * niceDist
493  - scaleWidget->minimumSizeHint().height();
494  if ( hDiff > dh )
495  dh = hDiff;
496  }
497  else
498  {
499  int wDiff = ( majCnt - 1 ) * niceDist
500  - scaleWidget->minimumSizeHint().width();
501  if ( wDiff > dw )
502  dw = wDiff;
503  }
504  }
505  }
506  return minimumSizeHint() + QSize( dw, dh );
507 }
508 
513 {
514  QSize hint = d_data->layout->minimumSizeHint( this );
515  hint += QSize( 2 * frameWidth(), 2 * frameWidth() );
516 
517  return hint;
518 }
519 
524 void QwtPlot::resizeEvent( QResizeEvent *e )
525 {
526  QFrame::resizeEvent( e );
527  updateLayout();
528 }
529 
540 {
541  bool doAutoReplot = autoReplot();
542  setAutoReplot( false );
543 
544  updateAxes();
545 
546  /*
547  Maybe the layout needs to be updated, because of changed
548  axes labels. We need to process them here before painting
549  to avoid that scales and canvas get out of sync.
550  */
551  QApplication::sendPostedEvents( this, QEvent::LayoutRequest );
552 
553  if ( d_data->canvas )
554  {
555  const bool ok = QMetaObject::invokeMethod(
556  d_data->canvas, "replot", Qt::DirectConnection );
557  if ( !ok )
558  {
559  // fallback, when canvas has no a replot method
560  d_data->canvas->update( d_data->canvas->contentsRect() );
561  }
562  }
563 
564  setAutoReplot( doAutoReplot );
565 }
566 
572 {
573  d_data->layout->activate( this, contentsRect() );
574 
575  QRect titleRect = d_data->layout->titleRect().toRect();
576  QRect footerRect = d_data->layout->footerRect().toRect();
577  QRect scaleRect[QwtPlot::axisCnt];
578  for ( int axisId = 0; axisId < axisCnt; axisId++ )
579  scaleRect[axisId] = d_data->layout->scaleRect( axisId ).toRect();
580  QRect legendRect = d_data->layout->legendRect().toRect();
581  QRect canvasRect = d_data->layout->canvasRect().toRect();
582 
583  // resize and show the visible widgets
584 
585  if ( !d_data->titleLabel->text().isEmpty() )
586  {
587  d_data->titleLabel->setGeometry( titleRect );
588  if ( !d_data->titleLabel->isVisibleTo( this ) )
589  d_data->titleLabel->show();
590  }
591  else
592  d_data->titleLabel->hide();
593 
594  if ( !d_data->footerLabel->text().isEmpty() )
595  {
596  d_data->footerLabel->setGeometry( footerRect );
597  if ( !d_data->footerLabel->isVisibleTo( this ) )
598  d_data->footerLabel->show();
599  }
600  else
601  {
602  d_data->footerLabel->hide();
603  }
604 
605  for ( int axisId = 0; axisId < axisCnt; axisId++ )
606  {
607  QwtScaleWidget* scaleWidget = axisWidget( axisId );
608 
609  if ( axisEnabled( axisId ) )
610  {
611  if ( scaleRect[axisId] != scaleWidget->geometry() )
612  {
613  scaleWidget->setGeometry( scaleRect[axisId] );
614 
615  int startDist, endDist;
616  scaleWidget->getBorderDistHint( startDist, endDist );
617  scaleWidget->setBorderDist( startDist, endDist );
618  }
619 
620  if ( !scaleWidget->isVisibleTo( this ) )
621  scaleWidget->show();
622  }
623  else
624  {
625  scaleWidget->hide();
626  }
627  }
628 
629  if ( d_data->legend )
630  {
631  if ( d_data->legend->isEmpty() )
632  {
633  d_data->legend->hide();
634  }
635  else
636  {
637  d_data->legend->setGeometry( legendRect );
638  d_data->legend->show();
639  }
640  }
641 
642  d_data->canvas->setGeometry( canvasRect );
643 }
644 
661  const QwtScaleMap maps[], const QRectF &canvasRect,
662  double &left, double &top, double &right, double &bottom) const
663 {
664  left = top = right = bottom = -1.0;
665 
666  const QwtPlotItemList& itmList = itemList();
667  for ( QwtPlotItemIterator it = itmList.begin();
668  it != itmList.end(); ++it )
669  {
670  const QwtPlotItem *item = *it;
672  {
673  double m[ QwtPlot::axisCnt ];
674  item->getCanvasMarginHint(
675  maps[ item->xAxis() ], maps[ item->yAxis() ],
676  canvasRect, m[yLeft], m[xTop], m[yRight], m[xBottom] );
677 
678  left = qwtMaxF( left, m[yLeft] );
679  top = qwtMaxF( top, m[xTop] );
680  right = qwtMaxF( right, m[yRight] );
681  bottom = qwtMaxF( bottom, m[xBottom] );
682  }
683  }
684 }
685 
695 {
696  QwtScaleMap maps[axisCnt];
697  for ( int axisId = 0; axisId < axisCnt; axisId++ )
698  maps[axisId] = canvasMap( axisId );
699 
700  double margins[axisCnt];
701  getCanvasMarginsHint( maps, canvas()->contentsRect(),
702  margins[yLeft], margins[xTop], margins[yRight], margins[xBottom] );
703 
704  bool doUpdate = false;
705  for ( int axisId = 0; axisId < axisCnt; axisId++ )
706  {
707  if ( margins[axisId] >= 0.0 )
708  {
709  const int m = qwtCeil( margins[axisId] );
710  plotLayout()->setCanvasMargin( m, axisId);
711  doUpdate = true;
712  }
713  }
714 
715  if ( doUpdate )
716  updateLayout();
717 }
718 
728 void QwtPlot::drawCanvas( QPainter *painter )
729 {
730  QwtScaleMap maps[axisCnt];
731  for ( int axisId = 0; axisId < axisCnt; axisId++ )
732  maps[axisId] = canvasMap( axisId );
733 
734  drawItems( painter, d_data->canvas->contentsRect(), maps );
735 }
736 
750 void QwtPlot::drawItems( QPainter *painter, const QRectF &canvasRect,
751  const QwtScaleMap maps[axisCnt] ) const
752 {
753  const QwtPlotItemList& itmList = itemList();
754  for ( QwtPlotItemIterator it = itmList.begin();
755  it != itmList.end(); ++it )
756  {
757  QwtPlotItem *item = *it;
758  if ( item && item->isVisible() )
759  {
760  painter->save();
761 
762  painter->setRenderHint( QPainter::Antialiasing,
764 
765 #if QT_VERSION < 0x050100
766  painter->setRenderHint( QPainter::HighQualityAntialiasing,
768 #endif
769 
770  item->draw( painter,
771  maps[item->xAxis()], maps[item->yAxis()],
772  canvasRect );
773 
774  painter->restore();
775  }
776  }
777 }
778 
786 QwtScaleMap QwtPlot::canvasMap( int axisId ) const
787 {
788  QwtScaleMap map;
789  if ( !d_data->canvas )
790  return map;
791 
792  map.setTransformation( axisScaleEngine( axisId )->transformation() );
793 
794  const QwtScaleDiv &sd = axisScaleDiv( axisId );
795  map.setScaleInterval( sd.lowerBound(), sd.upperBound() );
796 
797  if ( axisEnabled( axisId ) )
798  {
799  const QwtScaleWidget *s = axisWidget( axisId );
800  if ( axisId == yLeft || axisId == yRight )
801  {
802  double y = s->y() + s->startBorderDist() - d_data->canvas->y();
803  double h = s->height() - s->startBorderDist() - s->endBorderDist();
804  map.setPaintInterval( y + h, y );
805  }
806  else
807  {
808  double x = s->x() + s->startBorderDist() - d_data->canvas->x();
809  double w = s->width() - s->startBorderDist() - s->endBorderDist();
810  map.setPaintInterval( x, x + w );
811  }
812  }
813  else
814  {
815  const QRect &canvasRect = d_data->canvas->contentsRect();
816  if ( axisId == yLeft || axisId == yRight )
817  {
818  int top = 0;
819  if ( !plotLayout()->alignCanvasToScale( xTop ) )
820  top = plotLayout()->canvasMargin( xTop );
821 
822  int bottom = 0;
823  if ( !plotLayout()->alignCanvasToScale( xBottom ) )
824  bottom = plotLayout()->canvasMargin( xBottom );
825 
826  map.setPaintInterval( canvasRect.bottom() - bottom,
827  canvasRect.top() + top );
828  }
829  else
830  {
831  int left = 0;
832  if ( !plotLayout()->alignCanvasToScale( yLeft ) )
833  left = plotLayout()->canvasMargin( yLeft );
834 
835  int right = 0;
836  if ( !plotLayout()->alignCanvasToScale( yRight ) )
837  right = plotLayout()->canvasMargin( yRight );
838 
839  map.setPaintInterval( canvasRect.left() + left,
840  canvasRect.right() - right );
841  }
842  }
843 
844  return map;
845 }
846 
857 void QwtPlot::setCanvasBackground( const QBrush &brush )
858 {
859  QPalette pal = d_data->canvas->palette();
860  pal.setBrush( QPalette::Window, brush );
861 
862  canvas()->setPalette( pal );
863 }
864 
872 QBrush QwtPlot::canvasBackground() const
873 {
874  return canvas()->palette().brush(
875  QPalette::Normal, QPalette::Window );
876 }
877 
882 bool QwtPlot::axisValid( int axisId )
883 {
884  return ( ( axisId >= QwtPlot::yLeft ) && ( axisId < QwtPlot::axisCnt ) );
885 }
886 
921  QwtPlot::LegendPosition pos, double ratio )
922 {
923  d_data->layout->setLegendPosition( pos, ratio );
924 
925  if ( legend != d_data->legend )
926  {
927  if ( d_data->legend && d_data->legend->parent() == this )
928  delete d_data->legend;
929 
930  d_data->legend = legend;
931 
932  if ( d_data->legend )
933  {
934  connect(
935  this, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
937  );
938 
939  if ( d_data->legend->parent() != this )
940  d_data->legend->setParent( this );
941 
942  qwtEnableLegendItems( this, false );
943  updateLegend();
944  qwtEnableLegendItems( this, true );
945 
946  QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
947  if ( lgd )
948  {
949  switch ( d_data->layout->legendPosition() )
950  {
951  case LeftLegend:
952  case RightLegend:
953  {
954  if ( lgd->maxColumns() == 0 )
955  lgd->setMaxColumns( 1 ); // 1 column: align vertical
956  break;
957  }
958  case TopLegend:
959  case BottomLegend:
960  {
961  lgd->setMaxColumns( 0 ); // unlimited
962  break;
963  }
964  default:
965  break;
966  }
967  }
968 
969  QWidget *previousInChain = NULL;
970  switch ( d_data->layout->legendPosition() )
971  {
972  case LeftLegend:
973  {
974  previousInChain = axisWidget( QwtPlot::xTop );
975  break;
976  }
977  case TopLegend:
978  {
979  previousInChain = this;
980  break;
981  }
982  case RightLegend:
983  {
984  previousInChain = axisWidget( QwtPlot::yRight );
985  break;
986  }
987  case BottomLegend:
988  {
989  previousInChain = footerLabel();
990  break;
991  }
992  }
993 
994  if ( previousInChain )
995  qwtSetTabOrder( previousInChain, legend, true );
996  }
997  }
998 
999  updateLayout();
1000 }
1001 
1008 {
1009  const QwtPlotItemList& itmList = itemList();
1010  for ( QwtPlotItemIterator it = itmList.begin();
1011  it != itmList.end(); ++it )
1012  {
1013  updateLegend( *it );
1014  }
1015 }
1016 
1023 void QwtPlot::updateLegend( const QwtPlotItem *plotItem )
1024 {
1025  if ( plotItem == NULL )
1026  return;
1027 
1028  QList<QwtLegendData> legendData;
1029 
1030  if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
1031  legendData = plotItem->legendData();
1032 
1033  const QVariant itemInfo = itemToInfo( const_cast< QwtPlotItem *>( plotItem) );
1034  Q_EMIT legendDataChanged( itemInfo, legendData );
1035 }
1036 
1049 void QwtPlot::updateLegendItems( const QVariant &itemInfo,
1050  const QList<QwtLegendData> &legendData )
1051 {
1052  QwtPlotItem *plotItem = infoToItem( itemInfo );
1053  if ( plotItem )
1054  {
1055  const QwtPlotItemList& itmList = itemList();
1056  for ( QwtPlotItemIterator it = itmList.begin();
1057  it != itmList.end(); ++it )
1058  {
1059  QwtPlotItem *item = *it;
1061  item->updateLegend( plotItem, legendData );
1062  }
1063  }
1064 }
1065 
1072 void QwtPlot::attachItem( QwtPlotItem *plotItem, bool on )
1073 {
1074  if ( plotItem->testItemInterest( QwtPlotItem::LegendInterest ) )
1075  {
1076  // plotItem is some sort of legend
1077 
1078  const QwtPlotItemList& itmList = itemList();
1079  for ( QwtPlotItemIterator it = itmList.begin();
1080  it != itmList.end(); ++it )
1081  {
1082  QwtPlotItem *item = *it;
1083 
1084  QList<QwtLegendData> legendData;
1085  if ( on && item->testItemAttribute( QwtPlotItem::Legend ) )
1086  {
1087  legendData = item->legendData();
1088  plotItem->updateLegend( item, legendData );
1089  }
1090  }
1091  }
1092 
1093  if ( on )
1094  insertItem( plotItem );
1095  else
1096  removeItem( plotItem );
1097 
1098  Q_EMIT itemAttached( plotItem, on );
1099 
1100  if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
1101  {
1102  // the item wants to be represented on the legend
1103 
1104  if ( on )
1105  {
1106  updateLegend( plotItem );
1107  }
1108  else
1109  {
1110  const QVariant itemInfo = itemToInfo( plotItem );
1111  Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() );
1112  }
1113  }
1114 
1115  autoRefresh();
1116 }
1117 
1130 QVariant QwtPlot::itemToInfo( QwtPlotItem *plotItem ) const
1131 {
1132  return QVariant::fromValue( plotItem );
1133 }
1134 
1150 QwtPlotItem *QwtPlot::infoToItem( const QVariant &itemInfo ) const
1151 {
1152  if ( itemInfo.canConvert<QwtPlotItem *>() )
1153  return qvariant_cast<QwtPlotItem *>( itemInfo );
1154 
1155  return NULL;
1156 }
1157 
1158 #if QWT_MOC_INCLUDE
1159 #include "moc_qwt_plot.cpp"
1160 #endif
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:325
const QwtScaleDiv & axisScaleDiv(int axisId) const
Return the scale division of a specified axis.
int canvasMargin(int axisId) const
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:1150
Enable antialiasing.
LegendPosition
Definition: qwt_plot.h:117
X axis above the canvas.
Definition: qwt_plot.h:106
virtual void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const =0
Draw the item.
virtual void activate(const QwtPlot *, const QRectF &plotRect, Options options=Options())
Recalculate the geometry of all components.
void insertItem(QwtPlotItem *)
void setCanvasBackground(const QBrush &)
Change the background of the plotting area.
Definition: qwt_plot.cpp:857
lu_byte right
Definition: lparser.c:1229
bool isVisible() const
virtual void getCanvasMarginHint(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
Calculate a hint for the canvas margin.
A Widget which displays a QwtText.
QRectF legendRect() const
QwtTextLabel * titleLabel()
Definition: qwt_plot.cpp:354
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:660
void setRenderFlags(int)
Change the render flags.
Definition: qwt_text.cpp:281
Number of axes.
Definition: qwt_plot.h:109
virtual void drawItems(QPainter *, const QRectF &, const QwtScaleMap maps[axisCnt]) const
Definition: qwt_plot.cpp:750
QWT_CONSTEXPR float qwtMaxF(float a, float b)
Definition: qwt_math.h:123
int xAxis() const
Return xAxis.
lu_byte left
Definition: lparser.c:1228
QRectF footerRect() const
void setCanvas(QWidget *)
Set the drawing canvas of the plot widget.
Definition: qwt_plot.cpp:210
virtual QVariant itemToInfo(QwtPlotItem *) const
Build an information, that can be used to identify a plot item on the legend.
Definition: qwt_plot.cpp:1130
QPointer< QWidget > canvas
Definition: qwt_plot.cpp:92
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:307
void deleteAxesData()
QwtPlot::LegendPosition legendPosition() const
QPointer< QwtTextLabel > footerLabel
Definition: qwt_plot.cpp:91
void autoRefresh()
Replots the plot if autoReplot() is true.
Definition: qwt_plot.cpp:286
Y axis right of the canvas.
Definition: qwt_plot.h:100
virtual void replot()
Redraw the plot.
Definition: qwt_plot.cpp:539
QwtPlotLayout * layout
Definition: qwt_plot.cpp:94
A class representing a scale division.
Definition: qwt_scale_div.h:33
void setCanvasMargin(int margin, int axis=-1)
QwtTextLabel * footerLabel()
Definition: qwt_plot.cpp:398
void updateCanvasMargins()
Update the canvas margins.
Definition: qwt_plot.cpp:694
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:75
static void qwtSetTabOrder(QWidget *first, QWidget *second, bool withChildren)
Definition: qwt_plot.cpp:39
const QwtScaleDraw * scaleDraw() const
QPointer< QwtAbstractLegend > legend
Definition: qwt_plot.cpp:93
Y axis left of the canvas.
Definition: qwt_plot.h:97
QList< QwtPlotItem * >::ConstIterator QwtPlotItemIterator
Definition: qwt_plot_dict.h:19
static bool axisValid(int axisId)
Definition: qwt_plot.cpp:882
double upperBound() const
virtual QSize minimumSizeHint() const QWT_OVERRIDE
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
const QwtScaleWidget * axisWidget(int axisId) const
QwtAbstractLegend * legend()
Definition: qwt_plot.cpp:442
The item is represented on the legend.
QBrush canvasBackground() const
The legend will be below the footer.
Definition: qwt_plot.h:126
QRectF titleRect() const
uint maxColumns() const
Definition: qwt_legend.cpp:310
bool testItemAttribute(ItemAttribute) const
void setPlotLayout(QwtPlotLayout *)
Assign a new plot layout.
Definition: qwt_plot.cpp:415
int startBorderDist() const
bool autoDelete() const
QRectF scaleRect(int axis) const
QwtPlot(QWidget *=NULL)
Constructor.
Definition: qwt_plot.cpp:103
virtual void updateLayout()
Adjust plot content to its current size.
Definition: qwt_plot.cpp:571
bool testRenderHint(RenderHint) const
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.
virtual void drawCanvas(QPainter *)
Definition: qwt_plot.cpp:728
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:121
A class representing a text.
Definition: qwt_text.h:51
bool autoReplot() const
virtual QwtScaleMap canvasMap(int axisId) const
Definition: qwt_plot.cpp:786
virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE
Event filter.
Definition: qwt_plot.cpp:268
void attachItem(QwtPlotItem *, bool)
Attach/Detach a plot item.
Definition: qwt_plot.cpp:1072
The legend will be right from the QwtPlot::yRight axis.
Definition: qwt_plot.h:123
void setFooter(const QString &)
Definition: qwt_plot.cpp:369
int yAxis() const
Return yAxis.
The legend will be left from the QwtPlot::yLeft axis.
Definition: qwt_plot.h:120
QRectF canvasRect() const
A scale map.
Definition: qwt_scale_map.h:26
QPointer< QwtTextLabel > titleLabel
Definition: qwt_plot.cpp:90
static void qwtEnableLegendItems(QwtPlot *plot, bool on)
Definition: qwt_plot.cpp:27
int endBorderDist() const
virtual QSize sizeHint() const QWT_OVERRIDE
Definition: qwt_plot.cpp:477
int top(lua_State *L)
Definition: sol.hpp:10543
virtual QSize minimumSizeHint() const QWT_OVERRIDE
Return a minimum size hint.
Definition: qwt_plot.cpp:512
bool testItemInterest(ItemInterest) const
QwtText title() const
Definition: qwt_plot.cpp:348
Abstract base class for legend widgets.
QWidget * canvas()
Definition: qwt_plot.cpp:460
bool alignCanvasToScale(int axisId) const
void setBorderDist(int dist1, int dist2)
The legend widget.
Definition: qwt_legend.h:31
void updateLegend()
Definition: qwt_plot.cpp:1007
Layout engine for QwtPlot.
virtual bool event(QEvent *) QWT_OVERRIDE
Adds handling of layout requests.
Definition: qwt_plot.cpp:234
virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE
Definition: qwt_plot.cpp:524
void initPlot(const QwtText &title)
Initializes a QwtPlot instance.
Definition: qwt_plot.cpp:135
void insertLegend(QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
Insert a legend.
Definition: qwt_plot.cpp:920
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:296
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:129
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:65
PrivateData * d_data
Definition: qwt_plot.h:309
QList< double > ticks(int tickType) const
int qwtCeil(qreal value)
Definition: qwt_math.h:262
void updateAxes()
Rebuild the axes scales.
void updateLegendItems(const QVariant &itemInfo, const QList< QwtLegendData > &legendData)
Update all plot items interested in legend attributes.
Definition: qwt_plot.cpp:1049
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:77
X axis below the canvas.
Definition: qwt_plot.h:103
QwtPlotLayout * plotLayout()
Definition: qwt_plot.cpp:427
QwtText footer() const
Definition: qwt_plot.cpp:392


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10