add arc display for direction visualization

This commit is contained in:
interfisch 2019-06-12 14:08:41 +02:00
parent 68c6cf81d6
commit 1361451d7b
3 changed files with 70 additions and 17 deletions

View File

@ -255,7 +255,9 @@ public class Tacho extends Visualization {
public class Direction extends Visualization {
int size;
float angleoffset=0;
float angleoffset;
float minvisiblevalue;
float maxvisiblevalue;
public Direction(int px, int py, int psize,float pvmin, float pvmax, float pvlmin, float pvlmax, float pangleoffset) {
super.valueMin=pvmin;
@ -267,6 +269,24 @@ public class Direction extends Visualization {
super.value2Max=pvlmax;
this.angleoffset=pangleoffset;
this.minvisiblevalue=valueMin;
this.maxvisiblevalue=valueMax;
}
public Direction(int px, int py, int psize,float pvmin, float pvmax, float pvlmin, float pvlmax, float pangleoffset, float pminvisiblevalue, float pmaxvisiblevalue) {
super.valueMin=pvmin;
super.valueMax=pvmax;
super.posOrigin= new PVector(px,py); //center
this.size = psize; //radius from the center
super.value2Min=pvlmin;
super.value2Max=pvlmax;
this.angleoffset=pangleoffset;
this.minvisiblevalue=pminvisiblevalue;
this.maxvisiblevalue=pmaxvisiblevalue;
}
@ -276,8 +296,12 @@ public class Direction extends Visualization {
textSize(super.textsize);
stroke(super.cborder); noFill();
ellipseMode(RADIUS); //centerx, centery, width,height for ellipse
ellipse(super.posOrigin.x, super.posOrigin.y, this.size,this.size);
if (this.minvisiblevalue==super.valueMin & this.maxvisiblevalue==super.valueMax) {
ellipseMode(RADIUS); //centerx, centery, width,height for ellipse
ellipse(super.posOrigin.x, super.posOrigin.y, this.size,this.size);
}else{
arc(super.posOrigin.x, super.posOrigin.y, this.size*2,this.size*2, 0+this.angleoffset-PI, 2*PI+this.angleoffset-PI, PIE);
}
stroke(super.cmain);
float angle=map(super.getValueNormalized(),0,1,0,2*PI)+this.angleoffset;
@ -301,6 +325,8 @@ public class Direction extends Visualization {
}
public class GraphRoll extends Visualization {
PVector size;
float[] valuearray;
@ -390,4 +416,4 @@ public class GraphRoll extends Visualization {
text(super.title, super.posOrigin.x, super.posOrigin.y+super.textsize*1.5);
}
}

View File

@ -255,7 +255,9 @@ public class Tacho extends Visualization {
public class Direction extends Visualization {
int size;
float angleoffset=0;
float angleoffset;
float minvisiblevalue;
float maxvisiblevalue;
public Direction(int px, int py, int psize,float pvmin, float pvmax, float pvlmin, float pvlmax, float pangleoffset) {
super.valueMin=pvmin;
@ -267,6 +269,24 @@ public class Direction extends Visualization {
super.value2Max=pvlmax;
this.angleoffset=pangleoffset;
this.minvisiblevalue=valueMin;
this.maxvisiblevalue=valueMax;
}
public Direction(int px, int py, int psize,float pvmin, float pvmax, float pvlmin, float pvlmax, float pangleoffset, float pminvisiblevalue, float pmaxvisiblevalue) {
super.valueMin=pvmin;
super.valueMax=pvmax;
super.posOrigin= new PVector(px,py); //center
this.size = psize; //radius from the center
super.value2Min=pvlmin;
super.value2Max=pvlmax;
this.angleoffset=pangleoffset;
this.minvisiblevalue=pminvisiblevalue;
this.maxvisiblevalue=pmaxvisiblevalue;
}
@ -276,8 +296,12 @@ public class Direction extends Visualization {
textSize(super.textsize);
stroke(super.cborder); noFill();
ellipseMode(RADIUS); //centerx, centery, width,height for ellipse
ellipse(super.posOrigin.x, super.posOrigin.y, this.size,this.size);
if (this.minvisiblevalue==super.valueMin & this.maxvisiblevalue==super.valueMax) {
ellipseMode(RADIUS); //centerx, centery, width,height for ellipse
ellipse(super.posOrigin.x, super.posOrigin.y, this.size,this.size);
}else{
arc(super.posOrigin.x, super.posOrigin.y, this.size*2,this.size*2, 0+this.angleoffset-PI, 2*PI+this.angleoffset-PI, PIE);
}
stroke(super.cmain);
float angle=map(super.getValueNormalized(),0,1,0,2*PI)+this.angleoffset;
@ -301,6 +325,8 @@ public class Direction extends Visualization {
}
public class GraphRoll extends Visualization {
PVector size;
float[] valuearray;
@ -390,4 +416,4 @@ public class GraphRoll extends Visualization {
text(super.title, super.posOrigin.x, super.posOrigin.y+super.textsize*1.5);
}
}

View File

@ -1,6 +1,6 @@
float rawvalue=50;
float rawvalue=0;
float xoff = 0.0;
float xoff2 = 25532.32;
float xoff2 = 0;
Visualization vis;
@ -12,8 +12,9 @@ void setup() {
//vis = new BarV(150,150,10,100,0,100);
//vis = new BarH(150,150,100,10,0,100);
//vis = new Tacho(150,150,100,0,100);
//vis = new Direction(150,150,100,0,100,0,1,PI/2);
vis = new GraphRoll(150,150,200,100,0,100, 1);
//vis = new Direction(150,150,100,-127/30*360,127/30*360,0,2000,PI/2+PI);
vis = new Direction(150,150,100,-127/30*360,127/30*360,0,2000,PI/2+PI, 0,2*PI); //uses arc
//vis = new GraphRoll(150,150,200,100,0,100, 1);
vis.setShowMinMax(false);
vis.setTitle("Testwert");
@ -21,16 +22,16 @@ void setup() {
void draw() {
background(255);
//rawvalue +=random(-10,10);
//rawvalue = constrain(rawvalue, 0,100);
xoff += 0.01;
rawvalue +=random(-10,10);
rawvalue = constrain(rawvalue, -127,100);
//xoff += 0.01;
xoff2 += 0.004;
rawvalue=noise(xoff) * 100;
//rawvalue=noise(xoff) * 100;
vis.setValue(rawvalue);
//for direction with length
//vis.setValue2(noise(xoff2));
vis.setValue2(noise(xoff2)*2000);
vis.drawVis();