[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Thu Apr 8 14:19:08 UTC 2004


CVS commit by okellogg: 

ShieldWrongFloatingTextPos.diff by Achim Spangler (with minor modification.)


  M +48 -4     floatingtext.cpp   1.37
  M +9 -0      floatingtext.h   1.14


--- kdesdk/umbrello/umbrello/floatingtext.cpp  #1.36:1.37
@@ -73,11 +73,55 @@ void FloatingText::resizeEvent(QResizeEv
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 void FloatingText::setLinePos(int x, int y) {
+        bool xIsValid = (x >= restrictPositionMin && x <= restrictPositionMax);
+        bool yIsValid = (y >= restrictPositionMin && y <= restrictPositionMax);
+        if (xIsValid && yIsValid) { // fine
         setX(x);
         setY(y);
+        } else { // something is broken
+                kdDebug() << "FloatingText::setLinePositionRelatively( " << x
+                        << " , " << y << " ) - was blocked because at least one value is out of bounds: ["
+                        << restrictPositionMin << "..." << restrictPositionMax << "]  "
+                        << "origX: " << getX() << ", origY: " << getY()
+                        << endl;
+                // Let's just leave them at their original values.
+        }
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 void FloatingText::setLinePositionRelatively(int newX, int newY, int oldX, int oldY) {
-        setX( getX() + (newX-oldX) );
-        setY( getY() + (newY-oldY) );
+        int myNewX = getX() + (newX-oldX);
+        int myNewY = getY() + (newY-oldY);
+        if ( myNewX >= restrictPositionMin && myNewX <= restrictPositionMax )
+        { // fine
+                setX(myNewX);
+        }
+        else
+        { // something is broken
+                kdDebug() << "FloatingText::setLinePositionRelatively( " << myNewX
+                        << " , " << myNewY << " ) - was Blocked because at least one value is out of bounds: ["
+                        << restrictPositionMin << "..." << restrictPositionMax << "]\n"
+                        << "ToX: " << newX << ", ToY: " << newY
+                        << "FromX: " << oldX << ", FromY: " << oldY
+                        << "CurrentPointX: " << getX() << ", CurrentPointY: " << getY()
+                        << endl;
+                // set to 0
+                setX( 0 );
+        }
+
+        if ( myNewY >= restrictPositionMin && myNewY <= restrictPositionMax )
+        { // fine
+                setY(myNewY);
+        }
+        else
+        { // something is broken
+                kdDebug() << "FloatingText::setLinePositionRelatively( " << myNewX
+                        << " , " << myNewY << " ) - was Blocked because at least one value is out of bounds: ["
+                        << restrictPositionMin << "..." << restrictPositionMax << "]\n"
+                        << "ToX: " << newX << ", ToY: " << newY
+                        << "FromX: " << oldX << ", FromY: " << oldY
+                        << "CurrentPointX: " << getX() << ", CurrentPointY: " << getY()
+                        << endl;
+                // set to 0
+                setY( 0 );
+        }
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////

--- kdesdk/umbrello/umbrello/floatingtext.h  #1.13:1.14
@@ -35,4 +35,13 @@ class UMLView;
 class FloatingText : public UMLWidget {
 public:
+        /** sometimes the x/y values get numbers of <0 and >10000 - which is
+            probably due to a bug somewhere in calculating the position.
+                        -> workaround till problem is found: define min and max limits
+                        => if x or y is outside of interval, the position is reset
+                   ( e.g. by AssociationWidget::resetTextPositions() )
+         */
+        static const int restrictPositionMin = 0;
+        static const int restrictPositionMax = 3000;
+
 
         /**






More information about the umbrello-devel mailing list