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

Mike Fenton mike at staikos.net
Fri Feb 13 23:27:06 CET 2009


SVN commit 925702 by fenton:

Add creation status to ViewItem.
Fix continous repainting of plot items.
Trigger margin updates each redraw during plot creation.


 M  +3 -2      plotitem.cpp  
 M  +2 -3      sharedaxisboxitem.cpp  
 M  +0 -1      sharedaxisboxitem.h  
 M  +3 -0      viewitem.cpp  
 M  +9 -0      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #925701:925702
@@ -548,7 +548,7 @@
 
 
 void PlotItem::paint(QPainter *painter) {
-  qDebug() << "paint in plotitem";
+  painter->save();
   if (parentViewItem() && isInSharedAxisBox()) {
     setBrush(Qt::transparent);
   } else {
@@ -566,7 +566,7 @@
   // FIXME: the plot size calculations need to be separated from the 
   // painting to avoid n^2 or worse behavior.
 
-  if (parentView()->plotBordersDirty()) {
+  if (parentView()->plotBordersDirty() || (creationState() == ViewItem::InProgress)) {
     ViewGridLayout::standardizePlotMargins(this, painter);
     parentView()->setPlotBordersDirty(false);
   }
@@ -593,6 +593,7 @@
   paintPlotMarkers(painter);
 
   painter->restore();
+  painter->restore();
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #925701:925702
@@ -30,7 +30,7 @@
 namespace Kst {
 
 SharedAxisBoxItem::SharedAxisBoxItem(View *parent)
-    : ViewItem(parent), _layout(0), _loaded(false), _creationStarted(false) {
+    : ViewItem(parent), _layout(0), _loaded(false) {
   setName("Shared Axis Box");
   setZValue(SHAREDAXISBOX_ZVALUE);
   setBrush(Qt::transparent);
@@ -178,13 +178,12 @@
 void SharedAxisBoxItem::creationPolygonChanged(View::CreationEvent event) {
   if (event == View::MousePress) {
     ViewItem::creationPolygonChanged(event);
-    _creationStarted = true;
     return;
   }
 
   if (event == View::MouseMove) {
     ViewItem::creationPolygonChanged(event);
-    if (!_creationStarted) {
+    if (creationState() == ViewItem::None) {
       return;
     }
 
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.h #925701:925702
@@ -52,7 +52,6 @@
     QPointer<ViewGridLayout> _layout;
     QList<PlotItem*> _highlightedPlots;
     bool _loaded;
-    bool _creationStarted;
 };
 
 class KST_EXPORT CreateSharedAxisBoxCommand : public CreateCommand
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #925701:925702
@@ -47,6 +47,7 @@
     _isTiedZoom(false),
     _gripMode(Move),
     _allowedGripModes(Move | Resize | Rotate /*| Scale*/),
+    _creationState(None),
     _supportsTiedZoom(false),
     _fixedSize(false),
     _lockAspectRatio(false),
@@ -779,6 +780,7 @@
     setPos(poly.first().x(), poly.first().y());
     setViewRect(0.0, 0.0, 0.0, 0.0);
     parentView()->scene()->addItem(this);
+    _creationState = InProgress;
     //setZValue(1);
     return;
   }
@@ -803,6 +805,7 @@
     parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
     parentView()->setMouseMode(View::Default);
     maybeReparent();
+    _creationState = Completed;
     emit creationComplete();
     return;
   }
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #925701:925702
@@ -53,6 +53,12 @@
     };
     Q_DECLARE_FLAGS(ActiveGrips, ActiveGrip)
 
+    enum CreationState {
+      None,
+      InProgress,
+      Completed
+    };
+
     ViewItem(View *parent);
     virtual ~ViewItem();
 
@@ -159,6 +165,8 @@
     virtual void setTiedZoom(bool tiedZoom, bool checkAllTied = true);
     virtual QSizeF tiedZoomSize() const { return QSizeF(checkBox().controlPointRect().size() * 1.5); }
 
+    CreationState creationState() const { return _creationState; }
+
   Q_SIGNALS:
     void geometryChanged();
     void creationComplete();
@@ -242,6 +250,7 @@
   private:
     GripMode _gripMode;
     GripModes _allowedGripModes;
+    CreationState _creationState;
     bool _supportsTiedZoom;
     bool _fixedSize;
     bool _lockAspectRatio;


More information about the Kst mailing list