Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QGraphicsAnchorLayoutPrivate Class Reference

#include <qgraphicsanchorlayout_p.h>

Inheritance diagram for QGraphicsAnchorLayoutPrivate:
Collaboration diagram for QGraphicsAnchorLayoutPrivate:

Classes

struct  GraphParts

Public Types

enum  Interval { MinimumToMinPreferred = 0 , MinPreferredToPreferred , PreferredToMaxPreferred , MaxPreferredToMaximum }
typedef Qt::Orientation Orientation
Public Types inherited from QGraphicsLayoutItemPrivate
enum  SizeComponent { Width , Height }

Public Member Functions

 QGraphicsAnchorLayoutPrivate ()
void createLayoutEdges ()
void deleteLayoutEdges ()
void createItemEdges (QGraphicsLayoutItem *item)
void createCenterAnchors (QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge)
void removeCenterAnchors (QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge, bool substitute=true)
void removeCenterConstraints (QGraphicsLayoutItem *item, Qt::Orientation orientation)
QGraphicsAnchoracquireGraphicsAnchor (AnchorData *data)
QGraphicsAnchoraddAnchor (QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, qreal *spacing=nullptr)
void addAnchor_helper (QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, AnchorData *data)
QGraphicsAnchorgetAnchor (QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
void removeAnchor (AnchorVertex *firstVertex, AnchorVertex *secondVertex)
void removeAnchor_helper (AnchorVertex *v1, AnchorVertex *v2)
void removeAnchors (QGraphicsLayoutItem *item)
void removeVertex (QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
void correctEdgeDirection (QGraphicsLayoutItem *&firstItem, Qt::AnchorPoint &firstEdge, QGraphicsLayoutItem *&secondItem, Qt::AnchorPoint &secondEdge)
QLayoutStyleInfostyleInfo () const
AnchorDataaddAnchorMaybeParallel (AnchorData *newAnchor, bool *feasible)
void calculateGraphs ()
void calculateGraphs (Qt::Orientation orientation)
bool simplifyGraph (Qt::Orientation orientation)
bool simplifyVertices (Qt::Orientation orientation)
bool simplifyGraphIteration (Qt::Orientation orientation, bool *feasible)
bool replaceVertex (Qt::Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV, const QList< AnchorData * > &edges)
void restoreSimplifiedGraph (Qt::Orientation orientation)
void restoreSimplifiedAnchor (AnchorData *edge)
void restoreSimplifiedConstraints (ParallelAnchorData *parallel)
void restoreVertices (Qt::Orientation orientation)
bool calculateTrunk (Qt::Orientation orientation, const GraphPath &trunkPath, const QList< QSimplexConstraint * > &constraints, const QList< AnchorData * > &variables)
bool calculateNonTrunk (const QList< QSimplexConstraint * > &constraints, const QList< AnchorData * > &variables)
void refreshAllSizeHints (Qt::Orientation orientation)
void findPaths (Qt::Orientation orientation)
void constraintsFromPaths (Qt::Orientation orientation)
void updateAnchorSizes (Qt::Orientation orientation)
QList< QSimplexConstraint * > constraintsFromSizeHints (const QList< AnchorData * > &anchors)
GraphParts getGraphParts (Qt::Orientation orientation)
void identifyFloatItems (const QSet< AnchorData * > &visited, Qt::Orientation orientation)
void identifyNonFloatItems_helper (const AnchorData *ad, QSet< QGraphicsLayoutItem * > *nonFloatingItemsIdentifiedSoFar)
AnchorVertexinternalVertex (const std::pair< QGraphicsLayoutItem *, Qt::AnchorPoint > &itemEdge) const
AnchorVertexinternalVertex (const QGraphicsLayoutItem *item, Qt::AnchorPoint edge) const
void changeLayoutVertex (Qt::Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV)
AnchorVertexaddInternalVertex (QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
void removeInternalVertex (QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
void setItemsGeometries (const QRectF &geom)
void calculateVertexPositions (Qt::Orientation orientation)
void setupEdgesInterpolation (Qt::Orientation orientation)
void interpolateEdge (AnchorVertex *base, AnchorData *edge)
bool solveMinMax (const QList< QSimplexConstraint * > &constraints, const GraphPath &path, qreal *min, qreal *max)
bool solvePreferred (const QList< QSimplexConstraint * > &constraints, const QList< AnchorData * > &variables)
bool hasConflicts () const
Public Member Functions inherited from QGraphicsLayoutPrivate
 QGraphicsLayoutPrivate ()
void reparentChildItems (QGraphicsItem *newParent)
void getMargin (qreal *result, qreal userMargin, QStyle::PixelMetric pm) const
Qt::LayoutDirection visualDirection () const
void addChildLayoutItem (QGraphicsLayoutItem *item)
void activateRecursive (QGraphicsLayoutItem *item)
Public Member Functions inherited from QGraphicsLayoutItemPrivate
virtual ~QGraphicsLayoutItemPrivate ()
 QGraphicsLayoutItemPrivate (QGraphicsLayoutItem *parent, bool isLayout)
void init ()
QSizeFeffectiveSizeHints (const QSizeF &constraint) const
QGraphicsItemparentItem () const
void ensureUserSizeHints ()
void setSize (Qt::SizeHint which, const QSizeF &size)
void setSizeComponent (Qt::SizeHint which, SizeComponent component, qreal value)
bool hasHeightForWidth () const
bool hasWidthForHeight () const

Static Public Member Functions

static QGraphicsAnchorLayoutPrivateget (QGraphicsAnchorLayout *q)
static Qt::AnchorPoint oppositeEdge (Qt::AnchorPoint edge)
static Qt::Orientation edgeOrientation (Qt::AnchorPoint edge) noexcept
static Qt::AnchorPoint pickEdge (Qt::AnchorPoint edge, Qt::Orientation orientation)
Static Public Member Functions inherited from QGraphicsLayoutItemPrivate
static QGraphicsLayoutItemPrivateget (QGraphicsLayoutItem *q)
static const QGraphicsLayoutItemPrivateget (const QGraphicsLayoutItem *q)

Public Attributes

QHVContainer< qrealspacings = {-1, -1}
QHVContainer< std::array< qreal, 3 > > sizeHints = {{-1, -1, -1}, {-1, -1, -1}}
QList< QGraphicsLayoutItem * > items
QHash< std::pair< QGraphicsLayoutItem *, Qt::AnchorPoint >, std::pair< AnchorVertex *, int > > m_vertexList
QHVContainer< Graph< AnchorVertex, AnchorData > > graph
QHVContainer< AnchorVertex * > layoutFirstVertex = {}
QHVContainer< AnchorVertex * > layoutCentralVertex = {}
QHVContainer< AnchorVertex * > layoutLastVertex = {}
QHVContainer< QList< AnchorVertexPair * > > simplifiedVertices
QHVContainer< QList< AnchorData * > > anchorsFromSimplifiedVertices
QHVContainer< QMultiHash< AnchorVertex *, GraphPath > > graphPaths
QHVContainer< QList< QSimplexConstraint * > > constraints
QHVContainer< QList< QSimplexConstraint * > > itemCenterConstraints
QHVContainer< IntervalinterpolationInterval
QHVContainer< qrealinterpolationProgress = {-1, -1}
QHVContainer< bool > graphHasConflicts = {}
QHVContainer< QSet< QGraphicsLayoutItem * > > m_floatItems
uint calculateGraphCacheDirty: 1
uint styleInfoDirty: 1
QLayoutStyleInfo cachedStyleInfo
Public Attributes inherited from QGraphicsLayoutPrivate
qreal left
qreal top
qreal right
qreal bottom
bool activated
Public Attributes inherited from QGraphicsLayoutItemPrivate
QSizePolicy sizePolicy
QGraphicsLayoutItemparent
QSizeFuserSizeHints
QSizeF cachedSizeHints [Qt::NSizeHints]
QSizeF cachedConstraint
QSizeF cachedSizeHintsWithConstraints [Qt::NSizeHints]
quint32 sizeHintCacheDirty: 1
quint32 sizeHintWithConstraintCacheDirty: 1
quint32 isLayout: 1
quint32 ownedByLayout: 1
QGraphicsLayoutItemq_ptr
QRectF geom
QGraphicsItemgraphicsItem

Static Public Attributes

static constexpr Qt::Orientation Horizontal = Qt::Horizontal
static constexpr Qt::Orientation Vertical = Qt::Vertical

Friends

class QGraphicsAnchorPrivate

Detailed Description

QGraphicsAnchorLayout private methods and attributes.

Definition at line 349 of file qgraphicsanchorlayout_p.h.

Member Typedef Documentation

◆ Orientation

Member Enumeration Documentation

◆ Interval

Enumerator
MinimumToMinPreferred 
MinPreferredToPreferred 
PreferredToMaxPreferred 
MaxPreferredToMaximum 

Definition at line 359 of file qgraphicsanchorlayout_p.h.

Constructor & Destructor Documentation

◆ QGraphicsAnchorLayoutPrivate()

QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate ( )

Definition at line 586 of file qgraphicsanchorlayout_p.cpp.

Member Function Documentation

◆ acquireGraphicsAnchor()

QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::acquireGraphicsAnchor ( AnchorData * data)
inline

Definition at line 400 of file qgraphicsanchorlayout_p.h.

◆ addAnchor()

QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::addAnchor ( QGraphicsLayoutItem * firstItem,
Qt::AnchorPoint firstEdge,
QGraphicsLayoutItem * secondItem,
Qt::AnchorPoint secondEdge,
qreal * spacing = nullptr )

Implements the high level "addAnchor" feature. Called by the public API addAnchor method.

The optional spacing argument defines the size of the anchor. If not provided, the anchor size is either 0 or not-set, depending on type of anchor created (see matrix below).

All anchors that remain with size not-set will assume the standard spacing, set either by the layout style or through the "setSpacing" layout API.

Definition at line 1580 of file qgraphicsanchorlayout_p.cpp.

◆ addAnchor_helper()

void QGraphicsAnchorLayoutPrivate::addAnchor_helper ( QGraphicsLayoutItem * firstItem,
Qt::AnchorPoint firstEdge,
QGraphicsLayoutItem * secondItem,
Qt::AnchorPoint secondEdge,
AnchorData * data )

Definition at line 1674 of file qgraphicsanchorlayout_p.cpp.

◆ addAnchorMaybeParallel()

AnchorData * QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel ( AnchorData * newAnchor,
bool * feasible )

Adds newAnchor to the graph.

Returns the newAnchor itself if it could be added without further changes to the graph. If a new parallel anchor had to be created, then returns the new parallel anchor. If a parallel anchor had to be created and it results in an unfeasible setup, feasible is set to false, otherwise true.

Note that in the case a new parallel anchor is created, it might also take over some constraints from its children anchors.

Definition at line 626 of file qgraphicsanchorlayout_p.cpp.

◆ addInternalVertex()

AnchorVertex * QGraphicsAnchorLayoutPrivate::addInternalVertex ( QGraphicsLayoutItem * item,
Qt::AnchorPoint edge )

Definition at line 1836 of file qgraphicsanchorlayout_p.cpp.

◆ calculateGraphs() [1/2]

void QGraphicsAnchorLayoutPrivate::calculateGraphs ( )

Called on activation. Uses Linear Programming to define minimum, preferred and maximum sizes for the layout. Also calculates the sizes that each item should assume when the layout is in one of such situations.

Definition at line 1998 of file qgraphicsanchorlayout_p.cpp.

◆ calculateGraphs() [2/2]

void QGraphicsAnchorLayoutPrivate::calculateGraphs ( Qt::Orientation orientation)

Calculate graphs is the method that puts together all the helper routines so that the AnchorLayout can calculate the sizes of each item.

In a nutshell it should do:

1) Refresh anchor nominal sizes, that is, the size that each anchor would have if no other restrictions applied. This is done by querying the layout style and the sizeHints of the items belonging to the layout.

2) Simplify the graph by grouping together parallel and sequential anchors into "group anchors". These have equivalent minimum, preferred and maximum sizeHints as the anchors they replace.

3) Check if we got to a trivial case. In some cases, the whole graph can be simplified into a single anchor. If so, use this information. If not, then call the Simplex solver to calculate the anchors sizes.

4) Once the root anchors had its sizes calculated, propagate that to the anchors they represent.

Definition at line 2043 of file qgraphicsanchorlayout_p.cpp.

◆ calculateNonTrunk()

bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk ( const QList< QSimplexConstraint * > & constraints,
const QList< AnchorData * > & variables )

Definition at line 2208 of file qgraphicsanchorlayout_p.cpp.

◆ calculateTrunk()

bool QGraphicsAnchorLayoutPrivate::calculateTrunk ( Qt::Orientation orientation,
const GraphPath & path,
const QList< QSimplexConstraint * > & constraints,
const QList< AnchorData * > & variables )

Calculate the sizes for all anchors which are part of the trunk. This works on top of a (possibly) simplified graph.

Definition at line 2140 of file qgraphicsanchorlayout_p.cpp.

◆ calculateVertexPositions()

void QGraphicsAnchorLayoutPrivate::calculateVertexPositions ( Qt::Orientation orientation)

Calculate the position of each vertex based on the paths to each of them as well as the current edges sizes.

Definition at line 2624 of file qgraphicsanchorlayout_p.cpp.

◆ changeLayoutVertex()

void QGraphicsAnchorLayoutPrivate::changeLayoutVertex ( Qt::Orientation orientation,
AnchorVertex * oldV,
AnchorVertex * newV )
inline

Definition at line 491 of file qgraphicsanchorlayout_p.h.

◆ constraintsFromPaths()

void QGraphicsAnchorLayoutPrivate::constraintsFromPaths ( Qt::Orientation orientation)

Each vertex on the graph that has more than one path to it represents a contra int to the sizes of the items in these paths.

This method walks the list of paths to each vertex, generate the constraints and store them in a list so they can be used later by the Simplex solver.

Definition at line 2309 of file qgraphicsanchorlayout_p.cpp.

◆ constraintsFromSizeHints()

QList< QSimplexConstraint * > QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints ( const QList< AnchorData * > & anchors)

Create LP constraints for each anchor based on its minimum and maximum sizes, as specified in its size hints

Definition at line 2345 of file qgraphicsanchorlayout_p.cpp.

◆ correctEdgeDirection()

void QGraphicsAnchorLayoutPrivate::correctEdgeDirection ( QGraphicsLayoutItem *& firstItem,
Qt::AnchorPoint & firstEdge,
QGraphicsLayoutItem *& secondItem,
Qt::AnchorPoint & secondEdge )

Use heuristics to determine the correct orientation of a given anchor.

After API discussions, we decided we would like expressions like anchor(A, Left, B, Right) to mean the same as anchor(B, Right, A, Left). The problem with this is that anchors could become ambiguous, for instance, what does the anchor A, B of size X mean?

"pos(B) = pos(A) + X" or "pos(A) = pos(B) + X" ?

To keep the API user friendly and at the same time, keep our algorithm deterministic, we use an heuristic to determine a direction for each added anchor and then keep it. The heuristic is based on the fact that people usually avoid overlapping items, therefore:

"A, RIGHT to B, LEFT" means that B is to the LEFT of A. "B, LEFT to A, RIGHT" is corrected to the above anchor.

Special correction is also applied when one of the items is the layout. We handle Layout Left as if it was another items's Right and Layout Right as another item's Left.

Definition at line 1934 of file qgraphicsanchorlayout_p.cpp.

◆ createCenterAnchors()

void QGraphicsAnchorLayoutPrivate::createCenterAnchors ( QGraphicsLayoutItem * item,
Qt::AnchorPoint centerEdge )

By default, each item in the layout is represented internally as a single anchor in each direction. For instance, from Left to Right.

However, to support anchorage of items to the center of items, we must split this internal anchor into two half-anchors. From Left to Center and then from Center to Right, with the restriction that these anchors must have the same time at all times.

Definition at line 1389 of file qgraphicsanchorlayout_p.cpp.

◆ createItemEdges()

void QGraphicsAnchorLayoutPrivate::createItemEdges ( QGraphicsLayoutItem * item)

Definition at line 1363 of file qgraphicsanchorlayout_p.cpp.

◆ createLayoutEdges()

void QGraphicsAnchorLayoutPrivate::createLayoutEdges ( )

Create internal anchors to connect the layout edges (Left to Right and Top to Bottom).

These anchors doesn't have size restrictions, that will be enforced by other anchors and items in the layout.

Definition at line 1322 of file qgraphicsanchorlayout_p.cpp.

◆ deleteLayoutEdges()

void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges ( )

Definition at line 1350 of file qgraphicsanchorlayout_p.cpp.

◆ edgeOrientation()

Qt::Orientation QGraphicsAnchorLayoutPrivate::edgeOrientation ( Qt::AnchorPoint edge)
staticnoexcept

Definition at line 1308 of file qgraphicsanchorlayout_p.cpp.

◆ findPaths()

void QGraphicsAnchorLayoutPrivate::findPaths ( Qt::Orientation orientation)

This method walks the graph using a breadth-first search to find paths between the root vertex and each vertex on the graph. The edges directions in each path are considered and they are stored as a positive edge (left-to-right) or negative edge (right-to-left).

The list of paths is used later to generate a list of constraints.

Definition at line 2257 of file qgraphicsanchorlayout_p.cpp.

◆ get()

QGraphicsAnchorLayoutPrivate * QGraphicsAnchorLayoutPrivate::get ( QGraphicsAnchorLayout * q)
inlinestatic

Definition at line 372 of file qgraphicsanchorlayout_p.h.

◆ getAnchor()

QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::getAnchor ( QGraphicsLayoutItem * firstItem,
Qt::AnchorPoint firstEdge,
QGraphicsLayoutItem * secondItem,
Qt::AnchorPoint secondEdge )

Definition at line 1714 of file qgraphicsanchorlayout_p.cpp.

◆ getGraphParts()

QGraphicsAnchorLayoutPrivate::GraphParts QGraphicsAnchorLayoutPrivate::getGraphParts ( Qt::Orientation orientation)

Definition at line 2440 of file qgraphicsanchorlayout_p.cpp.

◆ hasConflicts()

bool QGraphicsAnchorLayoutPrivate::hasConflicts ( ) const

Returns true if there are no arrangement that satisfies all constraints. Otherwise returns false.

See also
addAnchor()

Definition at line 2900 of file qgraphicsanchorlayout_p.cpp.

◆ identifyFloatItems()

void QGraphicsAnchorLayoutPrivate::identifyFloatItems ( const QSet< AnchorData * > & visited,
Qt::Orientation orientation )

Use all visited Anchors on findPaths() so we can identify non-float Items.

Definition at line 2517 of file qgraphicsanchorlayout_p.cpp.

◆ identifyNonFloatItems_helper()

void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper ( const AnchorData * ad,
QSet< QGraphicsLayoutItem * > * nonFloatingItemsIdentifiedSoFar )

Given an anchor, if it is an internal anchor and Normal we must mark it's item as non-float. If the anchor is Sequential or Parallel, we must iterate on its children recursively until we reach internal anchors (items).

Definition at line 2540 of file qgraphicsanchorlayout_p.cpp.

◆ internalVertex() [1/2]

AnchorVertex * QGraphicsAnchorLayoutPrivate::internalVertex ( const QGraphicsLayoutItem * item,
Qt::AnchorPoint edge ) const
inline

Definition at line 486 of file qgraphicsanchorlayout_p.h.

◆ internalVertex() [2/2]

AnchorVertex * QGraphicsAnchorLayoutPrivate::internalVertex ( const std::pair< QGraphicsLayoutItem *, Qt::AnchorPoint > & itemEdge) const
inline

Definition at line 481 of file qgraphicsanchorlayout_p.h.

◆ interpolateEdge()

void QGraphicsAnchorLayoutPrivate::interpolateEdge ( AnchorVertex * base,
AnchorData * edge )

Calculate the current Edge size based on the current Layout size and the size the edge is supposed to have when the layout is at its:

  • minimum size,
  • preferred size,
  • maximum size.

These three key values are calculated in advance using linear programming (more expensive) or the simplification algorithm, then subsequential resizes of the parent layout require a simple interpolation.

Definition at line 2704 of file qgraphicsanchorlayout_p.cpp.

◆ oppositeEdge()

Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge ( Qt::AnchorPoint edge)
static

Definition at line 591 of file qgraphicsanchorlayout_p.cpp.

◆ pickEdge()

Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::pickEdge ( Qt::AnchorPoint edge,
Qt::Orientation orientation )
inlinestatic

Definition at line 382 of file qgraphicsanchorlayout_p.h.

◆ refreshAllSizeHints()

void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints ( Qt::Orientation orientation)

Traverse the graph refreshing the size hints. Edges will query their associated item or graphicsAnchor for their size hints.

Definition at line 2235 of file qgraphicsanchorlayout_p.cpp.

◆ removeAnchor()

void QGraphicsAnchorLayoutPrivate::removeAnchor ( AnchorVertex * firstVertex,
AnchorVertex * secondVertex )

Implements the high level "removeAnchor" feature. Called by the QAnchorData destructor.

Definition at line 1749 of file qgraphicsanchorlayout_p.cpp.

◆ removeAnchor_helper()

void QGraphicsAnchorLayoutPrivate::removeAnchor_helper ( AnchorVertex * v1,
AnchorVertex * v2 )

Definition at line 1823 of file qgraphicsanchorlayout_p.cpp.

◆ removeAnchors()

void QGraphicsAnchorLayoutPrivate::removeAnchors ( QGraphicsLayoutItem * item)

Definition at line 1898 of file qgraphicsanchorlayout_p.cpp.

◆ removeCenterAnchors()

void QGraphicsAnchorLayoutPrivate::removeCenterAnchors ( QGraphicsLayoutItem * item,
Qt::AnchorPoint centerEdge,
bool substitute = true )

Definition at line 1454 of file qgraphicsanchorlayout_p.cpp.

◆ removeCenterConstraints()

void QGraphicsAnchorLayoutPrivate::removeCenterConstraints ( QGraphicsLayoutItem * item,
Qt::Orientation orientation )

Definition at line 1537 of file qgraphicsanchorlayout_p.cpp.

◆ removeInternalVertex()

void QGraphicsAnchorLayoutPrivate::removeInternalVertex ( QGraphicsLayoutItem * item,
Qt::AnchorPoint edge )

returns the AnchorVertex that was dereferenced, also when it was removed. returns 0 if it did not exist.

Definition at line 1857 of file qgraphicsanchorlayout_p.cpp.

◆ removeVertex()

void QGraphicsAnchorLayoutPrivate::removeVertex ( QGraphicsLayoutItem * item,
Qt::AnchorPoint edge )

Definition at line 1885 of file qgraphicsanchorlayout_p.cpp.

◆ replaceVertex()

bool QGraphicsAnchorLayoutPrivate::replaceVertex ( Qt::Orientation orientation,
AnchorVertex * oldV,
AnchorVertex * newV,
const QList< AnchorData * > & edges )

Definition at line 832 of file qgraphicsanchorlayout_p.cpp.

◆ restoreSimplifiedAnchor()

void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor ( AnchorData * edge)

Definition at line 1135 of file qgraphicsanchorlayout_p.cpp.

◆ restoreSimplifiedConstraints()

void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints ( ParallelAnchorData * parallel)

Definition at line 1181 of file qgraphicsanchorlayout_p.cpp.

◆ restoreSimplifiedGraph()

void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph ( Qt::Orientation orientation)

Definition at line 1207 of file qgraphicsanchorlayout_p.cpp.

◆ restoreVertices()

void QGraphicsAnchorLayoutPrivate::restoreVertices ( Qt::Orientation orientation)

Definition at line 1236 of file qgraphicsanchorlayout_p.cpp.

◆ setItemsGeometries()

void QGraphicsAnchorLayoutPrivate::setItemsGeometries ( const QRectF & geom)

Use the current vertices distance to calculate and set the geometry of each item.

Definition at line 2566 of file qgraphicsanchorlayout_p.cpp.

◆ setupEdgesInterpolation()

void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation ( Qt::Orientation orientation)

Calculate interpolation parameters based on current Layout Size. Must be called once before calling "interpolateEdgeSize()" for the edges.

Definition at line 2669 of file qgraphicsanchorlayout_p.cpp.

◆ simplifyGraph()

bool QGraphicsAnchorLayoutPrivate::simplifyGraph ( Qt::Orientation orientation)

The purpose of this function is to simplify the graph. Simplification serves two purposes:

  1. Reduce the number of edges in the graph, (thus the number of variables to the equation solver is reduced, and the solver performs better).
  2. Be able to do distribution of sequences of edges more intelligently (esp. with sequential anchors)

It is essential that it must be possible to restore simplified anchors back to their "original" form. This is done by restoreSimplifiedAnchor().

There are two types of simplification that can be done:

  1. Sequential simplification Sequential simplification means that all sequences of anchors will be merged into one single anchor. Only anhcors that points in the same direction will be merged.
  2. Parallel simplification If a simplified sequential anchor is about to be inserted between two vertices in the graph and there already exist an anchor between those two vertices, a parallel anchor will be created that serves as a placeholder for the sequential anchor and the anchor that was already between the two vertices.

The process of simplification can be described as:

  1. Simplify all sequences of anchors into one anchor. If no further simplification was done, go to (3)
    • If there already exist an anchor where the sequential anchor is supposed to be inserted, take that anchor out of the graph
    • Then create a parallel anchor that holds the sequential anchor and the anchor just taken out of the graph.
  2. Go to (1)
  3. Done

When creating the parallel anchors, the algorithm might identify unfeasible situations. In this case the simplification process stops and returns false. Otherwise returns true.

Definition at line 775 of file qgraphicsanchorlayout_p.cpp.

◆ simplifyGraphIteration()

bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration ( Qt::Orientation orientation,
bool * feasible )

One iteration of the simplification algorithm. Returns true if another iteration is needed.

The algorithm walks the graph in depth-first order, and only collects vertices that has two edges connected to it. If the vertex does not have two edges or if it is a layout edge, it will take all the previously collected vertices and try to create a simplified sequential anchor representing all the previously collected vertices. Once the simplified anchor is inserted, the collected list is cleared in order to find the next sequence to simplify.

Note that there are some catches to this that are not covered by the above explanation, see the function comments for more details.

Definition at line 979 of file qgraphicsanchorlayout_p.cpp.

◆ simplifyVertices()

bool QGraphicsAnchorLayoutPrivate::simplifyVertices ( Qt::Orientation orientation)

Definition at line 866 of file qgraphicsanchorlayout_p.cpp.

◆ solveMinMax()

bool QGraphicsAnchorLayoutPrivate::solveMinMax ( const QList< QSimplexConstraint * > & constraints,
const GraphPath & path,
qreal * min,
qreal * max )

Definition at line 2724 of file qgraphicsanchorlayout_p.cpp.

◆ solvePreferred()

bool QGraphicsAnchorLayoutPrivate::solvePreferred ( const QList< QSimplexConstraint * > & constraints,
const QList< AnchorData * > & variables )

Definition at line 2783 of file qgraphicsanchorlayout_p.cpp.

◆ styleInfo()

QLayoutStyleInfo & QGraphicsAnchorLayoutPrivate::styleInfo ( ) const

Definition at line 1963 of file qgraphicsanchorlayout_p.cpp.

◆ updateAnchorSizes()

void QGraphicsAnchorLayoutPrivate::updateAnchorSizes ( Qt::Orientation orientation)

Definition at line 2328 of file qgraphicsanchorlayout_p.cpp.

◆ QGraphicsAnchorPrivate

friend class QGraphicsAnchorPrivate
friend

Definition at line 568 of file qgraphicsanchorlayout_p.h.

Member Data Documentation

◆ anchorsFromSimplifiedVertices

QHVContainer<QList<AnchorData *> > QGraphicsAnchorLayoutPrivate::anchorsFromSimplifiedVertices

Definition at line 545 of file qgraphicsanchorlayout_p.h.

◆ cachedStyleInfo

QLayoutStyleInfo QGraphicsAnchorLayoutPrivate::cachedStyleInfo
mutable

Definition at line 566 of file qgraphicsanchorlayout_p.h.

◆ calculateGraphCacheDirty

uint QGraphicsAnchorLayoutPrivate::calculateGraphCacheDirty

Definition at line 564 of file qgraphicsanchorlayout_p.h.

◆ constraints

QHVContainer<QList<QSimplexConstraint *> > QGraphicsAnchorLayoutPrivate::constraints

Definition at line 549 of file qgraphicsanchorlayout_p.h.

◆ graph

QHVContainer<Graph<AnchorVertex, AnchorData> > QGraphicsAnchorLayoutPrivate::graph

Definition at line 537 of file qgraphicsanchorlayout_p.h.

◆ graphHasConflicts

QHVContainer<bool> QGraphicsAnchorLayoutPrivate::graphHasConflicts = {}

Definition at line 557 of file qgraphicsanchorlayout_p.h.

◆ graphPaths

QHVContainer<QMultiHash<AnchorVertex *, GraphPath> > QGraphicsAnchorLayoutPrivate::graphPaths

Definition at line 548 of file qgraphicsanchorlayout_p.h.

◆ Horizontal

Qt::Orientation QGraphicsAnchorLayoutPrivate::Horizontal = Qt::Horizontal
inlinestaticconstexpr

Definition at line 367 of file qgraphicsanchorlayout_p.h.

◆ interpolationInterval

QHVContainer<Interval> QGraphicsAnchorLayoutPrivate::interpolationInterval

Definition at line 554 of file qgraphicsanchorlayout_p.h.

◆ interpolationProgress

QHVContainer<qreal> QGraphicsAnchorLayoutPrivate::interpolationProgress = {-1, -1}

Definition at line 555 of file qgraphicsanchorlayout_p.h.

◆ itemCenterConstraints

QHVContainer<QList<QSimplexConstraint *> > QGraphicsAnchorLayoutPrivate::itemCenterConstraints

Definition at line 550 of file qgraphicsanchorlayout_p.h.

◆ items

QList<QGraphicsLayoutItem *> QGraphicsAnchorLayoutPrivate::items

Definition at line 529 of file qgraphicsanchorlayout_p.h.

◆ layoutCentralVertex

QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutCentralVertex = {}

Definition at line 540 of file qgraphicsanchorlayout_p.h.

◆ layoutFirstVertex

QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutFirstVertex = {}

Definition at line 539 of file qgraphicsanchorlayout_p.h.

◆ layoutLastVertex

QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutLastVertex = {}

Definition at line 541 of file qgraphicsanchorlayout_p.h.

◆ m_floatItems

QHVContainer<QSet<QGraphicsLayoutItem *> > QGraphicsAnchorLayoutPrivate::m_floatItems

Definition at line 558 of file qgraphicsanchorlayout_p.h.

◆ m_vertexList

QHash<std::pair<QGraphicsLayoutItem*, Qt::AnchorPoint>, std::pair<AnchorVertex *, int> > QGraphicsAnchorLayoutPrivate::m_vertexList

Definition at line 534 of file qgraphicsanchorlayout_p.h.

◆ simplifiedVertices

QHVContainer<QList<AnchorVertexPair *> > QGraphicsAnchorLayoutPrivate::simplifiedVertices

Definition at line 544 of file qgraphicsanchorlayout_p.h.

◆ sizeHints

QHVContainer<std::array<qreal, 3> > QGraphicsAnchorLayoutPrivate::sizeHints = {{-1, -1, -1}, {-1, -1, -1}}

Definition at line 526 of file qgraphicsanchorlayout_p.h.

◆ spacings

QHVContainer<qreal> QGraphicsAnchorLayoutPrivate::spacings = {-1, -1}

Definition at line 524 of file qgraphicsanchorlayout_p.h.

◆ styleInfoDirty

uint QGraphicsAnchorLayoutPrivate::styleInfoDirty
mutable

Definition at line 565 of file qgraphicsanchorlayout_p.h.

◆ Vertical

Qt::Orientation QGraphicsAnchorLayoutPrivate::Vertical = Qt::Vertical
inlinestaticconstexpr

Definition at line 368 of file qgraphicsanchorlayout_p.h.


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