Просмотр исходного кода

Graphical tweaks and accent feature

yeswecan 9 лет назад
Родитель
Сommit
5ef9a454bb
1 измененных файлов с 28 добавлено и 8 удалено
  1. 28 8
      src/ofxPlotter.h

+ 28 - 8
src/ofxPlotter.h

@@ -15,6 +15,7 @@
 
 
 #include "ofMain.h"
 #include "ofMain.h"
 
 
+
 class ofxPlotter {
 class ofxPlotter {
     
     
     class Value {
     class Value {
@@ -66,13 +67,15 @@ public:
             if (history[i->first].size() > windowSize) {
             if (history[i->first].size() > windowSize) {
                 history[i->first].erase(history[i->first].begin());
                 history[i->first].erase(history[i->first].begin());
             }
             }
-            accents[i->first].push_back(false);
+            if (accents[i->first].size() > windowSize) {
+                accents[i->first].erase(accents[i->first].begin());
+            }
+            accents[i->first].push_back(0);
         }
         }
     }
     }
     
     
     void addAccent(std::string index) {
     void addAccent(std::string index) {
-//        ofLog() << "added accent";
-        accents[index][accents[index].back()] = true;
+        accents[index][accents[index].size() - 1] = 5;
     }
     }
     
     
     void update(ofEventArgs & args) {
     void update(ofEventArgs & args) {
@@ -144,15 +147,32 @@ public:
                     if (j != 0) ofLine(p2, p);
                     if (j != 0) ofLine(p2, p);
                     p2 = p;
                     p2 = p;
                     
                     
-                    if (accents[i->first][j]) {
+                }
+            
+                int lastx = -200;
+                for (int j = 0; j < (*historyValues).size(); j++) {
+                    if (accents[i->first][j] != 0) {
                         ofSetColor(255);
                         ofSetColor(255);
                         ofSetLineWidth(2);
                         ofSetLineWidth(2);
                         ofLine(j * stepWidth, index * yspace,
                         ofLine(j * stepWidth, index * yspace,
-                               j * stepWidth, index * (yspace + 1));
-                        ofLog() << "accent at index " << j;
+                               j * stepWidth, (index - 1) * yspace);
+                        ofCircle(j * stepWidth, index * yspace, 3);
+                        float mid = 0;
+                        if (j > 5) {
+                            for (int k = j - 5; k < j + 5; k++) {
+                                mid += (*historyValues)[k].getF();
+                            }
+                            mid /= 10;
+                        }
+                        if ((j * stepWidth - lastx) > 200) {
+                            ofDrawBitmapStringHighlight(ofToString(mid), j * stepWidth, index * yspace - 15);
+                            lastx = j * stepWidth;
+                        }
                     }
                     }
                 }
                 }
-                ofDrawBitmapStringHighlight(i->first + " ; current: " + ofToString(values[i->first].getFiltered(0.5)) + " ; min: " + ofToString(min) + " ; max: " + ofToString(max), 25, 25);
+            
+                ofSetColor(255, 50);
+                ofDrawBitmapStringHighlight(i->first + " ; current: " + ofToString(values[i->first].getFiltered(0.5), 4) + " ; min: " + ofToString(min, 4) + " ; max: " + ofToString(max, 4), 25, 25);
             ofPopMatrix();
             ofPopMatrix();
             
             
             index++;
             index++;
@@ -163,7 +183,7 @@ public:
     
     
     std::map<std::string, ofxPlotter::Value> values;
     std::map<std::string, ofxPlotter::Value> values;
     std::map<std::string, std::vector<ofxPlotter::Value>> history;
     std::map<std::string, std::vector<ofxPlotter::Value>> history;
-    std::map<std::string, std::vector<bool>> accents;
+    std::map<std::string, std::vector<int>> accents;
     
     
     
     
     // Parameters
     // Parameters