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

Duncan Hanson duncan.hanson at gmail.com
Thu May 10 00:39:45 CEST 2007


SVN commit 663060 by dhanson:

CCBUG:86915 give plots scalar outputs.

 M  +59 -1     kst2dplot.cpp  
 M  +14 -1     kst2dplot.h  


--- branches/work/kst/1.5/kst/src/libkstapp/kst2dplot.cpp #663059:663060
@@ -653,7 +653,7 @@
 
   _i_per = 0;
   
-  setTagName(KstObjectTag(in_tag, KstObjectTag::globalTagContext));  // FIXME: tag context
+  KstObject::setTagName(KstObjectTag(in_tag, KstObjectTag::globalTagContext));  // FIXME: tag context
   _isTied = false;
 
   XMin = xmin_in;
@@ -692,6 +692,8 @@
 
   // let this Kst2DPlot register doc changes.
   connect(this, SIGNAL(modified()), KstApp::inst(), SLOT(registerDocChange()));
+
+  CreateScalars();
 }
 
 
@@ -711,6 +713,15 @@
 
   _curveToMarkers = 0L;
   _vectorToMarkers = 0L;
+
+  KST::scalarList.lock().writeLock();
+  KST::scalarList.setUpdateDisplayTags(false);
+  for (QDictIterator<KstScalar> it(_scalars); it.current(); ++it) {
+    KST::scalarList.remove(it.current());
+    it.current()->_KShared_unref();
+  }
+  KST::scalarList.setUpdateDisplayTags(true);
+  KST::scalarList.lock().unlock();
 }
 
 
@@ -1402,6 +1413,8 @@
       kstdWarning() << "Bug in Kst2DPlot::updateScale: bad scale mode" << endl;
       break;
   }
+
+  updateScalears();
 }
 
 
@@ -7063,6 +7076,51 @@
 
 }
 
+void Kst2DPlot::CreateScalars() {
+    KstWriteLocker sl(&KST::scalarList.lock());
+    KST::scalarList.setUpdateDisplayTags(false);
+
+    KstScalarPtr sp;
+    _scalars.insert("xmin", sp = new KstScalar(KstObjectTag("XMin", tag()), this));
+    sp->_KShared_ref();
+    _scalars.insert("xmax", sp = new KstScalar(KstObjectTag("XMax", tag()), this));
+    sp->_KShared_ref();
+    _scalars.insert("ymin", sp = new KstScalar(KstObjectTag("YMin", tag()), this));
+    sp->_KShared_ref();
+    _scalars.insert("ymax", sp = new KstScalar(KstObjectTag("YMax", tag()), this));
+    sp->_KShared_ref();
+
+    KST::scalarList.setUpdateDisplayTags(true);
+}
+
+void Kst2DPlot::RenameScalars() {
+  KstWriteLocker sl(&KST::scalarList.lock());
+  KST::scalarList.setUpdateDisplayTags(false);
+
+  _scalars["xmax"]->setTagName(KstObjectTag("XMax", tag()));
+  _scalars["xmin"]->setTagName(KstObjectTag("XMin", tag()));
+  _scalars["ymax"]->setTagName(KstObjectTag("YMax", tag()));
+  _scalars["ymin"]->setTagName(KstObjectTag("YMin", tag()));
+
+  KST::scalarList.setUpdateDisplayTags(true);
+}
+
+void Kst2DPlot::updateScalears() {
+  _scalars["xmax"]->setValue(XMax);
+  _scalars["xmin"]->setValue(XMin);
+  _scalars["ymax"]->setValue(YMax);
+  _scalars["ymin"]->setValue(YMin);
+}
+
+void Kst2DPlot::setTagName(const KstObjectTag& newTag) {
+  if (newTag == tag()) {
+    return;
+  }
+
+  this->KstObject::setTagName(newTag);
+  RenameScalars();
+}
+
 QWidget *Kst2DPlot::configWidget() {
   return new View2DPlotWidget;
 }
--- branches/work/kst/1.5/kst/src/libkstapp/kst2dplot.h #663059:663060
@@ -28,6 +28,7 @@
 #include "kstviewwidget.h"
 #include "kstviewlegend.h"
 #include "kst_export.h"
+#include "kstscalar.h"
 
 #include <qvaluestack.h>
 
@@ -139,6 +140,8 @@
   void pushPlotColors();
   void popPlotColors();
 
+  void updateScalears();
+
   /** Set the scale */
   void setScale(double xmin, double ymin, double xmax, double ymax);
   /** Set the X scale */
@@ -383,9 +386,19 @@
 
   double verticalSizeFactor();
   double horizontalSizeFactor();
-  
+
+  virtual void setTagName(const KstObjectTag& newTag);
+
+protected:
+  QDict<KstScalar> _scalars;
+
+  /** Scalar Maintenance methods */
+  void CreateScalars();
+  void RenameScalars();
+
 signals:
   void modified();
+  void scaleChanged();
 
 public slots:
   void copy();


More information about the Kst mailing list