15 #include <qscrollbar.h> 79 const int w = qMin( hint.width(), qFloor( rect.width() ) );
81 int h = plot->
legend()->heightForWidth( w );
145 QWIDGETSIZE_MAX,
scale[axis].scaleFont );
166 plot->
canvas()->getContentsMargins(
509 static QRectF dummyRect;
564 w = h = minLeft = minRight = tickOffset = 0;
577 plot->
canvas()->getContentsMargins( &fw, NULL, NULL, NULL );
585 ScaleData &sd = scaleData[axis];
589 sd.h = hint.height();
591 sd.tickOffset = scl->
margin();
602 ScaleData &sd = scaleData[axis];
609 if ( shiftLeft > scaleData[QwtPlot::yLeft].
w )
618 if ( shiftRight > scaleData[QwtPlot::yRight].
w )
631 if ( shiftBottom > scaleData[QwtPlot::xBottom].tickOffset )
640 if ( shiftTop > scaleData[QwtPlot::xTop].tickOffset )
650 int left, top, right, bottom;
651 canvas->getContentsMargins( &left, &top, &right, &bottom );
653 const QSize minCanvasSize = canvas->minimumSize();
657 + left + 1 + right + 1;
658 w += qMax( cw, minCanvasSize.width() );
662 + top + 1 + bottom + 1;
663 h += qMax( ch, minCanvasSize.height() );
669 for (
int i = 0;
i < 2;
i++ )
680 if ( centerOnCanvas )
687 if ( labelH > labelW )
690 if ( centerOnCanvas )
705 if ( legend && !legend->
isEmpty() )
710 int legendW = legend->sizeHint().width();
711 int legendH = legend->heightForWidth( legendW );
713 if ( legend->frameWidth() > 0 )
726 int legendW = qMin( legend->sizeHint().width(), w );
727 int legendH = legend->heightForWidth( legendW );
729 if ( legend->frameWidth() > 0 )
739 return QSize( w, h );
753 const QRectF &rect )
const 768 if ( hint.height() > rect.height() )
787 legendRect.setWidth( dim );
790 legendRect.setX( rect.right() - dim );
791 legendRect.setWidth( dim );
794 legendRect.setHeight( dim );
797 legendRect.setY( rect.bottom() - dim );
798 legendRect.setHeight( dim );
823 alignedRect.setX( canvasRect.x() );
824 alignedRect.setWidth( canvasRect.width() );
831 alignedRect.setY( canvasRect.y() );
832 alignedRect.setHeight( canvasRect.height() );
854 dimTitle = dimFooter = 0;
861 backboneOffset[axis] = 0;
885 double w = rect.width();
908 double w = rect.width();
940 length -= scaleData.
start + scaleData.
end;
946 scaleData.
start - backboneOffset[QwtPlot::yLeft] );
948 scaleData.
end - backboneOffset[QwtPlot::yRight] );
954 length -= scaleData.
start + scaleData.
end;
986 if ( d > dimAxis[axis] )
1013 backboneOffset[axis] = 0;
1022 backboneOffset[axis] +=
1040 const int leftOffset =
1043 if ( leftScaleRect.isValid() )
1045 const double dx = leftOffset + leftScaleRect.width();
1052 const double cLeft = canvasRect.left();
1053 canvasRect.setLeft( qMax( cLeft, axisRect.left() - dx ) );
1057 const double minLeft = leftScaleRect.left();
1058 const double left = axisRect.left() + leftOffset;
1059 axisRect.setLeft( qMax( left, minLeft ) );
1066 canvasRect.setLeft( qMax( canvasRect.left(),
1067 axisRect.left() - leftOffset ) );
1071 if ( leftOffset > 0 )
1072 axisRect.setLeft( axisRect.left() + leftOffset );
1077 const int rightOffset =
1080 if ( rightScaleRect.isValid() )
1082 const double dx = rightOffset + rightScaleRect.width();
1089 const double cRight = canvasRect.right();
1090 canvasRect.setRight( qMin( cRight, axisRect.right() + dx ) );
1093 const double maxRight = rightScaleRect.right();
1094 const double right = axisRect.right() - rightOffset;
1095 axisRect.setRight( qMin( right, maxRight ) );
1101 canvasRect.setRight( qMin( canvasRect.right(),
1102 axisRect.right() + rightOffset ) );
1106 if ( rightOffset > 0 )
1107 axisRect.setRight( axisRect.right() - rightOffset );
1114 const int bottomOffset =
1117 if ( bottomScaleRect.isValid() )
1119 const double dy = bottomOffset + bottomScaleRect.height();
1126 const double cBottom = canvasRect.bottom();
1127 canvasRect.setBottom( qMin( cBottom, axisRect.bottom() + dy ) );
1131 const double maxBottom = bottomScaleRect.top() +
1133 const double bottom = axisRect.bottom() - bottomOffset;
1134 axisRect.setBottom( qMin( bottom, maxBottom ) );
1141 canvasRect.setBottom( qMin( canvasRect.bottom(),
1142 axisRect.bottom() + bottomOffset ) );
1146 if ( bottomOffset > 0 )
1147 axisRect.setBottom( axisRect.bottom() - bottomOffset );
1152 const int topOffset = backboneOffset[
QwtPlot::xTop] - startDist;
1154 if ( topScaleRect.isValid() )
1156 const double dy = topOffset + topScaleRect.height();
1163 const double cTop = canvasRect.top();
1164 canvasRect.setTop( qMax( cTop, axisRect.top() - dy ) );
1168 const double minTop = topScaleRect.bottom() -
1170 const double top = axisRect.top() + topOffset;
1171 axisRect.setTop( qMax( top, minTop ) );
1178 canvasRect.setTop( qMax( canvasRect.top(),
1179 axisRect.top() - topOffset ) );
1183 if ( topOffset > 0 )
1184 axisRect.setTop( axisRect.top() + topOffset );
1200 if ( !sRect.isValid() )
1219 sRect.setRight( y );
1225 sRect.setBottom( canvasRect.top() );
1227 sRect.setTop( canvasRect.bottom() );
1246 sRect.setBottom( x );
1252 sRect.setRight( canvasRect.left() );
1254 sRect.setLeft( canvasRect.right() );
1271 const QRectF &plotRect,
Options options )
1275 QRectF rect( plotRect );
1289 const QRegion region( rect.toRect() );
1339 rect.left(), rect.top(), rect.width(), dimTitle );
1355 if ( dimFooter > 0 )
1358 rect.left(), rect.bottom() - dimFooter, rect.width(), dimFooter );
1384 if ( dimAxes[axis] )
1386 int dim = dimAxes[axis];
1394 scaleRect.setWidth( dim );
1398 scaleRect.setWidth( dim );
1402 scaleRect.setHeight( dim );
1406 scaleRect.setHeight( dim );
1409 scaleRect = scaleRect.normalized();
int contentsMargins[QwtPlot::axisCnt]
QwtPlotLayout::LayoutData layoutData
virtual int heightForWidth(int) const
QwtPlotLayout()
Constructor.
virtual ~QwtPlotLayout()
Destructor.
void setFont(const QFont &)
QRectF scaleRect[QwtPlot::axisCnt]
void setLegendRect(const QRectF &)
Set the geometry for the legend.
A Widget which displays a QwtText.
QRectF legendRect() const
QwtTextLabel * titleLabel()
double legendRatio() const
QRectF layoutLegend(Options options, const QRectF &) const
void setCanvasRect(const QRectF &)
Set the geometry for the canvas.
QRectF alignLegend(const QRectF &canvasRect, const QRectF &legendRect) const
struct QwtPlotLayout::LayoutData::t_legendData legend
QRectF footerRect() const
QwtPlot::LegendPosition legendPosition() const
Y axis right of the canvas.
const QwtText & text() const
Return the text.
void setCanvasMargin(int margin, int axis=-1)
QwtTextLabel * footerLabel()
virtual QSize minimumSizeHint(const QwtPlot *) const
bool axisEnabled(int axisId) const
bool alignCanvasToScales[QwtPlot::axisCnt]
TFSIMD_FORCE_INLINE const tfScalar & y() const
struct QwtPlotLayout::LayoutData::t_scaleData scale[QwtPlot::axisCnt]
Y axis left of the canvas.
const QwtScaleWidget * axisWidget(int axisId) const
void expandLineBreaks(Options options, const QRectF &rect, int &dimTitle, int &dimFooter, int dimAxes[QwtPlot::axisCnt]) const
QwtAbstractLegend * legend()
bool testPaintAttribute(PaintAttribute) const
The legend will be below the footer.
void setAlignCanvasToScale(int axisId, bool)
virtual bool isEmpty() const =0
QRectF scaleRect(int axis) const
int canvasMargin(int axis) const
virtual void activate(const QwtPlot *, const QRectF &rect, Options options=0x00)
Recalculate the geometry of all components.
void setLegendPosition(QwtPlot::LegendPosition pos, double ratio)
Specify the position of the legend.
void setScaleRect(int axis, const QRectF &)
Set the geometry for an axis.
const QwtScaleWidget * scaleWidget
struct QwtPlotLayout::LayoutData::t_footerData footer
A class representing a text.
void setAlignCanvasToScales(bool)
Set the align-canvas-to-axis-scales flag for all axes.
virtual void invalidate()
double maxTickLength() const
The legend will be right from the QwtPlot::yRight axis.
The legend will be left from the QwtPlot::yLeft axis.
TFSIMD_FORCE_INLINE const tfScalar & x() const
QRectF canvasRect() const
void setTitleRect(const QRectF &)
Set the geometry for the title.
unsigned int canvasMargin[QwtPlot::axisCnt]
void setFooterRect(const QRectF &)
Set the geometry for the footer.
TFSIMD_FORCE_INLINE const tfScalar & w() const
struct QwtPlotLayout::LayoutData::t_titleData title
Abstract base class for legend widgets.
bool alignCanvasToScale(int axisId) const
void setLegendRatio(double ratio)
QwtPlot::LegendPosition legendPos
void init(const QwtPlot *, const QRectF &rect)
bool hasComponent(ScaleComponent) const
The legend will be above the title.
The text has an individual font.
void alignScales(Options options, QRectF &canvasRect, QRectF scaleRect[QwtPlot::axisCnt]) const
virtual int scrollExtent(Qt::Orientation) const
double heightForWidth(double width, const QFont &=QFont()) const
struct QwtPlotLayout::LayoutData::t_canvasData canvas
QFlags< Option > Options
Layout options.