80 const int w = qMin( hint.width(),
qwtFloor( rect.width() ) );
82 int h = plot->
legend()->heightForWidth( w );
146 QWIDGETSIZE_MAX,
scale[axis].scaleFont );
167 const QMargins m = plot->
canvas()->contentsMargins();
515 static QRectF dummyRect;
569 w = h = minLeft = minRight = tickOffset = 0;
581 const int fw = plot->
canvas()->contentsMargins().left();
589 ScaleData &sd = scaleData[axis];
593 sd.h = hint.height();
595 sd.tickOffset = scl->
margin();
606 ScaleData &sd = scaleData[axis];
613 if ( shiftLeft > scaleData[QwtPlot::yLeft].w )
622 if ( shiftRight > scaleData[QwtPlot::yRight].w )
635 if ( shiftBottom > scaleData[QwtPlot::xBottom].tickOffset )
644 if ( shiftTop > scaleData[QwtPlot::xTop].tickOffset )
654 const QMargins m = canvas->contentsMargins();
656 const QSize minCanvasSize = canvas->minimumSize();
660 + m.left() + 1 + m.right() + 1;
661 w += qMax( cw, minCanvasSize.width() );
665 + m.top() + 1 + m.bottom() + 1;
666 h += qMax( ch, minCanvasSize.height() );
672 for (
int i = 0; i < 2; i++ )
683 if ( centerOnCanvas )
690 if ( labelH > labelW )
693 if ( centerOnCanvas )
708 if ( legend && !legend->
isEmpty() )
713 int legendW = legend->sizeHint().width();
714 int legendH = legend->heightForWidth( legendW );
716 if ( legend->frameWidth() > 0 )
729 int legendW = qMin( legend->sizeHint().width(), w );
730 int legendH = legend->heightForWidth( legendW );
732 if ( legend->frameWidth() > 0 )
742 return QSize( w, h );
755 const QRectF &rect )
const 770 if ( hint.height() > rect.height() )
789 legendRect.setWidth( dim );
792 legendRect.setX( rect.right() - dim );
793 legendRect.setWidth( dim );
796 legendRect.setHeight( dim );
799 legendRect.setY( rect.bottom() - dim );
800 legendRect.setHeight( dim );
825 alignedRect.setX( canvasRect.x() );
826 alignedRect.setWidth( canvasRect.width() );
833 alignedRect.setY( canvasRect.y() );
834 alignedRect.setHeight( canvasRect.height() );
856 dimTitle = dimFooter = 0;
863 backboneOffset[axis] = 0;
887 double w = rect.width();
910 double w = rect.width();
942 length -= scaleData.
start + scaleData.
end;
948 scaleData.
start - backboneOffset[QwtPlot::yLeft] );
950 scaleData.
end - backboneOffset[QwtPlot::yRight] );
956 length -= scaleData.
start + scaleData.
end;
988 if ( d > dimAxis[axis] )
1015 backboneOffset[axis] = 0;
1024 backboneOffset[axis] +=
1042 const int leftOffset =
1045 if ( leftScaleRect.isValid() )
1047 const double dx = leftOffset + leftScaleRect.width();
1054 const double cLeft = canvasRect.left();
1055 canvasRect.setLeft(
qwtMaxF( cLeft, axisRect.left() - dx ) );
1059 const double minLeft = leftScaleRect.left();
1060 const double left = axisRect.left() + leftOffset;
1061 axisRect.setLeft(
qwtMaxF( left, minLeft ) );
1068 canvasRect.setLeft(
qwtMaxF( canvasRect.left(),
1069 axisRect.left() - leftOffset ) );
1073 if ( leftOffset > 0 )
1074 axisRect.setLeft( axisRect.left() + leftOffset );
1079 const int rightOffset =
1082 if ( rightScaleRect.isValid() )
1084 const double dx = rightOffset + rightScaleRect.width();
1091 const double cRight = canvasRect.right();
1092 canvasRect.setRight(
qwtMinF( cRight, axisRect.right() + dx ) );
1095 const double maxRight = rightScaleRect.right();
1096 const double right = axisRect.right() - rightOffset;
1097 axisRect.setRight(
qwtMinF( right, maxRight ) );
1103 canvasRect.setRight(
qwtMinF( canvasRect.right(),
1104 axisRect.right() + rightOffset ) );
1108 if ( rightOffset > 0 )
1109 axisRect.setRight( axisRect.right() - rightOffset );
1116 const int bottomOffset =
1119 if ( bottomScaleRect.isValid() )
1121 const double dy = bottomOffset + bottomScaleRect.height();
1128 const double cBottom = canvasRect.bottom();
1129 canvasRect.setBottom(
qwtMinF( cBottom, axisRect.bottom() + dy ) );
1133 const double maxBottom = bottomScaleRect.top() +
1135 const double bottom = axisRect.bottom() - bottomOffset;
1136 axisRect.setBottom(
qwtMinF( bottom, maxBottom ) );
1143 canvasRect.setBottom(
qwtMinF( canvasRect.bottom(),
1144 axisRect.bottom() + bottomOffset ) );
1148 if ( bottomOffset > 0 )
1149 axisRect.setBottom( axisRect.bottom() - bottomOffset );
1154 const int topOffset = backboneOffset[
QwtPlot::xTop] - startDist;
1156 if ( topScaleRect.isValid() )
1158 const double dy = topOffset + topScaleRect.height();
1165 const double cTop = canvasRect.top();
1166 canvasRect.setTop(
qwtMaxF( cTop, axisRect.top() - dy ) );
1170 const double minTop = topScaleRect.bottom() -
1172 const double top = axisRect.top() + topOffset;
1173 axisRect.setTop(
qwtMaxF( top, minTop ) );
1180 canvasRect.setTop(
qwtMaxF( canvasRect.top(),
1181 axisRect.top() - topOffset ) );
1185 if ( topOffset > 0 )
1186 axisRect.setTop( axisRect.top() + topOffset );
1202 if ( !sRect.isValid() )
1221 sRect.setRight( y );
1227 sRect.setBottom( canvasRect.top() );
1229 sRect.setTop( canvasRect.bottom() );
1248 sRect.setBottom( x );
1254 sRect.setRight( canvasRect.left() );
1256 sRect.setLeft( canvasRect.right() );
1277 QRectF rect( plotRect );
1291 const QRegion region( rect.toRect() );
1349 rect.left(), rect.top(), rect.width(), dimTitle );
1365 if ( dimFooter > 0 )
1368 rect.left(), rect.bottom() - dimFooter, rect.width(), dimFooter );
1394 if ( dimAxes[axis] )
1396 int dim = dimAxes[axis];
1405 scaleRect.setWidth( dim );
1411 scaleRect.setWidth( dim );
1417 scaleRect.setHeight( dim );
1423 scaleRect.setHeight( dim );
1427 scaleRect = scaleRect.normalized();
int contentsMargins[QwtPlot::axisCnt]
QwtPlotLayout::LayoutData layoutData
QwtPlotLayout()
Constructor.
int canvasMargin(int axisId) const
virtual ~QwtPlotLayout()
Destructor.
void setFont(const QFont &)
QRectF scaleRect[QwtPlot::axisCnt]
virtual void activate(const QwtPlot *, const QRectF &plotRect, Options options=Options())
Recalculate the geometry of all components.
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.
QWT_CONSTEXPR float qwtMaxF(float a, float b)
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)
virtual int heightForWidth(int) const QWT_OVERRIDE
QwtTextLabel * footerLabel()
virtual QSize minimumSizeHint(const QwtPlot *) const
bool axisEnabled(int axisId) const
bool alignCanvasToScales[QwtPlot::axisCnt]
QWT_CONSTEXPR float qwtMinF(float a, float b)
struct QwtPlotLayout::LayoutData::t_scaleData scale[QwtPlot::axisCnt]
Y axis left of the canvas.
int qwtFloor(qreal value)
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
double heightForWidth(double width) const
The legend will be below the footer.
void setAlignCanvasToScale(int axisId, bool)
virtual bool isEmpty() const =0
QRectF scaleRect(int axis) const
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.
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.
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
struct QwtPlotLayout::LayoutData::t_canvasData canvas