Commit aad2012f authored by Arnaud Blanchard's avatar Arnaud Blanchard

Add option for surface plot

parent b2e07816
......@@ -53,49 +53,53 @@ void create_graph(deque <blc_channel>&inputs, const char *title, int refresh_per
}
element_size=input->get_type_size();
switch (input->type){
case 'UIN8':gnuplot_format="%uchar";break;
case 'INT8':gnuplot_format="%char";break;
case 'IN16':gnuplot_format="%int16";break;
case 'UI16':gnuplot_format="%uint16";break;
case 'IN32':gnuplot_format="%int32";break;
case 'UI32':gnuplot_format="%uint32";break;
case 'FL32':gnuplot_format="%float32";break;
case 'FL64':gnuplot_format="%float64";break;
default: EXIT_ON_ARRAY_ERROR(input, "The type is not managed");
case 'UIN8':gnuplot_format="%uchar";break;
case 'INT8':gnuplot_format="%char";break;
case 'IN16':gnuplot_format="%int16";break;
case 'UI16':gnuplot_format="%uint16";break;
case 'IN32':gnuplot_format="%int32";break;
case 'UI32':gnuplot_format="%uint32";break;
case 'FL32':gnuplot_format="%float32";break;
case 'FL64':gnuplot_format="%float64";break;
default: EXIT_ON_ARRAY_ERROR(input, "The type is not managed");
}
init_term(pipef, title, verbatim);
if (ymin!=ymax) fprintf(pipef, "set yrange [%f:%f]\n", ymin, ymax);
if (columns_nb==1) xmin=-1;
if (xmin!=xmax) fprintf(pipef, "set xrange [%f:%f]\n", xmin, xmax);
if (with_option==nullptr){
if (inputs[0].total_length==1) with_option="boxes";
else with_option="lines";
}
if (input->dims_nb==2 && input->dims[0].length>1 && input->dims[1].length>1){
fprintf(pipef, "set xrange [%f:%f]\n", 0.f, 10.f);
fprintf(pipef, "set yrange [%f:%f]\n", 0.f, 10.f);
fprintf(pipef, "set zrange [%f:%f]\n", ymin, ymax);
fprintf(pipef, "set view 30,190\n");
offset=snprintf(command, LINE_MAX, "splot '-' binary format='%s' array=%dx%d title 'values' with pm3d ", gnuplot_format, columns_nb, rows_nb);
if (inputs.size()>1) EXIT_ON_ERROR("Multiple array of dims > 1 are not managed");
if (surface_option)
{
fprintf(pipef, "set yrange [%f:%f]\n", 0.f, 10.f);
fprintf(pipef, "set zrange [%f:%f]\n", ymin, ymax);
fprintf(pipef, "set view 30,190\n");
offset=snprintf(command, LINE_MAX, "splot '-' binary format='%s' array=%dx%d title 'values' with pm3d ", gnuplot_format, columns_nb, rows_nb);
}
else{
if (input->dims[1].length>64) EXIT_ON_ERROR("To many ( '%d' > 64 ) curves to draw", input->dims[1].length );
offset=snprintf(command, BLC_LINE_MAX, "plot '-' binary format='%s' record=%zu using ($0*%f):1 title '0' with %s", gnuplot_format, input->dims[0].length, label_max/(float)input->dims[0].length, with_option);
for(i=1; i<input->dims[1].length;i++){
offset+=snprintf(command+offset, BLC_LINE_MAX-offset, ", '-' binary format='%s' record=%zu using ($0*%f):1 title '%d' with %s", gnuplot_format, input->dims[0].length, label_max/(float)input->dims[0].length, i, with_option);
}
fprintf(stderr, "%s", command);
}
}
else{
if (with_option==nullptr){
if (inputs[0].total_length==1) with_option="boxes";
else with_option="lines";
offset=snprintf(command, BLC_LINE_MAX, "plot '-' binary format='%s' record=%zu using ($0*%f):1 title '%s' with %s", gnuplot_format, inputs[0].total_length, label_max/(float)inputs[0].total_length, input->name+1, with_option);
for(i=1; i<inputs.size();i++){
offset+=snprintf(command+offset, BLC_LINE_MAX-offset, ", '-' binary format='%s' record=%zu using ($0*%f):1 title '%s' with %s", gnuplot_format, inputs[i].total_length, label_max/(float)inputs[i].total_length, inputs[i].name+1, with_option);
}
offset=snprintf(command, LINE_MAX, "plot '-' binary format='%s' record=%zu using ($0*%f):1 title '%s' with %s", gnuplot_format, inputs[0].total_length, label_max/(float)inputs[0].total_length, input->name+1, with_option);
for(i=1; i<inputs.size();i++){
offset+=snprintf(command+offset, LINE_MAX-offset, ", '-' binary format='%s' record=%zu using ($0*%f):1 title '%s' with %s", gnuplot_format, inputs[i].total_length, label_max/(float)inputs[i].total_length, inputs[i].name+1, with_option);
}
/* for(i=1; i!=rows_nb; i++){
if (i<10) code=48+i;
else code=97+i-10;
offset+=snprintf(command+offset, LINE_MAX-offset, ", '-' binary format='%s' record=%d title '%c' with %s", gnuplot_format, columns_nb, code, with_option);
}*/
}
// sleep(3);
// sleep(3);
for (i=0;i<inputs.size();i++) {
blc_loop_try_add_waiting_semaphore(inputs[i].sem_new_data);
blc_loop_try_add_posting_semaphore(inputs[i].sem_ack_data);
......
......@@ -13,7 +13,8 @@
#include <deque>
extern char const *with_option, *style_option;
extern char const *with_option, *style_option, *surface_option;
void init_term(FILE *pipef, char const *title, char const* verbatim);
void create_history_graph(std::deque <blc_channel> &inputs, char const *title, int history_length, int refresh_period, int sampling_period, float min, float max, char const *verbatim);
......
......@@ -12,7 +12,7 @@ using namespace std;
deque <blc_channel> inputs;
blc_array history_array;
char const *with_option, *style_option;
char const *with_option, *style_option, *surface_option;
int sx, sy;
int sampling_period;
......@@ -43,6 +43,7 @@ int main(int argc, char *argv[]){
blc_program_add_option(&ymax_str, 'M', "max", "FL32", "maximal value", NULL);
blc_program_add_option(&sample_string, 'p', "period", "UI32", "sampling period in ms or history", "10");
blc_program_add_option(&style_option, 's', "style", "string", "gnuplot option set option (style, boxwidth, ...)", "fill solid");
blc_program_add_option(&surface_option, 'S', "surface", nullptr, "use splot", nullptr);
blc_program_add_option(&verbatim, 't', "text", "string", "text directly put on the gnuplot set commandline", NULL);
blc_program_add_option(&with_option, 'w', "with", "string", "gnuplot option with (lines, boxes, dots,...)", nullptr);
blc_program_add_option(&xmin_str, 'x', "xmin", "FL32", "minimal abscissa value", NULL);
......@@ -61,7 +62,7 @@ int main(int argc, char *argv[]){
if (inputs.size()==1){ //First time
type=inputs.back().type;
dims_nb=inputs.back().dims_nb;
total_length=inputs.back().total_length;
total_length=inputs.back().dims[0].length;
}
else{
if (type!=inputs.back().type) EXIT_ON_ERROR("Type of different channels must be the same");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment