Qt 4.8
Public Functions | Public Variables | List of all members
GraphPath Class Reference

Representation of a valid path for a given vertex in the graph. More...

#include <qgraphicsanchorlayout_p.h>

Public Functions

QSimplexConstraintconstraint (const GraphPath &path) const
 
 GraphPath ()
 
QString toString () const
 

Public Variables

QSet< AnchorData * > negatives
 
QSet< AnchorData * > positives
 

Detailed Description

Representation of a valid path for a given vertex in the graph.

Warning
This function is not part of the public interface.

In this struct, "positives" is the set of anchors that have been traversed in the forward direction, while "negatives" is the set with the ones walked backwards.

This paths are compared against each other to produce LP Constraints, the exact order in which the anchors were traversed is not relevant.

Definition at line 324 of file qgraphicsanchorlayout_p.h.

Constructors and Destructors

◆ GraphPath()

GraphPath::GraphPath ( )
inline

Definition at line 327 of file qgraphicsanchorlayout_p.h.

327 {}

Functions

◆ constraint()

QSimplexConstraint * GraphPath::constraint ( const GraphPath path) const

Definition at line 582 of file qgraphicsanchorlayout_p.cpp.

583 {
584  // Calculate
585  QSet<AnchorData *> cPositives;
586  QSet<AnchorData *> cNegatives;
587  QSet<AnchorData *> intersection;
588 
589  cPositives = positives + path.negatives;
590  cNegatives = negatives + path.positives;
591 
592  intersection = cPositives & cNegatives;
593 
594  cPositives -= intersection;
595  cNegatives -= intersection;
596 
597  // Fill
600  for (i = cPositives.begin(); i != cPositives.end(); ++i)
601  c->variables.insert(*i, 1.0);
602 
603  for (i = cNegatives.begin(); i != cNegatives.end(); ++i)
604  c->variables.insert(*i, -1.0);
605 
606  return c;
607 }
unsigned char c[8]
Definition: qnumeric_p.h:62
QHash< QSimplexVariable *, qreal > variables
Definition: qsimplex_p.h:91
iterator begin()
Definition: qset.h:166
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QSet< AnchorData * > negatives
iterator end()
Definition: qset.h:169
QSet< AnchorData * > positives

◆ toString()

QString GraphPath::toString ( ) const

Definition at line 610 of file qgraphicsanchorlayout_p.cpp.

611 {
612  QString string(QLatin1String("Path: "));
613  foreach(AnchorData *edge, positives)
614  string += QString::fromAscii(" (+++) %1").arg(edge->toString());
615 
616  foreach(AnchorData *edge, negatives)
617  string += QString::fromAscii(" (---) %1").arg(edge->toString());
618 
619  return string;
620 }
Represents an edge (anchor) in the internal graph.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QSet< AnchorData * > negatives
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QSet< AnchorData * > positives
QString toString() const

Properties

◆ negatives

QSet<AnchorData *> GraphPath::negatives

◆ positives

QSet<AnchorData *> GraphPath::positives

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