@@ -21,7 +21,7 @@ struct Dist {
2121 virtual auto gen () -> void = 0;
2222 virtual auto clear () -> void = 0;
2323 virtual auto compile () -> void = 0;
24- virtual auto draw (float x, float y, float w, float h) -> void = 0;
24+ virtual auto draw (float x, float y, float w, float h, bool graph = true ) -> void = 0;
2525 virtual ~Dist () = default ;
2626
2727 Dist () {};
@@ -94,7 +94,7 @@ struct ConcreteDist : public Dist {
9494 }
9595 }
9696
97- auto draw (float x, float y, float w, float h) -> void override {
97+ auto draw (float x, float y, float w, float h, bool graph = true ) -> void override {
9898 ofPushStyle ();
9999 ofPushMatrix ();
100100 {
@@ -108,66 +108,68 @@ struct ConcreteDist : public Dist {
108108 ofSetColor (255 , 255 , 255 , 255 );
109109 ofDrawBitmapStringHighlight (parameters_.getName () + " " + ofToString (cost_ * 1000 , 2 , 5 ) + " ms" , w + 5 , 12 );
110110
111- if constexpr (std::is_arithmetic_v<T>) {
112-
113- auto p = 0 .0f ;
114- double incr = w / bins_.size ();
115- auto fact = h / max_;
116- if (discrete_) {
117-
118- // line bars for discrete
119- ofTranslate (incr / 2 , 0 );
120- for (auto y : bins_) {
121- ofDrawLine (0 , h, 0 , h - float (y) * fact);
122- if (y == 0 ) {
123- ofNoFill ();
124- ofDrawCircle (0 , h - float (y) * fact, 2.5 );
125- ofFill ();
126- } else {
127- ofDrawCircle (0 , h - float (y) * fact, 3 );
111+ if (graph) {
112+ if constexpr (std::is_arithmetic_v<T>) {
113+
114+ auto p = 0 .0f ;
115+ double incr = w / bins_.size ();
116+ auto fact = h / max_;
117+ if (discrete_) {
118+
119+ // line bars for discrete
120+ ofTranslate (incr / 2 , 0 );
121+ for (auto ypos : bins_) {
122+ ofDrawLine (0 , h, 0 , h - float (ypos) * fact);
123+ if (y == 0 ) {
124+ ofNoFill ();
125+ ofDrawCircle (0 , h - float (ypos) * fact, 2.5 );
126+ ofFill ();
127+ } else {
128+ ofDrawCircle (0 , h - float (ypos) * fact, 3 );
129+ }
130+ ofTranslate (int (incr), 0 );
128131 }
129- ofTranslate (int (incr), 0 );
132+ } else {
133+
134+ // integral for reals
135+ ofPolyline line;
136+ line.addVertex (0 , h - bins_[0 ] * fact);
137+ for (auto ypos : bins_)
138+ line.lineTo (p += incr, h - float (ypos) * fact);
139+ line.draw ();
130140 }
141+
142+ } else if constexpr (std::is_same_v<T, glm::vec2>) {
143+
144+ ofSetColor (255 , 255 , 255 , 96 );
145+ for (const auto & d : data_) {
146+ if (d.x > w || d.y > h) underflow_++;
147+ if (d.x < 0 || d.y < 0 ) overflow_++;
148+ ofDrawCircle (d, 0.5 );
149+ }
150+
151+ } else if constexpr (std::is_same_v<T, glm::vec3>) {
152+
153+ ofSetColor (255 , 255 , 255 , 32 );
154+ of3dPrimitive prim;
155+ for (const auto & d : data_) {
156+ if (d.x > w || d.y > h) underflow_++;
157+ if (d.x < 0 || d.y < 0 ) overflow_++;
158+ }
159+ prim.getMesh ().getVertices () = data_;
160+ prim.getMesh ().setMode (OF_PRIMITIVE_POINTS);
161+ prim.rotateDeg (70 , { 0.2 , 0.3 , 0.5 }); // just some perspective
162+
163+ ofPushMatrix ();
164+ {
165+ ofTranslate (w * 0.2 , h * 0.2 );
166+ prim.drawWireframe ();
167+ prim.drawAxes (w * 0.5 );
168+ }
169+ ofPopMatrix ();
131170 } else {
132-
133- // integral for reals
134- ofPolyline line;
135- line.addVertex (0 , h - bins_[0 ] * fact);
136- for (auto y : bins_)
137- line.lineTo (p += incr, h - float (y) * fact);
138- line.draw ();
139- }
140-
141- } else if constexpr (std::is_same_v<T, glm::vec2>) {
142-
143- ofSetColor (255 , 255 , 255 , 96 );
144- for (const auto & d : data_) {
145- if (d.x > w || d.y > h) underflow_++;
146- if (d.x < 0 || d.y < 0 ) overflow_++;
147- ofDrawCircle (d, 0.5 );
148- }
149-
150- } else if constexpr (std::is_same_v<T, glm::vec3>) {
151-
152- ofSetColor (255 , 255 , 255 , 32 );
153- of3dPrimitive prim;
154- for (const auto & d : data_) {
155- if (d.x > w || d.y > h) underflow_++;
156- if (d.x < 0 || d.y < 0 ) overflow_++;
157- }
158- prim.getMesh ().getVertices () = data_;
159- prim.getMesh ().setMode (OF_PRIMITIVE_POINTS);
160- prim.rotateDeg (70 , { 0.2 , 0.3 , 0.5 }); // just some perspective
161-
162- ofPushMatrix ();
163- {
164- ofTranslate (w * 0.2 , h * 0.2 );
165- prim.drawWireframe ();
166- prim.drawAxes (w * 0.5 );
171+ ofDrawBitmapString (" unsupported visualisation" , 10 , 10 );
167172 }
168- ofPopMatrix ();
169- } else {
170- ofDrawBitmapString (" unsupported visualisation" , 10 , 10 );
171173 }
172174 ofSetColor (ofColor::deepPink);
173175 if (underflow_) ofDrawBitmapString (" undershoot: " + ofToString (underflow_), w + 5 , 70 );
@@ -185,15 +187,15 @@ struct DistGroup {
185187 DistGroup (std::vector<std::shared_ptr<Dist>> dists)
186188 : dists_(dists) { }
187189
188- auto draw (std::string label, int square, int gap) {
190+ auto draw (std::string label, int square, int gap, bool graph = true ) {
189191 panel_.draw ();
190192 ofPushMatrix ();
191193 {
192194 ofTranslate (panel_.getPosition ());
193195 ofDrawBitmapString (label, 0 , -10 );
194196 ofTranslate (panel_.getWidth () + 20 , 0 );
195197 for (const auto & dist : dists_) {
196- dist->draw (0 , 0 , square, square);
198+ dist->draw (0 , 0 , square, square, graph );
197199 ofTranslate (0 , square + gap);
198200 }
199201 }
0 commit comments