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

George Staikos staikos at kde.org
Thu Oct 4 08:49:41 CEST 2007


SVN commit 720963 by staikos:

make a class to handle (from,to) selection rects with built-in normalization
and tracking of the proper start and end points


 M  +2 -0      libkstapp.pro  
 M  +10 -8     plotrenderitem.cpp  
 M  +2 -1      plotrenderitem.h  
 A             selectionrect.cpp   [License: GPL (v2+)]
 A             selectionrect.h   [License: GPL (v2+)]


--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #720962:720963
@@ -61,6 +61,7 @@
     plotitem.cpp \
     plotrenderitem.cpp \
     qgetoptions.cpp \
+    selectionrect.cpp \
     sessionmodel.cpp \
     stroketab.cpp \
     svgitem.cpp \
@@ -120,6 +121,7 @@
     plotitem.h \
     plotrenderitem.h \
     qgetoptions.h \
+    selectionrect.h \
     sessionmodel.h \
     svgitem.h \
     stroketab.h \
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #720962:720963
@@ -24,7 +24,7 @@
 namespace Kst {
 
 PlotRenderItem::PlotRenderItem(const QString &name, PlotItem *parentItem)
-  : ViewItem(parentItem->parentView()), _zoomRect(QRectF()), _selectionRect(QRectF()) {
+  : ViewItem(parentItem->parentView()), _zoomRect(QRectF()) {
 
   setName(name);
   setParentItem(parentItem);
@@ -112,10 +112,10 @@
 
   paintRelations(painter);
 
-  if (_selectionRect.isValid() && !_selectionRect.isEmpty()) {
+  if (_selectionRect.isValid()) {
     painter->save();
     painter->setPen(Qt::black);
-    painter->drawRect(_selectionRect);
+    painter->drawRect(_selectionRect.rect());
     painter->restore();
   }
 
@@ -172,8 +172,10 @@
     return;
   }
 
-  _selectionRect.setBottomRight(event->pos());
-  update(); //FIXME should optimize instead of redrawing entire curve?
+  _selectionRect.setTo(event->pos());
+  if (_selectionRect.isValid()) {
+    update(); //FIXME should optimize instead of redrawing entire curve?
+  }
 }
 
 
@@ -183,7 +185,7 @@
     return;
   }
 
-  _selectionRect = QRectF(event->pos(), QSizeF(0,0));
+  _selectionRect.setFrom(event->pos());
 }
 
 
@@ -193,8 +195,8 @@
     return;
   }
 
-  _zoomRect = mapToProjection(_selectionRect);
-  _selectionRect = QRectF();
+  _zoomRect = mapToProjection(_selectionRect.rect());
+  _selectionRect.reset();
   update();
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #720962:720963
@@ -18,6 +18,7 @@
 #include <QPainterPath>
 
 #include "kstrelation.h"
+#include "selectionrect.h"
 
 namespace Kst {
 
@@ -76,7 +77,7 @@
     RenderType _type;
     KstRelationList _relationList;
     QRectF _zoomRect;
-    QRectF _selectionRect;
+    SelectionRect _selectionRect;
 };
 
 }


More information about the Kst mailing list