[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Tue Dec 20 06:54:47 CET 2005


SVN commit 489913 by staikos:

eliminate some unnecessary computations


 M  +4 -6      kst2dplot.cpp  
 M  +13 -12    kstviewobject.cpp  


--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #489912:489913
@@ -3540,17 +3540,16 @@
 
 
 bool Kst2DPlot::getNearestDataPoint(const QPoint& pos, QString& name, double &newxpos, double &newypos, double xpos, double ypos, double xmin, double xmax) {
-  QRect pr = GetPlotRegion();
   bool rc = false;
 
   // only makes sense to get nearest data point for vcurves
   KstVCurveList vcurves = kstObjectSubList<KstBaseCurve,KstVCurve>(Curves);
   if (vcurves.count() > 0) {
-    double best_distance = 1.0E300;
+    QRect pr = GetPlotRegion();
+    double near_x, near_y;
     double distance;
+    double best_distance = 1.0E300;
     double dx_per_pix;
-    double near_x;
-    double near_y;
     int i_near_x;
     
     // convert 1 pixel to plot units.
@@ -3591,7 +3590,6 @@
 
 void Kst2DPlot::drawCursorPos(QWidget *view) {
   QPainter p(view);
-
   drawCursorPos(p);
 }
 
@@ -3606,9 +3604,9 @@
 
 void Kst2DPlot::highlightNearestDataPoint(bool bRepaint, QWidget *view, const QPoint& pos) {
   QString msg;
-  int precision = 15;
 
   if (!Curves.isEmpty()) {
+    int precision = 15;
     QString msgXOffset;
     QString msgYOffset;
     QString name;
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #489912:489913
@@ -314,29 +314,30 @@
 
 
 void KstViewObject::paint(KstPainter& p, const QRegion& bounds) {
-  bool maximized = false;
-  bool nullBounds = bounds.isNull();
-  
   p.save();
   p.setViewport(geometry());
   p.setWindow(geometry());
 
   //update();
-  // handle the case where we have maximized plots
-  for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
-    if ((*i)->_maximized) {
-      (*i)->_lastClipRegion = (*i)->geometry();
-      (*i)->paint(p, bounds);
-      maximized = true;
-      break;
-    }
-  }
 
   if (p.type() == KstPainter::P_EXPORT || p.type() == KstPainter::P_PRINT) {
     for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
       (*i)->paint(p, bounds);
     }
   } else {
+    bool maximized = false;
+    bool nullBounds = bounds.isNull();
+
+    // handle the case where we have maximized plots
+    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+      if ((*i)->_maximized) {
+        (*i)->_lastClipRegion = (*i)->geometry();
+        (*i)->paint(p, bounds);
+        maximized = true;
+        break;
+      }
+    }
+
     if (!maximized && !_children.isEmpty()) {
       QRegion clipRegion = p.clipRegion();
       KstViewObjectList::Iterator begin = _children.begin();


More information about the Kst mailing list