ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QCPLayout Class Referenceabstract

The abstract base class for layouts. More...

#include <qcustomplot.h>

Inheritance diagram for QCPLayout:
Collaboration diagram for QCPLayout:

Public Member Functions

 QCPLayout ()
 
virtual void update (UpdatePhase phase)
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 
virtual int elementCount () const =0
 
virtual QCPLayoutElementelementAt (int index) const =0
 
virtual QCPLayoutElementtakeAt (int index)=0
 
virtual bool take (QCPLayoutElement *element)=0
 
virtual void simplify ()
 
bool removeAt (int index)
 
bool remove (QCPLayoutElement *element)
 
void clear ()
 
 QCPLayout ()
 
virtual void update (UpdatePhase phase)
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 
virtual int elementCount () const =0
 
virtual QCPLayoutElementelementAt (int index) const =0
 
virtual QCPLayoutElementtakeAt (int index)=0
 
virtual bool take (QCPLayoutElement *element)=0
 
virtual void simplify ()
 
bool removeAt (int index)
 
bool remove (QCPLayoutElement *element)
 
void clear ()
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 
virtual ~QCPLayoutElement ()
 
QCPLayoutlayout () const
 
QRect rect () const
 
QRect outerRect () const
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
SizeConstraintRect sizeConstraintRect () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
void setOuterRect (const QRect &rect)
 
void setMargins (const QMargins &margins)
 
void setMinimumMargins (const QMargins &margins)
 
void setAutoMargins (QCP::MarginSides sides)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int width, int height)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int width, int height)
 
void setSizeConstraintRect (SizeConstraintRect constraintRect)
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 
virtual QSize minimumOuterSizeHint () const
 
virtual QSize maximumOuterSizeHint () const
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 
virtual ~QCPLayoutElement ()
 
QCPLayoutlayout () const
 
QRect rect () const
 
QRect outerRect () const
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
void setOuterRect (const QRect &rect)
 
void setMargins (const QMargins &margins)
 
void setMinimumMargins (const QMargins &margins)
 
void setAutoMargins (QCP::MarginSides sides)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int width, int height)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int width, int height)
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 
virtual QSize minimumSizeHint () const
 
virtual QSize maximumSizeHint () const
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 
virtual ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
bool setLayer (const QString &layerName)
 
void setAntialiased (bool enabled)
 
bool realVisibility () const
 
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
bool setLayer (const QString &layerName)
 
void setAntialiased (bool enabled)
 
bool realVisibility () const
 

Protected Member Functions

virtual void updateLayout ()
 
void sizeConstraintsChanged () const
 
void adoptElement (QCPLayoutElement *el)
 
void releaseElement (QCPLayoutElement *el)
 
QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
 
virtual void updateLayout ()
 
void sizeConstraintsChanged () const
 
void adoptElement (QCPLayoutElement *el)
 
void releaseElement (QCPLayoutElement *el)
 
QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void layoutChanged ()
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
- Protected Member Functions inherited from QCPLayerable
virtual QCP::Interaction selectionCategory () const
 
virtual QRect clipRect () const
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details)
 
virtual void mouseMoveEvent (QMouseEvent *event, const QPointF &startPos)
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 
virtual QCP::Interaction selectionCategory () const
 
virtual QRect clipRect () const
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Static Protected Member Functions

static QSize getFinalMinimumOuterSize (const QCPLayoutElement *el)
 
static QSize getFinalMaximumOuterSize (const QCPLayoutElement *el)
 

Additional Inherited Members

- Public Types inherited from QCPLayoutElement
enum  UpdatePhase {
  upPreparation , upMargins , upLayout , upPreparation ,
  upMargins , upLayout
}
 
enum  SizeConstraintRect { scrInnerRect , scrOuterRect }
 
enum  UpdatePhase {
  upPreparation , upMargins , upLayout , upPreparation ,
  upMargins , upLayout
}
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 
void layerChanged (QCPLayer *newLayer)
 
- Protected Attributes inherited from QCPLayoutElement
QCPLayoutmParentLayout
 
QSize mMinimumSize
 
QSize mMaximumSize
 
SizeConstraintRect mSizeConstraintRect
 
QRect mRect
 
QRect mOuterRect
 
QMargins mMargins
 
QMargins mMinimumMargins
 
QCP::MarginSides mAutoMargins
 
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlotmParentPlot
 
QPointer< QCPLayerablemParentLayerable
 
QCPLayermLayer
 
bool mAntialiased
 

Detailed Description

The abstract base class for layouts.

This is an abstract base class for layout elements whose main purpose is to define the position and size of other child layout elements. In most cases, layouts don't draw anything themselves (but there are exceptions to this, e.g. QCPLegend).

QCPLayout derives from QCPLayoutElement, and thus can itself be nested in other layouts.

QCPLayout introduces a common interface for accessing and manipulating the child elements. Those functions are most notably elementCount, elementAt, takeAt, take, simplify, removeAt, remove and clear. Individual subclasses may add more functions to this interface which are more specialized to the form of the layout. For example, QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid more conveniently.

Since this is an abstract base class, you can't instantiate it directly. Rather use one of its subclasses like QCPLayoutGrid or QCPLayoutInset.

For a general introduction to the layout system, see the dedicated documentation page The Layout System.

Definition at line 1532 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLayout() [1/2]

QCPLayout::QCPLayout ( )
explicit

Creates an instance of QCPLayout and sets default values. Note that since QCPLayout is an abstract base class, it can't be instantiated directly.

Definition at line 3607 of file qcustomplot.cpp.

◆ QCPLayout() [2/2]

QCPLayout::QCPLayout ( )
explicit

Member Function Documentation

◆ adoptElement() [1/2]

◆ adoptElement() [2/2]

void QCPLayout::adoptElement ( QCPLayoutElement el)
protected

◆ clear() [1/2]

void QCPLayout::clear ( )

Removes and deletes all layout elements in this layout. Finally calls simplify to make sure all empty cells are collapsed.

See also
remove, removeAt

Definition at line 3701 of file qcustomplot.cpp.

References elementAt(), elementCount(), removeAt(), and simplify().

Referenced by QCPLayoutGrid::~QCPLayoutGrid(), and QCPLayoutInset::~QCPLayoutInset().

◆ clear() [2/2]

void QCPLayout::clear ( )

◆ elementAt() [1/2]

QCPLayoutElement * QCPLayout::elementAt ( int  index) const
pure virtual

Returns the element in the cell with the given index. If index is invalid, returns 0.

Note that even if index is valid, the respective cell may be empty in some layouts (e.g. QCPLayoutGrid), so this function may return 0 in those cases. You may use this function to check whether a cell is empty or not.

See also
elements, elementCount, takeAt

Implemented in QCPLayoutInset, QCPLayoutGrid, QCPLayoutInset, and QCPLayoutGrid.

Referenced by clear(), elements(), and update().

◆ elementAt() [2/2]

virtual QCPLayoutElement* QCPLayout::elementAt ( int  index) const
pure virtual

◆ elementCount() [1/2]

int QCPLayout::elementCount ( ) const
pure virtual

Returns the number of elements/cells in the layout.

See also
elements, elementAt

Implemented in QCPLayoutInset, QCPLayoutGrid, QCPLayoutInset, and QCPLayoutGrid.

Referenced by clear(), elements(), and update().

◆ elementCount() [2/2]

virtual int QCPLayout::elementCount ( ) const
pure virtual

◆ elements() [1/2]

QList< QCPLayoutElement * > QCPLayout::elements ( bool  recursive) const
virtual

Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

Warning
There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

Reimplemented from QCPLayoutElement.

Reimplemented in QCPLayoutGrid, and QCPLayoutGrid.

Definition at line 3633 of file qcustomplot.cpp.

References elementAt(), elementCount(), and result.

Referenced by QCPAxisRect::elements().

◆ elements() [2/2]

virtual QList<QCPLayoutElement *> QCPLayout::elements ( bool  recursive) const
virtual

Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.

Warning
There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

Reimplemented from QCPLayoutElement.

Reimplemented in QCPLayoutGrid, and QCPLayoutGrid.

◆ getFinalMaximumOuterSize()

◆ getFinalMinimumOuterSize()

◆ getSectionSizes() [1/2]

QVector< int > QCPLayout::getSectionSizes ( QVector< int >  maxSizes,
QVector< int >  minSizes,
QVector< double >  stretchFactors,
int  totalSize 
) const
protected

Definition at line 3822 of file qcustomplot.cpp.

Referenced by QCPLayoutGrid::updateLayout().

◆ getSectionSizes() [2/2]

QVector<int> QCPLayout::getSectionSizes ( QVector< int >  maxSizes,
QVector< int >  minSizes,
QVector< double >  stretchFactors,
int  totalSize 
) const
protected

◆ releaseElement() [1/2]

void QCPLayout::releaseElement ( QCPLayoutElement el)
protected

◆ releaseElement() [2/2]

void QCPLayout::releaseElement ( QCPLayoutElement el)
protected

◆ remove() [1/2]

bool QCPLayout::remove ( QCPLayoutElement element)

Removes and deletes the provided element. Returns true on success. If element is not in the layout, returns false.

This function internally uses takeAt to remove the element from the layout and then deletes the element. Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

See also
removeAt, take

Definition at line 3687 of file qcustomplot.cpp.

References take().

Referenced by ccHistogramWindow::refresh(), ccWaveWidget::refresh(), and QCPLegend::removeItem().

◆ remove() [2/2]

bool QCPLayout::remove ( QCPLayoutElement element)

◆ removeAt() [1/2]

bool QCPLayout::removeAt ( int  index)

Removes and deletes the element at the provided index. Returns true on success. If index is invalid or points to an empty cell, returns false.

This function internally uses takeAt to remove the element from the layout and then deletes the returned element. Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

See also
remove, takeAt

Definition at line 3668 of file qcustomplot.cpp.

References takeAt().

Referenced by clear(), and QCPLayoutGrid::simplify().

◆ removeAt() [2/2]

bool QCPLayout::removeAt ( int  index)

◆ simplify() [1/2]

void QCPLayout::simplify ( )
virtual

Simplifies the layout by collapsing empty cells. The exact behavior depends on subclasses, the default implementation does nothing.

Not all layouts need simplification. For example, QCPLayoutInset doesn't use explicit simplification while QCPLayoutGrid does.

Reimplemented in QCPLayoutInset, QCPLayoutGrid, QCPLayoutInset, and QCPLayoutGrid.

Definition at line 3655 of file qcustomplot.cpp.

Referenced by clear().

◆ simplify() [2/2]

virtual void QCPLayout::simplify ( )
virtual

◆ sizeConstraintsChanged() [1/2]

void QCPLayout::sizeConstraintsChanged ( ) const
protected

Subclasses call this method to report changed (minimum/maximum) size constraints.

If the parent of this layout is again a QCPLayout, forwards the call to the parent's sizeConstraintsChanged. If the parent is a QWidget (i.e. is the QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, it may update itself and resize cells accordingly.

Definition at line 3718 of file qcustomplot.cpp.

Referenced by QCPLayoutElement::setMaximumSize(), QCPLayoutElement::setMinimumSize(), and QCPLayoutElement::setSizeConstraintRect().

◆ sizeConstraintsChanged() [2/2]

void QCPLayout::sizeConstraintsChanged ( ) const
protected

◆ take() [1/2]

bool QCPLayout::take ( QCPLayoutElement element)
pure virtual

Removes the specified element from the layout and returns true on success.

If the element isn't in this layout, returns false.

Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

See also
takeAt

Implemented in QCPLayoutInset, QCPLayoutGrid, QCPLayoutInset, and QCPLayoutGrid.

Referenced by QCPLayoutGrid::addElement(), QCPLayoutInset::addElement(), remove(), and QCPLayoutElement::~QCPLayoutElement().

◆ take() [2/2]

virtual bool QCPLayout::take ( QCPLayoutElement element)
pure virtual

◆ takeAt() [1/2]

QCPLayoutElement * QCPLayout::takeAt ( int  index)
pure virtual

Removes the element with the given index from the layout and returns it.

If the index is invalid or the cell with that index is empty, returns 0.

Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

See also
elementAt, take

Implemented in QCPLayoutInset, QCPLayoutGrid, QCPLayoutInset, and QCPLayoutGrid.

Referenced by removeAt().

◆ takeAt() [2/2]

virtual QCPLayoutElement* QCPLayout::takeAt ( int  index)
pure virtual

◆ update() [1/2]

void QCPLayout::update ( UpdatePhase  phase)
virtual

If phase is upLayout, calls updateLayout, which subclasses may reimplement to reposition and resize their cells.

Finally, the call is propagated down to all child QCPLayoutElements.

For details about this method and the update phases, see the documentation of QCPLayoutElement::update.

First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

Then calls updateLayout which subclasses reimplement to reposition and resize their cells.

Finally, update is called on all child elements.

Reimplemented from QCPLayoutElement.

Definition at line 3619 of file qcustomplot.cpp.

References elementAt(), elementCount(), QCPLayoutElement::update(), updateLayout(), and QCPLayoutElement::upLayout.

Referenced by QCPAxisRect::update(), and QCustomPlot::updateLayout().

◆ update() [2/2]

virtual void QCPLayout::update ( UpdatePhase  phase)
virtual

Updates the layout element and sub-elements. This function is automatically called before every replot by the parent layout element. It is called multiple times, once for every UpdatePhase. The phases are run through in the order of the enum values. For details about what happens at the different phases, see the documentation of UpdatePhase.

Layout elements that have child elements should call the update method of their child elements, and pass the current phase unchanged.

The default implementation executes the automatic margin mechanism in the upMargins phase. Subclasses should make sure to call the base class implementation.

Reimplemented from QCPLayoutElement.

◆ updateLayout() [1/2]

void QCPLayout::updateLayout ( )
protectedvirtual

Reimplemented in QCPLayoutInset, QCPLayoutGrid, QCPLayoutInset, and QCPLayoutGrid.

Definition at line 3738 of file qcustomplot.cpp.

Referenced by update().

◆ updateLayout() [2/2]

virtual void QCPLayout::updateLayout ( )
protectedvirtual

The documentation for this class was generated from the following files: