[Uml-devel] branches/work/soc-umbrello/umbrello
Gopala Krishna A
krishna.ggk at gmail.com
Fri Jun 19 22:01:54 UTC 2009
SVN commit 984082 by gopala:
Added subset symbol support to AssociationLine.
M +38 -2 newlinepath.cpp
M +4 -1 newlinepath.h
--- branches/work/soc-umbrello/umbrello/newlinepath.cpp #984081:984082
@@ -37,6 +37,10 @@
PointPair(QPointF(0, -10), QPointF(0, 10))
},
{
+ QRectF(-15, -10, 30, 20), QPainterPath(), QLineF(-10, 0, 0, 0),
+ PointPair(QPointF(0, 0), QPointF(0, 0))
+ },
+ {
QRectF(-8, -8, 16, 16), QPainterPath(), QLineF(0, -8, 0, 8),
PointPair(QPointF(0, -8), QPointF(0, 8))
}
@@ -66,6 +70,15 @@
diamond.shape.lineTo(rect.center().x(), rect.top());
}
+ SymbolProperty &subset = symbolTable[Subset];
+ if (subset.shape.isEmpty()) {
+ QRectF rect = subset.boundRect;
+ //Defines an arc fitting in bound rect.
+ qreal start = 90, span = 180;
+ subset.shape.arcMoveTo(rect, start);
+ subset.shape.arcTo(rect, start, span);
+ }
+
SymbolProperty &circle = symbolTable[Circle];
if (circle.shape.isEmpty()) {
QRectF rect = circle.boundRect;
@@ -230,13 +243,13 @@
*/
AssociationLine::AssociationLine(New::AssociationWidget *assoc) : m_associationWidget(assoc)
{
+ Q_ASSERT(assoc);
m_activePointIndex = m_activeSegmentIndex = -1;
- m_startSymbol = m_endSymbol = 0;
+ m_startSymbol = m_endSymbol = m_subsetSymbol = 0;
// This tracker is only for debugging and testing purpose.
tracker = new QGraphicsLineItem;
tracker->setPen(QPen(Qt::darkBlue, 1));
tracker->setZValue(100);
- Q_ASSERT(assoc);
}
/// Destructor
@@ -501,6 +514,19 @@
}
/**
+ * Creates a subset symbol and aligns it.
+ */
+ void AssociationLine::createSubsetSymbol()
+ {
+ if (m_subsetSymbol) {
+ return;
+ }
+ m_subsetSymbol = new Symbol(Symbol::Subset, m_associationWidget);
+ m_subsetSymbol->setPen(pen());
+ alignSymbols();
+ }
+
+ /**
* This method aligns both the \b "start" and \b "end" symbols to
* the current angles of the \b "first" and the \b "last" line
* segment respectively.
@@ -522,6 +548,13 @@
QLineF segment(m_points[sz-2], m_points[sz - 1]);
m_endSymbol->alignTo(segment);
}
+
+ if (m_subsetSymbol) {
+ QLineF segment(m_points.at(0), (m_points.at(0) + m_points.at(1)) * .5);
+ uDebug() << "points: " << m_points.at(0) << m_points.at(1);
+ uDebug() << "segment: " << segment;
+ m_subsetSymbol->alignTo(segment);
+ }
}
@@ -586,6 +619,9 @@
if (m_endSymbol) {
m_endSymbol->setPen(changedPen);
}
+ if (m_subsetSymbol) {
+ m_subsetSymbol->setPen(changedPen);
+ }
calculateBoundingRect();
}
--- branches/work/soc-umbrello/umbrello/newlinepath.h #984081:984082
@@ -47,7 +47,7 @@
None = -1,
Arrow,
Diamond,
- // Subset,
+ Subset,
Circle,
Count
};
@@ -138,6 +138,7 @@
void setStartSymbol(Symbol::SymbolType symbolType);
void setEndSymbol(Symbol::SymbolType symbolType);
+ void createSubsetSymbol();
void alignSymbols();
bool loadFromXMI(QDomElement &qElement);
@@ -191,6 +192,8 @@
Symbol *m_startSymbol;
/// The symbol drawn at the end of "last" line segment.
Symbol *m_endSymbol;
+ /// The subset symbol.
+ Symbol *m_subsetSymbol;
/// The bounding rectangle of this AssociationLine
QRectF m_boundingRect;
More information about the umbrello-devel
mailing list