[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Thu Jul 1 19:25:03 UTC 2004
CVS commit by okellogg:
Unreopen bug 76114: FloatingTexts now have their own unique ID.
M +14 -14 associationwidget.cpp 1.108
M +6 -3 umlwidget.cpp 1.86
--- kdesdk/umbrello/umbrello/associationwidget.cpp #1.107:1.108
@@ -1834,5 +1834,4 @@ void AssociationWidget::calculateNameTex
yt += m_pName -> getHeight() / 2;
uint size = m_LinePath.count();
- int xi = 0, xj = 0, yi = 0, yj = 0;
//sum of length(PTP1) and length(PTP2)
float total_length = 0;
@@ -1841,10 +1840,10 @@ void AssociationWidget::calculateNameTex
QPoint pi = m_LinePath.getPoint( i );
QPoint pj = m_LinePath.getPoint( i+1 );
- xi = pi.x();
- xj = pj.x();
- yi = pi.y();
- yj = pj.y();
- total_length = sqrt( pow(double(xt - xi), 2.0) + pow(double(yt - yi), 2.0) )
- + sqrt( pow(double(xt - xj), 2.0) + pow(double(yt - yj), 2.0) );
+ int xtiDiff = xt - pi.x();
+ int xtjDiff = xt - pj.x();
+ int ytiDiff = yt - pi.y();
+ int ytjDiff = yt - pj.y();
+ total_length = sqrt( double(xtiDiff * xtiDiff + ytiDiff * ytiDiff) )
+ + sqrt( double(xtjDiff * xtjDiff + ytjDiff * ytjDiff) );
//this gives the closest point
if( total_length < smallest_length || i == 0) {
@@ -1970,8 +1969,12 @@ void AssociationWidget::mouseReleaseEven
int pos = m_LinePath.count() - 1;
int DISTANCE = 40;//must be within this many pixels for it to be a multi menu
- float lengthMAP = sqrt( pow( double(m_LinePath.getPoint(0).x() - p.x()), 2.0) +
- pow( double(m_LinePath.getPoint(0).y() - p.y()), 2.0) );
- float lengthMBP = sqrt( pow( double(m_LinePath.getPoint(pos).x() - p.x()), 2.0) +
- pow( double(m_LinePath.getPoint(pos).y() - p.y()), 2.0) );
+ QPoint lpStart = m_LinePath.getPoint(0);
+ QPoint lpEnd = m_LinePath.getPoint(pos);
+ int startXDiff = lpStart.x() - p.x();
+ int startYDiff = lpStart.y() - p.y();
+ int endXDiff = lpEnd.x() - p.x();
+ int endYDiff = lpEnd.y() - p.y();
+ float lengthMAP = sqrt( double(startXDiff * startXDiff + startYDiff * startYDiff) );
+ float lengthMBP = sqrt( double(endXDiff * endXDiff + endYDiff * endYDiff) );
Association_Type type = getAssocType();
//allow multiplicity
@@ -2777,7 +2780,4 @@ void AssociationWidget::cleanupBeforeFTs
void AssociationWidget::setupAfterFTsetLink(FloatingText *ft) {
- UMLAssociation *umla = getAssociation();
- if (umla != NULL) // sync id to association id.
- ft->setID( umla->getID() );
ft->addAssoc(this); // FIXME: This is horrible.
}
--- kdesdk/umbrello/umbrello/umlwidget.cpp #1.85:1.86
@@ -190,12 +190,15 @@ bool UMLWidget::operator==(const UMLWidg
void UMLWidget::setID(int id) {
- // kdWarning()<<"UMLWidget::setID(int id) called!"<<endl;
- if (m_pObject)
+ if (m_Type != wt_Text && m_pObject && m_pObject->getBaseType() == ot_Association) {
+ if (m_pObject->getID() != -1)
+ kdWarning() << "UMLWidget::setID(): changing old UMLObject "
+ << m_pObject->getID() << " to " << id << endl;
m_pObject->setID( id );
+ }
m_nId = id;
}
int UMLWidget::getID() const {
- if (m_pObject)
+ if (m_Type != wt_Text && m_pObject && m_pObject->getBaseType() == ot_Association)
return m_pObject->getID();
return m_nId;
More information about the umbrello-devel
mailing list