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

Adam Treat treat at kde.org
Fri May 25 18:53:36 CEST 2007


SVN commit 668248 by treat:

* Get ready to draw various creation modes


 M  +1 -1      kstplotitems.cpp  
 M  +18 -2     kstplotview.cpp  
 M  +3 -1      kstplotview.h  


--- branches/work/kst/portto4/kst/src/libkstapp/kstplotitems.cpp #668247:668248
@@ -76,7 +76,7 @@
 LineItem::LineItem(KstPlotView *parent)
     : KstPlotItem(parent) {
   setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
-  parent->setMouseMode(KstPlotView::Create);
+  parent->setMouseMode(KstPlotView::CreateClosedPath);
   connect(parent, SIGNAL(creationPolygonChanged()),
           this, SLOT(creationPolygonChanged()));
 }
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotview.cpp #668247:668248
@@ -52,13 +52,29 @@
 
 void KstPlotView::setMouseMode(MouseMode mode) {
 
-  if (_mouseMode == Create)
+  if (isMouseCreateMode()) {
     _creationPolygon.clear();
+  }
 
   _mouseMode = mode;
 }
 
 
+bool KstPlotView::isMouseCreateMode() const {
+  switch (_mouseMode) {
+  case CreateRubberBand:
+  case CreateClosedPath:
+  case CreateOpenPath:
+  case CreatePoints:
+    return true;
+  case Default:
+  case Move:
+  default:
+    return false;
+  }
+}
+
+
 QPolygonF KstPlotView::creationPolygon() const {
   return _creationPolygon;
 }
@@ -72,7 +88,7 @@
   case QEvent::GraphicsSceneMousePress:
     {
       QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
-      if (_mouseMode == Create) {
+      if (isMouseCreateMode()) {
         _creationPolygon << e->buttonDownScenePos(Qt::LeftButton);
         emit creationPolygonChanged();
         return false;
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotview.h #668247:668248
@@ -23,7 +23,7 @@
 {
   Q_OBJECT
 public:
-  enum MouseMode { Default, Move, Create };
+  enum MouseMode { Default, Move, CreateRubberBand, CreateClosedPath, CreateOpenPath, CreatePoints };
   KstPlotView();
   virtual ~KstPlotView();
 
@@ -33,6 +33,8 @@
   MouseMode mouseMode() const;
   void setMouseMode(MouseMode mode);
 
+  bool isMouseCreateMode() const;
+
   QPolygonF creationPolygon() const;
 
 Q_SIGNALS:


More information about the Kst mailing list