ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QCPMarginGroup Class Reference

A margin group allows synchronization of margin sides if working with multiple layout elements. More...

#include <qcustomplot.h>

Inheritance diagram for QCPMarginGroup:
Collaboration diagram for QCPMarginGroup:

Public Member Functions

 QCPMarginGroup (QCustomPlot *parentPlot)
 
virtual ~QCPMarginGroup ()
 
QList< QCPLayoutElement * > elements (QCP::MarginSide side) const
 
bool isEmpty () const
 
void clear ()
 
 QCPMarginGroup (QCustomPlot *parentPlot)
 
 ~QCPMarginGroup ()
 
QList< QCPLayoutElement * > elements (QCP::MarginSide side) const
 
bool isEmpty () const
 
void clear ()
 

Protected Member Functions

virtual int commonMargin (QCP::MarginSide side) const
 
void addChild (QCP::MarginSide side, QCPLayoutElement *element)
 
void removeChild (QCP::MarginSide side, QCPLayoutElement *element)
 
int commonMargin (QCP::MarginSide side) const
 
void addChild (QCP::MarginSide side, QCPLayoutElement *element)
 
void removeChild (QCP::MarginSide side, QCPLayoutElement *element)
 

Protected Attributes

QCustomPlotmParentPlot
 
QHash< QCP::MarginSide, QList< QCPLayoutElement * > > mChildren
 

Detailed Description

A margin group allows synchronization of margin sides if working with multiple layout elements.

QCPMarginGroup allows you to tie a margin side of two or more layout elements together, such that they will all have the same size, based on the largest required margin in the group.


Demonstration of QCPMarginGroup


In certain situations it is desirable that margins at specific sides are synchronized across layout elements. For example, if one QCPAxisRect is below another one in a grid layout, it will provide a cleaner look to the user if the left and right margins of the two axis rects are of the same size. The left axis of the top axis rect will then be at the same horizontal position as the left axis of the lower axis rect, making them appear aligned. The same applies for the right axes. This is what QCPMarginGroup makes possible.

To add/remove a specific side of a layout element to/from a margin group, use the QCPLayoutElement::setMarginGroup method. To completely break apart the margin group, either call clear, or just delete the margin group.

Example

First create a margin group:

qcpmargingroup-creation-1 Then set this group on the layout element sides:

qcpmargingroup-creation-2 Here, we've used the first two axis rects of the plot and synchronized their left margins with each other and their right margins with each other.

Definition at line 1378 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPMarginGroup() [1/2]

QCPMarginGroup::QCPMarginGroup ( QCustomPlot parentPlot)
explicit

Creates a new QCPMarginGroup instance in parentPlot.

Definition at line 2961 of file qcustomplot.cpp.

References mChildren, QCP::msBottom, QCP::msLeft, QCP::msRight, and QCP::msTop.

◆ ~QCPMarginGroup() [1/2]

QCPMarginGroup::~QCPMarginGroup ( )
virtual

Definition at line 2969 of file qcustomplot.cpp.

References clear().

◆ QCPMarginGroup() [2/2]

QCPMarginGroup::QCPMarginGroup ( QCustomPlot parentPlot)

◆ ~QCPMarginGroup() [2/2]

QCPMarginGroup::~QCPMarginGroup ( )

Member Function Documentation

◆ addChild() [1/2]

void QCPMarginGroup::addChild ( QCP::MarginSide  side,
QCPLayoutElement element 
)
protected

Definition at line 3035 of file qcustomplot.cpp.

References mChildren.

Referenced by QCPLayoutElement::setMarginGroup().

◆ addChild() [2/2]

void QCPMarginGroup::addChild ( QCP::MarginSide  side,
QCPLayoutElement element 
)
protected

◆ clear() [1/2]

void QCPMarginGroup::clear ( )

Clears this margin group. The synchronization of the margin sides that use this margin group is lifted and they will use their individual margin sizes again.

Definition at line 2989 of file qcustomplot.cpp.

References elements(), and mChildren.

Referenced by ~QCPMarginGroup().

◆ clear() [2/2]

void QCPMarginGroup::clear ( )

◆ commonMargin() [1/2]

int QCPMarginGroup::commonMargin ( QCP::MarginSide  side) const
protectedvirtual

Definition at line 3013 of file qcustomplot.cpp.

References elements(), QCP::getMarginValue(), mChildren, and result.

◆ commonMargin() [2/2]

int QCPMarginGroup::commonMargin ( QCP::MarginSide  side) const
protected

◆ elements() [1/2]

QList<QCPLayoutElement *> QCPMarginGroup::elements ( QCP::MarginSide  side) const
inline

Definition at line 1385 of file qcustomplot.h.

Referenced by clear(), and commonMargin().

◆ elements() [2/2]

QList<QCPLayoutElement *> QCPMarginGroup::elements ( QCP::MarginSide  side) const
inline

Definition at line 787 of file qcustomplot.h.

◆ isEmpty() [1/2]

bool QCPMarginGroup::isEmpty ( ) const

Returns whether this margin group is empty. If this function returns true, no layout elements use this margin group to synchronize margin sides.

Definition at line 2975 of file qcustomplot.cpp.

References mChildren.

◆ isEmpty() [2/2]

bool QCPMarginGroup::isEmpty ( ) const

◆ removeChild() [1/2]

void QCPMarginGroup::removeChild ( QCP::MarginSide  side,
QCPLayoutElement element 
)
protected

Definition at line 3051 of file qcustomplot.cpp.

References mChildren.

Referenced by QCPLayoutElement::setMarginGroup().

◆ removeChild() [2/2]

void QCPMarginGroup::removeChild ( QCP::MarginSide  side,
QCPLayoutElement element 
)
protected

Member Data Documentation

◆ mChildren

QHash< QCP::MarginSide, QList< QCPLayoutElement * > > QCPMarginGroup::mChildren
protected

Definition at line 1394 of file qcustomplot.h.

Referenced by addChild(), clear(), commonMargin(), isEmpty(), QCPMarginGroup(), and removeChild().

◆ mParentPlot

QCustomPlot * QCPMarginGroup::mParentPlot
protected

Definition at line 1393 of file qcustomplot.h.


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