22 #include <qpaintengine.h> 23 #include <qapplication.h> 31 plot, SIGNAL( legendDataChanged(
32 const QVariant &,
const QList<QwtLegendData> & ) ),
33 plot, SLOT( updateLegendItems(
34 const QVariant &,
const QList<QwtLegendData> & ) ) );
39 plot, SIGNAL( legendDataChanged(
40 const QVariant &,
const QList<QwtLegendData> & ) ),
41 plot, SLOT( updateLegendItems(
42 const QVariant &,
const QList<QwtLegendData> & ) ) );
47 QWidget *first, QWidget *second,
bool withChildren )
49 QList<QWidget *> tabChain;
55 QList<QWidget *> children = second->findChildren<QWidget *>();
57 QWidget *
w = second->nextInFocusChain();
58 while ( children.contains( w ) )
60 children.removeAll( w );
63 w = w->nextInFocusChain();
67 for (
int i = 0;
i < tabChain.size() - 1;
i++ )
69 QWidget *
from = tabChain[
i];
70 QWidget *
to = tabChain[
i+1];
72 const Qt::FocusPolicy policy1 = from->focusPolicy();
73 const Qt::FocusPolicy policy2 = to->focusPolicy();
75 QWidget *proxy1 = from->focusProxy();
76 QWidget *proxy2 = to->focusProxy();
78 from->setFocusPolicy( Qt::TabFocus );
79 from->setFocusProxy( NULL);
81 to->setFocusPolicy( Qt::TabFocus );
82 to->setFocusProxy( NULL);
84 QWidget::setTabOrder( from, to );
86 from->setFocusPolicy( policy1 );
87 from->setFocusProxy( proxy1);
89 to->setFocusPolicy( policy2 );
90 to->setFocusProxy( proxy2 );
152 d_data->
titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
177 setSizePolicy( QSizePolicy::MinimumExpanding,
178 QSizePolicy::MinimumExpanding );
182 QList<QWidget *> focusChain;
187 for (
int i = 0;
i < focusChain.size() - 1;
i++ )
227 canvas->setParent(
this );
228 canvas->installEventFilter(
this );
243 bool ok = QFrame::event( event );
244 switch ( event->type() )
246 case QEvent::LayoutRequest:
249 case QEvent::PolishRequest:
279 if ( event->type() == QEvent::Resize )
283 else if ( event->type() == QEvent::ContentsRectChange )
289 return QFrame::eventFilter(
object, event );
488 for (
int axisId = 0; axisId <
axisCnt; axisId++ )
492 const int niceDist = 40;
499 int hDiff = ( majCnt - 1 ) * niceDist
506 int wDiff = ( majCnt - 1 ) * niceDist
522 hint += QSize( 2 * frameWidth(), 2 * frameWidth() );
533 QFrame::resizeEvent( e );
558 QApplication::sendPostedEvents(
this, QEvent::LayoutRequest );
562 const bool ok = QMetaObject::invokeMethod(
585 for (
int axisId = 0; axisId <
axisCnt; axisId++ )
612 for (
int axisId = 0; axisId <
axisCnt; axisId++ )
618 if ( scaleRect[axisId] != scaleWidget->geometry() )
620 scaleWidget->setGeometry( scaleRect[axisId] );
622 int startDist, endDist;
627 if ( !scaleWidget->isVisibleTo(
this ) )
668 const QwtScaleMap maps[],
const QRectF &canvasRect,
669 double &left,
double &top,
double &right,
double &bottom)
const 671 left = top = right = bottom = -1.0;
675 it != itmList.end(); ++it )
685 left = qMax( left, m[
yLeft] );
686 top = qMax( top, m[
xTop] );
687 right = qMax( right, m[
yRight] );
688 bottom = qMax( bottom, m[
xBottom] );
704 for (
int axisId = 0; axisId <
axisCnt; axisId++ )
711 bool doUpdate =
false;
712 for (
int axisId = 0; axisId <
axisCnt; axisId++ )
714 if ( margins[axisId] >= 0.0 )
716 const int m = qCeil( margins[axisId] );
738 for (
int axisId = 0; axisId <
axisCnt; axisId++ )
762 it != itmList.end(); ++it )
771 painter->setRenderHint( QPainter::HighQualityAntialiasing,
819 const QRect &canvasRect =
d_data->
canvas->contentsRect();
831 canvasRect.top() + top );
844 canvasRect.right() - right );
864 pal.setBrush( QPalette::Window, brush );
866 canvas()->setPalette( pal );
878 return canvas()->palette().brush(
879 QPalette::Normal, QPalette::Window );
940 const QVariant &,
const QList<QwtLegendData> & ) ),
943 const QVariant &,
const QList<QwtLegendData> & ) )
976 QWidget *previousInChain = NULL;
986 previousInChain =
this;
1001 if ( previousInChain )
1018 it != itmList.end(); ++it )
1032 if ( plotItem == NULL )
1035 QList<QwtLegendData> legendData;
1040 const QVariant itemInfo =
itemToInfo( const_cast< QwtPlotItem *>( plotItem) );
1057 const QList<QwtLegendData> &legendData )
1064 it != itmList.end(); ++it )
1087 it != itmList.end(); ++it )
1091 QList<QwtLegendData> legendData;
1117 const QVariant itemInfo =
itemToInfo( plotItem );
1145 qVariantSetValue( itemInfo, plotItem );
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
void setTitle(const QString &)
const QwtScaleDiv & axisScaleDiv(int axisId) const
Return the scale division of a specified axis.
virtual QSize minimumSizeHint() const
Return a minimum size hint.
virtual QwtPlotItem * infoToItem(const QVariant &) const
Identify the plot item according to an item info object, that has bee generated from itemToInfo()...
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.
A Widget which displays a QwtText.
QRectF legendRect() const
QwtTextLabel * titleLabel()
virtual void getCanvasMarginsHint(const QwtScaleMap maps[], const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
Calculate the canvas margins.
virtual void drawItems(QPainter *, const QRectF &, const QwtScaleMap maps[axisCnt]) const
int xAxis() const
Return xAxis.
QList< QwtPlotItem * > QwtPlotItemList
See QT 4.x assistant documentation for QList.
QRectF footerRect() const
void setCanvas(QWidget *)
Set the drawing canvas of the plot widget.
virtual QVariant itemToInfo(QwtPlotItem *) const
Build an information, that can be used to identify a plot item on the legend.
QPointer< QWidget > canvas
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
void setAutoReplot(bool=true)
Set or reset the autoReplot option.
QwtPlot::LegendPosition legendPosition() const
QPointer< QwtTextLabel > footerLabel
void updateLegendItems(const QVariant &itemInfo, const QList< QwtLegendData > &data)
Update all plot items interested in legend attributes.
void autoRefresh()
Replots the plot if autoReplot() is true.
Y axis right of the canvas.
virtual void replot()
Redraw the plot.
A class representing a scale division.
void setCanvasMargin(int margin, int axis=-1)
QwtTextLabel * footerLabel()
void updateCanvasMargins()
Update the canvas margins.
virtual QSize minimumSizeHint(const QwtPlot *) const
bool axisEnabled(int axisId) const
void setScaleInterval(double s1, double s2)
Specify the borders of the scale interval.
static void qwtSetTabOrder(QWidget *first, QWidget *second, bool withChildren)
TFSIMD_FORCE_INLINE const tfScalar & y() const
QPointer< QwtAbstractLegend > legend
Y axis left of the canvas.
QList< QwtPlotItem * >::ConstIterator QwtPlotItemIterator
static bool axisValid(int axisId)
double upperBound() const
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
virtual bool event(QEvent *)
Adds handling of layout requests.
const QwtScaleWidget * axisWidget(int axisId) const
QwtAbstractLegend * legend()
The item is represented on the legend.
QBrush canvasBackground() const
The legend will be below the footer.
bool testItemAttribute(ItemAttribute) const
void setPlotLayout(QwtPlotLayout *)
Assign a new plot layout.
QRectF scaleRect(int axis) const
QwtPlot(QWidget *=NULL)
Constructor.
void setRenderFlags(int flags)
Change the render flags.
virtual void updateLayout()
Adjust plot content to its current size.
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.
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 *)
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.
A class representing a text.
virtual QwtScaleMap canvasMap(int axisId) const
virtual QSize sizeHint() const
void attachItem(QwtPlotItem *, bool)
Attach/Detach a plot item.
The legend will be right from the QwtPlot::yRight axis.
void setFooter(const QString &)
int yAxis() const
Return yAxis.
The legend will be left from the QwtPlot::yLeft axis.
TFSIMD_FORCE_INLINE const tfScalar & x() const
QRectF canvasRect() const
QPointer< QwtTextLabel > titleLabel
static void qwtEnableLegendItems(QwtPlot *plot, bool on)
TFSIMD_FORCE_INLINE const tfScalar & w() const
bool testItemInterest(ItemInterest) const
Abstract base class for legend widgets.
bool alignCanvasToScale(int axisId) const
Layout engine for QwtPlot.
void initPlot(const QwtText &title)
Initializes a QwtPlot instance.
void insertLegend(QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
Insert a legend.
QwtScaleEngine * axisScaleEngine(int axisId)
void setRenderHint(RenderHint, bool on=true)
void setMaxColumns(uint numColums)
Set the maximum number of entries in a row.
virtual void updateLegend(const QwtPlotItem *, const QList< QwtLegendData > &)
Update the item to changes of the legend info.
The legend will be above the title.
Base class for items on the plot canvas.
virtual void resizeEvent(QResizeEvent *e)
QList< double > ticks(int tickType) const
virtual bool eventFilter(QObject *, QEvent *)
Event filter.
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't matter.
QwtPlotLayout * plotLayout()