[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Mon Jun 14 23:54:15 CEST 2004


CVS commit by arwalker: 

Create vectors for the event monitoring system, which can then be used to create a curve if desired.


  M +56 -18    ksteventmonitorentry.cpp   1.12
  M +7 -0      ksteventmonitorentry.h   1.9


--- kdeextragear-2/kst/kst/ksteventmonitorentry.cpp  #1.11:1.12
@@ -45,14 +45,9 @@ extern "C" void *ParsedEquation;
 extern "C" struct yy_buffer_state *yy_scan_string(const char*);
 
-EventMonitorEntry::EventMonitorEntry(const QString &in_tag) : KstDataObject() {
-  _level = KstDebug::Warning;
-  _pExpression = NULL;
-  _bLogKstDebug = TRUE;
-  _bLogEMail = FALSE;
-  _bIsValid = FALSE;
-  _iNumDone = 0;
+const QString EventMonitorEntry::OUTXVECTOR = "X";
+const QString EventMonitorEntry::OUTYVECTOR = "Y";
 
-  _typeString = i18n("Event");
-  KstObject::setTagName(in_tag);
+EventMonitorEntry::EventMonitorEntry(const QString &in_tag) : KstDataObject() {
+  commonConstructor( in_tag );
 }
 
@@ -60,10 +55,4 @@ EventMonitorEntry::EventMonitorEntry(QDo
   QString strTag;
 
-  _level = KstDebug::Warning;
-  _pExpression = NULL;
-  _bLogKstDebug = TRUE;
-  _bLogEMail = FALSE;
-  _iNumDone = 0;
-  
   QDomNode n = e.firstChild();
   while( !n.isNull() ) {
@@ -89,10 +78,39 @@ EventMonitorEntry::EventMonitorEntry(QDo
   }
 
-  _typeString = i18n("Event");
-  KstObject::setTagName(strTag);
+  commonConstructor( strTag );
 
   update( );
 }
 
+void EventMonitorEntry::commonConstructor(const QString &in_tag) {
+  KstVectorPtr xv;
+  KstVectorPtr yv; 
+  int NS = 1;
+
+  _level = KstDebug::Warning;
+  _pExpression = NULL;
+  _bLogKstDebug = TRUE;
+  _bLogEMail = FALSE;
+  _bIsValid = FALSE;
+  _iNumDone = 0;
+
+  _typeString = i18n("Event");
+  KstObject::setTagName(in_tag);
+
+  xv = new KstVector(in_tag + "-x", NS);
+  if (xv) {
+    KST::addVectorToList(xv);
+    xv->zero();
+    _xVector = _outputVectors.insert(OUTXVECTOR, xv);
+  }
+
+  yv = new KstVector(in_tag + "-y", NS);
+  if (yv) {
+    KST::addVectorToList(yv);
+    yv->zero();
+    _yVector = _outputVectors.insert(OUTYVECTOR, yv);
+  }
+}
+
 void EventMonitorEntry::save(QTextStream &ts) {
   ts << "<event>" << endl;
@@ -116,5 +134,9 @@ EventMonitorEntry::~EventMonitorEntry() 
 KstObject::UpdateType EventMonitorEntry::update(int updateCounter) {
   KstObject::UpdateType retVal = NO_CHANGE;
+  KstVectorPtr xv = *_xVector;
+  KstVectorPtr yv = *_yVector;
   Equation::Context ctx;
+  double *pdRawValuesX = NULL;
+  double *pdRawValuesY = NULL;
   unsigned int i;
   double dValue;
@@ -151,4 +173,11 @@ KstObject::UpdateType EventMonitorEntry:
     }
 
+    if (xv && yv) {
+      xv->resize(ns);
+      yv->resize(ns);
+      pdRawValuesX = xv->value();
+      pdRawValuesY = yv->value();
+    }
+    
     ctx.sampleCount = ns;
     ctx.x = 0.0;
@@ -160,4 +189,13 @@ KstObject::UpdateType EventMonitorEntry:
           if (dValue) {
             log( ctx.i );
+            if (pdRawValuesX && pdRawValuesY) {
+              pdRawValuesX[ctx.i] = ctx.i;
+              pdRawValuesY[ctx.i] = 1.0;
+            }
+          } else {
+            if (pdRawValuesX && pdRawValuesY) {
+              pdRawValuesX[ctx.i] = ctx.i;
+              pdRawValuesY[ctx.i] = 0.0;
+            }
           }
         }

--- kdeextragear-2/kst/kst/ksteventmonitorentry.h  #1.8:1.9
@@ -72,4 +72,9 @@ public slots:    
 
 private:
+  void commonConstructor(const QString &in_tag);
+
+  static const QString OUTXVECTOR;
+  static const QString OUTYVECTOR;
+
   KstVectorList       _vectorsUsed;
   QValueList<int>     _indexArray;
@@ -79,4 +84,6 @@ private:
   KstDebug::LogLevel  _level;
   Equation::Node*     _pExpression;
+  KstVectorMap::Iterator _xVector;
+  KstVectorMap::Iterator _yVector;
   bool                _bLogKstDebug;
   bool                _bLogEMail;





More information about the Kst mailing list