[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Tue Sep 13 20:28:28 CEST 2005


SVN commit 460405 by staikos:

- delispify a bit
- use C++ type conversions
- factor out abs/fabs calls (ex: abs(x)/abs(y) == abs(x/y))
- note about kst_cast<> being expensive and finding a better solution for
finding the right handler object


 M  +11 -9     ksttoplevelview.cpp  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #460404:460405
@@ -853,7 +853,7 @@
     QRect old = _prevBand;
     double aspect;
     if (line->to().x() != line->from().x()) {
-      aspect = (double)(line->to().y() - line->from().y())/(double)(line->to().x() - line->from().x());
+      aspect = double(line->to().y() - line->from().y()) / double(line->to().x() - line->from().x());
     } else {
       if (line->to().y() < line->from().y()) {
         aspect = -1.0E300;
@@ -866,11 +866,11 @@
       // UP means we are on the start endpoint
       toPoint = line->to();
       if (shift) {
-        if (((double)abs(pos.y() - toPoint.y())/(double)abs(pos.x() - toPoint.x()) < aspect || fabs(aspect) < 0.1) && 
-              fabs(aspect) < 500) {
-          fromPoint = QPoint(pos.x(), toPoint.y() + (int)(aspect*(pos.x() - toPoint.x())));
+        double absAspect = fabs(aspect);
+        if (absAspect < 500 && (double(abs((pos.y() - toPoint.y())/(pos.x() - toPoint.x()))) < aspect || absAspect < 0.1)) {
+          fromPoint = QPoint(pos.x(), toPoint.y() + int(aspect*(pos.x() - toPoint.x())));
         } else {
-          fromPoint = QPoint(toPoint.x() + (int)((pos.y() - toPoint.y())/aspect), pos.y());
+          fromPoint = QPoint(toPoint.x() + int((pos.y() - toPoint.y())/aspect), pos.y());
         }
       } else {
         fromPoint = pos;
@@ -879,11 +879,11 @@
       // DOWN means we are on the end endpoint
       fromPoint = line->from();
       if (shift) {
-        if (((double)abs(pos.y() - toPoint.y())/(double)abs(pos.x() - toPoint.x()) < aspect || fabs(aspect) < 0.1) &&
-              fabs(aspect) < 500) {
-          toPoint = QPoint(pos.x(), fromPoint.y() + (int)(aspect*(pos.x() - fromPoint.x())));
+        double absAspect = fabs(aspect);
+        if (absAspect < 500 && (double(abs((pos.y() - toPoint.y())/(pos.x() - toPoint.x()))) < aspect || absAspect < 0.1)) {
+          toPoint = QPoint(pos.x(), fromPoint.y() + int(aspect*(pos.x() - fromPoint.x())));
         } else {
-          toPoint = QPoint(fromPoint.x() + (int)((pos.y() - fromPoint.y())/aspect), pos.y());
+          toPoint = QPoint(fromPoint.x() + int((pos.y() - fromPoint.y())/aspect), pos.y());
         }
       } else {
         toPoint = pos;
@@ -1553,6 +1553,8 @@
 
 
 void KstTopLevelView::saveDefaults(KstViewObjectPtr object) {
+  // FIXME: don't hardcode this.  Let's come up with a property of the object
+  //        instead.  This is very slow too.
   // figure out what kind of object it is
   if (KstViewArrowPtr arrow = kst_cast<KstViewArrow>(object)) {
     // if it has an arrow head, save it to the arrow mouse handler


More information about the Kst mailing list