[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Mon Apr 28 17:01:31 CEST 2008


SVN commit 802112 by fenton:

Update conversion of MaptoProject to properly support conversion when Axis are reversed.
Move drawing of SelectionRect outside of the painter translation to match the mouse / cursor location.


 M  +15 -2     plotitem.cpp  
 M  +2 -1      plotrenderitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #802111:802112
@@ -816,8 +816,21 @@
   QRectF projRect;
 
   // Invert and convert points.
-  QPointF topLeft = mapToProjection(rect.bottomLeft());
-  QPointF bottomRight = mapToProjection(rect.topRight());
+  QPointF topLeft;
+  QPointF bottomRight;
+  if (!(_xAxis->axisReversed() || _yAxis->axisReversed())) {
+    topLeft = mapToProjection(rect.bottomLeft());
+    bottomRight = mapToProjection(rect.topRight());
+  } else if (_xAxis->axisReversed() && _yAxis->axisReversed()) {
+    topLeft = mapToProjection(rect.topRight());
+    bottomRight = mapToProjection(rect.bottomLeft());
+  } else if (_yAxis->axisReversed()) {
+    topLeft = mapToProjection(rect.topLeft());
+    bottomRight = mapToProjection(rect.bottomRight());
+  } else {
+    topLeft = mapToProjection(rect.bottomRight());
+    bottomRight = mapToProjection(rect.topLeft());
+  }
 
   projRect.setTopLeft(topLeft);
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #802111:802112
@@ -201,11 +201,12 @@
   painter->setClipRect(rect());
   paintRelations(painter);
 
+  painter->restore();
+
   if (_selectionRect.isValid()) {
     painter->setPen(QPen(QBrush(Qt::black), 1.0, Qt::DotLine));
     painter->drawRect(_selectionRect.rect());
   }
-  painter->restore();
 
   painter->save();
   painter->setRenderHint(QPainter::Antialiasing, true);


More information about the Kst mailing list