Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_plot.cpp
1/******************************************************************************
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
27static 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
39static 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
87class QwtPlot::PrivateData
88{
89 public:
90 QPointer< QwtTextLabel > titleLabel;
91 QPointer< QwtTextLabel > footerLabel;
92 QPointer< QWidget > canvas;
93 QPointer< QwtAbstractLegend > legend;
94 QwtPlotLayout* layout;
95
96 bool autoReplot;
97};
98
103QwtPlot::QwtPlot( QWidget* parent )
104 : QFrame( parent )
105{
106 initPlot( QwtText() );
107}
108
114QwtPlot::QwtPlot( const QwtText& title, QWidget* parent )
115 : QFrame( parent )
116{
117 initPlot( title );
118}
119
122{
123 setAutoReplot( false );
125
126 delete m_data->layout;
127 deleteAxesData();
128 delete m_data;
129}
130
135void QwtPlot::initPlot( const QwtText& title )
136{
137 m_data = new PrivateData;
138
139 m_data->layout = new QwtPlotLayout;
140 m_data->autoReplot = false;
141
142 // title
143 m_data->titleLabel = new QwtTextLabel( this );
144 m_data->titleLabel->setObjectName( "QwtPlotTitle" );
145 m_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
146
147 QwtText text( title );
148 text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
149 m_data->titleLabel->setText( text );
150
151 // footer
152 m_data->footerLabel = new QwtTextLabel( this );
153 m_data->footerLabel->setObjectName( "QwtPlotFooter" );
154
156 footer.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
157 m_data->footerLabel->setText( footer );
158
159 // legend
160 m_data->legend = NULL;
161
162 // axes
163 initAxesData();
164
165 // canvas
166 m_data->canvas = new QwtPlotCanvas( this );
167 m_data->canvas->setObjectName( "QwtPlotCanvas" );
168 m_data->canvas->installEventFilter( this );
169
170 setSizePolicy( QSizePolicy::MinimumExpanding,
171 QSizePolicy::MinimumExpanding );
172
173 resize( 200, 200 );
174
175 using namespace QwtAxis;
176
177 QList< QWidget* > focusChain;
178 focusChain << this << m_data->titleLabel << axisWidget( XTop )
179 << axisWidget( YLeft ) << m_data->canvas
180 << axisWidget( YRight ) << axisWidget( XBottom )
181 << m_data->footerLabel;
182
183 for ( int i = 0; i < focusChain.size() - 1; i++ )
184 qwtSetTabOrder( focusChain[i], focusChain[i + 1], false );
185
186 qwtEnableLegendItems( this, true );
187}
188
213void QwtPlot::setCanvas( QWidget* canvas )
214{
215 if ( canvas == m_data->canvas )
216 return;
217
218 delete m_data->canvas;
219 m_data->canvas = canvas;
220
221 if ( canvas )
222 {
223 canvas->setParent( this );
224 canvas->installEventFilter( this );
225
226 if ( isVisible() )
227 canvas->show();
228 }
229}
230
237bool QwtPlot::event( QEvent* event )
238{
239 bool ok = QFrame::event( event );
240 switch ( event->type() )
241 {
242 case QEvent::LayoutRequest:
243 updateLayout();
244 break;
245 case QEvent::PolishRequest:
246 replot();
247 break;
248 default:;
249 }
250 return ok;
251}
252
271bool QwtPlot::eventFilter( QObject* object, QEvent* event )
272{
273 if ( object == m_data->canvas )
274 {
275 if ( event->type() == QEvent::Resize )
276 {
278 }
279 else if ( event->type() == QEvent::ContentsRectChange )
280 {
281 updateLayout();
282 }
283 }
284
285 return QFrame::eventFilter( object, event );
286}
287
290{
291 if ( m_data->autoReplot )
292 replot();
293}
294
311{
312 m_data->autoReplot = tf;
313}
314
320{
321 return m_data->autoReplot;
322}
323
328void QwtPlot::setTitle( const QString& title )
329{
330 if ( title != m_data->titleLabel->text().text() )
331 {
332 m_data->titleLabel->setText( title );
333 updateLayout();
334 }
335}
336
341void QwtPlot::setTitle( const QwtText& title )
342{
343 if ( title != m_data->titleLabel->text() )
344 {
345 m_data->titleLabel->setText( title );
346 updateLayout();
347 }
348}
349
352{
353 return m_data->titleLabel->text();
354}
355
358{
359 return m_data->titleLabel;
360}
361
364{
365 return m_data->titleLabel;
366}
367
372void QwtPlot::setFooter( const QString& text )
373{
374 if ( text != m_data->footerLabel->text().text() )
375 {
376 m_data->footerLabel->setText( text );
377 updateLayout();
378 }
379}
380
385void QwtPlot::setFooter( const QwtText& text )
386{
387 if ( text != m_data->footerLabel->text() )
388 {
389 m_data->footerLabel->setText( text );
390 updateLayout();
391 }
392}
393
396{
397 return m_data->footerLabel->text();
398}
399
402{
403 return m_data->footerLabel;
404}
405
408{
409 return m_data->footerLabel;
410}
411
419{
420 if ( layout != m_data->layout )
421 {
422 delete m_data->layout;
423 m_data->layout = layout;
424
425 updateLayout();
426 }
427}
428
431{
432 return m_data->layout;
433}
434
437{
438 return m_data->layout;
439}
440
446{
447 return m_data->legend;
448}
449
455{
456 return m_data->legend;
457}
458
459
464{
465 return m_data->canvas;
466}
467
471const QWidget* QwtPlot::canvas() const
472{
473 return m_data->canvas;
474}
475
480QSize QwtPlot::sizeHint() const
481{
482 int dw = 0;
483 int dh = 0;
484
485 for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
486 {
487 {
488 const QwtAxisId axisId( axisPos );
489
490 if ( isAxisVisible( 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 const QSize hint = scaleWidget->minimumSizeHint();
498
499 if ( QwtAxis::isYAxis( axisPos ) )
500 {
501 const int hDiff = ( majCnt - 1 ) * niceDist - hint.height();
502 dh = qMax( dh, hDiff );
503 }
504 else
505 {
506 const int wDiff = ( majCnt - 1 ) * niceDist - hint.width();
507 dw = qMax( dw, wDiff );
508 }
509 }
510 }
511 }
512 return minimumSizeHint() + QSize( dw, dh );
513}
514
519{
520 QSize hint = m_data->layout->minimumSizeHint( this );
521 hint += QSize( 2 * frameWidth(), 2 * frameWidth() );
522
523 return hint;
524}
525
530void QwtPlot::resizeEvent( QResizeEvent* e )
531{
532 QFrame::resizeEvent( e );
533 updateLayout();
534}
535
546{
547 bool doAutoReplot = autoReplot();
548 setAutoReplot( false );
549
550 updateAxes();
551
552 /*
553 Maybe the layout needs to be updated, because of changed
554 axes labels. We need to process them here before painting
555 to avoid that scales and canvas get out of sync.
556 */
557 QApplication::sendPostedEvents( this, QEvent::LayoutRequest );
558
559 if ( m_data->canvas )
560 {
561 const bool ok = QMetaObject::invokeMethod(
562 m_data->canvas, "replot", Qt::DirectConnection );
563 if ( !ok )
564 {
565 // fallback, when canvas has no a replot method
566 m_data->canvas->update( m_data->canvas->contentsRect() );
567 }
568 }
569
570 setAutoReplot( doAutoReplot );
571}
572
578{
579 QwtPlotLayout* layout = m_data->layout;
580 layout->activate( this, contentsRect() );
581
582 const QRect titleRect = layout->titleRect().toRect();
583 const QRect footerRect = layout->footerRect().toRect();
584 const QRect legendRect = layout->legendRect().toRect();
585 const QRect canvasRect = layout->canvasRect().toRect();
586
587 // resize and show the visible widgets
588
589 if ( !m_data->titleLabel->text().isEmpty() )
590 {
591 m_data->titleLabel->setGeometry( titleRect );
592 if ( !m_data->titleLabel->isVisibleTo( this ) )
593 m_data->titleLabel->show();
594 }
595 else
596 m_data->titleLabel->hide();
597
598 if ( !m_data->footerLabel->text().isEmpty() )
599 {
600 m_data->footerLabel->setGeometry( footerRect );
601 if ( !m_data->footerLabel->isVisibleTo( this ) )
602 m_data->footerLabel->show();
603 }
604 else
605 {
606 m_data->footerLabel->hide();
607 }
608
609 for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
610 {
611 {
612 const QwtAxisId axisId( axisPos );
613
614 QwtScaleWidget* scaleWidget = axisWidget( axisId );
615
616 if ( isAxisVisible( axisId ) )
617 {
618 const QRect scaleRect = layout->scaleRect( axisId ).toRect();
619
620 if ( scaleRect != scaleWidget->geometry() )
621 {
622 scaleWidget->setGeometry( scaleRect );
623
624 int startDist, endDist;
625 scaleWidget->getBorderDistHint( startDist, endDist );
626 scaleWidget->setBorderDist( startDist, endDist );
627 }
628
629 if ( !scaleWidget->isVisibleTo( this ) )
630 scaleWidget->show();
631 }
632 else
633 {
634 scaleWidget->hide();
635 }
636 }
637 }
638
639 if ( m_data->legend )
640 {
641 if ( m_data->legend->isEmpty() )
642 {
643 m_data->legend->hide();
644 }
645 else
646 {
647 m_data->legend->setGeometry( legendRect );
648 m_data->legend->show();
649 }
650 }
651
652 m_data->canvas->setGeometry( canvasRect );
653}
654
671 const QwtScaleMap maps[], const QRectF& canvasRect,
672 double& left, double& top, double& right, double& bottom) const
673{
674 left = top = right = bottom = -1.0;
675
676 const QwtPlotItemList& itmList = itemList();
677 for ( QwtPlotItemIterator it = itmList.begin();
678 it != itmList.end(); ++it )
679 {
680 const QwtPlotItem* item = *it;
682 {
683 using namespace QwtAxis;
684
685 double m[ AxisPositions ];
687 maps[ item->xAxis() ], maps[ item->yAxis() ],
688 canvasRect, m[YLeft], m[XTop], m[YRight], m[XBottom] );
689
690 left = qwtMaxF( left, m[YLeft] );
691 top = qwtMaxF( top, m[XTop] );
692 right = qwtMaxF( right, m[YRight] );
693 bottom = qwtMaxF( bottom, m[XBottom] );
694 }
695 }
696}
697
707{
708 using namespace QwtAxis;
709
710 QwtScaleMap maps[ AxisPositions ];
711 for ( int axisId = 0; axisId < AxisPositions; axisId++ )
712 maps[axisId] = canvasMap( axisId );
713
714 double margins[AxisPositions];
715 getCanvasMarginsHint( maps, canvas()->contentsRect(),
716 margins[YLeft], margins[XTop], margins[YRight], margins[XBottom] );
717
718 bool doUpdate = false;
719 for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ )
720 {
721 if ( margins[axisPos] >= 0.0 )
722 {
723 const int m = qwtCeil( margins[axisPos] );
724 plotLayout()->setCanvasMargin( m, axisPos);
725 doUpdate = true;
726 }
727 }
728
729 if ( doUpdate )
730 updateLayout();
731}
732
742void QwtPlot::drawCanvas( QPainter* painter )
743{
744 QwtScaleMap maps[ QwtAxis::AxisPositions ];
745 for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
746 maps[axisPos] = canvasMap( axisPos );
747
748 drawItems( painter, m_data->canvas->contentsRect(), maps );
749}
750
764void QwtPlot::drawItems( QPainter* painter, const QRectF& canvasRect,
765 const QwtScaleMap maps[ QwtAxis::AxisPositions ] ) const
766{
767 const QwtPlotItemList& itmList = itemList();
768 for ( QwtPlotItemIterator it = itmList.begin();
769 it != itmList.end(); ++it )
770 {
771 QwtPlotItem* item = *it;
772 if ( item && item->isVisible() )
773 {
774 const QwtAxisId xAxis = item->xAxis();
775 const QwtAxisId yAxis = item->yAxis();
776
777 painter->save();
778
779 painter->setRenderHint( QPainter::Antialiasing,
781
782#if QT_VERSION < 0x050100
783 painter->setRenderHint( QPainter::HighQualityAntialiasing,
785#endif
786
787 item->draw( painter, maps[xAxis], maps[yAxis], canvasRect );
788
789 painter->restore();
790 }
791 }
792}
793
800QwtScaleMap QwtPlot::canvasMap( QwtAxisId axisId ) const
801{
802 QwtScaleMap map;
803 if ( !m_data->canvas )
804 return map;
805
806 map.setTransformation( axisScaleEngine( axisId )->transformation() );
807
808 const QwtScaleDiv& sd = axisScaleDiv( axisId );
809 map.setScaleInterval( sd.lowerBound(), sd.upperBound() );
810
811 if ( isAxisVisible( axisId ) )
812 {
813 const QwtScaleWidget* s = axisWidget( axisId );
814 if ( QwtAxis::isYAxis( axisId ) )
815 {
816 double y = s->y() + s->startBorderDist() - m_data->canvas->y();
817 double h = s->height() - s->startBorderDist() - s->endBorderDist();
818 map.setPaintInterval( y + h, y );
819 }
820 else
821 {
822 double x = s->x() + s->startBorderDist() - m_data->canvas->x();
823 double w = s->width() - s->startBorderDist() - s->endBorderDist();
824 map.setPaintInterval( x, x + w );
825 }
826 }
827 else
828 {
829 using namespace QwtAxis;
830
831 const QRect& canvasRect = m_data->canvas->contentsRect();
832 if ( isYAxis( axisId ) )
833 {
834 int top = 0;
835 if ( !plotLayout()->alignCanvasToScale( XTop ) )
836 top = plotLayout()->canvasMargin( XTop );
837
838 int bottom = 0;
839 if ( !plotLayout()->alignCanvasToScale( XBottom ) )
840 bottom = plotLayout()->canvasMargin( XBottom );
841
842 map.setPaintInterval( canvasRect.bottom() - bottom,
843 canvasRect.top() + top );
844 }
845 else
846 {
847 int left = 0;
848 if ( !plotLayout()->alignCanvasToScale( YLeft ) )
849 left = plotLayout()->canvasMargin( YLeft );
850
851 int right = 0;
852 if ( !plotLayout()->alignCanvasToScale( YRight ) )
853 right = plotLayout()->canvasMargin( YRight );
854
855 map.setPaintInterval( canvasRect.left() + left,
856 canvasRect.right() - right );
857 }
858 }
859
860 return map;
861}
862
873void QwtPlot::setCanvasBackground( const QBrush& brush )
874{
875 QPalette pal = m_data->canvas->palette();
876 pal.setBrush( QPalette::Window, brush );
877
878 canvas()->setPalette( pal );
879}
880
889{
890 return canvas()->palette().brush(
891 QPalette::Normal, QPalette::Window );
892}
893
928 QwtPlot::LegendPosition pos, double ratio )
929{
930 m_data->layout->setLegendPosition( pos, ratio );
931
932 if ( legend != m_data->legend )
933 {
934 if ( m_data->legend && m_data->legend->parent() == this )
935 delete m_data->legend;
936
937 m_data->legend = legend;
938
939 if ( m_data->legend )
940 {
941 connect(
942 this, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
943 m_data->legend, SLOT(updateLegend(QVariant,QList<QwtLegendData>))
944 );
945
946 if ( m_data->legend->parent() != this )
947 m_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 ( m_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 ( m_data->layout->legendPosition() )
978 {
979 case LeftLegend:
980 {
981 const QwtAxisId axisId( QwtAxis::XTop );
982 previousInChain = axisWidget( axisId );
983 break;
984 }
985 case TopLegend:
986 {
987 previousInChain = this;
988 break;
989 }
990 case RightLegend:
991 {
992 const QwtAxisId axisId( QwtAxis::YRight );
993 previousInChain = axisWidget( axisId );
994 break;
995 }
996 case BottomLegend:
997 {
998 previousInChain = footerLabel();
999 break;
1000 }
1001 }
1002
1003 if ( previousInChain )
1004 qwtSetTabOrder( previousInChain, legend, true );
1005 }
1006 }
1007
1008 updateLayout();
1009}
1010
1017{
1018 const QwtPlotItemList& itmList = itemList();
1019 for ( QwtPlotItemIterator it = itmList.begin();
1020 it != itmList.end(); ++it )
1021 {
1022 updateLegend( *it );
1023 }
1024}
1025
1032void QwtPlot::updateLegend( const QwtPlotItem* plotItem )
1033{
1034 if ( plotItem == NULL )
1035 return;
1036
1037 QList< QwtLegendData > legendData;
1038
1039 if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
1040 legendData = plotItem->legendData();
1041
1042 const QVariant itemInfo = itemToInfo( const_cast< QwtPlotItem* >( plotItem ) );
1043 Q_EMIT legendDataChanged( itemInfo, legendData );
1044}
1045
1058void QwtPlot::updateLegendItems( const QVariant& itemInfo,
1059 const QList< QwtLegendData >& legendData )
1060{
1061 QwtPlotItem* plotItem = infoToItem( itemInfo );
1062 if ( plotItem )
1063 {
1064 const QwtPlotItemList& itmList = itemList();
1065 for ( QwtPlotItemIterator it = itmList.begin();
1066 it != itmList.end(); ++it )
1067 {
1068 QwtPlotItem* item = *it;
1070 item->updateLegend( plotItem, legendData );
1071 }
1072 }
1073}
1074
1081void QwtPlot::attachItem( QwtPlotItem* plotItem, bool on )
1082{
1084 {
1085 // plotItem is some sort of legend
1086
1087 const QwtPlotItemList& itmList = itemList();
1088 for ( QwtPlotItemIterator it = itmList.begin();
1089 it != itmList.end(); ++it )
1090 {
1091 QwtPlotItem* item = *it;
1092
1093 QList< QwtLegendData > legendData;
1094 if ( on && item->testItemAttribute( QwtPlotItem::Legend ) )
1095 {
1096 legendData = item->legendData();
1097 plotItem->updateLegend( item, legendData );
1098 }
1099 }
1100 }
1101
1102 if ( on )
1103 insertItem( plotItem );
1104 else
1105 removeItem( plotItem );
1106
1107 Q_EMIT itemAttached( plotItem, on );
1108
1109 if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
1110 {
1111 // the item wants to be represented on the legend
1112
1113 if ( on )
1114 {
1115 updateLegend( plotItem );
1116 }
1117 else
1118 {
1119 const QVariant itemInfo = itemToInfo( plotItem );
1120 Q_EMIT legendDataChanged( itemInfo, QList< QwtLegendData >() );
1121 }
1122 }
1123
1124 autoRefresh();
1125}
1126
1139QVariant QwtPlot::itemToInfo( QwtPlotItem* plotItem ) const
1140{
1141 return QVariant::fromValue( plotItem );
1142}
1143
1159QwtPlotItem* QwtPlot::infoToItem( const QVariant& itemInfo ) const
1160{
1161 if ( itemInfo.canConvert< QwtPlotItem* >() )
1162 return qvariant_cast< QwtPlotItem* >( itemInfo );
1163
1164 return NULL;
1165}
1166
1167#include "moc_qwt_plot.cpp"
Abstract base class for legend widgets.
const QwtScaleDiv & scaleDiv() const
The legend widget.
Definition qwt_legend.h:32
uint maxColumns() const
void setMaxColumns(uint numColums)
Set the maximum number of entries in a row.
Canvas of a QwtPlot.
void insertItem(QwtPlotItem *)
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
bool autoDelete() const
void removeItem(QwtPlotItem *)
void detachItems(int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true)
A 2-D plotting widget.
Definition qwt_plot.h:79
void insertLegend(QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
Insert a legend.
Definition qwt_plot.cpp:927
virtual bool eventFilter(QObject *, QEvent *) override
Event filter.
Definition qwt_plot.cpp:271
void setPlotLayout(QwtPlotLayout *)
Assign a new plot layout.
Definition qwt_plot.cpp:418
void itemAttached(QwtPlotItem *plotItem, bool on)
void updateAxes()
Rebuild the axes scales.
virtual ~QwtPlot()
Destructor.
Definition qwt_plot.cpp:121
void setFooter(const QString &)
Definition qwt_plot.cpp:372
LegendPosition
Definition qwt_plot.h:94
@ TopLegend
The legend will be above the title.
Definition qwt_plot.h:105
@ LeftLegend
The legend will be left from the QwtAxis::YLeft axis.
Definition qwt_plot.h:96
@ RightLegend
The legend will be right from the QwtAxis::YRight axis.
Definition qwt_plot.h:99
@ BottomLegend
The legend will be below the footer.
Definition qwt_plot.h:102
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:670
QwtScaleEngine * axisScaleEngine(QwtAxisId)
bool autoReplot() const
Definition qwt_plot.cpp:319
virtual QVariant itemToInfo(QwtPlotItem *) const
Build an information, that can be used to identify a plot item on the legend.
virtual void drawItems(QPainter *, const QRectF &, const QwtScaleMap maps[QwtAxis::AxisPositions]) const
Definition qwt_plot.cpp:764
virtual bool event(QEvent *) override
Adds handling of layout requests.
Definition qwt_plot.cpp:237
QWidget * canvas()
Definition qwt_plot.cpp:463
QwtTextLabel * footerLabel()
Definition qwt_plot.cpp:401
bool isAxisVisible(QwtAxisId) const
virtual void replot()
Redraw the plot.
Definition qwt_plot.cpp:545
QwtPlotLayout * plotLayout()
Definition qwt_plot.cpp:430
void setTitle(const QString &)
Definition qwt_plot.cpp:328
void updateLegend()
virtual QSize minimumSizeHint() const override
Return a minimum size hint.
Definition qwt_plot.cpp:518
virtual QwtPlotItem * infoToItem(const QVariant &) const
Identify the plot item according to an item info object, that has bee generated from itemToInfo().
QBrush canvasBackground() const
Definition qwt_plot.cpp:888
void setAutoReplot(bool=true)
Set or reset the autoReplot option.
Definition qwt_plot.cpp:310
QwtAbstractLegend * legend()
Definition qwt_plot.cpp:445
const QwtScaleWidget * axisWidget(QwtAxisId) const
QwtText footer() const
Definition qwt_plot.cpp:395
QwtTextLabel * titleLabel()
Definition qwt_plot.cpp:357
virtual QwtScaleMap canvasMap(QwtAxisId) const
Definition qwt_plot.cpp:800
QwtPlot(QWidget *=NULL)
Constructor.
Definition qwt_plot.cpp:103
virtual void resizeEvent(QResizeEvent *) override
Definition qwt_plot.cpp:530
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
virtual void updateLayout()
Adjust plot content to its current size.
Definition qwt_plot.cpp:577
void setCanvasBackground(const QBrush &)
Change the background of the plotting area.
Definition qwt_plot.cpp:873
virtual void drawCanvas(QPainter *)
Definition qwt_plot.cpp:742
void setCanvas(QWidget *)
Set the drawing canvas of the plot widget.
Definition qwt_plot.cpp:213
void autoRefresh()
Replots the plot if autoReplot() is true.
Definition qwt_plot.cpp:289
const QwtScaleDiv & axisScaleDiv(QwtAxisId) const
Return the scale division of a specified axis.
void updateCanvasMargins()
Update the canvas margins.
Definition qwt_plot.cpp:706
virtual QSize sizeHint() const override
Definition qwt_plot.cpp:480
QwtText title() const
Definition qwt_plot.cpp:351
Base class for items on the plot canvas.
QwtAxisId yAxis() const
Return yAxis.
virtual void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const =0
Draw the item.
bool isVisible() const
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
QwtAxisId xAxis() const
Return xAxis.
bool testItemInterest(ItemInterest) const
@ Rtti_PlotItem
Unspecific value, that can be used, when it doesn't matter.
@ RenderAntialiased
Enable antialiasing.
bool testItemAttribute(ItemAttribute) const
bool testRenderHint(RenderHint) const
@ Legend
The item is represented on the legend.
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.
virtual void updateLegend(const QwtPlotItem *, const QList< QwtLegendData > &)
Update the item to changes of the legend info.
Layout engine for QwtPlot.
QRectF titleRect() const
void setCanvasMargin(int margin, int axis=-1)
void setLegendPosition(QwtPlot::LegendPosition pos, double ratio)
Specify the position of the legend.
QRectF footerRect() const
int canvasMargin(int axisId) const
QRectF legendRect() const
QwtPlot::LegendPosition legendPosition() const
virtual QSize minimumSizeHint(const QwtPlot *) const
QRectF scaleRect(QwtAxisId) const
QRectF canvasRect() const
virtual void activate(const QwtPlot *, const QRectF &plotRect, Options options=Options())
Recalculate the geometry of all components.
A class representing a scale division.
double lowerBound() const
double upperBound() const
QList< double > ticks(int tickType) const
@ MajorTick
Major ticks.
A scale map.
void setPaintInterval(double p1, double p2)
Specify the borders of the paint device interval.
void setScaleInterval(double s1, double s2)
Specify the borders of the scale interval.
void setTransformation(QwtTransform *)
A Widget which contains a scale.
int startBorderDist() const
const QwtScaleDraw * scaleDraw() const
int endBorderDist() const
void getBorderDistHint(int &start, int &end) const
Calculate a hint for the border distances.
void setBorderDist(int dist1, int dist2)
virtual QSize minimumSizeHint() const override
A class representing a text.
Definition qwt_text.h:52
void setRenderFlags(int)
Change the render flags.
Definition qwt_text.cpp:304
A Widget which displays a QwtText.
bool isYAxis(int axisPos)
Definition qwt_axis.h:57
@ YRight
Y axis right of the canvas.
Definition qwt_axis.h:27
@ XTop
X axis above the canvas.
Definition qwt_axis.h:33