g4tools  5.4.0
plotter
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_sg_plotter
5 #define tools_sg_plotter
6 
7 #include "../lina/vec2f"
8 
9 #include "render_action"
10 #include "plottables"
11 #include "style"
12 #include "rep"
13 #include "colormap"
14 #include "noderef"
15 #include "atb_vertices"
16 #include "cube" //for lego
17 #include "matrix"
18 #include "normal"
19 #include "holder"
20 #include "tex_rect" //for plottable_img.
21 
22 #include "axis"
23 #include "infos_box"
24 #include "legend"
25 #include "text"
26 #include "torche"
27 #include "ellipse"
28 
29 #include "../data_axis"
30 #include "../hatcher"
31 #include "../clist_contour"
32 #include "../tess_contour"
33 #include "../lina/geom3"
34 #include "../spline"
35 #include "../rtausmef"
36 
37 //#define INLIBS_SG_PLOTTER_TIMING
38 #ifdef INLIBS_SG_PLOTTER_TIMING
39 #include "../sys/atime"
40 #endif
41 
42 namespace tools {
43 namespace sg {
44 
45 class plotter : public node {
47 private:
48  static const std::string& s_infos_what_def() {
49  static const std::string s_v("name entries mean rms fit_quality fit_ndf fit_parameters fit_errors");
50  return s_v;
51  }
52  static float default_infos_margin() {return 0.005f;}
53  static float default_title_box_width() {return 0.3f;}
54  static float default_title_box_height() {return 0.05f;}
55  static float default_title_box_x_margin() {return 0.01f;}
56  static float default_title_box_y_margin() {return 0.005f;}
57 public:
58  sf<float> width; //PAW XSIZ
59  sf<float> height; //PAW YSIZ
60  sf<float> left_margin; //PAW XMGL
61  sf<float> right_margin; //PAW XMGR
63  sf<float> top_margin; //PAW YMGU
64 
68 
74  sf_string title; //output if title_automated.
75 
78  cells = 0,
79  min_max
80  };
84 
85  // Wanted axes parameters.
86  // They are not necessary realized on the sg::axis nodes.
92 
98 
104 
108 
109  sf<float> infos_width; //in percent of width.
110  sf<float> infos_x_margin; //in percent of width. From right.
111  sf<float> infos_y_margin; //in percent of height. From top.
113 
114  sf<float> title_box_width; //in percent of width.
115  sf<float> title_box_height; //in percent of height.
116  sf<float> title_box_x_margin; //in percent of width. From left.
117  sf<float> title_box_y_margin; //in percent of height. From top.
118 
120 
121  // used with shape xyz
122  sf<float> theta; //in degrees.
123  sf<float> phi; //in degrees.
124  sf<float> tau; //in degrees.
125 
130  //sf<bool> legends_attached_to_infos;
131  //if legends_attached_to_infos is false :
132  // legends_origin is used to place the legends. It is then
133  // the lower left corner of the box containing all legends.
134  mf_vec<vec2f,float> legends_origin; //common origin of legend boxes.
135  enum unit_type {
137  unit_axis
138  };
140  mf_vec<vec2f,float> legends_size; //overall legend boxes size.
142 
146 
148 
149  enum shape_type {
150  xy = 0,
151  xyz
152  };
154 
155  // used with xy shape :
156  sf<float> xy_depth; //all is in z [0,xy_depth]
157 
159 
161 
162  // for gopaw :
165  // to be implemented :
169  //sf<bool> grid_visible;
170  // For contours :
173  //sf<bool> frozen;
174  //sf<float> ttfScale;
175  //sf<bool> wallEnforced;
176  //sf<bool> gridEnforced;
177  //SoMFString infos; //Output
178  //SoMFString legend; //Output
179 
180 public:
181  virtual const desc_fields& node_desc_fields() const {
183  static const desc_fields s_v(parent::node_desc_fields(),63, //WARNING : take care of count.
184 
195 
200 
203 
208 
210  "left",left,
211  "center",center,
212  "right",right
214 
216 
222 
228 
234 
238 
243 
248 
250 
252  "unit_percent",unit_percent,
253  "unit_axis",unit_axis
255 
259 
261 
263  "xy",xy,
264  "xyz",xyz
266 
269 
272 
274 
277 
282 
283  );
284  return s_v;
285  }
286  virtual bool touched() {
287  if(parent::touched()) return true;
288 
289  if(background_style().touched()) return true;
290  if(title_style().touched()) return true;
291  if(infos_style().touched()) return true;
292  if(title_box_style().touched()) return true;
293  if(inner_frame_style().touched()) return true;
294  if(grid_style().touched()) return true;
295  if(wall_style().touched()) return true;
296 
297  {tools_vforit(style,m_bins_style,it) {if((*it).touched()) return true;}}
298  {tools_vforit(style,m_errors_style,it) {if((*it).touched()) return true;}}
299  {tools_vforit(style,m_func_style,it) {if((*it).touched()) return true;}}
300  {tools_vforit(style,m_points_style,it) {if((*it).touched()) return true;}}
301  {tools_vforit(style,m_left_hatch_style,it) {if((*it).touched()) return true;}}
302  {tools_vforit(style,m_right_hatch_style,it) {if((*it).touched()) return true;}}
303  {tools_vforit(style,m_legend_style,it) {if((*it).touched()) return true;}}
304 
305  return false;
306  }
307  virtual void reset_touched() {
308  parent::reset_touched();
309 
317 
318  {tools_vforit(style,m_bins_style,it) (*it).reset_touched();}
319  {tools_vforit(style,m_errors_style,it) (*it).reset_touched();}
320  {tools_vforit(style,m_func_style,it) (*it).reset_touched();}
321  {tools_vforit(style,m_points_style,it) (*it).reset_touched();}
322  {tools_vforit(style,m_left_hatch_style,it) (*it).reset_touched();}
323  {tools_vforit(style,m_right_hatch_style,it) (*it).reset_touched();}
324  {tools_vforit(style,m_legend_style,it) (*it).reset_touched();}
325  }
326 
327 private:
328  void add_fields(){
329  // if adding a field, look for reset_style(), set_from_style() and set_from_string()
330  add_field(&width);
331  add_field(&height);
336  add_field(&depth);
339 
345  add_field(&title);
346 
352 
358 
364 
368 
373 
378 
380  add_field(&theta);
381  add_field(&phi);
382  add_field(&tau);
383 
385  //add_field(&legends_attached_to_infos);
390 
392  add_field(&shape);
393 
397  add_field(&levels);
401  }
402 public: //style
403  void copy_style(const plotter& a_from) { //used in sg::plots.
408  shape = a_from.shape;
409  xy_depth = a_from.xy_depth;
414  infos_what = a_from.infos_what;
415  infos_width = a_from.infos_width;
416  //infos height is automatic.
419 
424 
427  title = a_from.title;
428  title_up = a_from.title_up;
429  title_hjust = a_from.title_hjust;
430 
435 
437  levels = a_from.levels;
441 
447  x_axis_min = a_from.x_axis_min;
448  x_axis_max = a_from.x_axis_max;
449  x_axis_is_log = a_from.x_axis_is_log;
450 
453  y_axis_min = a_from.y_axis_min;
454  y_axis_max = a_from.y_axis_max;
455  y_axis_is_log = a_from.y_axis_is_log;
456 
459  z_axis_min = a_from.z_axis_min;
460  z_axis_max = a_from.z_axis_max;
461  z_axis_is_log = a_from.z_axis_is_log;
462 
463  /*
464  m_x_axis = a_from.m_x_axis;
465  m_y_axis = a_from.m_y_axis;
466  m_z_axis = a_from.m_z_axis;
467  m_cmap_axis = a_from.m_cmap_axis;
468 
469  */
473 
475  m_title_style = a_from.m_title_style;
476  m_infos_style = a_from.m_infos_style;
479  m_grid_style = a_from.m_grid_style;
480  m_wall_style = a_from.m_wall_style;
481 
482  m_bins_style = a_from.m_bins_style;
484  m_func_style = a_from.m_func_style;
489  }
490 
491  void reset_style(bool a_geom = false) {
492  //reset fields that are considered as part of the style.
493 
494  //::printf("debug : tools::sg::plotter::reset_style :\n");
495 
496  shape_automated = true;
497  shape = xy;
498 
499  xy_depth = 0.01f;
502  value_top_margin = 0.1f; //percent. // CERN-PAW seems to have 0.1F and CERN-ROOT 0.05F.
503  value_bottom_margin = 0.0f; //percent.
504  value_bins_with_entries = true; //gopaw uses false.
505 
506  infos_what = s_infos_what_def();
507  infos_width = 0.3f;
508  //infos height is automatic.
509  infos_x_margin = default_infos_margin(); //percent of width
510  infos_y_margin = default_infos_margin(); //percent of height
511 
512  title_box_width = default_title_box_width();
513  title_box_height = default_title_box_height();
514  title_box_x_margin = default_title_box_x_margin(); //percent of width
515  title_box_y_margin = default_title_box_y_margin(); //percent of height
516 
517  legends_automated = true;
518 
520 
521  if(a_geom) {
522  float xfac = 1.0F/20.0F; //0.05
523  float yfac = 1.0F/20.0F; //0.05
524 
525  // Take PAW defaults :
526  float XSIZ = 20 * xfac; //1 //page width
527  float YSIZ = 20 * yfac; //1 //page height
528  float XMGL = 2 * xfac; //0.1 //left x margin (to data frame).
529  float XMGR = 2 * xfac; //0.1 //right y margin (to data frame).
530  float YMGL = 2 * yfac; //0.1 //low y margin (to data frame).
531  float YMGU = 2 * yfac; //0.1 //up y margin (to data frame).
532  // Axes :
533  float VSIZ = 0.28F * yfac; //0.014 //tick label character size.
534  float XVAL = 0.4F * xfac; //0.02 //x distance of y tick label to data frame.
535  float YVAL = 0.4F * yfac; //0.02 //y distance of x tick label to data frame.
536  float XTIC = 0.3F * yfac; //0.015 //y length of X axis ticks.
537  float YTIC = 0.3F * xfac; //0.015 //x length of Y axis ticks.
538  float XLAB = 1.4F * xfac; //0.07 //x distance of y title to data frame.
539  float YLAB = 0.8F * yfac; //0.04 //y distance of x title to data frame.
540  float ASIZ = 0.28F * yfac; //0.014 // axis title (label) character size.
541 
542  float YHTI = 1.2F * yfac; //0.06 //y distance of title to x axis.
543  float TSIZ = 0.28F * yfac; //0.014 //title character size
544 
545  float zfac = 1.0F/20.0F; //0.05
546  float ZSIZ = 20 * zfac; //1 //page depth
547  float ZMGD = 2 * zfac; //0.1 //low y margin (to data frame).
548  float ZMGU = 2 * zfac; //0.1 //up y margin (to data frame).
549 
550  // Data area :
551  //float wData = XSIZ-XMGL-XMGR;
552  //float hData = YSIZ-YMGL-YMGU;
553  //float dData = ZSIZ-ZMGD-ZMGU;
554 
555  width = XSIZ;
556  height = YSIZ;
557  depth = ZSIZ;
558 
559  left_margin = XMGL;
560  right_margin = XMGR;
561  bottom_margin = YMGL;
562  top_margin = YMGU;
563  down_margin = ZMGD;
564  up_margin = ZMGU;
565 
566  title_to_axis = YHTI;
567  title_height = TSIZ;
568 
569  if(shape.value()==xy) {
570  m_x_axis.tick_length.value(XTIC);
575 
576  m_y_axis.tick_length.value(YTIC);
581 
582  //set anyway z axis :
583  //m_z_axis.tick_length.value(YTIC);
584  //m_z_axis.label_to_axis.value(XVAL);
585  //m_z_axis.label_height.value(VSIZ);
586  //m_z_axis.title_to_axis.value(XLAB);
587  //m_z_axis.title_height.value(ASIZ);
588 
594 
595  } else { //xyz
596  m_x_axis.tick_length.value(XTIC);
601 
602  m_y_axis.tick_length.value(XTIC);
607 
608  m_z_axis.tick_length.value(YTIC);
613 
619 
620  }
621 
622  }
623 
624  title_automated = true;
625  title.value().clear();
626  title_up = true;
628 
630  colormap_visible = true;
632  colormap_attached = true;
633  colormap_axis_visible = true;
634 
636  x_axis_enforced = false;
637  x_axis_automated = true;
638  x_axis_min = 0;
639  x_axis_max = 1;
640  x_axis_is_log = false;
641 
642  y_axis_enforced = false;
643  y_axis_automated = true;
644  y_axis_min = 0;
645  y_axis_max = 1;
646  y_axis_is_log = false;
647 
648  z_axis_enforced = false;
649  z_axis_automated = true;
650  z_axis_min = 0;
651  z_axis_max = 1;
652  z_axis_is_log = false;
653 
657 
661  number_of_levels = 10;
662  levels.clear();
664  primitives_enforced = false;
665  inner_frame_enforced = false;
666 
668  // setup styles :
670 
675  m_wall_style = style();
677  m_grid_style = style();
678 
679  m_title_style.color = colorf_black();
683 
684  m_background_style.back_color = colorf_white();
685  m_background_style.line_width = 0; //no border
686  m_background_style.color = colorf_black(); //border
687 
688  m_inner_frame_style.color = colorf_black();
690 
691  m_grid_style.color = colorf_black();
693 
697 
698  m_title_box_style.visible = false;
702 
704  (*it) = style();
705  (*it).modeling = modeling_top_lines();
706  (*it).marker_size = 5; //for bins1D of profile.
707  }}
708  {tools_vforit(style,m_errors_style,it) {(*it) = style();(*it).visible = false;}}
709  {tools_vforit(style,m_func_style,it) (*it) = style();}
711  (*it) = style();
712  (*it).modeling = modeling_markers(); //for gopaw.
713  }}
714  {tools_vforit(style,m_left_hatch_style,it) {(*it) = style();(*it).visible = false;}}
715  {tools_vforit(style,m_right_hatch_style,it) {(*it) = style();(*it).visible = false;}}
716  {tools_vforit(style,m_legend_style,it) {(*it) = style();(*it).visible = false;}}
717 
718  }
719 
722  (*it) = style();
723  (*it).modeling = modeling_top_lines();
724  (*it).marker_size = 5; //for bins1D of profile.
725  }}
726 
727  {tools_vforit(style,m_errors_style,it) {(*it) = style();(*it).visible = false;}}
728  {tools_vforit(style,m_func_style,it) (*it) = style();}
730  (*it) = style();
731  (*it).modeling = modeling_markers(); //for gopaw.
732  }}
733  {tools_vforit(style,m_left_hatch_style,it) {(*it) = style();(*it).visible = false;}}
734  {tools_vforit(style,m_right_hatch_style,it) {(*it) = style();(*it).visible = false;}}
735  {tools_vforit(style,m_legend_style,it) {(*it) = style();(*it).visible = false;}}
736  }
737 
738  typedef std::pair<std::string,std::string> style_item_t;
739  typedef std::vector<style_item_t> style_t;
740  bool set_from_style(std::ostream& a_out,const style_t& a_style) {
741  tools_vforcit(style_item_t,a_style,it) {
742  const std::string& key = (*it).first;
743  const std::string& sv = (*it).second;
744  //::printf("debug : plotter::set_from_style : key \"%s\" \"%s\"\n",key.c_str(),sv.c_str());
745  //if(key=="reset") {}
746  if(key=="tag") {
747  // key to find back <plotter_style>s.
748  // see also :
749  // xml_style::load_plotter_style()
750  // xml_style::find_plotter_styles()
751 
752 
753  //width,height,depth : could set from style (for exa for lego).
754  } else if(key=="width") {
755  float v;
756  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
757  width = v;
758  } else if(key=="height") {
759  float v;
760  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
761  height = v;
762  } else if(key=="depth") {
763  float v;
764  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
765  depth = v;
766 
767  } else if(key=="left_margin") {
768  float v;
769  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
770  left_margin = v;
771  } else if(key=="right_margin") {
772  float v;
773  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
774  right_margin = v;
775  } else if(key=="bottom_margin") {
776  float v;
777  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
778  bottom_margin = v;
779  } else if(key=="top_margin") {
780  float v;
781  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
782  top_margin = v;
783  } else if(key=="down_margin") {
784  float v;
785  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
786  down_margin = v;
787  } else if(key=="up_margin") {
788  float v;
789  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
790  up_margin = v;
791 
792  } else if(key=="title") {
793  title = sv;
794  } else if(key=="title_up") {
795  bool v;
796  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
797  title_up = v;
798  } else if(key=="title_to_axis") {
799  float v;
800  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
801  title_to_axis = v;
802  } else if(key=="title_height") {
803  float v;
804  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
805  title_height = v;
806  } else if(key=="title_automated") {
807  bool v;
808  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
809  title_automated = v;
810  } else if(key=="title_hjust") {
811  hjust v;
812  if(!shjust(sv,v))
813  {style_failed(a_out,key,sv);return false;}
814  title_hjust = v;
815 
816  } else if(key=="x_axis_enforced") {
817  bool v;
818  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
819  x_axis_enforced = v;
820  } else if(key=="x_axis_automated") {
821  bool v;
822  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
823  x_axis_automated = v;
824  } else if(key=="x_axis_min") {
825  float v;
826  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
827  x_axis_min = v;
828  } else if(key=="x_axis_max") {
829  float v;
830  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
831  x_axis_max = v;
832  } else if(key=="x_axis_is_log") {
833  bool v;
834  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
835  x_axis_is_log = v;
836 
837  } else if(key=="y_axis_enforced") {
838  bool v;
839  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
840  y_axis_enforced = v;
841  } else if(key=="y_axis_automated") {
842  bool v;
843  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
844  y_axis_automated = v;
845  } else if(key=="y_axis_min") {
846  float v;
847  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
848  y_axis_min = v;
849  } else if(key=="y_axis_max") {
850  float v;
851  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
852  y_axis_max = v;
853  } else if(key=="y_axis_is_log") {
854  bool v;
855  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
856  y_axis_is_log = v;
857 
858  } else if(key=="z_axis_enforced") {
859  bool v;
860  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
861  z_axis_enforced = v;
862  } else if(key=="z_axis_automated") {
863  bool v;
864  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
865  z_axis_automated = v;
866  } else if(key=="z_axis_min") {
867  float v;
868  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
869  z_axis_min = v;
870  } else if(key=="z_axis_max") {
871  float v;
872  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
873  z_axis_max = v;
874  } else if(key=="z_axis_is_log") {
875  bool v;
876  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
877  z_axis_is_log = v;
878 
879  } else if(key=="value_top_margin") {
880  float v;
881  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
882  value_top_margin = v;
883  } else if(key=="value_bottom_margin") {
884  float v;
885  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
887  } else if(key=="value_bins_with_entries") {
888  float v;
889  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
891  } else if(key=="infos_width") {
892  float v;
893  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
894  infos_width = v;
895  } else if(key=="infos_x_margin") {
896  float v;
897  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
898  infos_x_margin = v;
899  } else if(key=="infos_y_margin") {
900  float v;
901  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
902  infos_y_margin = v;
903 
904  } else if(key=="title_box_width") {
905  float v;
906  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
907  title_box_width = v;
908  } else if(key=="title_box_height") {
909  float v;
910  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
911  title_box_height = v;
912  } else if(key=="title_box_x_margin") {
913  float v;
914  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
915  title_box_x_margin = v;
916  } else if(key=="title_box_y_margin") {
917  float v;
918  if(!to<float>(sv,v)) {style_failed(a_out,key,sv);return false;}
919  title_box_y_margin = v;
920 
921  } else if(key=="infos_what") {
922  infos_what = sv;
923 
924 // } else if(key=="legends_visible") {
925 // bool v;
926 // if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
927 // legends_visible = v;
928  } else if(key=="legends_automated") {
929  bool v;
930  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
931  legends_automated = v;
932 // } else if(key=="legends_attached_to_infos") {
933 // bool v;
934 // if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
935 // legends_attached_to_infos = v;
936  } else if(key=="legends_origin") {
937  vec2f v;
938  if(!sto(sv,v)) {style_failed(a_out,key,sv);return false;}
939  legends_origin.setValue(v);
940  } else if(key=="legends_size") {
941  vec2f v;
942  if(!sto(sv,v)) {style_failed(a_out,key,sv);return false;}
943  legends_size.setValue(v);
944  } else if(key=="legends_origin_unit") {
945  unit_type v;
946  if(!sto(sv,v)) {style_failed(a_out,key,sv);return false;}
948 
949  } else if(key=="shape_automated") {
950  bool v;
951  if(!to(sv,v)) {style_failed(a_out,key,sv);return false;}
952  shape_automated = v;
953 
954  } else if(key=="shape") {
955  if(sv=="xy") {
956  shape = xy;
957  } else if(sv=="xyz") {
958  shape = xyz;
959  } else {
960  style_failed(a_out,key,sv);return false;
961  }
962 
963  //legends_string
964  //legends_color
965  //legends_string mf_string
966  //legends_color mf_vec<colorf,float>
967 
968  } else {
969  a_out << "tools::sg::plotter::set_from_style : unknown key " << key << "." << std::endl;
970  }
971  }
972  return true;
973  }
974 
975 protected:
976  bool s2axis(const std::string& a_s,sg::axis*& a_axis) {
977  if(a_s=="x_axis") {a_axis = &(x_axis());return true;}
978  else if(a_s=="y_axis") {a_axis = &(y_axis());return true;}
979  else if(a_s=="z_axis") {a_axis = &(z_axis());return true;}
980  else if(a_s=="colormap_axis") {a_axis = &(colormap_axis());return true;}
981  else {
982  a_axis = 0;
983  return false;
984  }
985  }
986 public:
987  bool set_from_string(std::ostream& a_out,cmaps_t& a_cmaps,const std::string& a_field,const std::string& a_value) {
988  // see also plotter_style file.
989  std::string::size_type pos = a_field.find('.');
990  bool status = true;
991  if(pos==std::string::npos) {
992  style_t _style;
993  _style.push_back(style_item_t(a_field,a_value));
994  if(!set_from_style(a_out,_style)) status = false;
995  } else {
996  std::vector<std::string> _words;
997  words(a_field,".",false,_words);
998  if(_words.size()==2) {
999  const std::string& word0 = _words[0];
1000  const std::string& word1 = _words[1];
1001  std::string _s = word1+" "+std::string(a_value);
1002  sg::axis* _axis = 0;
1003  if(word0=="background_style") {if(!background_style().from_string(a_out,a_cmaps,_s)) status = false;}
1004  else if(word0=="title_style") {if(!title_style().from_string(a_out,a_cmaps,_s)) status = false;}
1005  else if(word0=="infos_style") {if(!infos_style().from_string(a_out,a_cmaps,_s)) status = false;}
1006  else if(word0=="title_box_style") {if(!title_box_style().from_string(a_out,a_cmaps,_s)) status = false;}
1007  else if(word0=="inner_frame_style") {if(!inner_frame_style().from_string(a_out,a_cmaps,_s)) status = false;}
1008  else if(word0=="grid_style") {if(!grid_style().from_string(a_out,a_cmaps,_s)) status = false;}
1009  else if(word0=="wall_style") {if(!wall_style().from_string(a_out,a_cmaps,_s)) status = false;}
1010  else if(!s2axis(word0,_axis)) {
1011  a_out << "tools::sg::plotter::set_from_string : unexpected axis field " << word0 << "." << std::endl;
1012  status = false;
1013  } else {
1014  style_t _style;
1015  _style.push_back(style_item_t(word1,a_value));
1016  if(!_axis->set_from_style(a_out,_style)) status = false;
1017  }
1018  } else if(_words.size()==3) {
1019  const std::string& word0 = _words[0];
1020  const std::string& word1 = _words[1];
1021  const std::string& word2 = _words[2];
1022  sg::axis* _axis = 0;
1023  std::string _s = word2+" "+std::string(a_value);
1024  unsigned int index;
1025  bool to_status = to<unsigned int>(word1,index);
1026  if(word0=="bins_style") {
1027  if(!to_status) {
1028  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1029  status = false;
1030  } else {
1031  if(!bins_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1032  }
1033  } else if(word0=="errors_style") {
1034  if(!to_status) {
1035  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1036  status = false;
1037  } else {
1038  if(!errors_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1039  }
1040  } else if(word0=="func_style") {
1041  if(!to_status) {
1042  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1043  status = false;
1044  } else {
1045  if(!func_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1046  }
1047  } else if(word0=="points_style") {
1048  if(!to_status) {
1049  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1050  status = false;
1051  } else {
1052  if(!points_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1053  }
1054  } else if(word0=="left_hatch_style") {
1055  if(!to_status) {
1056  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1057  status = false;
1058  } else {
1059  if(!left_hatch_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1060  }
1061  } else if(word0=="right_hatch_style") {
1062  if(!to_status) {
1063  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1064  status = false;
1065  } else {
1066  if(!right_hatch_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1067  }
1068  } else if(word0=="legend_style") {
1069  if(!to_status) {
1070  a_out << "tools::sg::plotter::set_from_string : bad string " << word1 << " for an index." << std::endl;
1071  status = false;
1072  } else {
1073  if(!legend_style(index).from_string(a_out,a_cmaps,_s)) status = false;
1074  }
1075  } else if(!s2axis(word0,_axis)) {
1076  a_out << "tools::sg::plotter::set_from_string : unexpected axis field " << word0 << "." << std::endl;
1077  status = false;
1078  } else {
1079  if(word1=="line_style") {if(!_axis->line_style().from_string(a_out,a_cmaps,_s)) status = false;}
1080  else if(word1=="ticks_style") {if(!_axis->ticks_style().from_string(a_out,a_cmaps,_s)) status = false;}
1081  else if(word1=="labels_style") {if(!_axis->labels_style().from_string(a_out,a_cmaps,_s)) status = false;}
1082  else if(word1=="mag_style") {if(!_axis->mag_style().from_string(a_out,a_cmaps,_s)) status = false;}
1083  else if(word1=="title_style") {if(!_axis->title_style().from_string(a_out,a_cmaps,_s)) status = false;}
1084  else {
1085  a_out << "tools::sg::plotter::set_from_string : unexpected style field " << word1 << "." << std::endl;
1086  status = false;
1087  }
1088  }
1089  } else {
1090  a_out << "tools::sg::plotter::set_from_string : unexpected number of fields " << _words.size() << "." << std::endl;
1091  status = false;
1092  }
1093  }
1094  return status;
1095  }
1096 
1097  void set_encoding(const std::string& a_value) {
1098  title_style().encoding = a_value;
1099  infos_style().encoding = a_value;
1100  title_box_style().encoding = a_value;
1101  m_x_axis.set_encoding(a_value);
1102  m_y_axis.set_encoding(a_value);
1103  m_z_axis.set_encoding(a_value);
1104  m_cmap_axis.set_encoding(a_value);
1105  }
1107 
1108  void print_available_customization(std::ostream& a_out) const {
1109  a_out << "plotter fields :" << std::endl;
1110  {const std::vector<field_desc>& fds = node_desc_fields();
1111  tools_vforcit(field_desc,fds,itd) {
1112  a_out << " " << (*itd).name() << ", class " << (*itd).cls() << std::endl;
1113  }}
1114  a_out << std::endl;
1115 
1116  a_out << "plotter data available styles :" << std::endl;
1117  a_out << " bins_style.<uint>, class style" << std::endl;
1118  a_out << " errors_style.<uint>, class style" << std::endl;
1119  a_out << " func_style.<uint>, class style" << std::endl;
1120  a_out << " points_style.<uint>, class style" << std::endl;
1121  a_out << " left_hatch_style.<uint>, class style" << std::endl;
1122  a_out << " right_hatch_style.<uint>, class style" << std::endl;
1123  a_out << " legend_style.<uint>, class style" << std::endl;
1124  a_out << std::endl;
1125 
1126  a_out << "plotter available styles :" << std::endl;
1127  a_out << " title_style, class text_style" << std::endl;
1128  a_out << " infos_style, class text_style" << std::endl;
1129  a_out << " title_box_style, class text_style" << std::endl;
1130  a_out << " background_style, class style" << std::endl;
1131  a_out << " inner_frame_style, class style" << std::endl;
1132  a_out << " grid_style, class style" << std::endl;
1133  a_out << " wall_style, class style" << std::endl;
1134  a_out << std::endl;
1135 
1136  a_out << "plotter available axes :" << std::endl;
1137  a_out << " x_axis" << std::endl;
1138  a_out << " y_axis" << std::endl;
1139  a_out << " z_axis" << std::endl;
1140  a_out << " colormap_axis" << std::endl;
1141  a_out << std::endl;
1142 
1143  a_out << "plotter axis available styles :" << std::endl;
1144  a_out << " title_style, class text_style" << std::endl;
1145  a_out << " labels_style, class text_style" << std::endl;
1146  a_out << " mag_style, class text_style" << std::endl;
1147  a_out << " line_style, class line_style" << std::endl;
1148  a_out << " ticks_style, class line_style" << std::endl;
1149  a_out << std::endl;
1150 
1151  a_out << "plotter style class fields :" << std::endl;
1152  {style _style;
1153  const std::vector<field_desc>& fds = _style.node_desc_fields();
1154  tools_vforcit(field_desc,fds,itd) {
1155  a_out << " " << (*itd).name() << ", class " << (*itd).cls() << std::endl;
1156  }}
1157  a_out << std::endl;
1158 
1159  a_out << "plotter text_style class fields :" << std::endl;
1160  {text_style _style;
1161  const std::vector<field_desc>& fds = _style.node_desc_fields();
1162  tools_vforcit(field_desc,fds,itd) {
1163  a_out << " " << (*itd).name() << ", class " << (*itd).cls() << std::endl;
1164  }}
1165  a_out << std::endl;
1166 
1167  a_out << "plotter line_style class fields :" << std::endl;
1168  {line_style _style;
1169  const std::vector<field_desc>& fds = _style.node_desc_fields();
1170  tools_vforcit(field_desc,fds,itd) {
1171  a_out << " " << (*itd).name() << ", class " << (*itd).cls() << std::endl;
1172  }}
1173  a_out << std::endl;
1174  }
1175 protected:
1176  void style_failed(std::ostream& a_out,const std::string& a_key,const std::string& a_value) {
1177  a_out << "tools::sg::plotter::set_from_style :"
1178  << " failed for key " << sout(a_key)
1179  << " and value " << sout(a_value) << "."
1180  << std::endl;
1181  }
1182 public:
1183  virtual void render(render_action& a_action) {
1184  if(touched()) {
1185  update_sg(a_action.out());
1186  reset_touched();
1187  }
1188  m_group.render(a_action);
1189  }
1190  virtual void pick(pick_action& a_action) {
1191  if(touched()) {
1192  update_sg(a_action.out());
1193  reset_touched();
1194  }
1195  nodekit_pick(a_action,m_group,this);
1196  }
1197  virtual void search(search_action& a_action) {
1198  if(touched()) {
1199  update_sg(a_action.out());
1200  reset_touched();
1201  }
1202  node::search(a_action);
1203  if(a_action.done()) return;
1204  m_group.search(a_action);
1205  }
1206  virtual void bbox(bbox_action& a_action) {
1207  if(touched()) {
1208  update_sg(a_action.out());
1209  reset_touched();
1210  }
1211  m_group.bbox(a_action);
1212  }
1213 
1214  virtual bool write(write_action& a_action) {
1215  if(touched()) {
1216  update_sg(a_action.out());
1217  reset_touched();
1218  }
1219  //if(!write_fields(a_action)) return false;
1220  return m_group.write(a_action);
1221  }
1222 public:
1223  plotter(const base_freetype& a_ttf)
1224  :parent()
1225  ,width(0)
1226  ,height(0)
1227  ,left_margin(0)
1228  ,right_margin(0)
1229  ,bottom_margin(0)
1230  ,top_margin(0)
1231  ,depth(0)
1232  ,down_margin(0)
1233  ,up_margin(0)
1234 
1235  ,title_up(true)
1236  ,title_to_axis(0) //set below.
1237  ,title_height(0) //set below.
1238  ,title_automated(true)
1240  ,title("")
1241 
1242  ,colormap_visible(true)
1244  ,colormap_attached(true)
1245  ,colormap_axis_visible(true)
1246 
1247  ,x_axis_enforced(false)
1248  ,x_axis_automated(true)
1249  ,x_axis_min(0)
1250  ,x_axis_max(1)
1251  ,x_axis_is_log(false)
1252  ,y_axis_enforced(false)
1253  ,y_axis_automated(true)
1254  ,y_axis_min(0)
1255  ,y_axis_max(1)
1256  ,y_axis_is_log(false)
1257  ,z_axis_enforced(false)
1258  ,z_axis_automated(true)
1259  ,z_axis_min(0)
1260  ,z_axis_max(1)
1261  ,z_axis_is_log(false)
1262 
1263  ,value_top_margin(0.1f) //percent. // CERN-PAW seems to have 0.1F and CERN-ROOT 0.05F.
1264  ,value_bottom_margin(0.0f) //percent.
1266 
1267  ,infos_width(0.3f) //percent of width
1268  ,infos_x_margin(default_infos_margin()) //percent of width
1269  ,infos_y_margin(default_infos_margin()) //percent of height
1270  ,infos_what(s_infos_what_def())
1271 
1272  ,title_box_width(default_title_box_width()) //percent of width
1273  ,title_box_height(default_title_box_height()) //percent of height
1274  ,title_box_x_margin(default_title_box_x_margin()) //percent of width
1275  ,title_box_y_margin(default_title_box_y_margin()) //percent of height
1276 
1277  ,func2D_borders_visible(true)
1278  ,theta(30)
1279  ,phi(30)
1280  ,tau(-90)
1281 
1282  ,legends_automated(true)
1283  //,legends_attached_to_infos(true)
1284  // if legends_attached_to_infos is false and
1285  // unit_percent, legends_origin is the position
1286  // of the upper right corner of the legends
1287  // relative to the upper right corner of the plotter
1288  // with positive values going in reverse x,y axis.
1289  //,legends_origin(vec2f(0.01f,0.01f))
1290  //,legends_origin_unit(unit_percent)
1291  //,legends_size(vec2f(0.2f,0.16f))
1292  //legends_string
1293 
1294  ,shape_automated(true)
1295  ,shape(xy)
1296 
1297  ,xy_depth(0.01f)
1300  ,primitives_enforced(false)
1301  ,inner_frame_enforced(false)
1302  ,number_of_levels(10)
1303  ,levels()
1304 
1305  ,m_ttf(a_ttf)
1306 
1307  ,m_cmap_axis(a_ttf)
1308  ,m_x_axis(a_ttf)
1309  ,m_y_axis(a_ttf)
1310  ,m_z_axis(a_ttf)
1311 
1312  ,m_shape(xy)
1313  {
1314  m_cmaps[style_default_colormap::s_default()] = style_default_colormap(); //costly
1315 
1316  add_fields();
1317  reset_style(true);
1318 
1319  init_sg(); // skeleton of scene graph.
1320  }
1321  virtual ~plotter(){
1322  clear_plottables();
1323  clear_primitives();
1324  clear_cmaps();
1325  }
1326 public:
1327  plotter(const plotter& a_from)
1328  :parent(a_from)
1329  ,width(a_from.width)
1330  ,height(a_from.height)
1331  ,left_margin(a_from.left_margin)
1332  ,right_margin(a_from.right_margin)
1333  ,bottom_margin(a_from.bottom_margin)
1334  ,top_margin(a_from.top_margin)
1335  ,depth(a_from.depth)
1336  ,down_margin(a_from.down_margin)
1337  ,up_margin(a_from.up_margin)
1338 
1339  ,title_up(a_from.title_up)
1340  ,title_to_axis(a_from.title_to_axis)
1341  ,title_height(a_from.title_height)
1343  ,title_hjust(a_from.title_hjust)
1344  ,title(a_from.title)
1345 
1350 
1353  ,x_axis_min(a_from.x_axis_min)
1354  ,x_axis_max(a_from.x_axis_max)
1355  ,x_axis_is_log(a_from.x_axis_is_log)
1358  ,y_axis_min(a_from.y_axis_min)
1359  ,y_axis_max(a_from.y_axis_max)
1360  ,y_axis_is_log(a_from.y_axis_is_log)
1363  ,z_axis_min(a_from.z_axis_min)
1364  ,z_axis_max(a_from.z_axis_max)
1365  ,z_axis_is_log(a_from.z_axis_is_log)
1369 
1370  ,infos_width(a_from.infos_width)
1373  ,infos_what(a_from.infos_what)
1374 
1379 
1381  ,theta(a_from.theta)
1382  ,phi(a_from.phi)
1383  ,tau(a_from.tau)
1384 
1386 //,legends_attached_to_infos(a_from.legends_attached_to_infos)
1389  ,legends_size(a_from.legends_size)
1391 
1393  ,shape(a_from.shape)
1394 
1395  ,xy_depth(a_from.xy_depth)
1401  ,levels(a_from.levels)
1402 
1403  ,m_ttf(a_from.m_ttf)
1404 
1405  ,m_background_sep()
1406 
1407  ,m_cmap_axis(m_ttf)
1408  ,m_x_axis(m_ttf)
1409  ,m_y_axis(m_ttf)
1410  ,m_z_axis(m_ttf)
1411 
1412  ,m_etc_sep(a_from.m_etc_sep)
1413 
1414  ,m_shape(a_from.m_shape)
1415 
1416  ,m_bins_style(a_from.m_bins_style)
1418  ,m_func_style(a_from.m_func_style)
1423 
1424  ,m_title_style(a_from.m_title_style)
1425  ,m_infos_style(a_from.m_infos_style)
1428  ,m_wall_style(a_from.m_wall_style)
1430  ,m_grid_style(a_from.m_grid_style)
1431  ,m_cmaps(a_from.m_cmaps)
1432  {
1433  add_fields();
1434 
1435  // to copy axes styles :
1436  m_x_axis = a_from.m_x_axis;
1437  m_y_axis = a_from.m_y_axis;
1438  m_z_axis = a_from.m_z_axis;
1439  m_cmap_axis = a_from.m_cmap_axis;
1440 
1441  init_sg(); // skeleton of scene graph.
1442 
1443  {tools_vforcit(plottable*,a_from.m_plottables,it) {m_plottables.push_back((*it)->copy());}}
1444  {tools_vforcit(plotprim*,a_from.m_primitives,it) {m_primitives.push_back((*it)->copy());}}
1445  }
1446  plotter& operator=(const plotter& a_from){
1447  parent::operator=(a_from);
1448  if(&a_from==this) return *this;
1449 
1450  width = a_from.width;
1451  height = a_from.height;
1452  left_margin = a_from.left_margin;
1453  right_margin = a_from.right_margin;
1454  bottom_margin = a_from.bottom_margin;
1455  top_margin = a_from.top_margin;
1456  depth = a_from.depth;
1457  down_margin = a_from.down_margin;
1458  up_margin = a_from.up_margin;
1459 
1460  title_up = a_from.title_up;
1461  title_to_axis = a_from.title_to_axis;
1462  title_height = a_from.title_height;
1464  title_hjust = a_from.title_hjust;
1465  title = a_from.title;
1466 
1471 
1474  x_axis_min = a_from.x_axis_min;
1475  x_axis_max = a_from.x_axis_max;
1476  x_axis_is_log = a_from.x_axis_is_log;
1479  y_axis_min = a_from.y_axis_min;
1480  y_axis_max = a_from.y_axis_max;
1481  y_axis_is_log = a_from.y_axis_is_log;
1484  z_axis_min = a_from.z_axis_min;
1485  z_axis_max = a_from.z_axis_max;
1486  z_axis_is_log = a_from.z_axis_is_log;
1490 
1491  infos_width = a_from.infos_width;
1492  infos_x_margin = a_from.infos_x_margin;
1493  infos_y_margin = a_from.infos_y_margin;
1494  infos_what = a_from.infos_what;
1495 
1500 
1502  theta = a_from.theta;
1503  phi = a_from.phi;
1504  tau = a_from.tau;
1505 
1507  //legends_attached_to_infos = a_from.legends_attached_to_infos;
1508  legends_origin = a_from.legends_origin;
1510  legends_size = a_from.legends_size;
1511  legends_string = a_from.legends_string;
1512 
1514  shape = a_from.shape;
1515 
1516  xy_depth = a_from.xy_depth;
1519  levels = a_from.levels;
1523 
1524  m_etc_sep = a_from.m_etc_sep;
1525 
1526  m_bins_style = a_from.m_bins_style;
1527  m_errors_style = a_from.m_errors_style;
1528  m_func_style = a_from.m_func_style;
1529  m_points_style = a_from.m_points_style;
1532  m_legend_style = a_from.m_legend_style;
1533 
1534  m_title_style = a_from.m_title_style;
1535  m_infos_style = a_from.m_infos_style;
1538  m_wall_style = a_from.m_wall_style;
1540  m_grid_style = a_from.m_grid_style;
1541 
1542  // to copy axes styles :
1543  m_x_axis = a_from.m_x_axis;
1544  m_y_axis = a_from.m_y_axis;
1545  m_z_axis = a_from.m_z_axis;
1546  m_cmap_axis = a_from.m_cmap_axis;
1547 
1548  m_cmaps = a_from.m_cmaps;
1549 
1550  clear_plottables();
1551  clear_primitives();
1552  clear_todels();
1553 
1554  {tools_vforcit(plottable*,a_from.m_plottables,it) {m_plottables.push_back((*it)->copy());}}
1555  {tools_vforcit(plotprim*,a_from.m_primitives,it) {m_primitives.push_back((*it)->copy());}}
1556 
1557  return *this;
1558  }
1559 public:
1560  size_t number_of_plottables() const {
1561  size_t number = 0;
1563  plottable* object = *it;
1564  if(!object) continue;
1565  if(!object->is_valid()) continue;
1566  // take into account all valid plottables, even the one without a representation.
1567  number++;
1568  }
1569  return number;
1570  }
1571 
1572 #define TOOLS_SG_PLOTTER_NUMBER_OF(a__what) \
1573  size_t number_of_plotted_##a__what##s() const {\
1574  size_t number = 0;\
1575  tools_vforcit(plottable*,m_plottables,it) {\
1576  plottable* object = *it;\
1577  if(!object) continue;\
1578  if(!object->is_valid()) continue;\
1579  if(safe_cast<plottable,a__what>(*object)) number++;\
1580  }\
1581  return number;\
1582  }
1583 
1586  TOOLS_SG_PLOTTER_NUMBER_OF(points2D)
1587  TOOLS_SG_PLOTTER_NUMBER_OF(points3D)
1590 
1591 #undef TOOLS_SG_PLOTTER_NUMBER_OF
1592 
1593  void plotted_object_names(std::vector<std::string>& a_names) const {
1594  a_names.clear();
1596  plottable* object = *it;
1597  if(!object) continue;
1598  if(!object->is_valid()) continue;
1599  // take into account all valid plottables, even the one without a representation.
1600  a_names.push_back(object->name());
1601  }
1602  }
1603 
1604 public: //public
1605  const torche& data_light() const {return m_data_light;}
1607 
1608  matrix& tsf() {return m_tsf;}
1609 
1610  const separator& etc_sep() const {return m_etc_sep;}
1612 
1613  const std::vector<plottable*>& plottables() const {return m_plottables;}
1614 
1616  //WARNING : it takes ownership of a_p object.
1617  m_plottables.push_back(a_p);
1618  touch();
1619  }
1620 
1622  //WARNING : it takes ownership of a_p object.
1623  m_plottables.insert(m_plottables.begin(),a_p);
1624  touch();
1625  }
1626 
1627  void transfer_plottables(std::vector<plottable*>& a_to) {
1628  a_to = m_plottables;
1629  m_plottables.clear(); //do not delete plottables !
1630  touch();
1631  }
1632 
1633  template <class T>
1635  bool found = false;
1636  std::vector<plottable*>::iterator it;
1637  for(it=m_plottables.begin();it!=m_plottables.end();) {
1638  plottable* object = *it;
1639  if(object && safe_cast<plottable,T>(*object)) {
1640  it = m_plottables.erase(it);
1641  delete object;
1642  found = true;
1643  } else {
1644  it++;
1645  }
1646  }
1647  if(found) touch();
1648  return found;
1649  }
1650 
1651  void add_primitive(plotprim* a_prim) {m_primitives.push_back(a_prim);touch();}
1652 
1653  void transfer_primitives(std::vector<plotprim*>& a_to) {
1654  a_to = m_primitives;
1655  m_primitives.clear(); //do not delete primitives !
1656  touch();
1657  }
1658 
1659  template <class T>
1660  void add_todel(T* a_obj) {
1661  m_todel_group.add(new sg::holder<T>(a_obj));
1662  }
1663  template <class T>
1665  remove_holders<T>(m_todel_group.children());
1666  }
1667  void transfer_todels(std::vector<node*>& a_to) { //used in sg::plots.
1668  m_todel_group.transfer(a_to);
1669  }
1670  void add_node_todel(node* a_node) { //used in sg::plots.
1671  m_todel_group.add(a_node);
1672  }
1673 
1674  void clear() {
1675  clear_plottables();
1676  clear_primitives();
1677  clear_todels();
1678 
1681  legends_origin.clear();
1682  legends_size.clear();
1683 
1684  //wallEnforced.setValue(false);
1685  //gridEnforced.setValue(false);
1686  primitives_enforced = false;
1687  inner_frame_enforced = false;
1688 
1689  //getEtcSeparator()->removeAllChildren();
1690  //getEtcDataSeparator()->removeAllChildren();
1691  }
1692 
1693  const sg::axis& x_axis() const {return m_x_axis;}
1694  sg::axis& x_axis() {return m_x_axis;}
1695 
1696  const sg::axis& y_axis() const {return m_y_axis;}
1697  sg::axis& y_axis() {return m_y_axis;}
1698 
1699  const sg::axis& z_axis() const {return m_z_axis;}
1700  sg::axis& z_axis() {return m_z_axis;}
1701 
1702  const sg::axis& colormap_axis() const {return m_cmap_axis;}
1704 
1712 
1713  style& bins_style(size_t a_index) {
1714  size_t sz = m_bins_style.size();
1715  if(a_index>=sz) {
1716  //012345 sz=6
1717  // 9 a_index wanted
1718  // 6789 loop
1719  for(size_t index=sz;index<=a_index;index++) {
1720  m_bins_style.push_back(style());
1721  m_bins_style.back().modeling = modeling_top_lines();
1722  m_bins_style.back().marker_size = 5; //for bins1D of profile.
1723  }
1724  }
1725  return m_bins_style[a_index];
1726  }
1727 
1728  style& errors_style(size_t a_index) {
1729  size_t sz = m_errors_style.size();
1730  if(a_index>=sz) {
1731  for(size_t index=sz;index<=a_index;index++) {
1732  m_errors_style.push_back(style());
1733  m_errors_style.back().visible = false;
1734  }
1735  }
1736  return m_errors_style[a_index];
1737  }
1738 
1739  style& func_style(size_t a_index) {
1740  size_t sz = m_func_style.size();
1741  if(a_index>=sz) {
1742  for(size_t index=sz;index<=a_index;index++) {
1743  m_func_style.push_back(style());
1744  }
1745  }
1746  return m_func_style[a_index];
1747  }
1748 
1749  style& points_style(size_t a_index) {
1750  size_t sz = m_points_style.size();
1751  if(a_index>=sz) {
1752  //012345 sz=6
1753  // 9 a_index wanted
1754  // 6789 loop
1755  for(size_t index=sz;index<=a_index;index++) {
1756  m_points_style.push_back(style());
1757  m_points_style.back().modeling = modeling_markers(); //for gopaw.
1758  }
1759  }
1760  return m_points_style[a_index];
1761  }
1762 
1763  style& left_hatch_style(size_t a_index) {
1764  size_t sz = m_left_hatch_style.size();
1765  if(a_index>=sz) {
1766  for(size_t index=sz;index<=a_index;index++) {
1767  m_left_hatch_style.push_back(style());
1768  m_left_hatch_style.back().visible = false;
1769  }
1770  }
1771  return m_left_hatch_style[a_index];
1772  }
1773 
1774  style& right_hatch_style(size_t a_index) {
1775  size_t sz = m_right_hatch_style.size();
1776  if(a_index>=sz) {
1777  for(size_t index=sz;index<=a_index;index++) {
1778  m_right_hatch_style.push_back(style());
1779  m_right_hatch_style.back().visible = false;
1780  }
1781  }
1782  return m_right_hatch_style[a_index];
1783  }
1784 
1785  style& legend_style(size_t a_index) {
1786  size_t sz = m_legend_style.size();
1787  if(a_index>=sz) {
1788  for(size_t index=sz;index<=a_index;index++) {
1789  m_legend_style.push_back(style());
1790  }
1791  }
1792  return m_legend_style[a_index];
1793  }
1794 
1795  void bins_modelings(size_t a_index,std::vector<std::string>& a_opts) {
1796  a_opts.clear();
1797  update_shape();
1798  if(m_shape==xy) {
1799  size_t ibins = 0;
1801  plottable* object = *it;
1802  if(!object) continue;
1803  if(bins1D* b1 = safe_cast<plottable,bins1D>(*object)) {
1804  //update_bins1D_xy
1805  if(a_index==ibins) {
1806  if(b1->is_profile()) {
1807  a_opts.push_back(modeling_points());
1808  a_opts.push_back(modeling_markers());
1809  return;
1810  } else {
1811  a_opts.push_back(modeling_boxes());
1812  a_opts.push_back(modeling_wire_boxes());
1813  a_opts.push_back(modeling_bar_chart());
1814  a_opts.push_back(modeling_top_lines());
1815  a_opts.push_back(modeling_points());
1816  a_opts.push_back(modeling_markers());
1817  return;
1818  }
1819  }
1820  ibins++;
1821  } if(safe_cast<plottable,bins2D>(*object)) {
1822  //update_bins2D_xy
1823  if(a_index==ibins) {
1824  a_opts.push_back(modeling_curve());
1825  a_opts.push_back(modeling_filled_curve());
1826  a_opts.push_back(modeling_boxes());
1827  a_opts.push_back(modeling_wire_boxes());
1828  a_opts.push_back(modeling_solid());
1829  a_opts.push_back(modeling_points());
1830  return;
1831  }
1832  ibins++;
1833  }
1834  }
1835  }
1836  }
1837 
1838  bool xx_2_yy(const vec3f& a_pos,vec3f& a_out) const {
1839  // a_pos is in data frame NDC coordinates.
1840  {float XSIZ = width;
1841  float XMGL = left_margin;
1842  float XMGR = right_margin;
1843  float wData = XSIZ-XMGL-XMGR;
1844  a_out[0] = wData*a_pos[0];}
1845 
1846  {float YSIZ = height;
1847  float YMGL = bottom_margin;
1848  float YMGU = top_margin;
1849  float hData = YSIZ-YMGL-YMGU;
1850  a_out[1] = hData*a_pos[1];}
1851 
1852  {float ZSIZ = depth;
1853  float ZMGD = down_margin;
1854  float ZMGU = up_margin;
1855  float dData = ZSIZ-ZMGD-ZMGU;
1856  a_out[2] = dData*a_pos[2];}
1857 
1858  return true;
1859  }
1860 
1861  bool data_frame_2_vp(const vec3f& a_pos,vec3f& a_vp) const {
1862  // a_pos is in data frame NDC coordinates.
1863  // a_vp is in viewport/screen coordinates (in [0,1]).
1864  {float XSIZ = width;
1865  float XMGL = left_margin;
1866  float XMGR = right_margin;
1867  float wData = XSIZ-XMGL-XMGR;
1868  if(XSIZ==0.0F) {
1869  //SoDebugError::postInfo("inlib::sg;:plotter::data_frame_2_vp","XSIZ is 0");
1870  return false;
1871  }
1872  a_vp[0] = (wData*a_pos[0] + XMGL)/XSIZ;}
1873 
1874  {float YSIZ = height;
1875  float YMGL = bottom_margin;
1876  float YMGU = top_margin;
1877  float hData = YSIZ-YMGL-YMGU;
1878  if(YSIZ==0.0F) {
1879  //SoDebugError::postInfo("inlib::sg;:plotter::data_frame_2_vp","YSIZ is 0");
1880  return false;
1881  }
1882  a_vp[1] = (hData*a_pos[1] + YMGL)/YSIZ;}
1883 
1884  {float ZSIZ = depth;
1885  float ZMGD = down_margin;
1886  float ZMGU = up_margin;
1887  float dData = ZSIZ-ZMGD-ZMGU;
1888  if(ZSIZ==0.0F) {
1889  //SoDebugError::postInfo("inlib::sg;:plotter::data_frame_2_vp","ZSIZ is 0");
1890  return false;
1891  }
1892  a_vp[2] = (dData*a_pos[2] + ZMGD)/ZSIZ;}
1893 
1894  return true;
1895  }
1896 
1897  bool vp_2_data_frame(const vec3f& a_vp,vec3f& a_pos) const {
1898  // a_vp is in viewport/screen coordinates (in [0,1]).
1899  // a_pos is in data frame NDC coordinates.
1900 
1901  {float XSIZ = width;
1902  float XMGL = left_margin;
1903  float XMGR = right_margin;
1904  float wData = XSIZ-XMGL-XMGR;
1905  if(wData==0.0F) {
1906  //SoDebugError::postInfo("inlib::sg;:plotter::vp_2_data_frame","wData is 0");
1907  return false;
1908  }
1909  a_pos[0] = (a_vp[0]*XSIZ - XMGL)/wData;}
1910 
1911  {float YSIZ = height;
1912  float YMGL = bottom_margin;
1913  float YMGU = top_margin;
1914  float hData = YSIZ-YMGL-YMGU;
1915  if(hData==0.0F) {
1916  //SoDebugError::postInfo("inlib::sg;:plotter::vp_2_data_frame","hData is 0");
1917  return false;
1918  }
1919  a_pos[1] = (a_vp[1]*YSIZ - YMGL)/hData;}
1920 
1921  {float ZSIZ = depth;
1922  float ZMGD = down_margin;
1923  float ZMGU = up_margin;
1924  float dData = ZSIZ-ZMGD-ZMGU;
1925  if(dData==0.0F) {
1926  //SoDebugError::postInfo("inlib::sg;:plotter::vp_2_data_frame","dData is 0");
1927  return false;
1928  }
1929  a_pos[2] = (a_vp[2]*ZSIZ - ZMGD)/dData;}
1930 
1931  return true;
1932  }
1933 
1934  bool data_frame_2_axis(const vec3f& aDF,vec3f& a_pos) const {
1935  // aDF is in data area coordinates. In [0,1][0,1][0,1].
1936  // a_pos is in axes coordinates.
1937 
1938  // Assume that axes min,max,is_log are up to date.
1939 
1940  {float mn = m_x_axis.minimum_value;
1941  float mx = m_x_axis.maximum_value;
1942  bool lg = m_x_axis.is_log;
1943  if(lg) {
1944  mn = fpow(10,mn);
1945  mx = fpow(10,mx);
1946  }
1947  a_pos[0] = verify_log_inv(aDF[0],mn,mx-mn,lg);}
1948 
1949  {float mn = m_y_axis.minimum_value;
1950  float mx = m_y_axis.maximum_value;
1951  bool lg = m_y_axis.is_log;
1952  if(lg) {
1953  mn = fpow(10,mn);
1954  mx = fpow(10,mx);
1955  }
1956  a_pos[1] = verify_log_inv(aDF[1],mn,mx-mn,lg);}
1957 
1958  {float mn = m_z_axis.minimum_value;
1959  float mx = m_z_axis.maximum_value;
1960  bool lg = m_z_axis.is_log;
1961  if(lg) {
1962  mn = fpow(10,mn);
1963  mx = fpow(10,mx);
1964  }
1965  a_pos[2] = verify_log_inv(aDF[2],mn,mx-mn,lg);}
1966 
1967  return true;
1968  }
1969 
1970  bool axis_2_data_frame(const vec3f& a_pos,vec3f& aDF) const {
1971  // a_pos is in axes coordinates.
1972  // aDF in data area coordinate. In [0,1][0,1][0,1].
1973 
1974  // Assume that axes min,max,logScale are up to date.
1975 
1976  {float mn = m_x_axis.minimum_value;
1977  float mx = m_x_axis.maximum_value;
1978  if(mx==mn) {
1979  //SoDebugError::postInfo
1980  // ("inlib::sg;:plotter::axis_2_data_frame","x : mn (%g) == mx (%g)",mn,mx);
1981  return false;
1982  }
1983  bool lg = m_x_axis.is_log;
1984  if(lg) {
1985  if(mn<=0) {
1986  //SoDebugError::postInfo
1987  // ("inlib::sg;:plotter::axis_2_data_frame","x log but mn (%g) <=0",mn);
1988  return false;
1989  }
1990  if(mx<=0) {
1991  //SoDebugError::postInfo
1992  // ("inlib::sg;:plotter::axis_2_data_frame","x log but mx (%g) <=0",mx);
1993  return false;
1994  }
1995  mn = flog10(mn);
1996  mx = flog10(mx);
1997  }
1998  aDF[0] = verify_log(a_pos[0],mn,mx-mn,lg);}
1999 
2000  {float mn = m_y_axis.minimum_value;
2001  float mx = m_y_axis.maximum_value;
2002  if(mx==mn) {
2003  //SoDebugError::postInfo
2004  // ("inlib::sg;:plotter::axis_2_data_frame","y : mn (%g) == mx (%g)",mn,mx);
2005  return false;
2006  }
2007  bool lg = m_y_axis.is_log;
2008  if(lg) {
2009  if(mn<=0) {
2010  //SoDebugError::postInfo
2011  // ("inlib::sg;:plotter::axis_2_data_frame","y log but mn (%g) <=0",mn);
2012  return false;
2013  }
2014  if(mx<=0) {
2015  //SoDebugError::postInfo
2016  // ("inlib::sg;:plotter::axis_2_data_frame","y log but mx (%g) <=0",mx);
2017  return false;
2018  }
2019  mn = flog10(mn);
2020  mx = flog10(mx);
2021  }
2022  aDF[1] = verify_log(a_pos[1],mn,mx-mn,lg);}
2023 
2024  {float mn = m_z_axis.minimum_value;
2025  float mx = m_z_axis.maximum_value;
2026  if(mx==mn) {
2027  //SoDebugError::postInfo
2028  // ("inlib::sg;:plotter::axis_2_data_frame","z : mn (%g) == mx (%g)",mn,mx);
2029  return false;
2030  }
2031  bool lg = m_z_axis.is_log;
2032  if(lg) {
2033  if(mn<=0) {
2034  //SoDebugError::postInfo
2035  // ("inlib::sg;:plotter::axis_2_data_frame","z log but mn (%g) <=0",mn);
2036  return false;
2037  }
2038  if(mx<=0) {
2039  //SoDebugError::postInfo
2040  // ("inlib::sg;:plotter::axis_2_data_frame","z log but mx (%g) <=0",mx);
2041  return false;
2042  }
2043  mn = flog10(mn);
2044  mx = flog10(mx);
2045  }
2046  aDF[2] = verify_log(a_pos[2],mn,mx-mn,lg);}
2047 
2048  return true;
2049  }
2050 
2051  bool axis_2_vp(const vec3f& a_pos,vec3f& a_vp) const {
2052  // a_pos is in axes coordinates.
2053  // a_vp is in viewport/screen coordinates (in [0,1]).
2054  vec3f d; // In data area coordinate. In [0,1][0,1][0,1].
2055  if(!axis_2_data_frame(a_pos,d)) return false;
2056  return data_frame_2_vp(d,a_vp);
2057  }
2058 
2059  bool vp_2_axis(const vec3f& a_vp,vec3f& a_pos) const {
2060  // a_vp is in viewport/screen coordinates (in [0,1]).
2061  // a_pos is in axes coordinates.
2062  vec3f d; // In data area coordinate. In [0,1][0,1][0,1].
2063  if(!vp_2_data_frame(a_vp,d)) return false;
2064  return data_frame_2_axis(d,a_pos);
2065  }
2066 
2067 public:
2068  void set_axes_modeling(const std::string& a_v){
2069  m_x_axis.modeling = a_v;
2070  m_y_axis.modeling = a_v;
2071  m_z_axis.modeling = a_v;
2072  m_cmap_axis.modeling = a_v;
2073  }
2074 
2075  void set_axes_color(const colorf& a_color){
2076  m_x_axis.line_style().color = a_color;
2077  m_x_axis.ticks_style().color = a_color;
2078  m_x_axis.labels_style().color = a_color;
2079  m_x_axis.title_style().color = a_color;
2080  m_x_axis.mag_style().color = a_color;
2081 
2082  m_y_axis.line_style().color = a_color;
2083  m_y_axis.ticks_style().color = a_color;
2084  m_y_axis.labels_style().color = a_color;
2085  m_y_axis.title_style().color = a_color;
2086  m_y_axis.mag_style().color = a_color;
2087 
2088  m_z_axis.line_style().color = a_color;
2089  m_z_axis.ticks_style().color = a_color;
2090  m_z_axis.labels_style().color = a_color;
2091  m_z_axis.title_style().color = a_color;
2092  m_z_axis.mag_style().color = a_color;
2093 
2094  m_cmap_axis.line_style().color = a_color;
2095  m_cmap_axis.ticks_style().color = a_color;
2096  m_cmap_axis.labels_style().color = a_color;
2097  m_cmap_axis.title_style().color = a_color;
2098  m_cmap_axis.mag_style().color = a_color;
2099  }
2100 
2101  void set_axes_text_scale(float a_v){
2102  m_x_axis.labels_style().scale = a_v;
2103  m_x_axis.title_style().scale = a_v;
2104  m_x_axis.mag_style().scale = a_v;
2105 
2106  m_y_axis.labels_style().scale = a_v;
2107  m_y_axis.title_style().scale = a_v;
2108  m_y_axis.mag_style().scale = a_v;
2109 
2110  m_z_axis.labels_style().scale = a_v;
2111  m_z_axis.title_style().scale = a_v;
2112  m_z_axis.mag_style().scale = a_v;
2113 
2114  m_cmap_axis.labels_style().scale = a_v;
2115  m_cmap_axis.title_style().scale = a_v;
2116  m_cmap_axis.mag_style().scale = a_v;
2117  }
2118 
2119  void set_axes_line_pattern(unsigned short a_v){
2120  m_x_axis.line_style().pattern = a_v;
2121  m_y_axis.line_style().pattern = a_v;
2122  m_z_axis.line_style().pattern = a_v;
2123  m_cmap_axis.line_style().pattern = a_v;
2124  }
2125 
2126  void set_axes_line_width(int a_v){
2127  m_x_axis.line_style().width = float(a_v);
2128  m_y_axis.line_style().width = float(a_v);
2129  m_z_axis.line_style().width = float(a_v);
2130  m_cmap_axis.line_style().width = float(a_v);
2131 
2132  m_x_axis.ticks_style().width = float(a_v);
2133  m_y_axis.ticks_style().width = float(a_v);
2134  m_z_axis.ticks_style().width = float(a_v);
2135  m_cmap_axis.ticks_style().width = float(a_v);
2136  }
2137 
2138  void set_axes_tick_length(float a_v){
2139  m_x_axis.tick_length = a_v;
2140  m_y_axis.tick_length = a_v;
2141  m_z_axis.tick_length = a_v;
2142  m_cmap_axis.tick_length = a_v;
2143  }
2144 
2145  void set_axes_title_height(float a_v){
2146  m_x_axis.title_height = a_v;
2147  m_y_axis.title_height = a_v;
2148  m_z_axis.title_height = a_v;
2149  m_cmap_axis.title_height = a_v;
2150  }
2151 
2152  void set_axes_label_height(float a_v){
2153  m_x_axis.label_height = a_v;
2154  m_y_axis.label_height = a_v;
2155  m_z_axis.label_height = a_v;
2156  m_cmap_axis.label_height = a_v;
2157  }
2158 
2163 
2167 
2171 
2175  }
2176 
2179  title_style().font_modeling = a_v;
2180  infos_style().font_modeling = a_v;
2182  }
2183 protected:
2184  void init_sg(){
2185 
2187  m_group.add(new noderef(m_cmap_sep));
2192  m_group.add(new noderef(m_tsf));
2193  m_group.add(new noderef(m_layout));
2198  m_group.add(new noderef(m_grid_sep));
2199  m_group.add(new noderef(m_data_sep));
2201 
2206 
2209 
2212 
2215 
2218 
2225  }
2226 
2228  float XSIZ = width;
2229  float XMGL = left_margin;
2230  float XMGR = right_margin;
2231  float wData = XSIZ-XMGL-XMGR;
2232 
2233  float YSIZ = height;
2234  float YMGL = bottom_margin;
2235  float YMGU = top_margin;
2236  float hData = YSIZ-YMGL-YMGU;
2237 
2238  float ZSIZ = depth;
2239  float ZMGD = down_margin;
2240  float ZMGU = up_margin;
2241  float dData = ZSIZ-ZMGD-ZMGU;
2242 
2243  {mat4f& mtx = m_layout.mtx.value();
2244  mtx.set_identity();
2245 
2246  if(m_shape==xy) {
2247  // in rep primitives (0,0) is the lower left corner
2248  // of the data area square;
2249  mtx.mul_translate(-XSIZ/2+XMGL,-YSIZ/2+YMGL,0);
2250 
2252  vec3f dir(0,0,-1);
2253  m_data_light.direction = dir;
2254 
2255  } else { //xyz
2256  //printf("debug : update_layout : X : %g %g %g %g\n",
2257  // XSIZ,XMGL,XMGR,wData);
2258  //printf("debug : update_layout : Y : %g %g %g %g\n",
2259  // YSIZ,YMGL,YMGU,hData);
2260 
2261  // global transformation (to have a "lego" layout) :
2262  // translate so that the center of the scene
2263  // is the center of the data area cube;
2264  // then rotate to have lego 3D layout.
2265 
2266  mtx.mul_rotate(1,0,0,theta*fdeg2rad());
2267  mtx.mul_rotate(0,1,0,phi*fdeg2rad());
2268  mtx.mul_rotate(1,0,0,tau*fdeg2rad());
2269 
2270  // To place as CERN-PAW default.
2271  // In CERN-PAW, it is the projection
2272  // which fits in the (XSIZ,XMGL,XMGR)/(YSIZ,YMGL,YMGU)
2273  // page setup.
2274 
2275  rotf r1(vec3f(1,0,0),theta * fdeg2rad());
2276  rotf r2(vec3f(0,1,0),phi * fdeg2rad());
2277  rotf r3(vec3f(1,0,0),tau * fdeg2rad());
2278 
2279  rotf r = r1*r2*r3;
2280  mat4f m;
2281  r.value(m);
2282 
2283  float xmn = -0.5F*wData;
2284  float ymn = -0.5F*hData;
2285  float zmn = -0.5F*dData;
2286  float xmx = 0.5F*wData;
2287  float ymx = 0.5F*hData;
2288  float zmx = 0.5F*dData;
2289 
2290  box3f _box;
2291  float x,y,z;
2292  // zmn face :
2293  {x = xmn;y = ymn;z = zmn;
2294  m.mul_3f(x,y,z);
2295  _box.extend_by(x,y,z);}
2296  {x = xmx;y = ymn;z = zmn;
2297  m.mul_3f(x,y,z);
2298  _box.extend_by(x,y,z);}
2299  {x = xmx;y = ymx;z = zmn;
2300  m.mul_3f(x,y,z);
2301  _box.extend_by(x,y,z);}
2302  {x = xmn;y = ymx;z = zmn;
2303  m.mul_3f(x,y,z);
2304  _box.extend_by(x,y,z);}
2305 
2306  // zmx face :
2307  {x = xmn;y = ymn;z = zmx;
2308  m.mul_3f(x,y,z);
2309  _box.extend_by(x,y,z);}
2310  {x = xmx;y = ymn;z = zmx;
2311  m.mul_3f(x,y,z);
2312  _box.extend_by(x,y,z);}
2313  {x = xmx;y = ymx;z = zmx;
2314  m.mul_3f(x,y,z);
2315  _box.extend_by(x,y,z);}
2316  {x = xmn;y = ymx;z = zmx;
2317  m.mul_3f(x,y,z);
2318  _box.extend_by(x,y,z);}
2319 
2320  float xfac = _box.mx()[0]-_box.mn()[0];
2321  float yfac = _box.mx()[1]-_box.mn()[1];
2322  float zfac = _box.mx()[2]-_box.mn()[2];
2323 
2324  //cube setup (driven by hData) :
2325  mtx.mul_scale(hData/xfac,hData/yfac,hData/zfac);
2326 
2327  mtx.mul_translate(-wData/2,-hData/2,-dData/2); //Applied first.
2328 
2330  {vec3f dir(1,-1,-10);
2331  float dx,dy,dz;dir.value(dx,dy,dz);
2332  mat4f inv;
2333  if(mtx.invert(inv)) {
2334  inv.mul_dir_3f(dx,dy,dz);
2335  m_data_light.direction = vec3f(dx,dy,dz);
2336  }}
2337  }}
2338 
2339  {mat4f& mtx = m_data_matrix.mtx.value();
2340  mtx.set_identity();
2341  if(m_shape==xy) {
2342  mtx.mul_scale(wData,hData,1); //z size decided with xy_depth
2343  } else if(m_shape==xyz) {
2344  mtx.mul_scale(wData,hData,dData);
2345  }}
2346 
2347  }
2348 
2349 public:
2350  void update_sg(std::ostream& a_out) {
2351 
2352  update_shape();
2353  update_axes_data(a_out);
2354 
2356  update_layout();
2357 
2358  // roundtrip over plottables to check if they are valids. Done first.
2359  unsigned int nplottables = 0;
2360  unsigned int nbins = 0;
2361  unsigned int npoints = 0;
2362  unsigned int nfunc = 0;
2364  plottable* object = *it;
2365  if(!object) continue;
2366  if(!object->is_valid()) {
2367  *it = 0;
2368  delete object;
2369  } else {
2370  if(safe_cast<plottable,bins1D>(*object)) {
2371  nplottables++;
2372  nbins++;
2373  } else if(safe_cast<plottable,bins2D>(*object)) {
2374  nplottables++;
2375  nbins++;
2376 
2377  } else if(safe_cast<plottable,points2D>(*object)) {
2378  nplottables++;
2379  npoints++;
2380  } else if(safe_cast<plottable,points3D>(*object)) {
2381  nplottables++;
2382  npoints++;
2383 
2384  } else if(safe_cast<plottable,func1D>(*object)) {
2385  nplottables++;
2386  nfunc++;
2387  } else if(safe_cast<plottable,func2D>(*object)) {
2388  nplottables++;
2389  nfunc++;
2390  }
2391  }
2392  }}
2393 
2394  clear_cmaps();
2395  m_bins_cmaps.resize(nbins,0);
2396  m_points_cmaps.resize(npoints,0);
2397  m_func_cmaps.resize(nfunc,0);
2398 
2399  // even if !nplottables we continue.
2400 
2402  m_infos_sep.clear();
2403  m_legend_strings.clear();
2404 
2405  bool superpose = false;
2406  /*uuuu
2407  bool superpose = superposeBins;
2408  if(superpose) {
2409  // Check compatibility of bins :
2410  if( (nbins1D<=0) || (m_shape!=XY) ) {
2411  superpose = false;
2412  } else {
2413  SbPlottableBins1D* bins = f_bins1DList[0];
2414  int xnbin = bins->getAxisNumberOfBins();
2415  float xmn = bins->get_axis_min();
2416  float xmx = bins->get_axis_max();
2417  superpose = true;
2418  for(int ibins=1;ibins<nbins1D;ibins++) {
2419  SbPlottableBins1D* binsloop = f_bins1DList[ibins];
2420  if( (xnbin!=binsloop->getAxisNumberOfBins()) ||
2421  (xmn!=binsloop->get_axis_min()) ||
2422  (xmx!=binsloop->get_axis_max()) ) {
2423  superpose = false;
2424  break;
2425  }
2426  }
2427  if(superpose) { //Compatible bins :
2428  if(y_axis_automated) {
2429  // Correct Y axis if XY shape and superposing bins.
2430  // Get min/max
2431  float bmin,bmax;
2432  getHeight(nbins1D-1,f_bins1DList,bins1DListSwMnMx,0,bmin,bmax);
2433  bmin = bmax;
2434  for(int ibin=1;ibin<xnbin;ibin++) {
2435  float mini,maxi;
2436  getHeight
2437  (nbins1D-1,f_bins1DList,bins1DListSwMnMx,ibin,mini,maxi);
2438  bmin = SbMinimum(bmin,maxi);
2439  bmax = SbMaximum(bmax,maxi);
2440  }
2441  f_yDataAxis.setMinimumValue(bmin);
2442  f_yDataAxis.setMaximumValue(bmax);
2443  f_yDataAxis.adjustAxis();
2444  }
2445  }
2446  }
2447  }*/
2448 
2449  float xmin = m_x_axis_data.min_value();
2450  float xmax = m_x_axis_data.max_value();
2451  bool xlog = m_x_axis_data.is_log();
2452  if(xlog) {
2453  if((xmin<=0) || (xmax<=0) ) {
2455  xmin = m_x_axis_data.min_value();
2456  xmax = m_x_axis_data.max_value();
2457  // now should have reasonable values.
2458  }
2459  if((xmin<=0) || (xmax<=0) ) {
2460  xlog = false;
2461  } else {
2462  xmin = flog10(xmin);
2463  xmax = flog10(xmax);
2464  }
2465  }
2466 
2467  float ymin = m_y_axis_data.min_value();
2468  float ymax = m_y_axis_data.max_value();
2469  bool ylog = m_y_axis_data.is_log();
2470  if(ylog) {
2471  if((ymin<=0) || (ymax<=0) ) {
2473  ymin = m_y_axis_data.min_value();
2474  ymax = m_y_axis_data.max_value();
2475  // now should have reasonable values.
2476  }
2477  if((ymin<=0) || (ymax<=0) ) {
2478  ylog = false;
2479  }else{
2480  ymin = flog10(ymin);
2481  ymax = flog10(ymax);
2482  }
2483  }
2484 
2485  float zmin = m_z_axis_data.min_value();
2486  float zmax = m_z_axis_data.max_value();
2487  bool zlog = m_z_axis_data.is_log();
2488  if(zlog) {
2489  if((zmin<=0) || (zmax<=0) ) {
2491  zmin = m_z_axis_data.min_value();
2492  zmax = m_z_axis_data.max_value();
2493  // now should have reasonable values.
2494  }
2495  if((zmin<=0) || (zmax<=0) ) {
2496  zlog = false;
2497  }else{
2498  zmin = flog10(zmin);
2499  zmax = flog10(zmax);
2500  }
2501  }
2502 
2503  if(m_shape==xy) {
2504  if(xmin>=xmax) {
2505  DUMP_UPDATE_WHAT(a_out,"bad min/max x axes");
2506  }
2507  if(ymin>=ymax) {
2508  DUMP_UPDATE_WHAT(a_out,"bad min/max y axes");
2509  }
2510  } else if(m_shape==xyz) {
2511  if(xmin>=xmax) {
2512  DUMP_UPDATE_WHAT(a_out,"bad min/max x axes");
2513  }
2514  if(ymin>=ymax) {
2515  DUMP_UPDATE_WHAT(a_out,"bad min/max y axes");
2516  }
2517  if(zmin>=zmax) {
2518  DUMP_UPDATE_WHAT(a_out,"bad min/max z axes");
2519  }
2520  }
2521 
2522  {float XSIZ = width;
2523  float XMGL = left_margin;
2524  float XMGR = right_margin;
2525  float wData = XSIZ-XMGL-XMGR;
2526 
2527  float YSIZ = height;
2528  float YMGL = bottom_margin;
2529  float YMGU = top_margin;
2530  float hData = YSIZ-YMGL-YMGU;
2531  if(m_shape==xy) {
2532  if(wData<=0) {
2533  DUMP_UPDATE_WHAT(a_out,"null w data area");
2534  }
2535  if(hData<=0) {
2536  DUMP_UPDATE_WHAT(a_out,"null h data area");
2537  }
2538  } else if(m_shape==xyz) {
2539  float ZSIZ = depth;
2540  float ZMGD = down_margin;
2541  float ZMGU = up_margin;
2542  float dData = ZSIZ-ZMGD-ZMGU;
2543  if(wData<=0) {
2544  DUMP_UPDATE_WHAT(a_out,"null w data area");
2545  }
2546  if(hData<=0) {
2547  DUMP_UPDATE_WHAT(a_out,"null h data area");
2548  }
2549  if(dData<=0) {
2550  DUMP_UPDATE_WHAT(a_out,"null d data area");
2551  }
2552  }}
2553 
2554  float dx = xmax - xmin;
2555  float dy = ymax - ymin;
2556  float dz = zmax - zmin;
2557 
2558  rep_box boxX(xmin,dx,xlog);
2559  rep_box boxY(ymin,dy,ylog);
2560  rep_box boxZ(zmin,dz,zlog);
2561 
2565  if(m_shape==xy) {
2566  //a_out << "tools::sg::plotter::update_sg : shape xy :" << std::endl;
2567 
2568  // first data plane is at zz = _zoffset().
2569 
2570  float zz = 0;
2571 
2575 
2576  //if(verbose) {
2577  // SoDebugError::postInfo("inlib::sg;:plotter::updateChildren",
2578  // "%lu : XY : update bins",(unsigned long)this);
2579  //}
2580 
2581  {m_bins_sep.clear();
2582  m_errors_sep.clear();
2583 
2584  unsigned int ibins = 0; //used to get each bins style and colormap.
2585  //unsigned int ibins1D = 0;
2586  //unsigned int ibins2D = 0;
2588  plottable* object = *it;
2589  if(!object) continue;
2590  if(bins1D* b1 = safe_cast<plottable,bins1D>(*object)) {
2591 
2592  zz += _zoffset(); // ibins = 0 back (PAW convention).
2593  style* data_style = merge_bins_style(ibins,*object);
2594  style* _left_hatch_style = merge_left_hatch_style(ibins,*object);
2595  style* _right_hatch_style = merge_right_hatch_style(ibins,*object);
2596  style* error_style = merge_errors_style(ibins,*object);
2597 
2598  update_bins1D_xy(a_out,*b1,
2599  *data_style,*_left_hatch_style,*_right_hatch_style,*error_style,ibins,
2600  superpose,boxX,boxY,zz);
2601 
2602  if(legends_automated.value()) {
2603  m_legend_strings.push_back(object->legend());
2604  style& _style = legend_style(m_legend_strings.size()-1);
2605  _style.color = data_style->color;
2606  _style.marker_style = data_style->marker_style;
2607  _style.marker_size = data_style->marker_size;
2608  }
2609 
2610  delete data_style;
2611  delete _left_hatch_style;
2612  delete _right_hatch_style;
2613  delete error_style;
2614  ibins++;
2615  //ibins1D++;
2616  } if(bins2D* b2 = safe_cast<plottable,bins2D>(*object)) {
2617  //a_out << "tools::sg::plotter::update_sg : bins2D." << std::endl;
2618  zz += _zoffset(); // ibins = 0 back (PAW convention).
2619  style* data_style = merge_bins_style(ibins,*object);
2620 
2621  update_bins2D_xy(a_out,*b2,*data_style,ibins,boxX,boxY,boxZ,zz);
2622 
2623  if(legends_automated.value()) {
2624  m_legend_strings.push_back(object->legend());
2625  style& _style = legend_style(m_legend_strings.size()-1);
2626  _style.color = data_style->color;
2627  _style.marker_style = data_style->marker_style;
2628  _style.marker_size = data_style->marker_size;
2629  }
2630 
2631  delete data_style;
2632  ibins++;
2633  }
2634  }}
2635 
2639 
2640  {m_func_sep.clear();
2641  //zz = 0; // Functions in front.
2642  unsigned int ifunc = 0; //used to get each func style and colormap.
2644  plottable* object = *it;
2645  if(!object) continue;
2646  if(func1D* f1 = safe_cast<plottable,func1D>(*object)) {
2647  zz += _zoffset();
2648  style* data_style = merge_func_style(ifunc,*object);
2649  update_func1D_xy(a_out,*f1,*data_style,boxX,boxY,zz);
2650  if(legends_automated.value()) {
2651  m_legend_strings.push_back(object->legend());
2652  style& _style = legend_style(m_legend_strings.size()-1);
2653  _style.color = data_style->color;
2654  _style.marker_style = data_style->marker_style;
2655  _style.marker_size = data_style->marker_size;
2656  }
2657  delete data_style;
2658  ifunc++;
2659  } else if(func2D* f2 = safe_cast<plottable,func2D>(*object)) {
2660  zz += _zoffset();
2661  style* data_style = merge_func_style(ifunc,*object);
2662  update_func2D_xy(a_out,*f2,ifunc,*data_style,boxX,boxY,boxZ,zz);
2663  if(legends_automated.value()) {
2664  m_legend_strings.push_back(object->legend());
2665  style& _style = legend_style(m_legend_strings.size()-1);
2666  _style.color = data_style->color;
2667  _style.marker_style = data_style->marker_style;
2668  _style.marker_size = data_style->marker_size;
2669  }
2670  delete data_style;
2671  ifunc++;
2672  }
2673  }}
2674 
2678  {m_points_sep.clear();
2679  unsigned int ipoints = 0; //used to get each points style and colormap.
2681  plottable* object = *it;
2682  if(!object) continue;
2683  if(points2D* p2 = safe_cast<plottable,points2D>(*object)) {
2684 
2685  zz += _zoffset(); // ibins = 0 back (PAW convention).
2686  style* data_style = merge_points_style(ipoints,*object);
2687  update_points2D_xy(a_out,*p2,*data_style,boxX,boxY,zz);
2688 
2689  if(legends_automated.value()) {
2690  m_legend_strings.push_back(object->legend());
2691  style& _style = legend_style(m_legend_strings.size()-1);
2692  _style.color = data_style->color;
2693  _style.modeling = data_style->modeling;
2694  _style.marker_style = data_style->marker_style;
2695  _style.marker_size = data_style->marker_size;
2696  _style.point_size = data_style->point_size;
2697  }
2698 
2699  delete data_style;
2700  ipoints++;
2701  }
2702  }}
2703  }
2704 
2705  if(m_shape==xyz) {
2706 
2710  {m_bins_sep.clear();
2711  m_errors_sep.clear();
2712  unsigned int ibins = 0; //used to get each bins style and colormap.
2714  plottable* object = *it;
2715  if(!object) continue;
2716  if(safe_cast<plottable,bins1D>(*object)) {
2717  ibins++;
2718  } else if(bins2D* b2 = safe_cast<plottable,bins2D>(*object)) {
2719  style* data_style = merge_bins_style(ibins,*object);
2720  update_bins2D_xyz(a_out,*b2,ibins,*data_style,boxX,boxY,boxZ);
2721  delete data_style;
2722  ibins++;
2723  }
2724  }}
2725 
2729 
2730  {m_func_sep.clear();
2731  unsigned int ifunc = 0; //used to get each func style and colormap.
2733  plottable* object = *it;
2734  if(!object) continue;
2735  if(safe_cast<plottable,func1D>(*object)) {
2736  ifunc++;
2737  } else if(func2D* f2 = safe_cast<plottable,func2D>(*object)) {
2738  style* data_style = merge_func_style(ifunc,*object);
2739  update_func2D_xyz(a_out,*f2,ifunc,*data_style,boxX,boxY,boxZ);
2740  delete data_style;
2741  ifunc++;
2742  }
2743  }}
2744 
2748  {m_points_sep.clear();
2749  unsigned int ipoints = 0; //used to get each points style and colormap.
2751  plottable* object = *it;
2752  if(!object) continue;
2753  if(points3D* p3 = safe_cast<plottable,points3D>(*object)) {
2754 
2755  style* data_style = merge_points_style(ipoints,*object);
2756  update_points3D_xyz(a_out,*p3,*data_style,boxX,boxY,boxZ);
2757 
2758  if(legends_automated.value()) {
2759  m_legend_strings.push_back(object->legend());
2760  style& _style = legend_style(m_legend_strings.size()-1);
2761  _style.color = data_style->color;
2762  _style.modeling = data_style->modeling;
2763  _style.marker_style = data_style->marker_style;
2764  _style.marker_size = data_style->marker_size;
2765  _style.point_size = data_style->point_size;
2766  }
2767 
2768  delete data_style;
2769  ipoints++;
2770  }
2771  }}
2772  }
2773 
2777  // done before update_legends() which needs
2778  // the x_axis min/max if legends_origin_unit
2779  // is unit_axis.
2780 
2781  // axes :
2782  if(m_shape==xy){
2783  if(x_axis_enforced.value()) {
2784  update_x_axis_2D();
2788  m_x_axis.update_sg(a_out); // So that the grid be correct.
2790  } else {
2791  if(!nplottables) {
2792  m_x_axis.width = 0;
2793  } else {
2794  update_x_axis_2D();
2796  }
2797  }
2798 
2799  if(y_axis_enforced.value()) {
2800  update_y_axis_2D();
2804  m_y_axis.update_sg(a_out); // So that the grid be correct.
2806  } else {
2807  if(!nplottables) {
2808  m_y_axis.width = 0;
2809  } else {
2810  update_y_axis_2D();
2812  }
2813  }
2814 
2815  if(z_axis_enforced.value()) {
2816  update_z_axis_2D();
2820  m_z_axis.update_sg(a_out); // So that the grid be correct.
2822  } else {
2823  if(!nplottables) {
2824  m_z_axis.width = 0;
2825  } else {
2826  update_z_axis_2D();
2827  }
2828  }
2829  }
2830 
2831  if(m_shape==xyz){
2832  if(x_axis_enforced.value()) {
2833  update_x_axis_3D();
2837  m_x_axis.update_sg(a_out); // So that the grid be correct.
2839  } else {
2840  if(!nplottables) {
2841  m_x_axis.width = 0;
2842  } else {
2843  update_x_axis_3D();
2845  }
2846  }
2847 
2848  if(y_axis_enforced.value()) {
2849  update_y_axis_3D();
2853  m_y_axis.update_sg(a_out); // So that the grid be correct.
2855  } else {
2856  if(!nplottables) {
2857  m_y_axis.width = 0;
2858  } else {
2859  update_y_axis_3D();
2861  }
2862  }
2863 
2864  if(z_axis_enforced.value()) {
2865  update_z_axis_3D();
2869  m_z_axis.update_sg(a_out); // So that the grid be correct.
2871  } else {
2872  if(!nplottables) {
2873  m_z_axis.width = 0;
2874  } else {
2875  update_z_axis_3D();
2877  }
2878  }
2879  }
2880 
2881  if(nplottables) {
2882  // infos box is done before update_legends()
2883  // because legends may be placed relative to it.
2884  update_infos(a_out);
2885  }
2886  m_legend_sep.clear();
2887 
2888  if(!legends_automated) {
2890  }
2891  update_legends(a_out);
2892 
2893  if(title_automated) {
2894  std::string _s;
2895  get_title(_s);
2896  title.value(_s);
2897  title.reset_touched(); //output field.
2898  }
2899  m_title_sep.clear();
2900  if(nplottables) update_title();
2901 
2903  if(nplottables) update_title_box();
2904 
2906  if(inner_frame_enforced.value() || nplottables) {
2907  if(m_shape==xy) {
2909  } else {
2911  }
2912  }
2913 
2914  m_grid_sep.clear();
2915  if(nplottables) {
2916  if(m_shape==xy) {
2917  update_grid_XY();
2918  } else {
2919  update_grid_XYZ();
2920  }
2921  }
2922 
2923  m_cmap_axis.width = 0;
2925  if(m_bins_cmaps.size() && m_bins_cmaps[0] && m_bins_cmaps[0]->valn()) { //major_bins
2926  update_cmap(a_out,*(m_bins_cmaps[0]));
2927  } else if(m_points_cmaps.size() && m_points_cmaps[0] && m_points_cmaps[0]->valn()) { //major_points
2928  update_cmap(a_out,*(m_points_cmaps[0]));
2929  } else if(m_func_cmaps.size() && m_func_cmaps[0] && m_func_cmaps[0]->valn()) { //major_func
2930  update_cmap(a_out,*(m_func_cmaps[0]));
2931  }
2932 
2933  update_primitives(a_out);
2934  }
2935 
2936  void get_value_axis_min_max(float a_Sw_mn,float a_Sw_mx,bool a_is_log,float& a_min,float& a_max,bool a_min_visible) {
2937  if(a_Sw_mn>a_Sw_mx) {
2938  a_min = 0;
2939  a_max = 0;
2940  return;
2941  }
2942  // a_Sw_mx >= a_Sw_mn.
2943  if(a_is_log && (a_Sw_mn<=0) ) { //let data_axis.adjust() do something.
2944  a_min = a_Sw_mn;
2945  a_max = a_Sw_mx;
2946  return;
2947  }
2948  float mn;
2949  if(a_is_log) {
2950  if(value_bottom_margin.value()!=0) {
2951  float log_Sw_mn = flog10(a_Sw_mn);
2952  float log_Sw_mx = flog10(a_Sw_mx);
2953  float log_mn = log_Sw_mn - (log_Sw_mx-log_Sw_mn)*value_bottom_margin;
2954  mn = fpow(10,log_mn);
2955  } else {
2956  mn = a_Sw_mn;
2957  if(a_min_visible) { // arrang so that the bin with a_Sw_mn be visible.
2958  float log_Sw_mn = flog10(a_Sw_mn);
2959  mn = fpow(10,log_Sw_mn)*(1.0f-0.4f);
2960  }
2961  }
2962  } else {
2963  if(value_bottom_margin.value()!=0) {
2964  mn = a_Sw_mn - (a_Sw_mx-a_Sw_mn)*value_bottom_margin;
2965  } else {
2966  if(a_min_visible) {
2967  // Arrange so that the bin with a_Sw_mn (if not 0) be visible. (If 0, it will be anyway on the x axis) :
2968  if(a_Sw_mn>0) {
2969  mn = 0; //PAW logic.
2970  } else if(a_Sw_mn==0) {
2971  mn = 0; //PAW logic. min bin will be anyway on x axis.
2972  } else {
2973  mn = a_Sw_mn; // min bin will be anyway on x axis.
2974  }
2975  } else {
2976  mn = a_Sw_mn; //min bin will be on x axis.
2977  }
2978  }
2979  }
2980  a_min = mn;
2981 
2982  float mx;
2983  if(a_is_log) {
2984  if(value_top_margin.value()!=0) {
2985  float log_Sw_mn = flog10(a_Sw_mn);
2986  float log_Sw_mx = flog10(a_Sw_mx);
2987  float log_mx = log_Sw_mx + (log_Sw_mx-log_Sw_mn)*value_top_margin;
2988  mx = fpow(10,log_mx);
2989  } else {
2990  mx = a_Sw_mx; //max bin will be on top of frame (then not visible if same color).
2991  }
2992  } else {
2993  mx = a_Sw_mx + (a_Sw_mx-mn)*value_top_margin;
2994  //mx = a_Sw_mx + (a_Sw_mx-a_Sw_mn)*value_top_margin; //not compatible with gopaw.
2995  }
2996  a_max = mx;
2997  }
2998 
2999  void update_axes_data(std::ostream& a_out){
3003 
3007 
3011 
3012  if(!x_axis_automated) { //def = true
3015  }
3016 
3017  if(!y_axis_automated) {
3020  }
3021 
3022  if(!z_axis_automated) {
3025  }
3026 
3027  bins1D* b1;
3028  bins2D* b2;
3029 
3030  func1D* f1;
3031  func2D* f2;
3032 
3033  points2D* p2;
3034  points3D* p3;
3035 
3036  if(first_bins(b1,b2)) {
3037 
3038  if(b1) {
3039 
3040  if(x_axis_automated) {
3043  }
3044 
3045  if(y_axis_automated) {
3046  //::printf("debug : value %g %g %d : is log %d\n",
3047  // value_bottom_margin.value(),value_top_margin.value(),value_bins_with_entries.value(),
3048  // m_y_axis_data.is_log());
3049  float Sw_mn,Sw_mx;
3050  b1->bins_Sw_range(Sw_mn,Sw_mx,value_bins_with_entries.value());
3051  //::printf("debug : Sw %g %g\n",Sw_mn,Sw_mx);
3052  float mn,mx;
3053  get_value_axis_min_max(Sw_mn,Sw_mx,m_y_axis_data.is_log(),mn,mx,true);
3054  //::printf("debug : mn mx %g %g\n",mn,mx);
3057 
3059  //::printf("debug : adjusted : mn mx %g %g\n",mn,mx);
3060  }
3061 
3062  } if(b2) {
3063  if(x_axis_automated) {
3066  }
3067 
3068  if(y_axis_automated) {
3071  }
3072 
3073  if(z_axis_automated) {
3074  float Sw_mn,Sw_mx;
3075  b2->bins_Sw_range(Sw_mn,Sw_mx,value_bins_with_entries.value());
3076  float mn,mx;
3077  get_value_axis_min_max(Sw_mn,Sw_mx,m_z_axis_data.is_log(),mn,mx,false);
3080 
3082  }
3083  } /*else if(f_binsList[0]->getDimension()==3) {
3084  //FIXME : should do something.
3085  } else {
3086  // Unusual case.
3087  }*/
3088 
3089  } else if(first_points(p2,p3)) {
3090  if(p2) {
3091  if(x_axis_automated) {
3094  }
3095  if(y_axis_automated) {
3096  float ymn = p2->y_axis_min();
3097  float ymx = p2->y_axis_max();
3098  // For pawex22 ?
3099  //m_y_axis_data.set_min_value(ymn*1.1F);
3100  //m_y_axis_data.set_max_value(ymx*1.1F);
3103  }
3104  } else if(p3) {
3105 
3106  if(x_axis_automated) {
3109  }
3110 
3111  if(y_axis_automated) {
3114  }
3115 
3116  if(z_axis_automated) {
3119  }
3120  }
3121 
3122  } else if(first_func(f1,f2)) {
3123 
3124  if(f1) {
3125 
3126  if(x_axis_automated) {
3127  float xmn = f1->x_min();
3128  float xmx = f1->x_max();
3129  if(xmx<=xmn) {
3130  xmn = -1;
3131  xmx = 1;
3132  }
3135  }
3136 
3137  if(y_axis_automated) {
3138  float xmn = m_x_axis_data.min_value();
3139  float xmx = m_x_axis_data.max_value();
3140  unsigned int nstp = f1->x_steps();
3141  nstp = nstp <=0 ? curve_number_of_points.value(): nstp;
3142 
3143  float df = (xmx - xmn)/nstp;
3144  bool problem = false;
3145  float vmin;
3146  if(!f1->value(xmn,vmin)) problem = true;
3147  float vmax = vmin;
3148  for(unsigned int ibin=0;ibin<=nstp;ibin++) {
3149  float xx = xmn + ibin * df;
3150  float val;
3151  if(!f1->value(xx,val)) problem = true;
3152  vmax = mx<float>(vmax,val);
3153  vmin = mn<float>(vmin,val);
3154  }
3155  if(problem) {
3156  a_out << "tools::sg::plotter :"
3157  << " problem when getting some function value."
3158  << std::endl;
3159  }
3163  }
3164 
3165  } else if(f2) {
3166  if(x_axis_automated) {
3167  float xmn = f2->x_min();
3168  float xmx = f2->x_max();
3169  if(xmx<=xmn) {
3170  xmn = -1;
3171  xmx = 1;
3172  }
3175  }
3176 
3177  if(y_axis_automated) {
3178  float ymn = f2->y_min();
3179  float ymx = f2->y_max();
3180  if(ymx<=ymn) {
3181  ymn = -1;
3182  ymx = 1;
3183  }
3186  }
3187 
3188  if(z_axis_automated) {
3189 
3190  float xmn = m_x_axis_data.min_value();
3191  float xmx = m_x_axis_data.max_value();
3192  int nx = f2->x_steps();
3193  nx = nx <=0 ? curve_number_of_points.value() : nx;
3194 
3195  float ymn = m_y_axis_data.min_value();
3196  float ymx = m_y_axis_data.max_value();
3197  int ny = f2->y_steps();
3198  ny = ny <=0 ? curve_number_of_points.value() : ny;
3199 
3200  float dfx = (xmx - xmn)/nx;
3201  float dfy = (ymx - ymn)/ny;
3202 
3203  bool problem = false;
3204  float vmin;
3205  if(!f2->value(xmn,ymn,vmin)) problem = true;
3206  float vmax = vmin;
3207  for(int jbin=ny-1;jbin>=0;jbin--) {
3208  for(int ibin=nx-1;ibin>=0;ibin--) {
3209  float xx = xmn + ibin * dfx;
3210  float yy = ymn + jbin * dfy;
3211  float val;
3212  if(!f2->value(xx,yy,val)) problem = true;
3213  vmin = mn<float>(vmin,val);
3214  vmax = mx<float>(vmax,val);
3215  }
3216  }
3217  if(problem) {
3218  a_out << "tools::sg::plotter :"
3219  << " problem when getting some function value."
3220  << std::endl;
3221  }
3225  }
3226  }
3227  }
3228  }
3230  m_shape = get_shape();
3231  //uuuu if(shapeAutomated) {
3232  // shape.setValue(m_shape);
3233  //}
3234  }
3235 
3236  void update_axis(std::ostream& a_out,sg::axis& a_axis,data_axis& a_data){
3237  a_axis.minimum_value = a_data.min_value();
3238  a_axis.maximum_value = a_data.max_value();
3239  a_axis.is_log = a_data.is_log();
3240  a_axis.update_sg(a_out); // So that the grid be correct.
3241  a_axis.reset_touched();
3242  }
3243 
3245  float XSIZ = width;
3246  float XMGL = left_margin;
3247  float XMGR = right_margin;
3248  float wData = XSIZ-XMGL-XMGR;
3249 
3250  //m_x_axis.verbose.setValue(verbose);
3251  m_x_axis.tick_up = true;
3252  m_x_axis.width = wData;
3253 
3255  if(!style.enforced.value()) { //gopaw may enforce style.
3256  style.x_orientation = vec3f(1,0,0);
3257  style.y_orientation = vec3f(0,1,0);
3258  style.hjust = center;
3259  style.vjust = top;
3260  }}
3261 
3263  style.x_orientation = vec3f(1,0,0);
3264  style.y_orientation = vec3f(0,1,0);
3265  style.hjust = m_x_axis.title_hjust;
3266  style.vjust = top;}
3267 
3269  style.hjust = left;
3270  style.vjust = bottom;}
3271 
3273  }
3274 
3276  float YSIZ = height;
3277  float YMGL = bottom_margin;
3278  float YMGU = top_margin;
3279  float hData = YSIZ-YMGL-YMGU;
3280 
3281  //m_x_axis.verbose.setValue(verbose);
3282  m_y_axis.tick_up.value(true);
3283  m_y_axis.width.value(hData);
3284 
3286  if(!style.enforced.value()) {
3287  style.x_orientation = vec3f(0,1,0);
3288  style.y_orientation = vec3f(1,0,0);
3289  style.hjust = right;
3290  style.vjust = middle;
3291  }}
3292 
3294  style.x_orientation = vec3f(1,0,0);
3295  style.y_orientation = vec3f(0,-1,0);
3296  style.hjust = m_y_axis.title_hjust;
3297  style.vjust = bottom;}
3298 
3300  style.x_orientation = vec3f(0,1,0);
3301  style.y_orientation = vec3f(1,0,0);
3302  style.hjust = right;
3303  style.vjust = bottom;}
3304 
3305  {mat4f& mtx = m_y_axis_matrix.mtx.value();
3306  mtx.set_translate(0,0,_zaxis());
3307  mtx.mul_rotate(0,1,0,fpi());
3308  mtx.mul_rotate(0,0,1,fhalf_pi());}
3309  }
3310 
3312  m_z_axis.width = 0;
3314  }
3315 
3317  float XSIZ = width;
3318  float XMGL = left_margin;
3319  float XMGR = right_margin;
3320  float wData = XSIZ-XMGL-XMGR;
3321 
3322  //m_x_axis.verbose.setValue(verbose);
3323  m_x_axis.tick_up = false;
3324  m_x_axis.width = wData;
3325 
3327  if(!style.enforced.value()) {
3328  //style->font_name = SbFont_Hershey; //Enforce Hershey.
3329  style.x_orientation = vec3f(1,0,0);
3330  style.y_orientation = vec3f(0,1,0);
3331  style.hjust = center;
3332  style.vjust = top;
3333  }}
3334 
3336  style.x_orientation = vec3f(1,0,0);
3337  style.y_orientation = vec3f(0,1,0);
3338  style.hjust = right;
3339  style.vjust = top;}
3340 
3341  //{text_style& style = m_x_axis.mag_style();
3342  // style.hjust = left;
3343  // style.vjust = bottom;}
3344 
3346 
3347  }
3348 
3350  float YSIZ = height;
3351  float YMGL = bottom_margin;
3352  float YMGU = top_margin;
3353  float hData = YSIZ-YMGL-YMGU;
3354 
3355  //m_x_axis.verbose.setValue(verbose);
3356  m_y_axis.tick_up = false;
3357  m_y_axis.width = hData;
3358 
3360  if(!style.enforced.value()) {
3361  //style->fontName.setValue(SbFont_Hershey); //Enforce Hershey.
3362  style.x_orientation = vec3f(-1,0,0);
3363  style.y_orientation = vec3f( 0,1,0);
3364  style.hjust = center;
3365  style.vjust = top;
3366  }}
3367 
3369  style.x_orientation = vec3f(-1,0,0);
3370  style.y_orientation = vec3f( 0,1,0);
3371  style.hjust = left;
3372  style.vjust = top;}
3373 
3374  //{text_style& style = m_y_axis.mag_style();
3375  // style.x_orientation = vec3f(0,1,0);
3376  // style.y_orientation = vec3f(1,0,0);
3377  // style.hjust = right;
3378  // style.vjust = bottom;}
3379 
3380  {mat4f& mtx = m_y_axis_matrix.mtx.value();
3381  mtx.set_rotate(0,1,0,fhalf_pi());
3382  mtx.mul_rotate(0,0,1,fhalf_pi());}
3383  }
3384 
3386  float ZSIZ = depth;
3387  float ZMGD = down_margin;
3388  float ZMGU = up_margin;
3389  float dData = ZSIZ-ZMGD-ZMGU;
3390 
3391  m_z_axis.tick_up = false;
3392  m_z_axis.width = dData;
3393 
3395  if(!style.enforced.value()) {
3396  //style->fontName.setValue(SbFont_Hershey); //Enforce Hershey.
3397  style.x_orientation = vec3f(0,1,0);
3398  style.y_orientation = vec3f(1,0,0);
3399  style.hjust = right;
3400  style.vjust = middle;
3401  }}
3402 
3404  style.x_orientation = vec3f(0,1,0);
3405  style.y_orientation = vec3f(1,0,0);
3406  style.hjust = right;
3407  style.vjust = bottom;}
3408 
3409  //{text_style& style = m_z_axis.mag_style();
3410  // style.hjust = center;
3411  // style.vjust = bottom;}
3412 
3413  {mat4f& mtx = m_z_axis_matrix.mtx.value();
3414  mtx.set_translate(0,m_y_axis.width.value(),0);
3415  mtx.mul_rotate(0,0,1,-fhalf_pi());
3416  mtx.mul_rotate(0,1,0,-fhalf_pi());}
3417 
3418  }
3419 
3420  void update_cmap(std::ostream& a_out,const base_colormap& a_cmap){
3421  if(!colormap_visible.value()) return;
3422 
3423  size_t valn = a_cmap.valn();
3424  if(!valn) return;
3425  size_t coln = a_cmap.colorn();
3426  if(!coln) return;
3427 
3428  float XSIZ = width;
3429  float XMGL = left_margin;
3430  float XMGR = right_margin;
3431  float wData = XSIZ-XMGL-XMGR;
3432 
3433  float YSIZ = height;
3434  float YMGL = bottom_margin;
3435  float YMGU = top_margin;
3436  float hData = YSIZ-YMGL-YMGU;
3437 
3438  float hcmap = hData;
3439 
3440  {mat4f& mtx = m_cmap_matrix.mtx.value();
3441  if(m_shape==xy) {
3442  mtx = m_layout.mtx.value();
3443  mtx.mul_translate(0,0,_zgrid());
3444  } else {
3445  float ZSIZ = depth;
3446  float ZMGD = down_margin;
3447  float ZMGU = up_margin;
3448  float dData = ZSIZ-ZMGD-ZMGU;
3449  hcmap = dData;
3450  if(colormap_attached.value()) {
3451  mtx = m_layout.mtx.value();
3452  mtx.mul_rotate(1,0,0,90.0F*fdeg2rad());
3453  } else { //OpenPAW
3454  float zz = -depth*0.5f;
3455  mtx.set_translate(-XSIZ/2+XMGL,-YSIZ/2+YMGL,zz); //applied first
3456  }
3457  }}
3458 
3459  float w = XMGR*0.3F;
3460  float xx = wData+XMGR*0.1F;
3461  float zz = 0;
3462 
3463  float yy = 0;
3464  float h = hcmap/float(coln);
3465 
3466  // colored cells :
3469  for(unsigned int index=0;index<coln;index++) {
3470  rgba* mat = new rgba();
3471  mat->color = a_cmap.color(index);
3473 
3474  vertices* vtxs = new vertices;
3475  vtxs->mode = gl::triangle_fan();
3476  m_cmap_cells_sep.add(vtxs);
3477 
3478  vtxs->add(xx ,yy ,zz);
3479  vtxs->add(xx + w ,yy ,zz);
3480  vtxs->add(xx + w ,yy + h ,zz);
3481  vtxs->add(xx ,yy + h ,zz);
3482 
3483  yy += h;
3484  }}
3485 
3486  // surrounding box :
3487  {rgba* mat = new rgba();
3488  mat->color = colorf_black();
3490 
3491  draw_style* ds = new draw_style;
3492  ds->style = draw_lines;
3493  ds->line_pattern = line_solid;
3494  ds->line_width = 1;
3495  m_cmap_cells_sep.add(ds);
3496 
3497  vertices* vtxs = new vertices;
3498  vtxs->mode = gl::line_strip();
3499  m_cmap_cells_sep.add(vtxs);
3500 
3501  vtxs->add(xx ,0 ,zz);
3502  vtxs->add(xx + w ,0 ,zz);
3503  vtxs->add(xx + w ,hcmap ,zz);
3504  vtxs->add(xx ,hcmap ,zz);
3505  vtxs->add(xx ,0 ,zz);}
3506 
3507  if(!colormap_axis_visible.value()) {
3508  m_cmap_axis.width = 0;
3509  } else {
3510 
3511  // right axis :
3512  mat4f& mtx = m_cmap_axis_matrix.mtx.value();
3513  mtx.set_identity();
3514 
3515  zz += _zoffset()*0.01f;
3516 
3517  if(safe_cast<base_colormap,by_value_colormap>(a_cmap)) {
3519  if((valn+1)==coln) { // <col> <num> <col> ... <num> <col>
3520  mtx.set_translate(xx+w,h,zz);
3521  } else {
3522  mtx.set_translate(xx+w,0,zz);
3523  }
3524  } else {
3525  mtx.set_translate(xx+w,0,zz);
3526  }
3527  } else { //grey_scale,grey_scale_inverse,violet_to_red
3528  mtx.set_translate(xx+w,0,zz);
3529  }
3530 
3531  mtx.mul_rotate(0,0,1,fhalf_pi());
3532 
3533  m_cmap_axis.title = "";
3534  m_cmap_axis.tick_up = true;
3535  //m_cmap_axis.label_to_axis = 0.01F;
3536  //m_cmap_axis.label_height = 0.10F;
3537  //m_cmap_axis.ttf_scale = 10.0F;
3538 
3539  if(safe_cast<base_colormap,by_value_colormap>(a_cmap)) {
3541  if((valn+1)==coln) { // <col> <num> <col> ... <num> <col>
3542  m_cmap_axis.width = hcmap-2*h;
3544  m_cmap_axis.tick_number = uint32(valn);
3547  for(unsigned int index=0;index<valn;index++) {
3548  //FIXME : for the labels, have a "mag" logic similar to SoAxis.
3549  char tmp[32];
3550  snpf(tmp,sizeof(tmp),"%g",a_cmap.value(index));
3551  m_cmap_axis.labels.add(tmp);
3552  m_cmap_axis.coords.add(h*index);
3553  }
3554  } else if((coln+1)==valn) { // <num> <col> <num> ... <col> <num>
3555  m_cmap_axis.width = hcmap;
3557  m_cmap_axis.tick_number = uint32(valn);
3560  for(unsigned int index=0;index<valn;index++) {
3561  //FIXME : for the labels, have a "mag" logic similar to SoAxis.
3562  char tmp[32];
3563  snpf(tmp,sizeof(tmp),"%g",a_cmap.value(index));
3564  m_cmap_axis.labels.add(tmp);
3565  m_cmap_axis.coords.add(h*index);
3566  }
3567  } else {
3568  a_out << "tools::sg::plotter::update_cmap :"
3569  << " inconsistent by value colormap."
3570  << std::endl;
3571  }
3572  } else {
3574  m_cmap_axis.width = hcmap;
3575  m_cmap_axis.minimum_value = a_cmap.value(0);
3576  m_cmap_axis.maximum_value = a_cmap.value(uint32(valn)-1);
3577  }
3578  } else { //grey_scale,grey_scale_inverse,violet_to_red
3580  m_cmap_axis.width = hcmap;
3581  m_cmap_axis.minimum_value = a_cmap.value(0);
3582  m_cmap_axis.maximum_value = a_cmap.value(uint32(valn)-1);
3583  }
3584 
3586  style.x_orientation = vec3f(0,-1,0);
3587  style.y_orientation = vec3f(1,0,0);
3588  style.hjust = left;
3589  style.vjust = middle;}
3590 
3592  style.hjust = center;
3593  style.vjust = bottom;}
3594 
3595  }//end axis
3596  }
3597 
3598  void update_primitives(std::ostream& a_out) {
3599 // if(primitives_enforced.value()) {
3602  if(plottable_text* ptext = safe_cast<plotprim,plottable_text>(*(*it))) {
3603  update_primitive_text(*ptext);
3604  } else if(plottable_box* pbox = safe_cast<plotprim,plottable_box>(*(*it))) {
3605  update_primitive_box(a_out,*pbox);
3606  } else if(plottable_ellipse* pellipse = safe_cast<plotprim,plottable_ellipse>(*(*it))) {
3607  update_primitive_ellipse(a_out,*pellipse);
3608  } else if(plottable_img* pimg = safe_cast<plotprim,plottable_img>(*(*it))) {
3609  update_primitive_img(a_out,*pimg);
3610  }
3611  }
3612  //}
3613  }
3614 
3615 protected: //vis bins
3616  void update_bins1D_xy(std::ostream& a_out,
3617  const bins1D& a_bins,
3618  const style& a_data_style,
3619  const style& a_left_hatch_style,
3620  const style& a_right_hatch_style,
3621  const style& a_errors_style,
3622  int a_index,
3623  /*SoStyle& aGraphicStyle,
3624  int aIndex1D,
3625  const std::vector<SbPlottableBins1D*>& a_bins1DList,
3626  const SbPList& a_bins1DListSwMnMx,*/
3627  bool /*aSuperpose*/,
3628  const rep_box& a_box_x,
3629  const rep_box& a_box_y,
3630  float a_zz){
3631 
3632  //char sid[128];
3633  //::sprintf(sid,"tools::sg::bins1D/0x%lx",
3634  // (unsigned long)const_cast<bins1D*>(&a_bins));
3635 
3636  //bool hbe = a_bins.has_entries_per_bin();
3637 
3638  float bmin = 0;
3639  float bmax = 0;
3640 
3641  size_t xnbin = a_bins.bins();
3642  std::vector<rep_bin1D> bins(xnbin);
3643  {bool first = true;
3644  for(size_t ibin=0;ibin<xnbin;ibin++) {
3645  //if(hbe && (a_bins.bin_entries(size_t(ibin))<=0)) continue;
3646  float val = a_bins.bin_Sw(int(ibin));
3647  float xx = float(a_bins.bin_lower_edge(int(ibin)));
3648  float xe = float(a_bins.bin_upper_edge(int(ibin)));
3649  bins[ibin] = rep_bin1D(xx,xe,0,val);
3650  if(first) {
3651  first = false;
3652  bmin = val;
3653  bmax = val;
3654  } else {
3655  bmin = mn<float>(bmin,val);
3656  bmax = mx<float>(bmax,val);
3657  }
3658  }}
3659 
3660  //a_bins.bins_Sw_range(bmin,bmax,false);
3661 
3662  //modeling_profile could override errors_visible.
3663  bool errors_visible = a_errors_style.visible;
3664 
3665  if(a_data_style.visible) {
3666 
3667  painting_policy painting = a_data_style.painting;
3668  if(painting==painting_by_value) {
3669  m_bins_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_data_style.color_mapping);
3670  } else if( (painting==painting_grey_scale) ||
3671  (painting==painting_grey_scale_inverse) ||
3672  (painting==painting_violet_to_red) ){
3673  {float dbins = bmax-bmin;
3674  if(dbins!=0.0F) {
3675  for(size_t index=0;index<xnbin;index++) bins[index].m_ratio = (a_bins.bin_Sw(int(index))-bmin)/dbins;
3676  }}
3677  if(painting==painting_grey_scale) {
3678  m_bins_cmaps[a_index] = new grey_scale_colormap(bmin,bmax,50);
3679  } else if(painting==painting_grey_scale_inverse) {
3680  m_bins_cmaps[a_index] = new grey_scale_inverse_colormap(bmin,bmax,50);
3681  } else if(painting==painting_violet_to_red) {
3682  m_bins_cmaps[a_index] = new violet_to_red_colormap(bmin,bmax,50);
3683  }
3684  } else {
3685  m_bins_cmaps[a_index] = new const_colormap(a_data_style.color);
3686  }
3687 
3688  if(a_bins.is_profile()) {
3689  // enforce with a_data_style, a bins rep with :
3690  // rep_bins1D_xy_points
3691  // AND :
3692  // rep_errors_plus for bins rep.
3693  // NOTE : a_data_style.modeling not used for the moment.
3694  //printf("debug : bins is profile : modeling %s\n",a_data_style.modeling.value().c_str());
3695 
3696  style data_style = a_data_style;
3697  data_style.modeling = modeling_markers();
3698  rep_bins1D_xy_points(a_out,data_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz);
3699 
3700  std::vector<float> bars(xnbin);
3701  for(size_t ibin=0;ibin<xnbin;ibin++) bars[ibin] = a_bins.bin_error(int(ibin));
3702 
3703  rep_errors_plus_xy(a_out,a_data_style,bins,a_box_x,a_box_y,bars,a_zz+_zerrors());
3704  errors_visible = false;
3705 
3706  } else {
3707 
3708  const std::string& modeling = a_data_style.modeling;
3709 
3710  //bool one_node = false;
3711  //bool oneNode = false;
3712  //{int nlimit = aGraphicStyle.multiNodeLimit.value();
3713  //if(nlimit!=NoLimit) {
3714  // oneNode = (xnbin>nlimit?true:false);
3715  //}}
3716 
3717  bool _bar_chart = false;
3718 
3719  //char sid_bin[128];
3720  //::sprintf(sid_bin,"SbBin1D/0x%lx",(unsigned long)&a_bins);
3721 
3722  if((modeling==modeling_points())||(modeling==modeling_markers())){
3723  //if(oneNode) {
3724  // rep_bins1D_xy_points_one(binsNode,aGraphicStyle,
3725  // bins,a_box_x,a_box_y,a_zz,std::string(sid));
3726  //} else {
3727  rep_bins1D_xy_points(a_out,a_data_style,
3728  *(m_bins_cmaps[a_index]),
3729  bins,a_box_x,a_box_y,a_zz);
3730  //}
3731  } else if(modeling==modeling_boxes()) {
3732  //if(oneNode) {
3733  // rep_bins1D_xy_boxes_one(binsNode,aGraphicStyle,
3734  // bins,a_box_x,a_box_y,a_zz,std::string(sid));
3735  //} else {
3736  rep_bins1D_xy_boxes(a_data_style,
3737  *(m_bins_cmaps[a_index]),
3738  bins,a_box_x,a_box_y,a_zz //,std::string(sid_bin)
3739  );
3740  //}
3741 
3742  } else if(modeling==modeling_wire_boxes()) {
3743  //if(oneNode) {
3744  // rep_bins1D_xy_wire_boxes_one(binsNode,aGraphicStyle,barChart,
3745  // bins,a_box_x,a_box_y,a_zz,std::string(sid));
3746  //} else {
3747  rep_bins1D_xy_wire_boxes(a_data_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz,false);
3748  //}
3749  } else if(modeling==modeling_bar_chart()) {
3750  _bar_chart = true;
3751  //if(oneNode) {
3752  // rep_bins1D_xy_wire_boxes_one(binsNode,aGraphicStyle,barChart,
3753  // bins,a_box_x,a_box_y,a_zz,std::string(sid));
3754  //} else {
3755  rep_bins1D_xy_wire_boxes(a_data_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz,true);
3756  //}
3757 
3758  } else if(modeling==modeling_lines()){
3759  rep_bins1D_xy_lines_one(a_data_style,bins,a_box_x,a_box_y,a_zz/*,std::string(sid)*/);
3760  } else if(modeling==modeling_curve()){
3761  rep_bins1D_xy_curve_one(a_out,a_data_style,bins,a_box_x,a_box_y,a_zz/*,std::string(sid)*/);
3762 
3763  } else if(modeling==modeling_top_lines_boxes()) { //gopaw. pawex24, k_plus.
3764  style _style;_style.color = colorf_white();
3765  rep_bins1D_xy_boxes(_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz);
3766  rep_bins1D_xy_top_lines(a_data_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz+_zhatch());
3767 
3768  } else { //default modeling==modeling_top_lines()
3769  rep_bins1D_xy_top_lines(a_data_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz/*,std::string(sid_bin)*/);
3770 
3771  }
3772 
3773  hatching_policy hatching = a_data_style.hatching.value();
3774  //::printf("debug : bins1D %d hatching : %d\n",a_index,hatching);
3775  if(hatching!=hatching_none) {
3776  // WARNING : must come AFTER rep_bins1_xy.
3777  if((hatching==hatching_right)||((hatching==hatching_left_and_right))) {
3778  //if(oneNode) {
3779  //repHatch1D_xy_one(binsNode,aRightHatchStyle,barChart,bins,a_box_x,a_box_y,a_zz+_zhatch(),std::string(sid));
3780  //} else {
3781  rep_hatch1D_xy(a_right_hatch_style,bins,a_box_x,a_box_y,a_zz+_zhatch(),_bar_chart);
3782  //}
3783  }
3784  if((hatching==hatching_left)||((hatching==hatching_left_and_right))) {
3785  //if(oneNode) {
3786  //repHatch1D_xy_one(binsNode,aLeftHatchStyle,barChart,bins,a_box_x,a_box_y,a_zz+_zhatch(),std::string(sid));
3787  //} else {
3788  rep_hatch1D_xy(a_left_hatch_style,bins,a_box_x,a_box_y,a_zz+_zhatch(),_bar_chart);
3789  //}
3790  }
3791  }
3792 
3793  } //end !is_profile.
3794  } //end data_style visible
3795 
3796  // Errors :
3797  if(errors_visible) {
3798  std::vector<float> bars(xnbin);
3799  for(size_t ibin=0;ibin<xnbin;ibin++) bars[ibin] = a_bins.bin_error(int(ibin));
3800  const std::string& modeling = a_errors_style.modeling;
3801  if(modeling==modeling_plus()) {
3802  rep_errors_plus_xy(a_out,a_errors_style,bins,a_box_x,a_box_y,bars,a_zz+_zerrors());
3803  } else { //modeling_I()
3804  rep_errors_I_xy(a_out,a_errors_style,bins,a_box_x,a_box_y,bars,a_zz+_zerrors());
3805  }
3806  }
3807 
3808  }
3809 
3810  static bool bins2D_to_func(const bins2D& a_bins,float a_X,float a_Y,float& a_value){
3811  unsigned int xn = a_bins.x_bins();
3812  float xmn = a_bins.x_axis_min();
3813  float xmx = a_bins.x_axis_max();
3814  unsigned int yn = a_bins.y_bins();
3815  float ymn = a_bins.y_axis_min();
3816  float ymx = a_bins.y_axis_max();
3817 
3818  float dx = (xmx-xmn)/xn;
3819  float dy = (ymx-ymn)/yn;
3820  int ibin = (int)((a_X-xmn)/dx);
3821  int jbin = (int)((a_Y-ymn)/dy);
3822 
3823  if((ibin<0)||(ibin>=int(xn))) {a_value=0;return false;}
3824  if((jbin<0)||(jbin>=int(yn))) {a_value=0;return false;}
3825 
3826  float xx_0 = a_bins.bin_lower_edge_x(ibin);
3827  //float xe_0 = a_bins.bin_upper_edge_x(ibin);
3828  float xx_1 = a_bins.bin_lower_edge_x(ibin+1);
3829  //float xe_1 = a_bins.bin_upper_edge_x(ibin+1);
3830 
3831  float yy_0 = a_bins.bin_lower_edge_y(jbin);
3832  //float ye_0 = a_bins.bin_upper_edge_y(jbin);
3833  float yy_1 = a_bins.bin_lower_edge_y(jbin+1);
3834  //float ye_1 = a_bins.bin_upper_edge_y(jbin+1);
3835 
3836  float val1 = a_bins.bin_Sw(ibin,jbin);
3837  float val2 = a_bins.bin_Sw(ibin+1,jbin);
3838  //float val3 = a_bins.getBinSumOfWeights(ibin+1,jbin+1);
3839  float val4 = a_bins.bin_Sw(ibin,jbin+1);
3840 
3841  // Interpolate :
3842  vec3f p1(xx_0,yy_0,val1);
3843  vec3f p2(xx_1,yy_0,val2);
3844  //vec3f p3(xx_1,yy_1,val3);
3845  vec3f p4(xx_0,yy_1,val4);
3846 
3847  //FIXME : case of (x,y) in (p2,p3,p4)
3848 
3849  plane<vec3f> _plane(p1,p2,p4);
3850  vec3f pt;
3851  line<vec3f> _line(vec3f(a_X,a_Y,0),vec3f(a_X,a_Y,10));
3852  _plane.intersect(_line,pt);
3853 
3854  a_value = pt[2];
3855  return true;
3856  }
3857 
3858  typedef struct {
3861  double m_limits[4];
3862  double m_limits_in[4];
3864  } SbFunc;
3865 
3866  static double bins2D_to_contour(double a_X,double a_Y,void* aData) {
3867  SbFunc* func =(SbFunc*)aData;
3868  if( (a_X<func->m_limits_in[0])||
3869  (a_X>func->m_limits_in[1])||
3870  (a_Y<func->m_limits_in[2])||
3871  (a_Y>func->m_limits_in[3])
3872  ) return -FLT_MAX;
3873  float value;
3874  if(!bins2D_to_func(*(func->m_bins2D),(float)a_X,(float)a_Y,value)) func->m_problem = true;
3875  return value;
3876  }
3877 
3878  static double log_bins2D_to_contour(double a_X,double a_Y,void* aData) {
3879  SbFunc* func =(SbFunc*)aData;
3880  if( (a_X<func->m_limits_in[0])||
3881  (a_X>func->m_limits_in[1])||
3882  (a_Y<func->m_limits_in[2])||
3883  (a_Y>func->m_limits_in[3])
3884  ) return -FLT_MAX;
3885  float value;
3886  if(!bins2D_to_func(*(func->m_bins2D),(float)a_X,(float)a_Y,value)) func->m_problem = true;
3887  return take_log(value);
3888  }
3889 
3890  void update_bins2D_xy(std::ostream& a_out,
3891  const bins2D& a_bins,
3892  const style& a_data_style,
3893  int a_index,
3894  const rep_box& a_box_x,
3895  const rep_box& a_box_y,
3896  const rep_box& a_box_z,
3897  float a_zz){
3898 
3899  //a_out << "tools::sg::update_bins2D_xy : begin :" << std::endl;
3900 
3901  if(!a_data_style.visible) return;
3902 
3903  //a_out << "tools::sg::update_bins2D_xy : visible :" << std::endl;
3904 
3905  unsigned int xnbin = a_bins.x_bins();
3906  unsigned int ynbin = a_bins.y_bins();
3907 
3908  const std::string& modeling = a_data_style.modeling;
3909 
3910  if( (modeling==modeling_curve()) || (modeling==modeling_filled_curve()) ){
3911 
3912  a_out << "tools::sg::update_bins2D_xy : modeling_curve :" << std::endl;
3913 
3914  painting_policy painting = a_data_style.painting;
3915 
3916  float zmin = a_box_z.m_pos;
3917  float dz = a_box_z.m_width;
3918  bool zlog = a_box_z.m_log;
3919 
3920  float xmn = m_x_axis_data.min_value();
3921  float xmx = m_x_axis_data.max_value();
3922  float ymn = m_y_axis_data.min_value();
3923  float ymx = m_y_axis_data.max_value();
3924 
3925  clist_contour list_contour;
3926  //int nFir = 32;
3927  int nFir = 128;
3928  list_contour.set_first_grid(nFir,nFir); //Default : 32,32
3929  //int nSec = 256;
3930  int nSec = 512; //slower than 256
3931  list_contour.set_secondary_grid(nSec,nSec); //Default : 256,256.
3932 
3933  double limits[4];
3934  // User limits :
3935  limits[0] = xmn;
3936  limits[1] = xmx;
3937  limits[2] = ymn;
3938  limits[3] = ymx;
3939 
3940  SbFunc sbFunc;
3941  sbFunc.m_func2D = 0;
3942  sbFunc.m_problem = false;
3943  sbFunc.m_bins2D = &a_bins;
3944  sbFunc.m_limits_in[0] = limits[0];
3945  sbFunc.m_limits_in[1] = limits[1];
3946  sbFunc.m_limits_in[2] = limits[2];
3947  sbFunc.m_limits_in[3] = limits[3];
3948 
3949  // Extend the grid to have some borders in order to close contours :
3950  int n = nSec - 2 * 10;
3951  double dx = (limits[1]-limits[0]) /n;
3952  double dy = (limits[3]-limits[2]) /n;
3953  limits[0] = limits[0] - 10 * dx;
3954  limits[1] = limits[1] + 10 * dx;
3955  limits[2] = limits[2] - 10 * dy;
3956  limits[3] = limits[3] + 10 * dy;
3957 
3958  sbFunc.m_limits[0] = limits[0];
3959  sbFunc.m_limits[1] = limits[1];
3960  sbFunc.m_limits[2] = limits[2];
3961  sbFunc.m_limits[3] = limits[3];
3962 
3963  list_contour.set_limits(limits);
3964 
3965  if(levels.size()) {
3966  size_t zn = levels.size();
3967  std::vector<double> zs(zn);
3968  for(size_t zi=0;zi<zn;zi++) zs[zi] = levels[zi];
3969  list_contour.set_planes(zs);
3970  } else {
3971  unsigned int zn = number_of_levels.value();
3972  if(zn<=0) zn = 1;
3973  std::vector<double> zs(zn+1);
3974  float zmax = zmin + dz;
3975  double zd = (zmax-zmin)/zn;
3976  for(unsigned int zi=0;zi<=zn;zi++) zs[zi] = zmin + zi * zd;
3977  list_contour.set_planes(zs);
3978  }
3979 
3980  if(zlog)
3981  list_contour.set_field_fcn(log_bins2D_to_contour,(void*)&sbFunc);
3982  else
3983  list_contour.set_field_fcn(bins2D_to_contour,(void*)&sbFunc);
3984 
3985 #ifdef INLIBS_SG_PLOTTER_TIMING
3986  atime _start = atime::now();
3987 #endif
3988  list_contour.ccontour::generate();
3989 #ifdef INLIBS_SG_PLOTTER_TIMING
3990  a_out << "tools::sg::update_bins2D_xy : contour generate elapsed " << atime::elapsed(_start) << "." << std::endl;
3991  _start = atime::now();
3992 #endif
3993 
3994  if(!list_contour.compact_strips ()) {
3995  a_out << "tools::sg::plotter::updateBins2D_XY : clist_contour::compact_strips () : failure." << std::endl;
3996  } else {
3997 #ifdef INLIBS_SG_PLOTTER_TIMING
3998  a_out << "tools::sg::update_bins2D_xy : contour compact strips elapsed " << atime::elapsed(_start) << "." << std::endl;
3999 #endif
4000  if( (painting==painting_by_level) || (painting==painting_by_value) ){
4001  m_bins_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_data_style.color_mapping);
4002  //bool zlog = a_box_z.m_log;
4003  if(zlog) m_bins_cmaps[a_index]->set_PAW_coloring();
4004  } else {
4005  m_bins_cmaps[a_index] = new const_colormap(a_data_style.color);
4006  }
4007 
4008  if(modeling==modeling_filled_curve()) {
4009  rep_contour_xy_filled(a_out,a_data_style,
4010  painting,*(m_bins_cmaps[a_index]),
4011  list_contour,a_box_x,a_box_y,a_box_z,a_zz /*,std::string(sid.c_str())*/);
4012  } else {
4013  rep_contour_xy(a_out,a_data_style,
4014  painting,*(m_bins_cmaps[a_index]),
4015  list_contour,a_box_x,a_box_y,a_box_z,a_zz /*,std::string(sid.c_str())*/);
4016  }
4017 
4018  }
4019 
4020  if(sbFunc.m_problem) {
4021  a_out << "tools::sg::plotter::updateFunction_XY(SbPlottableFunction2D) : "
4022  << "problem when getting some function value." << std::endl;
4023  }
4024 
4025  } else {
4026 
4027  bool hbe = a_bins.has_entries_per_bin();
4028 
4029  float bmin = 0;
4030  float bmax = 0;
4031 
4032  std::vector<rep_bin2D> bins;
4033  {bool first = true;
4034  for(int jbin=ynbin-1;jbin>=0;jbin--) {
4035  for(int ibin=xnbin-1;ibin>=0;ibin--) {
4036  if(hbe && (a_bins.bin_entries(ibin,jbin)<=0)) continue;
4037 
4038  float val = a_bins.bin_Sw(ibin,jbin);
4039 
4040  float xx = a_bins.bin_lower_edge_x(ibin);
4041  float xe = a_bins.bin_upper_edge_x(ibin);
4042  float yy = a_bins.bin_lower_edge_y(jbin);
4043  float ye = a_bins.bin_upper_edge_y(jbin);
4044 
4045  bins.push_back(rep_bin2D(xx,xe,yy,ye,val,ibin,jbin));
4046 
4047  if(first) {
4048  first = false;
4049  bmin = val;
4050  bmax = val;
4051  } else {
4052  bmin = mn<float>(bmin,val);
4053  bmax = mx<float>(bmax,val);
4054  }
4055  }
4056  }}
4057  size_t number = bins.size();
4058 
4059  //a_bins.bins_Sw_range(bmin,bmax,false);
4060 
4061  painting_policy painting = a_data_style.painting;
4062  if(painting==painting_by_value) {
4063  m_bins_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_data_style.color_mapping);
4064  } else if( (painting==painting_grey_scale) ||
4065  (painting==painting_grey_scale_inverse) ||
4066  (painting==painting_violet_to_red) ){
4067  {float dbins = bmax-bmin;
4068  if(dbins!=0.0F) {
4069  for(size_t index=0;index<number;index++) {
4070  bins[index].m_ratio = (bins[index].m_val-bmin)/dbins;
4071  }
4072  }}
4073  if(painting==painting_grey_scale) {
4074  m_bins_cmaps[a_index] = new grey_scale_colormap(bmin,bmax,50);
4075  } else if(painting==painting_grey_scale_inverse) {
4076  m_bins_cmaps[a_index] = new grey_scale_inverse_colormap(bmin,bmax,50);
4077  } else if(painting==painting_violet_to_red) {
4078  m_bins_cmaps[a_index] = new violet_to_red_colormap(bmin,bmax,50);
4079  }
4080  } else {
4081  m_bins_cmaps[a_index] = new const_colormap(a_data_style.color);
4082  }
4083 
4084  if(modeling==modeling_solid()) {
4085  //a_out << "tools::sg::update_bins2D_xy : modeling_solid :" << std::endl;
4086 
4087  rep_bins2D_xy_solid(a_data_style,*(m_bins_cmaps[a_index]),bins,a_box_x,a_box_y,a_zz);
4088 
4089  } else if(modeling==modeling_points()) {
4090  //a_out << "tools::sg::update_bins2D_xy : modeling_points :" << std::endl;
4091  rep_bins2D_xy_random_one(a_data_style,bins,a_box_x,a_box_y,bmin,bmax,a_zz/*,std::string(sid)*/);
4092 
4093  } else if(modeling==modeling_wire_boxes()) {
4094  //a_out << "tools::sg::update_bins2D_xy : modeling_wire_boxes :" << std::endl;
4095 
4096  // one node decision :
4097  /*bool oneNode = false;
4098  {int nlimit = aGraphicStyle.multiNodeLimit.value();
4099  if(nlimit!=NoLimit) {
4100  oneNode = (number>nlimit?true:false);
4101  }}*/
4102 
4103  /*if(oneNode) {
4104  rep_bins2D_xy_wire_box_one(a_data_style,bins,a_box_x,a_box_y,bmin,bmax,std::string(sid));
4105  } else {*/
4106  rep_bins2D_xy_wire_box(a_data_style,bins,a_box_x,a_box_y,bmin,bmax,a_zz/*,std::string(sid_bin)*/);
4107  //}
4108 
4109  } else if(modeling==modeling_texts()) {
4110  //a_out << "tools::sg::update_bins2D_xy : modeling_wire_texts :" << std::endl;
4111 
4112  // one node decision :
4113  //bool oneNode = false;
4114  //{int nlimit = aGraphicStyle.multiNodeLimit.value();
4115  // if(nlimit!=NoLimit) {
4116  // oneNode = (number>nlimit?true:false);
4117  //}}
4118 
4119  //if(oneNode) {
4120  // rep_bins2D_xy_text_one(binsNode,
4121  // aGraphicStyle,
4122  // bins,a_box_x,a_box_y,std::string(sid));
4123  //} else {
4124  rep_bins2D_xy_text(a_data_style,bins,a_box_x,a_box_y/*,std::string(sid_bin)*/);
4125  //}
4126 
4127  } else { //default rep modeling==modeling_boxes()
4128  //a_out << "tools::sg::update_bins2D_xy : modeling_<else> :" << std::endl;
4129 
4130  rep_bins2D_xy_box(a_data_style,bins,a_box_x,a_box_y,bmin,bmax,a_zz);
4131 
4132  }
4133 
4134 
4135  } //end if modeling
4136 
4137  }
4138 
4139  void update_func1D_xy(std::ostream& a_out,const func1D& a_func,
4140  const style& a_style,const rep_box& a_box_x,const rep_box& a_box_y,float a_zz){
4141 
4142  //a_out << "debug : tools::sg::plotter::update_func1D_xy : modeling " << a_style.modeling.value() << " :" << std::endl;
4143 
4144  if(!a_style.visible) return;
4145 
4146  float xmn = m_x_axis_data.min_value();
4147  float xmx = m_x_axis_data.max_value();
4148 
4149  unsigned int nstp = a_func.x_steps();
4150  nstp = nstp <=0 ? curve_number_of_points.value() : nstp;
4151 
4152  float df = (xmx - xmn)/nstp;
4153 
4154  bool problem = false;
4155  std::vector<vec3f> points(nstp+1);
4156  for(unsigned int ibin=0;ibin<=nstp;ibin++) {
4157  float xx = xmn + ibin * df;
4158  float val;
4159  if(!a_func.value(xx,val)) problem = true;
4160  points[ibin].set_value(xx,val,a_zz);
4161  }
4162  if(problem) {
4163  a_out << "tools::sg::plotter::update_func1D_xy :"
4164  << " problem when getting some function value."
4165  << std::endl;
4166  }
4167 
4168  const std::string& modeling = a_style.modeling;
4169 
4170  if(modeling==modeling_points()){
4171  vertices* vtxs = new vertices;
4172  std::vector<float>& pts = vtxs->xyzs.values(); //npt*3
4173  clip_points_2D(points,a_box_x,a_box_y,pts);
4174  if(pts.size()) {
4175  //a_out << "debug : tools::sg::plotter::update_func1D_xy :"
4176  // << " ptn " << pts.size()
4177  // << std::endl;
4178 
4179  separator* sep = new separator;
4180  m_func_sep.add(sep);
4181 
4182  rgba* mat = new rgba();
4183  mat->color = a_style.color;
4184  sep->add(mat);
4185 
4186  draw_style* ds = new draw_style;
4187  ds->style = draw_points;
4188  ds->point_size = a_style.point_size;
4189  sep->add(ds);
4190 
4191  vtxs->mode = gl::points();
4192  sep->add(vtxs);
4193  } else {
4194  delete vtxs;
4195  }
4196 
4197  } else if(modeling==modeling_markers()){
4198  markers* _marks = new markers;
4199  std::vector<float>& pts = _marks->xyzs.values(); //npt*3
4200  clip_points_2D(points,a_box_x,a_box_y,pts);
4201  if(pts.size()) {
4202  //a_out << "debug : tools::sg::plotter::update_func1D_xy :"
4203  // << " ptn " << pts.size()
4204  // << std::endl;
4205 
4206  separator* sep = new separator;
4207  m_func_sep.add(sep);
4208 
4209  rgba* mat = new rgba();
4210  mat->color = a_style.color;
4211  sep->add(mat);
4212 
4213  _marks->size = a_style.marker_size;
4214  _marks->style = a_style.marker_style;
4215  sep->add(_marks);
4216  } else {
4217  delete _marks;
4218  }
4219 
4220  } else {
4221 
4222  vertices* vtxs = new vertices;
4223  std::vector<float>& pts = vtxs->xyzs.values(); //npt*3
4224 
4225  clip_polyline_2D(points,a_box_x,a_box_y,pts);
4226  if(pts.size()) {
4227  //a_out << "debug : tools::sg::plotter::update_func1D_xy : ptn " << pts.size() << std::endl;
4228 
4229  separator* sep = new separator;
4230  m_func_sep.add(sep);
4231 
4232  rgba* mat = new rgba();
4233  mat->color = a_style.color;
4234  sep->add(mat);
4235 
4236  draw_style* ds = new draw_style;
4237  ds->style = draw_lines;
4238  ds->line_pattern = a_style.line_pattern;
4239  ds->line_width = a_style.line_width;
4240  sep->add(ds);
4241 
4242  vtxs->mode = gl::line_strip();
4243  sep->add(vtxs);
4244  } else {
4245  delete vtxs;
4246  }
4247  }
4248  }
4249 
4250  static double function_to_contour(double a_X,double a_Y,void* aData) {
4251  SbFunc* func = (SbFunc*)aData;
4252  if( (a_X<func->m_limits_in[0])||
4253  (a_X>func->m_limits_in[1])||
4254  (a_Y<func->m_limits_in[2])||
4255  (a_Y>func->m_limits_in[3])
4256  ) return -FLT_MAX;
4257  float value;
4258  if(!func->m_func2D->value((float)a_X,(float)a_Y,value)) func->m_problem = true;
4259  return double(value);
4260  }
4261  static double log_function_to_contour(double a_X,double a_Y,void* aData) {
4262  SbFunc* func =(SbFunc*)aData;
4263  if( (a_X<func->m_limits_in[0])||
4264  (a_X>func->m_limits_in[1])||
4265  (a_Y<func->m_limits_in[2])||
4266  (a_Y>func->m_limits_in[3])
4267  ) return -FLT_MAX;
4268  float value;
4269  if(!func->m_func2D->value((float)a_X,(float)a_Y,value)) func->m_problem = true;
4270  return take_log(value);
4271  }
4272 
4273  void update_func2D_xy(std::ostream& a_out,const func2D& a_func,int a_index,style& a_data_style,
4274  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z,float a_zz){
4275  //a_out << "debug : tools::sg::plotter::update_func2D_xy(Function2D) : begin :" << std::endl;
4276  if(!a_data_style.visible.value()) return;
4277 
4278  // std::string sid;
4279  // {std::string sp;
4280  // if(!p2sx(&a_func,sp)){}
4281  // sid = "SbFunction2D/"+sp;}
4282 
4283  const std::string& modeling = a_data_style.modeling.getValue();
4284  painting_policy painting = a_data_style.painting;
4285 
4286  if( (modeling==modeling_curve()) || (modeling==modeling_filled_curve()) ) {
4287 
4288  //a_out << "debug : tools::sg::plotter::update_func2D_xy(Function2D) : curve." << std::endl;
4289 
4290  float zmin = a_box_z.m_pos;
4291  float dz = a_box_z.m_width;
4292  bool zlog = a_box_z.m_log;
4293 
4294  float xmn = m_x_axis_data.min_value();
4295  float xmx = m_x_axis_data.max_value();
4296  float ymn = m_y_axis_data.min_value();
4297  float ymx = m_y_axis_data.max_value();
4298 
4299  clist_contour list_contour;
4300  //int nFir = 32;
4301  int nFir = 128;
4302  list_contour.set_first_grid(nFir,nFir); //Default : 32,32
4303  //int nSec = 256;
4304  int nSec = 512; //slower than 256
4305  list_contour.set_secondary_grid(nSec,nSec); //Default : 256,256.
4306 
4307  double limits[4];
4308  // User limits :
4309  limits[0] = xmn;
4310  limits[1] = xmx;
4311  limits[2] = ymn;
4312  limits[3] = ymx;
4313 
4314  SbFunc sbFunc;
4315  sbFunc.m_func2D = &a_func;
4316  sbFunc.m_problem = false;
4317  sbFunc.m_bins2D = 0;
4318  sbFunc.m_limits_in[0] = limits[0];
4319  sbFunc.m_limits_in[1] = limits[1];
4320  sbFunc.m_limits_in[2] = limits[2];
4321  sbFunc.m_limits_in[3] = limits[3];
4322 
4323  // Extend the grid to have some borders in order to close contours :
4324  int n = nSec - 2 * 10;
4325  double dx = (limits[1]-limits[0]) /n;
4326  double dy = (limits[3]-limits[2]) /n;
4327  limits[0] = limits[0] - 10 * dx;
4328  limits[1] = limits[1] + 10 * dx;
4329  limits[2] = limits[2] - 10 * dy;
4330  limits[3] = limits[3] + 10 * dy;
4331 
4332  sbFunc.m_limits[0] = limits[0];
4333  sbFunc.m_limits[1] = limits[1];
4334  sbFunc.m_limits[2] = limits[2];
4335  sbFunc.m_limits[3] = limits[3];
4336 
4337  list_contour.set_limits(limits);
4338 
4339  if(levels.getNum()) {
4340  size_t zn = levels.size();
4341  std::vector<double> zs(zn);
4342  for(size_t zi=0;zi<zn;zi++) zs[zi] = levels[zi];
4343  list_contour.set_planes(zs);
4344  } else {
4345  unsigned int zn = number_of_levels;
4346  if(zn<=0) zn = 1;
4347  std::vector<double> zs(zn+1);
4348  float zmax = zmin + dz;
4349  double zd = (zmax-zmin)/zn;
4350  for(unsigned int zi=0;zi<=zn;zi++) zs[zi] = zmin + zi * zd;
4351  list_contour.set_planes(zs);
4352  }
4353 
4354  if(zlog) {
4355  list_contour.set_field_fcn(log_function_to_contour,(void*)&sbFunc);
4356  } else {
4357  list_contour.set_field_fcn(function_to_contour,(void*)&sbFunc);
4358  }
4359 
4360 #ifdef INLIBS_SG_PLOTTER_TIMING
4361  atime _start = atime::now();
4362 #endif
4363  list_contour.ccontour::generate();
4364 
4365 #ifdef INLIBS_SG_PLOTTER_TIMING
4366  a_out << "tools::sg::update_func2D_xy : contour generate elapsed " << atime::elapsed(_start) << "." << std::endl;
4367  _start = atime::now();
4368 #endif
4369 
4370  if(!list_contour.compact_strips ()) {
4371  a_out << "tools::sg::plotter::update_func2D_xy : clist_contour::compact_strips () : failure." << std::endl;
4372  } else {
4373 #ifdef INLIBS_SG_PLOTTER_TIMING
4374  a_out << "tools::sg::update_func2D_xy : contour compact strips elapsed " << atime::elapsed(_start) << "." << std::endl;
4375 #endif
4376  if( (painting==painting_by_level) || (painting==painting_by_value) ){
4377  m_func_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_data_style.color_mapping.value());
4378  //bool zlog = a_box_z.m_log;
4379  if(zlog) m_func_cmaps[a_index]->set_PAW_coloring();
4380  } else {
4381  m_func_cmaps[a_index] = new const_colormap(a_data_style.color.value());
4382  }
4383 
4384  if(modeling==modeling_filled_curve()) {
4385  rep_contour_xy_filled(a_out,a_data_style,
4386  painting,*(m_func_cmaps[a_index]),
4387  list_contour,a_box_x,a_box_y,a_box_z,a_zz /*,std::string(sid.c_str())*/);
4388  } else {
4389  rep_contour_xy(a_out,a_data_style,
4390  painting,*(m_func_cmaps[a_index]),
4391  list_contour,a_box_x,a_box_y,a_box_z,a_zz /*,std::string(sid.c_str())*/);
4392  }
4393  }
4394 
4395  if(sbFunc.m_problem) {
4396  a_out << "tools::sg::plotter::update_func2D_xy : problem when getting some function value." << std::endl;
4397  }
4398 
4399  /*
4400  } else if(modeling==SbModeling_polygon) {
4401 
4402  int npoint = a_func.getNumberOfPoints();
4403  if(npoint) {
4404 
4405  std::vector<vec3f> points(npoint);
4406  std::vector<int> controls;
4407  for(int count=0;count<npoint;count++) {
4408  float xx,yy;
4409  bool isControl;
4410  a_func.getIthPoint(count,xx,yy,isControl);
4411  points[count] = vec3f(xx,yy,a_zz);
4412  if(isControl) controls.push_back(count);
4413  }
4414  //check closure :
4415  if((points.size()>=2) && (points[points.size()-1]!=points[0]) ) {
4416  points.push_back(points[0]);
4417  }
4418 
4419  project2D(points,a_box_x,a_box_y);
4420 
4421  bool editable = a_data_style.editable.getValue();
4422  if(!editable) {
4423  clip<float> clipper;
4424  {size_t ptn = points.size();
4425  for(size_t index=0;index<ptn;index++) clipper.add(points[index]);}
4426 
4427  plane<vec3f> plane_xy_bot(vec3f(0, 1,0),vec3f(0,0,0));
4428  plane<vec3f> plane_xy_top(vec3f(0,-1,0),vec3f(0,1,0));
4429  plane<vec3f> plane_yz_left (vec3f( 1, 0,0),vec3f(0,0,0));
4430  plane<vec3f> plane_yz_right(vec3f(-1, 0,0),vec3f(1,0,0));
4431 
4432  clipper.execute(plane_xy_bot);
4433  clipper.execute(plane_xy_top);
4434  clipper.execute(plane_yz_left);
4435  clipper.execute(plane_yz_right);
4436 
4437  {int n = clipper.getNumVertices();
4438  points.resize(n);
4439  for(int index=0;index<n;index++) {
4440  clipper.getVertex(index,points[index]);
4441  }}
4442  if((points.size()>=2) && (points[points.size()-1]!=points[0]) ) {
4443  points.push_back(points[0]);
4444  }
4445  }
4446 
4447  int ptn = points.size();
4448  if(ptn) {
4449  vec3f* pts = &(points[0]);
4450 
4451  SoSceneGraph* separator = new SoSceneGraph();
4452  separator->setString(sid.c_str());
4453  functionNode->addChild(separator);
4454 
4455  SoSeparator* sep = new SoSeparator;
4456  separator->addChild(sep);
4457 
4458  sep->addChild(fStyleCache->getFilled());
4459  sep->addChild(fStyleCache->getNormalBindingOverall());
4460  sep->addChild(fStyleCache->getNormalZ());
4461  sep->addChild(fStyleCache->getMaterial(a_data_style.color.getValue(),a_data_style.transparency.getValue()));
4462 
4463  SoCoordinate3* coordinate3 = new SoCoordinate3;
4464  coordinate3->point.setValues(0,ptn,pts);
4465  sep->addChild(coordinate3);
4466 
4467  SoFaceSet* faceSet = new SoFaceSet;
4468  faceSet->numVertices.set1Value(0,ptn);
4469  sep->addChild(faceSet);
4470 
4471  sep->addChild(fStyleCache->getLineStyle(SbLinePattern_solid,1));
4472  sep->addChild(fStyleCache->getMaterial(SbColor_black,0));
4473 
4474  //NOTE : we could simply add faceSet again !
4475  SoLineSet* lineSet = new SoLineSet;
4476  lineSet->numVertices.set1Value(0,ptn);
4477  sep->addChild(lineSet);
4478 
4479  if(editable) {
4480  SoSeparator* sep = new SoSeparator;
4481  separator->addChild(sep);
4482 
4483  float scale = 0.05F;
4484 
4485  for(int index=0;index<controls.size();index++) {
4486  int icontrol = controls[index];
4487  const vec3f& pt = pts[icontrol];
4488 
4489  SoSeparator* sp = new SoSeparator;
4490  sep->addChild(sp);
4491 
4492  SoTransform* tsf = new SoTransform();
4493  tsf->translation.setValue(pt);
4494  tsf->scaleFactor.setValue(scale,scale,scale);
4495  sp->addChild(tsf);
4496 
4497  SoPlotter_dragger* dragger =
4498  new SoPlotter_dragger(*coordinate3,icontrol,scale,*this,const_cast<SbPlottableFunction2D&>(a_func),a_box_x,a_box_y,a_zz);
4499  SoTools_setDraggerColor(*dragger,SbColor_red);
4500  sp->addChild(dragger);
4501  }
4502  }
4503 
4504  } //ptn
4505  } //npoint
4506 
4507  */
4508  } else {
4509  a_out << "tools::sg::plotter::update_func2D_xy :"
4510  << " modeling " << modeling
4511  << " does not apply on Functi on2D in XY. Valid modelings ared curve, filled_curve and polygon."
4512  << std::endl;
4513  }
4514 
4515  }
4516 
4517  void update_points2D_xy(std::ostream& a_out,const points2D& a_points,const style& a_style,
4518  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz) {
4519 
4520  //a_out << "debug : tools::sg::plotter::update_points2D_xy : modeling " << a_style.modeling.value() << std::endl;
4521 
4522  if(!a_style.visible) return;
4523 
4524  size_t number = a_points.points();
4525  if(!number) return;
4526 
4527  const std::string& modeling = a_style.modeling;
4528 
4529  if(modeling==modeling_lines()) {
4530  rep_points2D_xy_lines(a_style,a_points,a_box_x,a_box_y,a_zz);
4531  } else if(modeling==modeling_curve()) {
4532  rep_points2D_xy_curve(a_out,a_style,a_points,a_box_x,a_box_y,a_zz);
4533  } else {
4534  rep_points2D_xy_points(a_out,a_style,a_points,a_box_x,a_box_y,a_zz);
4535  }
4536  }
4537 
4538  void update_points3D_xyz(std::ostream& a_out,const points3D& a_points,const style& a_style,
4539  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z) {
4540 
4541  //a_out << "debug : tools::sg::plotter::update_points3D_xyz : modeling " << a_style.modeling.value() << std::endl;
4542 
4543  if(!a_style.visible) return;
4544 
4545  size_t number = a_points.points();
4546  if(!number) return;
4547 
4548  rep_points3D_xyz_points(a_out,a_style,a_points,a_box_x,a_box_y,a_box_z);
4549  }
4550 
4551  void get_title(std::string& a_s){
4552  a_s.clear();
4553  bins1D* b1;
4554  bins2D* b2;
4555  func1D* f1;
4556  func2D* f2;
4557  points2D* p2;
4558  points3D* p3;
4559  if(first_bins(b1,b2)) {
4560  if(b1) {
4561  a_s = b1->title();
4562  } else if(b2) {
4563  a_s = b2->title();
4564  }
4565  } else if(first_points(p2,p3)) {
4566  if(p2) {
4567  a_s = p2->title();
4568  } else if(p3) {
4569  a_s = p3->title();
4570  }
4571  } else if(first_func(f1,f2)) {
4572  if(f1) {
4573  a_s = f1->title();
4574  } if(f2) {
4575  a_s = f2->title();
4576  }
4577  }
4578  }
4579 
4580  void update_bins2D_xyz(std::ostream& a_out,const bins2D& a_bins,unsigned int a_index,const style& a_style,
4581  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z){
4582  //a_out << "tools::sg::update_bins2D_xyz : begin :" << std::endl;
4583 
4584  if(!a_style.visible) return;
4585 
4586  //a_out << "tools::sg::update_bins2D_xyz : visible :" << std::endl;
4587 
4588  unsigned int xnbin = a_bins.x_bins();
4589  unsigned int ynbin = a_bins.y_bins();
4590  if(!xnbin || !ynbin) return;
4591 
4592  const std::string& modeling = a_style.modeling;
4593 
4594  if(modeling==modeling_boxes()) {
4595 
4596  bool hbe = a_bins.has_entries_per_bin();
4597 
4598  float bmin = 0;
4599  float bmax = 0;
4600 
4601  std::vector<rep_bin2D> bins;
4602  {bool first = true;
4603  for(int jbin=ynbin-1;jbin>=0;jbin--) {
4604  for(int ibin=xnbin-1;ibin>=0;ibin--) {
4605  if(hbe && (a_bins.bin_entries(ibin,jbin)<=0)) continue;
4606 
4607  float val = a_bins.bin_Sw(ibin,jbin);
4608 
4609  float xx = a_bins.bin_lower_edge_x(ibin);
4610  float xe = a_bins.bin_upper_edge_x(ibin);
4611  float yy = a_bins.bin_lower_edge_y(jbin);
4612  float ye = a_bins.bin_upper_edge_y(jbin);
4613 
4614  bins.push_back(rep_bin2D(xx,xe,yy,ye,val,ibin,jbin));
4615 
4616  if(first) {
4617  first = false;
4618  bmin = val;
4619  bmax = val;
4620  } else {
4621  bmin = mn<float>(bmin,val);
4622  bmax = mx<float>(bmax,val);
4623  }
4624  }
4625  }}
4626  size_t number = bins.size();
4627 
4628  //a_bins.bins_Sw_range(bmin,bmax,false);
4629 
4630  painting_policy painting = a_style.painting;
4631  if(painting==painting_by_value) {
4632  m_bins_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_style.color_mapping);
4633  } else if( (painting==painting_grey_scale) ||
4634  (painting==painting_grey_scale_inverse) ||
4635  (painting==painting_violet_to_red) ){
4636  {float dbins = bmax-bmin;
4637  if(dbins!=0.0F) {
4638  for(size_t index=0;index<number;index++) {
4639  bins[index].m_ratio = (bins[index].m_val-bmin)/dbins;
4640  }
4641  }}
4642  if(painting==painting_grey_scale) {
4643  m_bins_cmaps[a_index] = new grey_scale_colormap(bmin,bmax,50);
4644  } else if(painting==painting_grey_scale_inverse) {
4645  m_bins_cmaps[a_index] = new grey_scale_inverse_colormap(bmin,bmax,50);
4646  } else if(painting==painting_violet_to_red) {
4647  m_bins_cmaps[a_index] = new violet_to_red_colormap(bmin,bmax,50);
4648  }
4649  } else {
4650  m_bins_cmaps[a_index] = new const_colormap(a_style.color);
4651  }
4652 
4653  rep_bins2D_xyz_box(a_style,*m_bins_cmaps[a_index],bins,a_box_x,a_box_y,a_box_z,bmin,bmax);
4654 
4655  } else if(modeling==modeling_curve()){ //gopaw
4656 
4657  float bmin = 0;
4658  float bmax = 0;
4659 
4660  std::vector<rep_top_face2D> faces((xnbin-1)*(ynbin-1));
4661  {bool first = true;
4662  size_t facei = 0;
4663  unsigned int xnbin_1 = xnbin-1;
4664  unsigned int ynbin_1 = ynbin-1;
4665  for(unsigned int jbin=0;jbin<ynbin_1;jbin++) {
4666  for(unsigned int ibin=0;ibin<xnbin_1;ibin++) {
4667 
4668  float xx_0 = a_bins.bin_lower_edge_x(ibin);
4669  float xe_0 = a_bins.bin_upper_edge_x(ibin);
4670  float xx_1 = a_bins.bin_lower_edge_x(ibin+1);
4671  float xe_1 = a_bins.bin_upper_edge_x(ibin+1);
4672 
4673  float yy_0 = a_bins.bin_lower_edge_y(jbin);
4674  float ye_0 = a_bins.bin_upper_edge_y(jbin);
4675  float yy_1 = a_bins.bin_lower_edge_y(jbin+1);
4676  float ye_1 = a_bins.bin_upper_edge_y(jbin+1);
4677 
4678  float xx = (xx_0+xe_0)/2;
4679  float xe = (xx_1+xe_1)/2;
4680  float yy = (yy_0+ye_0)/2;
4681  float ye = (yy_1+ye_1)/2;
4682 
4683  float val1 = a_bins.bin_Sw(ibin,jbin);
4684  float val2 = a_bins.bin_Sw(ibin+1,jbin);
4685  float val3 = a_bins.bin_Sw(ibin+1,jbin+1);
4686  float val4 = a_bins.bin_Sw(ibin,jbin+1);
4687 
4688  faces[facei] = rep_top_face2D(xx,xe,yy,ye,val1,val2,val3,val4);
4689 
4690  if(first) {
4691  first = false;
4692  bmin = val1;
4693  bmax = val1;
4694  } else {
4695  bmin = mn<float>(bmin,val1);
4696  bmax = mx<float>(bmax,val1);
4697  }
4698 
4699  facei++;
4700  }
4701  }}
4702 
4703  //a_bins.bins_Sw_range(bmin,bmax,false);
4704 
4705  painting_policy painting = a_style.painting;
4706  if((painting==painting_by_value)||(painting==painting_by_level)) {
4707  m_bins_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_style.color_mapping);
4708  } else {
4709  m_bins_cmaps[a_index] = new const_colormap(a_style.color);
4710  }
4711 
4712  if(painting==painting_by_level) { //gopaw
4713  rep_top_face2D_xyz_by_level(a_style,painting,*(m_bins_cmaps[a_index]),
4714  faces,a_box_x,a_box_y,a_box_z,
4715  bmin,bmax/*,SbString(sid.c_str())*/);
4716  //if(a_style.area_style.value()==area_edged) {
4717  // style gs;
4718  // gs.light_model = light_model_base_color();
4719  // gs.line_width = 1;
4720  // rep_top_face2D_xyz_line(gs,faces,a_box_x,a_box_y,a_box_z);
4721  //}
4722 
4723  } else {
4724 
4725  //bool oneNode = false;
4726  //{int nlimit = aGraphicStyle.multiNodeLimit.getValue();
4727  //if(nlimit!=NoLimit) {
4728  //oneNode = ((int)faces.size()>nlimit?true:false);
4729  //}}
4730 
4731  //if(oneNode) {
4732  //repTopFaces2D_xyz_one(binsNode,aGraphicStyle,faces,a_box_x,a_box_y,a_box_z,SbString(sid.c_str()));
4733  //} else {
4734  bool zlog = a_box_z.m_log;
4735  if(zlog) m_func_cmaps[a_index]->set_PAW_coloring();
4736  rep_top_face2D_xyz(m_bins_sep,a_style,*(m_bins_cmaps[a_index]),faces,a_box_x,a_box_y,a_box_z);
4737 
4738  if(a_style.area_style.value()==area_edged) {
4739  style gs;
4741  gs.line_width = 1;
4742  rep_top_face2D_xyz_line(gs,faces,a_box_x,a_box_y,a_box_z/*,SbString(sid.c_str())*/);
4743  }
4744 
4745  if(painting==painting_uniform) { //gopaw SURF3 (s_SURF_CONT).
4746 
4747  base_colormap* cmap = new by_value_colormap(a_out,m_cmaps,a_style.color_mapping);
4748  if(cmap->colorn()<=0) {
4749  //a_out << "tools::sg::update_bins2D_xyz : bypass rep_contour_xy_filled." << std::endl;
4750  delete cmap;
4751  } else {
4752  //updateBins2D_XY(a_bins,aIndex,*gs,a_box_x,a_box_y,boxZ,1.1F);
4753 
4754  float zmin = a_box_z.m_pos;
4755  float dz = a_box_z.m_width;
4756  //bool zlog = a_box_z.m_log;
4757 
4758  float xmn = m_x_axis_data.min_value();
4759  float xmx = m_x_axis_data.max_value();
4760  float ymn = m_y_axis_data.min_value();
4761  float ymx = m_y_axis_data.max_value();
4762 
4763  clist_contour list_contour;
4764  //int nFir = 32;
4765  int nFir = 128;
4766  list_contour.set_first_grid(nFir,nFir); //Default : 32,32
4767  //int nSec = 256;
4768  int nSec = 512;
4769  list_contour.set_secondary_grid(nSec,nSec); //Default : 256,256.
4770 
4771  double limits[4];
4772  // User limits :
4773  limits[0] = xmn;
4774  limits[1] = xmx;
4775  limits[2] = ymn;
4776  limits[3] = ymx;
4777 
4778  SbFunc sbFunc;
4779  sbFunc.m_func2D = 0;
4780  sbFunc.m_problem = false;
4781  sbFunc.m_bins2D = &a_bins;
4782  sbFunc.m_limits_in[0] = limits[0];
4783  sbFunc.m_limits_in[1] = limits[1];
4784  sbFunc.m_limits_in[2] = limits[2];
4785  sbFunc.m_limits_in[3] = limits[3];
4786 
4787  // Extend the grid to have some borders in order to close contours :
4788  int n = nSec - 2 * 10;
4789  double dx = (limits[1]-limits[0]) /n;
4790  double dy = (limits[3]-limits[2]) /n;
4791  limits[0] = limits[0] - 10 * dx;
4792  limits[1] = limits[1] + 10 * dx;
4793  limits[2] = limits[2] - 10 * dy;
4794  limits[3] = limits[3] + 10 * dy;
4795 
4796  sbFunc.m_limits[0] = limits[0];
4797  sbFunc.m_limits[1] = limits[1];
4798  sbFunc.m_limits[2] = limits[2];
4799  sbFunc.m_limits[3] = limits[3];
4800 
4801  list_contour.set_limits(limits);
4802 
4803  //int zn = numberOfLevels.getValue();
4804  size_t zn = cmap->colorn();
4805  if(zn<=0) zn = 1;
4806 
4807  std::vector<double> zs(zn+1);
4808  float zmax = zmin + dz;
4809  double zd = (zmax-zmin)/zn;
4810  for(size_t zi=0;zi<=zn;zi++) zs[zi] = zmin + zi * zd;
4811  list_contour.set_planes(zs);
4812 
4813  if(zlog) list_contour.set_field_fcn(log_bins2D_to_contour,(void*)&sbFunc);
4814  else list_contour.set_field_fcn(bins2D_to_contour,(void*)&sbFunc);
4815 
4816  list_contour.ccontour::generate();
4817  if(!list_contour.compact_strips ()) {
4818  a_out << "tools::sg::plotter::update_bins2D_xyz : clist_contour::compact_strips () : failure." << std::endl;
4819  delete cmap;
4820  } else {
4821  delete m_bins_cmaps[a_index];
4822  m_bins_cmaps[a_index] = cmap; //to visualize the cmap.
4823 
4824  matrix* transf = new matrix;
4825  //contour back is at ZZ - 0.01F;
4826  transf->set_translate(0,0,1.02F);
4827  transf->mul_scale(1,1,0.01F); //applied first.
4828  m_bins_sep.add(transf);
4829 
4830  style gs;
4832  //FIXME gs.transparency = 0.3F;
4833 
4834  float ZZ = 0.0F;
4835 
4836  rep_contour_xy_filled(a_out,gs,painting_by_level,*cmap,list_contour,
4837  a_box_x,a_box_y,a_box_z,ZZ/*,SbString(sid.c_str())*/);
4838  }
4839  }
4840 
4841  } //uniform
4842 
4843  }
4844 
4845  } //end if modeling
4846 
4847  }
4848 
4849  void update_func2D_xyz(std::ostream& a_out,
4850  const func2D& a_func,
4851  unsigned int a_index,
4852  const style& a_style,
4853  const rep_box& a_box_x,
4854  const rep_box& a_box_y,
4855  const rep_box& a_box_z){
4856  //a_out << "tools::sg::plotter::update_func2D_xyz : begin :" << std::endl;
4857  if(!a_style.visible) return;
4858 
4859  //a_out << "tools::sg::plotter::update_func2D_xyz : visible :" << std::endl;
4860 
4861  float xmn = m_x_axis_data.min_value();
4862  float xmx = m_x_axis_data.max_value();
4863 
4864  unsigned int nx = a_func.x_steps();
4865  nx = !nx?20:nx;
4866 
4867  float ymn = m_y_axis_data.min_value();
4868  float ymx = m_y_axis_data.max_value();
4869 
4870  unsigned int ny = a_func.y_steps();
4871  ny = !ny?20:ny;
4872 
4873  float dfx = (xmx - xmn)/nx;
4874  float dfy = (ymx - ymn)/ny;
4875 
4876  //printf("debug : nx %d ny %d\n",nx,ny);
4877 
4878  std::vector<rep_top_face2D> faces(nx*ny);
4879  {bool problem = false;
4880  unsigned int facei = 0;
4881  float* vprev = new float[2*nx];
4882  for(int jbin=ny-1;jbin>=0;jbin--) {
4883  float o1 = 0;
4884  float o4 = 0;
4885  for(int ibin=nx-1;ibin>=0;ibin--) {
4886 
4887  float xx = xmn + ibin * dfx;
4888  float yy = ymn + jbin * dfy;
4889  float xe = xx + dfx;
4890  float ye = yy + dfy;
4891 
4892  // Values at the corner :
4893  float val1;
4894  if(!a_func.value(xx,yy,val1)) problem = true;
4895  float val2;
4896  if(ibin==int(nx-1)) {
4897  if(!a_func.value(xe,yy,val2)) problem = true;
4898  } else {
4899  val2 = o1;
4900  }
4901  float val3,val4;
4902  if(jbin==int(ny-1)) {
4903  if(ibin==int(nx-1)) {
4904  if(!a_func.value(xe,ye,val3)) problem = true;
4905  } else {
4906  val3 = o4;
4907  }
4908  if(!a_func.value(xx,ye,val4)) problem = true;
4909  } else {
4910  val3 = vprev[2*ibin+1];
4911  val4 = vprev[2*ibin];
4912  }
4913  //printf("debug : %d %d : %g %g %g %g\n",
4914  // ibin,jbin,
4915  // val1,val2,val3,val4);
4916  vprev[2*ibin] = val1;
4917  vprev[2*ibin+1] = val2;
4918  o4 = val4;
4919  o1 = val1;
4920 
4921  faces[facei] = rep_top_face2D(xx,xe,yy,ye,val1,val2,val3,val4);
4922  facei++;
4923  }
4924  }
4925  delete [] vprev;
4926  if(problem) {
4927  a_out << "tools::sg::plotter::update_func2D_xyz :"
4928  << " problem when getting some function value."
4929  << std::endl;
4930  }}
4931 
4932  painting_policy painting = a_style.painting;
4933 
4934  if(painting==painting_by_value) {
4935  m_func_cmaps[a_index] = new by_value_colormap(a_out,m_cmaps,a_style.color_mapping);
4936 
4937  } else if( (painting==painting_grey_scale) ||
4938  (painting==painting_grey_scale_inverse) ||
4939  (painting==painting_violet_to_red) ){
4940  float vmin = faces[0].m_v1;
4941  float vmax = faces[0].m_v1;
4942  size_t number = faces.size();
4943  for(size_t index=0;index<number;index++) {
4944  float vmean = faces[index].m_v1;
4945  vmean += faces[index].m_v2;
4946  vmean += faces[index].m_v3;
4947  vmean += faces[index].m_v4;
4948  vmean /= 4.0f;
4949 
4950  vmin = mn<float>(vmin,vmean);
4951  vmax = mx<float>(vmax,vmean);
4952 
4953  faces[index].m_ratio = vmean;
4954  }
4955 
4956  {float dbins = vmax-vmin;
4957  if(dbins!=0.0F) {
4958  for(size_t index=0;index<number;index++) {
4959  faces[index].m_ratio = (faces[index].m_ratio-vmin)/dbins;
4960  }
4961  }}
4962 
4963  if(painting==painting_grey_scale) {
4964  m_func_cmaps[a_index] = new grey_scale_colormap(vmin,vmax,50);
4965  } else if(painting==painting_grey_scale_inverse) {
4966  m_func_cmaps[a_index] = new grey_scale_inverse_colormap(vmin,vmax,50);
4967  } else if(painting==painting_violet_to_red) {
4968  m_func_cmaps[a_index] = new violet_to_red_colormap(vmin,vmax,50);
4969  }
4970 
4971  } else {
4972  m_func_cmaps[a_index] = new const_colormap(a_style.color);
4973  }
4974 
4975  // bool oneNode = false;
4976  //{int nlimit = a_data_style.multiNodeLimit.getValue();
4977  // if(nlimit!=NoLimit) {
4978  // oneNode = ((int)faces.size()>nlimit?true:false);
4979  //}}
4980 
4981  //char sid[128];
4982  //::sprintf(sid,"SbFunction2D/0x%lx",(unsigned long)&a_func);
4983 
4984  //if(oneNode) {
4985  // repTopFaces2D_xyz_one(functionNode,a_data_style,
4986  // faces,a_box_x,a_box_y,a_box_z,std::string(sid));
4987  //} else
4988  {
4989  bool zlog = a_box_z.m_log;
4990  if(zlog) m_func_cmaps[a_index]->set_PAW_coloring();
4991  rep_top_face2D_xyz(m_func_sep,a_style,*(m_func_cmaps[a_index]),faces,a_box_x,a_box_y,a_box_z);
4992  }
4993 
4994  float xmin = a_box_x.m_pos;
4995  float dx = a_box_x.m_width;
4996  bool xlog = a_box_x.m_log;
4997 
4998  float ymin = a_box_y.m_pos;
4999  float dy = a_box_y.m_width;
5000  bool ylog = a_box_y.m_log;
5001 
5002  float zmin = a_box_z.m_pos;
5003  float dz = a_box_z.m_width;
5004  bool zlog = a_box_z.m_log;
5005 
5007  // border X (Y=0)
5008 
5009  {separator* sep = new separator;
5010  {normal* nm = new normal;
5011  nm->vec = vec3f(0,-1,0);
5012  sep->add(nm);}
5013  {rgba* mat = new rgba();
5014  mat->color = colorf(0.6f,0.2f,0.2f); //brown
5015  sep->add(mat);}
5016 
5017  vertices* vtxs = new vertices;
5018  vtxs->mode = gl::triangle_fan();
5019  sep->add(vtxs);
5020 
5021  bool empty = true;
5022  bool problem = false;
5023 
5024  {float xx = xmn;
5025  float yy = ymn;
5026  xx = verify_log(xx,xmin,dx,xlog);
5027  yy = verify_log(yy,ymin,dy,ylog);
5028  vtxs->add(xx,yy,0);}
5029 
5030  {float xx = xmx;
5031  float yy = ymn;
5032  xx = verify_log(xx,xmin,dx,xlog);
5033  yy = verify_log(yy,ymin,dy,ylog);
5034  vtxs->add(xx,yy,0);}
5035 
5036  {float val;
5037  {if(!a_func.value(xmx,ymn,val)) problem = true;
5038  val = verify_log(val,zmin,dz,zlog);
5039  if(val<0) val = 0;
5040  if(val>1) val = 1;}
5041  {float xx = xmx;
5042  float yy = ymn;
5043  xx = verify_log(xx,xmin,dx,xlog);
5044  yy = verify_log(yy,ymin,dy,ylog);
5045  vtxs->add(xx,yy,val);}}
5046 
5047  for(int ibin=nx-1;ibin>=0;ibin--) {
5048 
5049  float xx = xmn + ibin * dfx;
5050  //float xe = xx + dfx;
5051  float yy = ymn;
5052 
5053  float val;
5054  {if(!a_func.value(xx,yy,val)) problem = true;
5055  val = verify_log(val,zmin,dz,zlog);
5056  if(val<0) val = 0;
5057  if(val>1) val = 1;}
5058 
5059  xx = verify_log(xx,xmin,dx,xlog);
5060  yy = verify_log(yy,ymin,dy,ylog);
5061 
5062  if((xx>=0)&&(xx<=1) && (yy>=0)&&(yy<=1) ) {
5063 
5064  vtxs->add(xx,yy,val);
5065 
5066  empty = false;
5067  }
5068  }
5069  if(empty) {
5070  delete sep;
5071  } else {
5072  m_func_sep.add(sep);
5073  }
5074  if(problem) {
5075  a_out << "tools::sg::plotter::update_func2D_xyz :"
5076  << " problem when getting some function value."
5077  << std::endl;
5078  }}
5079 
5080  // border Y (X=0)
5081  {separator* sep = new separator;
5082  {normal* nm = new normal;
5083  nm->vec = vec3f(-1,0,0);
5084  sep->add(nm);}
5085  {rgba* mat = new rgba();
5086  mat->color = colorf(0.6f,0.2f,0.2f); //brown
5087  sep->add(mat);}
5088 
5089  vertices* vtxs = new vertices;
5090  vtxs->mode = gl::triangle_fan();
5091  sep->add(vtxs);
5092 
5093  {float xx = xmn;
5094  float yy = ymx;
5095  xx = verify_log(xx,xmin,dx,xlog);
5096  yy = verify_log(yy,ymin,dy,ylog);
5097  vtxs->add(xx,yy,0);}
5098 
5099  {float xx = xmn;
5100  float yy = ymn;
5101  xx = verify_log(xx,xmin,dx,xlog);
5102  yy = verify_log(yy,ymin,dy,ylog);
5103  vtxs->add(xx,yy,0);}
5104 
5105  bool empty = true;
5106  bool problem = false;
5107 
5108  for(unsigned int jbin=0;jbin<ny;jbin++) {
5109 
5110  float xx = xmn;
5111  float yy = ymn + jbin * dfy;
5112 
5113  float val;
5114  {if(!a_func.value(xx,yy,val)) problem = true;
5115  val = verify_log(val,zmin,dz,zlog);
5116  if(val<0) val = 0;
5117  if(val>1) val = 1;}
5118 
5119  xx = verify_log(xx,xmin,dx,xlog);
5120  yy = verify_log(yy,ymin,dy,ylog);
5121 
5122  if((xx>=0)&&(xx<=1) &&
5123  (yy>=0)&&(yy<=1) ){
5124 
5125  vtxs->add(xx,yy,val);
5126 
5127  empty = false;
5128 
5129  }
5130  }
5131 
5132  {float val;
5133  {if(!a_func.value(xmn,ymx,val)) problem = true;
5134  val = verify_log(val,zmin,dz,zlog);
5135  if(val<0) val = 0;
5136  if(val>1) val = 1;}
5137  {float xx = xmn;
5138  float yy = ymx;
5139  xx = verify_log(xx,xmin,dx,xlog);
5140  yy = verify_log(yy,ymin,dy,ylog);
5141  vtxs->add(xx,yy,val);}}
5142  if(empty) {
5143  delete sep;
5144  } else {
5145  m_func_sep.add(sep);
5146  }
5147  if(problem) {
5148  a_out << "tools::sg::plotter::update_func2D_xyz :"
5149  << " problem when getting some function value."
5150  << std::endl;
5151  }}
5152 
5153 
5154  } //func2D_borders_visible
5155 
5156  }
5157 
5159  if(!m_title_style.visible) return;
5160 
5161  if(m_shape==xyz) return;
5162 
5163  if(title.value().empty()) return;
5164 
5165  // Use the XY layout transform to position the title.
5166  // (Else we would have to compensate the 3D rotation
5167  // in order to bring the title at the right position
5168  // without rotation).
5169  //titleNode->addChild(layout);
5170 
5171  rgba* mat = new rgba();
5172  mat->color = m_title_style.color;
5173  m_title_sep.add(mat);
5174 
5175  float text_size = title_height * m_title_style.scale;
5176 
5177  std::string font = m_title_style.font.value();
5178 
5179  if(font==font_hershey()) {
5180  draw_style* ds = new draw_style;
5181  ds->style = draw_lines;
5184  m_title_sep.add(ds);
5185  } else {
5186  m_title_sep.add(new normal);
5187  }
5188 
5189  float XSIZ = width;
5190  float XMGL = left_margin;
5191  float XMGR = right_margin;
5192  float wData = XSIZ-XMGL-XMGR;
5193 
5194  float YSIZ = height;
5195  float YMGL = bottom_margin;
5196  float YMGU = top_margin;
5197  float hData = YSIZ-YMGL-YMGU;
5198 
5199  float xx = wData/2;
5200  float yy = hData + title_to_axis;
5201 
5202  float zz = _zinfos();
5203 
5204  vjust vjust = bottom;
5205  if(!title_up) {
5206  yy = -title_to_axis;
5207  vjust = top;
5208  }
5209 
5210  //::printf("debug : %lu : %g %g : text_size : %g : %s\n",
5211  // this,xx,yy,text_size,title.value().c_str());
5212 
5213  vec3f TX(1,0,0);
5214  vec3f TY(0,1,0);
5216  font,
5220  title.value(),
5221  xx,yy,zz, //vec
5222  TX,TY,
5223  text_size,
5225  m_ttf);
5226  }
5227 
5229  if(!m_title_box_style.visible) return;
5230  if(title.value().empty()) return;
5231 
5232  // same plane than infos, then in front of data and grid.
5233  float zz = _zinfos();
5234  if(m_shape==xyz) zz = depth*0.5f;
5235 
5236  float wbox = width*title_box_width;
5237  float hbox = height*title_box_height;
5238 
5239  float xmargin = width*title_box_x_margin; //from left border
5240  float ymargin = height*title_box_y_margin; //from top border
5241 
5242  matrix* _tsf = new matrix;
5243  {float xx = -width*0.5f+wbox*0.5f+xmargin; //at left.
5244  float yy = height*0.5f-hbox*0.5F-ymargin; //at top.
5245  _tsf->set_translate(xx,yy,zz);
5246  _tsf->mul_scale(1,1,_zscale_text());}
5247  m_title_box_sep.add(_tsf);
5248 
5249  sg::text* title_box = new sg::text(m_ttf);
5250  title_box->width = wbox;
5251  title_box->height = hbox;
5252  title_box->back_area::color = m_title_box_style.back_color;
5253  title_box->color = m_title_box_style.color;
5254  title_box->font = m_title_box_style.font;
5256  title_box->encoding = m_title_box_style.encoding;
5258  //title_box->front_face = m_title_box_style.front_face;
5259  title_box->confine = true;
5260  title_box->back_area::shadow = m_title_box_style.back_shadow;
5261 
5262  title_box->strings.add(title.value());
5263 
5264  m_title_box_sep.add(title_box);
5265  }
5266 
5267  void get_infos(std::string& a_s){
5268  // return "[<key>\n<value>]\n".
5269  a_s.clear();
5270  const std::string& opts = infos_what.value();
5271  {bins1D* b1;
5272  bins2D* b2;
5273  func1D* f1;
5274  func2D* f2;
5275  points2D* p2;
5276  points3D* p3;
5277  if(first_bins(b1,b2)) {
5278  if(b1) {
5279  b1->infos(opts,a_s);
5280  } else if(b2) {
5281  b2->infos(opts,a_s);
5282  }
5283  } else if(first_points(p2,p3)) {
5284  if(p2) {
5285  p2->infos(opts,a_s);
5286  } else if(p3) {
5287  p3->infos(opts,a_s);
5288  }
5289  } else if(first_func(f1,f2)) {
5290  if(f1) {
5291  f1->infos(opts,a_s);
5292  } if(f2) {
5293  f2->infos(opts,a_s);
5294  }
5295  }}
5296  //look for fit infos :
5298  plottable* object = *it;
5299  if(!object) continue;
5300  if(object->cast(s_tools_sg_fit2plot())) {
5301  if(a_s.size()) a_s += "\n";
5302  std::string _s;
5303  object->infos(opts,_s);
5304  a_s += _s;
5305  }
5306  }}
5307  }
5308 
5310  if(m_infos_sep.empty()) return 0;
5311  return (matrix*)m_infos_sep[0]; //WARNING.
5312  }
5314  if(m_infos_sep.empty()) return 0;
5315  return (sg::infos_box*)m_infos_sep[1]; //WARNING.
5316  }
5317 
5318  void update_infos(std::ostream&){
5319  if(!m_infos_style.visible) return;
5320 
5321  std::string sinfos;
5322  get_infos(sinfos);
5323  std::vector<std::string> ws;
5324  words(sinfos,"\n",false,ws);
5325  size_t linen = ws.size()/2;
5326 
5327  float zz = _zinfos(); //xy
5328  if(m_shape==xyz) zz = depth*0.5f;
5329 
5330  float _height = height;
5331  if(m_shape==xyz) _height = depth;
5332 
5333  float wbox = width*infos_width;
5334 
5335  matrix* infos_title_tsf = 0;
5336  sg::text* infos_title_text = 0;
5337 
5338  std::string infos_title;
5340  std::vector<std::string> _ws; //to rm "Name".
5341  for(size_t index=0;index<linen;index++) {
5342  const std::string& name = ws[2*index];
5343  const std::string& value = ws[2*index+1];
5344  if(name=="Name") {
5345  infos_title = value;
5346  } else {
5347  _ws.push_back(name);
5348  _ws.push_back(value);
5349  }
5350  }
5351  ws = _ws;
5352  linen = ws.size()/2;
5353  }
5354 
5355  if(infos_title.size()) {
5356  float hbox = _height*0.05f;
5357 
5358  matrix* _tsf = new matrix;
5359  {float xx = width*0.5f - wbox*0.5f - width*infos_x_margin;
5360  float yy = _height*0.5f - hbox*0.5F - _height*infos_y_margin;
5361  _tsf->mul_translate(xx,yy,zz);
5362  _tsf->mul_scale(1,1,_zscale_text());}
5363  //in case of having infos, the tsf is refined below.
5364  m_infos_title_sep.add(_tsf);
5365 
5366  // same params as title_box.
5367  sg::text* txt = new sg::text(m_ttf);
5368  txt->width = wbox;
5369  txt->height = hbox;
5370  txt->back_area::color = m_infos_style.back_color;
5371  txt->color = m_infos_style.color;
5372  txt->font = m_infos_style.font;
5376  //txt->front_face = m_infos_style.front_face;
5377  txt->confine = true;
5378  txt->back_area::shadow = m_infos_style.back_shadow;
5379 
5380  txt->hjust = center;
5381 
5382  txt->strings.add(infos_title);
5383  m_infos_title_sep.add(txt);
5384 
5385  // to refine height below.
5386  infos_title_tsf = _tsf;
5387  infos_title_text = txt;
5388  }
5389 
5390  if(sinfos.empty()) return;
5391  if(!linen) return;
5392 
5393  matrix* _tsf = new matrix;
5394  m_infos_sep.add(_tsf);
5395 
5397  infos->width = wbox;
5398  //infos->height is an output field, see below.
5399  infos->back_area::color = m_infos_style.back_color;
5400  infos->color = m_infos_style.color;
5401  infos->font = m_infos_style.font;
5402  infos->encoding = m_infos_style.encoding;
5403  infos->font_modeling = m_infos_style.font_modeling;
5404  infos->line_width = m_infos_style.line_width;
5405  //infos->front_face = m_infos_style.front_face;
5406  infos->back_area::shadow = m_infos_style.back_shadow;
5407  infos->border_line_width = m_infos_style.line_width;
5408 
5409  {for(size_t index=0;index<linen;index++) {
5410  const std::string& name = ws[2*index];
5411  const std::string& value = ws[2*index+1];
5412  infos->lstrings.add(name);
5413  infos->rstrings.add(value);
5414  //a_out << "debug : name " << sout(name)
5415  // << " value " << sout(value) << std::endl;
5416  }}
5417 
5418  // enforce an infos::update_sg to get infos::height
5419  // to place the box.
5420  infos->update_sg();
5421 
5422  // if any, set infos_title height :
5423  float title_hbox = 0;
5424  if(infos_title_tsf && infos_title_text) {
5425  title_hbox = infos->height/linen;
5426  float xx = width*0.5f - wbox*0.5f - width*infos_x_margin;
5427  float yy = _height*0.5f - title_hbox*0.5F - _height*infos_y_margin;
5428  infos_title_tsf->set_identity();
5429  infos_title_tsf->mul_translate(xx,yy,zz);
5430  infos_title_tsf->mul_scale(1,1,_zscale_text());
5431 
5432  infos_title_text->height = title_hbox;
5433  }
5434 
5435  float hbox = infos->height;
5436  {float xx = width*0.5f -wbox*0.5f -width*infos_x_margin;
5437  float yy = _height*0.5f -hbox*0.5F - _height*infos_y_margin;
5438  yy -= title_hbox;
5439  _tsf->set_translate(xx,yy,zz);
5440  _tsf->mul_scale(1,1,_zscale_text());}
5441 
5443  }
5444 
5445 /*
5446  void update_legends(std::ostream& a_out){
5447  if(!legends_visible) return;
5448 
5449  if(m_legend_strings.empty()) return;
5450  if(m_legend_colors.size()!=m_legend_strings.size()) return;
5451 
5452  //m_legend_sep contains :
5453  // one global mtx
5454  // one sep per legend.
5455 
5456  {matrix* _tsf = new matrix;
5457  m_legend_sep.add(_tsf);
5458 
5459  float zz = _zinfos();
5460 
5461  //set legends layout :
5462  if(legends_attached_to_infos) {
5463  _tsf->set_translate(0,0,zz);
5464  } else {
5465  if(legends_origin_unit==unit_axis) {
5466 
5467  // legends_origin is in axes coordinates.
5468  float x = legends_origin.value()[0];
5469  float y = legends_origin.value()[1];
5470 
5471  vec3f pos;
5472  if(!axis_2_vp(vec3f(x,y,0),pos)) {
5473  //SoDebugError::postInfo("SoPlotterRegion::updateChildren",
5474  // "failed for %g %g.",x,y);
5475  } else {
5476  //pos is in NDC of [0,width][0,height].
5477 
5478  float xx = width * (-0.5f+pos[0]);
5479  float yy = height * (-0.5f+pos[1]);
5480 
5481  _tsf->set_translate(xx,yy,zz);
5482 
5483  }
5484 
5485  } else { //unit_percent
5486  // legends_origin is
5487  // the UR corner of legend region relative
5488  // to UR of plotter region.
5489  float xur = legends_origin.value()[0];
5490  float yur = legends_origin.value()[1];
5491 
5492  vec2f ur(1-xur,1-yur);
5493 
5494  float w = legends_size.value()[0];
5495  float h = legends_size.value()[1];
5496 
5497  float x = ur[0]-w;
5498  float y = ur[1]-h;
5499 
5500  float xx = width * (x-0.5f);
5501  float yy = height * (y-0.5f);
5502 
5503  _tsf->set_translate(xx,yy,zz);
5504 
5505  }
5506  }}
5507 
5508  size_t number = m_legend_strings.size();
5509  for(size_t index=0;index<number;index++) {
5510 
5511  separator* sep = new separator;
5512  m_legend_sep.add(sep);
5513 
5514  matrix* _tsf = new matrix;
5515  sep->add(_tsf);
5516 
5517  //sg::text* text = new sg::text;
5518  legend* text = new legend(m_ttf);
5519  //text->confine = true;
5520  text->strings.add(m_legend_strings[index]);
5521  sep->add(text);
5522  text->color = m_legend_colors[index];
5523 
5524  if(legends_attached_to_infos) {
5525  // global tsf should be the identity.
5526 
5527  // legend box geometry and placement is relative
5528  // to the infos box placement and geometry :
5529  if(m_infos_style.visible) {
5530  sg::infos_box* inode = get_infos_node();
5531  if(!inode) {delete sep;return;}
5532  matrix* imtx = get_infos_matrix();
5533  if(!imtx) {delete sep;return;}
5534 
5535  float wbox = inode->width;
5536  float hbox = inode->height/number;
5537 
5538  text->width = wbox;
5539  text->height = hbox;
5540 
5541  _tsf->mtx = imtx->mtx;
5542 
5543  float xx = width*0.5f-wbox*0.5f;
5544 
5545  float yy = height*0.5f-inode->height-hbox*0.5f-hbox*index;
5546 
5547  _tsf->set_translate(xx,yy,0);
5548 
5549  } else {
5550  float wbox = width * legends_size.value()[0];
5551  float hbox = (height * legends_size.value()[1])/number;
5552 
5553  text->width = wbox;
5554  text->height = hbox;
5555 
5556  float xx = width*0.5f-wbox*0.5f - width*infos_x_margin;
5557  float yy = height*0.5f-hbox*0.5F - height*infos_y_margin;
5558 
5559  yy -= hbox*index;
5560 
5561  _tsf->set_translate(xx,yy,0);
5562  }
5563 
5564  } else {
5565 
5566  //legends_size is in NDC of [0,width][0,height].
5567  float w = width * legends_size.value()[0];
5568  float h = height * legends_size.value()[1];
5569 
5570  text->width = w;
5571  text->height = h/number;
5572 
5573  float xx = w * 0.5f;
5574  float yy = text->height * 0.5f;
5575  yy += text->height*(number-index-1);
5576 
5577  _tsf->set_translate(xx,yy,0);
5578 
5579  }
5580  _tsf->mul_scale(1,1,_zscale_text());
5581 
5582  }
5583  }
5584 */
5585 
5586  void update_legends(std::ostream& a_out) {
5587  //::printf("debug : update_legends : begin\n");
5588  if(m_legend_strings.empty()) return;
5589  if(m_legend_strings.size()!=legends_origin.size()) return;
5590  if(legends_size.size()!=legends_origin.size()) return;
5591  if(legends_origin_unit.size()!=legends_origin.size()) return;
5592 
5593  float zz = _zinfos();
5594 
5595  {matrix* _tsf = new matrix;
5596  _tsf->mul_scale(1,1,_zscale_text());
5597  m_legend_sep.add(_tsf);}
5598 
5599  size_t number = m_legend_strings.size();
5600  //::printf("debug : update_legends : 001 %lu\n",number);
5601  for(size_t index=0;index<number;index++) {
5602  const style& _style = legend_style(index);
5603  if(!_style.visible) continue;
5604  //::printf("debug : update_legends : 002 %lu |%s|\n",index,m_legend_strings[index].c_str());
5605 
5606  separator* sep = new separator;
5607  m_legend_sep.add(sep);
5608 
5609  matrix* _tsf = new matrix;
5610  sep->add(_tsf);
5611 
5612  //sg::text* text = new sg::text;
5613  legend* text = new legend(m_ttf);
5614  text->font = _style.font;
5615  text->font_modeling = _style.font_modeling;
5616  text->encoding = _style.encoding;
5617  text->strings.add(m_legend_strings[index]);
5618  text->color = _style.color;
5619  text->marker_style = _style.marker_style;
5620  text->marker_size = _style.marker_size;
5621  text->back_visible = false;
5622  sep->add(text);
5623 
5624  //legends_size is in NDC of [0,width][0,height].
5625  float w = width * legends_size[index][0];
5626  float h = height * legends_size[index][1];
5627  text->width = w;
5628  text->height = h;
5629 
5630  float xxx = w * 0.5f;
5631  float yyy = h * 0.5f;
5632 
5633  if(legends_origin_unit[index]==unit_axis) {
5634 
5635  // legends_origin is in axes coordinates.
5636  float x = legends_origin[index][0];
5637  float y = legends_origin[index][1];
5638 
5639  vec3f pos;
5640  if(!axis_2_vp(vec3f(x,y,0),pos)) {
5641  a_out << "tools::sg::plotter::update_legends : axis_2_vp() failed for x=" << x << ", y=" << y << "." << std::endl;
5642  } else {
5643  //pos is in NDC of [0,width][0,height].
5644  float xx = width * (-0.5f+pos[0]);
5645  float yy = height * (-0.5f+pos[1]);
5646  _tsf->set_translate(xx,yy,zz);
5647  }
5648 
5649  } else { //unit_percent
5650  // legends_origin is
5651  // the UR corner of legend region relative
5652  // to UR of plotter region.
5653  float xur = legends_origin[index][0];
5654  float yur = legends_origin[index][1];
5655 
5656  vec2f ur(1-xur,1-yur);
5657 
5658  float x = width*ur[0] - w;
5659  float y = height*ur[1] - h;
5660 
5661  float xx = -width*0.5f + x;
5662  float yy = -height*0.5f + y;
5663 
5664  _tsf->set_translate(xx,yy,zz);
5665  }
5666 
5667  _tsf->mul_translate(xxx,yyy,0); //applied first.
5668 
5669  }
5670  }
5671 
5674  if(!m_background_style.visible) return;
5675 
5676  matrix* _tsf = new matrix;
5677  m_background_sep.add(_tsf);
5678 
5679  float w2 = width*0.5F;
5680  float h2 = height*0.5F;
5681 
5682  float zz = 0; //in xy, then before first data plane at _zoffset()
5683  if(m_shape==xyz) zz = -depth*0.5f;
5684 
5685  {rgba* mat = new rgba();
5686  if(m_background_style.line_width) { //there is a border.
5687  mat->color = m_background_style.color; //then border color !
5688  } else {
5690  }
5692 
5694 
5695  vertices* vtxs = new vertices;
5696  vtxs->mode = gl::triangle_fan();
5697  m_background_sep.add(vtxs);
5698 
5699  vtxs->add(-w2,-h2,zz);
5700  vtxs->add( w2,-h2,zz);
5701  vtxs->add( w2, h2,zz);
5702  vtxs->add(-w2, h2,zz);}
5703 
5704  if(m_background_style.line_width) { //border
5705  //WARNING : line_width should be in percent of width.
5706 
5707  //NOTE : border is done by drawing a front smaller polygon.
5708 
5709  rgba* mat = new rgba();
5710  mat->color = m_background_style.back_color; //yes,yes !
5712 
5713  vertices* vtxs = new vertices;
5714  vtxs->mode = gl::triangle_fan();
5715  m_background_sep.add(vtxs);
5716 
5717  //float d = width*0.005;
5719 
5720  zz += _zoffset()*0.5f;
5721 
5722  vtxs->add(-w2+d,-h2+d,zz);
5723  vtxs->add( w2-d,-h2+d,zz);
5724  vtxs->add( w2-d, h2-d,zz);
5725  vtxs->add(-w2+d, h2-d,zz);
5726  }
5727 
5728  }
5729 
5731  if(!m_inner_frame_style.visible) return;
5732 
5733  rgba* mat = new rgba();
5734  mat->color = m_inner_frame_style.color;
5736 
5737  draw_style* ds = new draw_style;
5738  ds->style = draw_lines;
5741  m_inner_frame_sep.add(ds);
5742 
5743  vertices* vtxs = new vertices;
5744  vtxs->mode = gl::line_strip();
5745  m_inner_frame_sep.add(vtxs);
5746 
5747  float zz = _zgrid();
5748 
5749  vtxs->add(0,0,zz);
5750  vtxs->add(1,0,zz);
5751  vtxs->add(1,1,zz);
5752  vtxs->add(0,1,zz);
5753  vtxs->add(0,0,zz);
5754  }
5755 
5757  if(!m_inner_frame_style.visible) return;
5758 
5759  rgba* mat = new rgba();
5760  mat->color = m_inner_frame_style.color;
5762 
5763  draw_style* ds = new draw_style;
5764  ds->style = draw_lines;
5767  m_inner_frame_sep.add(ds);
5768 
5769  vertices* ls = new vertices;
5770  ls->mode = gl::lines();
5771  m_inner_frame_sep.add(ls);
5772 
5773  // z bottom :
5774  ls->add(0,0,0);ls->add(1,0,0);
5775  ls->add(1,0,0);ls->add(1,1,0);
5776  ls->add(1,1,0);ls->add(0,1,0);
5777  ls->add(0,1,0);ls->add(0,0,0);
5778 
5779  // z top :
5780  ls->add(0,0,1);ls->add(1,0,1);
5781  ls->add(1,0,1);ls->add(1,1,1);
5782  ls->add(1,1,1);ls->add(0,1,1);
5783  ls->add(0,1,1);ls->add(0,0,1);
5784 
5785  // sides along z :
5786  ls->add(0,0,0);ls->add(0,0,1);
5787  ls->add(1,0,0);ls->add(1,0,1);
5788  ls->add(1,1,0);ls->add(1,1,1);
5789  ls->add(0,1,0);ls->add(0,1,1);
5790  }
5791 
5793  if(!m_grid_style.visible) return;
5794 
5795  unsigned int number = m_x_axis.tick_number + m_y_axis.tick_number;
5796  if(number<=0) return;
5797 
5798  bool draw_vertical = true;
5799  bool draw_horizontal = true;
5800  if(m_grid_style.options.value()=="vertical") draw_horizontal = false;
5801  if(m_grid_style.options.value()=="horizontal") draw_vertical = false;
5802 
5803  rgba* mat = new rgba();
5804  mat->color = m_grid_style.color;
5805  m_grid_sep.add(mat);
5806 
5807  draw_style* ds = new draw_style;
5808  ds->style = draw_lines;
5809  ds->line_pattern = line_solid;
5811  m_grid_sep.add(ds);
5812 
5813  float zz = _zgrid();
5814 
5815  vertices* vtxs = new vertices;
5816  vtxs->mode = gl::lines();
5817  m_grid_sep.add(vtxs);
5818 
5819  std::vector<float>& pts = vtxs->xyzs.values();
5820 
5821  bool is_solid = m_grid_style.line_pattern.value()==line_solid;
5822 
5823  if(draw_vertical) {
5824  float _width = m_y_axis.width;
5825  float xx;
5826  {size_t _number = m_x_axis.coords.size();
5827  if(is_solid) {
5828  pts.reserve(_number*6);
5829  for(size_t count=0;count<_number;count++) {
5830  xx = m_x_axis.coords[count];
5831  vtxs->add(xx, 0 ,zz);
5832  vtxs->add(xx, _width,zz);
5833  }
5834  } else {
5835  pts.reserve(_number*100*6);
5836  for(size_t count=0;count<_number;count++) {
5837  xx = m_x_axis.coords[count];
5838  vtxs->add_dashed_line(xx,0,zz,xx,_width,zz,100);
5839  }
5840  }}
5841  if(m_x_axis.is_log) {
5842  size_t _number = m_x_axis.sub_coords.size();
5843  if(is_solid) {
5844  pts.reserve(_number*6);
5845  for(size_t count=0;count<_number;count++) {
5846  xx = m_x_axis.sub_coords[count];
5847  vtxs->add(xx, 0 ,zz);
5848  vtxs->add(xx,_width,zz);
5849  }
5850  } else {
5851  pts.reserve(_number*100*6);
5852  for(size_t count=0;count<_number;count++) {
5853  xx = m_x_axis.sub_coords[count];
5854  vtxs->add_dashed_line(xx,0,zz,xx,_width,zz,100);
5855  }
5856  }
5857  }
5858  }
5859 
5860  if(draw_horizontal) {
5861  float _width = m_x_axis.width;
5862  float yy;
5863  {size_t _number = m_y_axis.coords.size();
5864  if(is_solid) {
5865  pts.reserve(_number*6);
5866  for(size_t count=0;count<_number;count++) {
5867  yy = m_y_axis.coords[count];
5868  vtxs->add(0,yy ,zz);
5869  vtxs->add(_width,yy,zz);
5870  }
5871  } else {
5872  pts.reserve(_number*100*6);
5873  for(size_t count=0;count<_number;count++) {
5874  yy = m_y_axis.coords[count];
5875  vtxs->add_dashed_line(0,yy,zz,_width,yy,zz,100);
5876  }
5877  }}
5878  if(m_y_axis.is_log) {
5879  size_t _number = m_y_axis.sub_coords.size();
5880  if(is_solid) {
5881  pts.reserve(_number*6);
5882  for(size_t count=0;count<_number;count++) {
5883  yy = m_y_axis.sub_coords[count];
5884  vtxs->add(0,yy, zz);
5885  vtxs->add(_width,yy,zz);
5886  }
5887  } else {
5888  pts.reserve(_number*100*6);
5889  for(size_t count=0;count<_number;count++) {
5890  yy = m_y_axis.sub_coords[count];
5891  vtxs->add_dashed_line(0,yy,zz,_width,yy,zz,100);
5892  }
5893  }
5894  }
5895  }
5896 
5897  }
5898 
5900  if(!m_grid_style.visible) return;
5901 
5902  rgba* mat = new rgba();
5903  mat->color = m_grid_style.color;
5904  m_grid_sep.add(mat);
5905 
5906  draw_style* ds = new draw_style;
5907  ds->style = draw_lines;
5910  m_grid_sep.add(ds);
5911 
5912 /*
5913  vertices* vtxs = new vertices;
5914  vtxs->mode = gl::line_strip();
5915  m_grid_sep.add(vtxs);
5916 
5917  float z = 0.5F;
5918 
5919  vtxs->add(0,0,z);
5920  vtxs->add(1,0,z);
5921  vtxs->add(1,1,z);
5922  vtxs->add(0,1,z);
5923  vtxs->add(0,0,z);
5924 */
5925 /*
5926  int ntick = m_z_axis.tickNumber;
5927  if(ntick<=0) return;
5928 
5929  SoSeparator* sep = (SoSeparator*)gridSeparator.value();
5930 
5931  sep->addChild(fStyleCache->getMaterial
5932  (style->color.value(),
5933  style->transparency.value()));
5934 
5935  sep->addChild(getLineStyle(*style));
5936 
5937  vec3f* points = new vec3f[4 * ntick];
5938  int pos = 0;
5939  for(int count=0;count<ntick;count++) {
5940  float xe = m_x_axis.width.value();
5941  float ye = m_y_axis.width.value();
5942  float zz = m_z_axis.coords[count];
5943  LIST_SET(points,pos,0 ,ye,zz);pos++;
5944  LIST_SET(points,pos,xe,ye,zz);pos++;
5945  LIST_SET(points,pos,xe,ye,zz);pos++;
5946  LIST_SET(points,pos,xe,0 ,zz);pos++;
5947  }
5948  if(pos>0) {
5949  SoCoordinate3* coordinate3 = new SoCoordinate3;
5950  int32_t pointn = pos;
5951  coordinate3->point.setValues(0,pointn,points);
5952  sep->addChild(coordinate3);
5953 
5954  SoLineSet* lineSet = new SoLineSet;
5955  int segmentn = pointn/2;
5956  int32_t* vertices = new int32_t[segmentn];
5957  for (int count=0;count<segmentn;count++) vertices[count] = 2;
5958  lineSet->numVertices.setValues(0,segmentn,vertices);
5959  delete [] vertices;
5960  sep->addChild(lineSet);
5961  }
5962 
5963  delete [] points;
5964 */
5965  }
5966 
5967 protected: //rep
5969  // reps xy /////////////////////////////////////////////////////////////////
5971  void rep_bins1D_xy_top_lines(const style& a_style,
5972  const base_colormap& a_cmap,
5973  const std::vector<rep_bin1D>& a_bins,
5974  const rep_box& a_box_x,
5975  const rep_box& a_box_y,
5976  float a_zz/*,
5977  const std::string& aID*/){
5978  painting_policy painting = a_style.painting;
5979 
5980  float xmin = a_box_x.m_pos;
5981  float dx = a_box_x.m_width;
5982  bool xlog = a_box_x.m_log;
5983 
5984  float ymin = a_box_y.m_pos;
5985  float dy = a_box_y.m_width;
5986  bool ylog = a_box_y.m_log;
5987 
5988  float y0 = 0;
5989  y0 = verify_log(y0,ymin,dy,ylog);
5990  if(y0<0) y0 = 0;
5991  if(y0>1) y0 = 1;
5992 
5993  separator* _sep = new separator();
5994 
5995  draw_style* ds = new draw_style;
5996  ds->style = draw_lines;
5997  ds->line_pattern = a_style.line_pattern;
5998  ds->line_width = a_style.line_width;
5999  _sep->add(ds);
6000 
6001  bool empty = true;
6002  colorf clr;
6003 
6004  float yp = 0;
6005  size_t xnbin = a_bins.size();
6006  for(size_t index=0;index<xnbin;index++) {
6007  float xx = a_bins[index].m_x_min;
6008  float xe = a_bins[index].m_x_max;
6009  float y = a_bins[index].m_val;
6010 
6011  float val = a_bins[index].m_val;
6012 
6013  xx = verify_log(xx,xmin,dx,xlog);
6014  xe = verify_log(xe,xmin,dx,xlog);
6015  y = verify_log(y,ymin,dy,ylog);
6016 
6017  // Clipping :
6018  if(xe<0) continue;
6019  if(xx>1) continue;
6020  if(xx<0) xx = 0;
6021  if(xe>1) xe = 1;
6022  if(y<0) y = 0;
6023  if(y>1) y = 1;
6024 
6025  separator* sep = new separator();
6026  _sep->add(sep);
6027 
6028  /*uuu
6029  a_bins[index].fSeparator = sep;
6030 
6031  {char s[128];
6032  //::sprintf(s,"%d",index);
6033  sep->setInfos(s);
6034  //::sprintf(s,"/0x%lx",(unsigned long)sep->getInfos());
6035  std::string sid = aID;
6036  sid += std::string(s);
6037  sep->setString(sid);}*/
6038 
6039  if(painting==painting_by_value) {
6040  a_cmap.get_color(val,clr);
6041  } else if( (painting==painting_grey_scale) ||
6042  (painting==painting_grey_scale_inverse) ||
6043  (painting==painting_violet_to_red) ){
6044  a_cmap.get_color(a_bins[index].m_ratio,clr);
6045  } else {
6046  clr = a_style.color;
6047  }
6048 
6049  rgba* mat = new rgba();
6050  mat->color = clr;
6051  sep->add(mat);
6052 
6053  vertices* vtxs = new vertices;
6054  vtxs->mode = gl::line_strip();
6055  sep->add(vtxs);
6056 
6057  vtxs->add(xx,yp,a_zz);
6058  vtxs->add(xx,y,a_zz);
6059  vtxs->add(xe,y,a_zz);
6060  if(index==xnbin-1){
6061  vtxs->add(xe,y0,a_zz);
6062  }
6063 
6064  empty = false;
6065  yp = y;
6066  }
6067 
6068  if(empty) {
6069  delete _sep;
6070  } else {
6071  m_bins_sep.add(_sep);
6072  }
6073  }
6074 
6075  void rep_bins1D_xy_points(std::ostream& a_out,
6076  const style& a_style,
6077  const base_colormap& a_cmap,
6078  const std::vector<rep_bin1D>& a_bins,
6079  const rep_box& a_box_x,
6080  const rep_box& a_box_y,
6081  float a_zz/*,
6082  const std::string& aID*/){
6083  //::printf("debug : tools::sg::plotter::rep_bins1D_xy_points : begin\n");
6084  float xmin = a_box_x.m_pos;
6085  float dx = a_box_x.m_width;
6086  bool xlog = a_box_x.m_log;
6087 
6088  float ymin = a_box_y.m_pos;
6089  float dy = a_box_y.m_width;
6090  bool ylog = a_box_y.m_log;
6091 
6092  painting_policy painting = a_style.painting;
6093 
6094  separator* _sep = new separator();
6095 
6096  if(a_style.modeling==modeling_points()) {
6097  draw_style* ds = new draw_style;
6098  ds->style = draw_points;
6099  ds->point_size = a_style.point_size;
6100  _sep->add(ds);
6101  }
6102 
6103  bool empty = true;
6104  colorf clr;
6105  size_t xnbin = a_bins.size();
6106  for(size_t index=0;index<xnbin;index++) {
6107  float x = (a_bins[index].m_x_min + a_bins[index].m_x_max)/2;
6108  float y = a_bins[index].m_val;
6109  float val = a_bins[index].m_val;
6110 
6111  x = verify_log(x,xmin,dx,xlog);
6112  y = verify_log(y,ymin,dy,ylog);
6113 
6114  if((x<0)||(x>1)||(y<0)||(y>1)) continue;
6115 
6116  //::printf("debug : tools::sg::plotter::rep_bins1D_xy_points : x %g, y %g, val %g\n",x,y,val);
6117 
6118  separator* sep = new separator();
6119  _sep->add(sep);
6120 
6121  //a_bins[index].fSeparator = sep;
6122 
6123  //{char s[128];
6124  // ::sprintf(s,"%d",index);
6125  // sep->setInfos(s);
6126  // ::sprintf(s,"/0x%lx",(unsigned long)sep->getInfos());
6127  // std::string sid = aID;
6128  // sid += std::string(s);
6129  // sep->setString(sid);}
6130 
6131  if(painting==painting_by_value) {
6132  a_cmap.get_color(val,clr);
6133  } else if( (painting==painting_grey_scale) ||
6134  (painting==painting_grey_scale_inverse) ||
6135  (painting==painting_violet_to_red) ){
6136  a_cmap.get_color(a_bins[index].m_ratio,clr);
6137  } else {
6138  clr = a_style.color;
6139  }
6140 
6141  rgba* mat = new rgba();
6142  mat->color = clr;
6143  sep->add(mat);
6144 
6145  if(a_style.modeling==modeling_points()) {
6146  vertices* vtxs = new vertices;
6147  vtxs->mode = gl::points();
6148  vtxs->add(x,y,a_zz);
6149  sep->add(vtxs);
6150  } else if(a_style.modeling==modeling_markers()) {
6151  markers* _marks = new markers;
6152  _marks->size = a_style.marker_size;
6153  _marks->style = a_style.marker_style;
6154  _marks->add(x,y,a_zz);
6155  sep->add(_marks);
6156  } else {
6157  a_out << "tools::sg::plotter::rep_bins1D_xy_points :"
6158  << " bad modeling style " << tools::sout(a_style.modeling) << std::endl;
6159  delete _sep;
6160  return;
6161  }
6162 
6163  empty = false;
6164  }
6165 
6166  if(empty) {
6167  delete _sep;
6168  } else {
6169  m_bins_sep.add(_sep);
6170  }
6171  }
6172 
6173  void rep_bins1D_xy_boxes(const style& a_style,
6174  const base_colormap& a_cmap,
6175  const std::vector<rep_bin1D>& a_bins,
6176  const rep_box& a_box_x,
6177  const rep_box& a_box_y,
6178  float a_zz //,const std::string& aID
6179  ){
6180  painting_policy painting = a_style.painting;
6181 
6182  float xmin = a_box_x.m_pos;
6183  float dx = a_box_x.m_width;
6184  bool xlog = a_box_x.m_log;
6185 
6186  float ymin = a_box_y.m_pos;
6187  float dy = a_box_y.m_width;
6188  bool ylog = a_box_y.m_log;
6189 
6190  separator* _sep = new separator();
6191 
6192  _sep->add(new normal);
6193 
6194  bool empty = true;
6195  colorf clr;
6196 
6197  tools_vforcit(rep_bin1D,a_bins,it) {
6198  const rep_bin1D& rbin = *it;
6199 
6200  float xx = rbin.m_x_min;
6201  float xe = rbin.m_x_max;
6202  float yy = rbin.m_v_min;
6203  float ye = rbin.m_val;
6204  if(ye<yy) {
6205  yy = rbin.m_val;
6206  ye = rbin.m_v_min;
6207  }
6208 
6209  float val = rbin.m_val;
6210 
6211  xx = verify_log(xx,xmin,dx,xlog);
6212  xe = verify_log(xe,xmin,dx,xlog);
6213  yy = verify_log(yy,ymin,dy,ylog);
6214  ye = verify_log(ye,ymin,dy,ylog);
6215 
6216  // Clipping :
6217  if(xx>1) continue;
6218  if(xe<0) continue;
6219  if(xx<0) xx = 0;
6220  if(xe>1) xe = 1;
6221  if(yy>1) continue;
6222  if(ye<0) continue;
6223  if(yy<0) yy = 0;
6224  if(ye>1) ye = 1;
6225 
6226  //FIXME if(ye<=yy) continue; //Else we shall have a tessellation error.
6227 
6228  separator* sep = new separator();
6229  _sep->add(sep);
6230 
6231  //a_bins[index].fSeparator = sep;
6232  //{char s[128];
6233  //::sprintf(s,"%d",index);
6234  //sep->setInfos(s);
6235  //::sprintf(s,"/0x%lx",(unsigned long)sep->getInfos());
6236  //std::string sid = aID;
6237  //sid += std::string(s);
6238  //sep->setString(sid);}
6239 
6240  if(painting==painting_by_value) {
6241  a_cmap.get_color(val,clr);
6242  } else if( (painting==painting_grey_scale) ||
6243  (painting==painting_grey_scale_inverse) ||
6244  (painting==painting_violet_to_red) ){
6245  a_cmap.get_color(rbin.m_ratio,clr);
6246  } else {
6247  clr = a_style.color;
6248  }
6249 
6250  rgba* mat = new rgba();
6251  mat->color = clr;
6252  sep->add(mat);
6253 
6254  vertices* vtxs = new vertices;
6255  vtxs->mode = gl::triangle_fan();
6256  sep->add(vtxs);
6257 
6258  vtxs->add(xx,yy,a_zz);
6259  vtxs->add(xe,yy,a_zz);
6260  vtxs->add(xe,ye,a_zz);
6261  vtxs->add(xx,ye,a_zz);
6262 
6263  empty = false;
6264  }
6265 
6266  if(empty) {
6267  delete _sep;
6268  } else {
6269  m_bins_sep.add(_sep);
6270  }
6271  }
6272 
6273  void rep_bins1D_xy_wire_boxes(const style& a_style,
6274  const base_colormap& a_cmap,
6275  const std::vector<rep_bin1D>& a_bins,
6276  const rep_box& a_box_x,const rep_box& a_box_y,
6277  float a_zz,
6278  bool a_bar_chart/*,
6279  const std::string& aID*/){
6280 
6281  painting_policy painting = a_style.painting;
6282 
6283  float xmin = a_box_x.m_pos;
6284  float dx = a_box_x.m_width;
6285  bool xlog = a_box_x.m_log;
6286 
6287  float ymin = a_box_y.m_pos;
6288  float dy = a_box_y.m_width;
6289  bool ylog = a_box_y.m_log;
6290 
6291  separator* _sep = new separator();
6292 
6293  bool empty = true;
6294  colorf clr;
6295 
6296  tools_vforcit(rep_bin1D,a_bins,it) {
6297  const rep_bin1D& rbin = *it;
6298 
6299  float xx = rbin.m_x_min;
6300  float xe = rbin.m_x_max;
6301  float yy = rbin.m_v_min;
6302  float ye = rbin.m_val;
6303  if(ye<yy) {
6304  yy = rbin.m_val;
6305  ye = rbin.m_v_min;
6306  }
6307 
6308  float val = rbin.m_val;
6309 
6310  if(a_bar_chart) {
6311  bar_chart(a_style.bar_offset.value(),
6312  a_style.bar_width.value(),xx,xe);
6313  }
6314 
6315  xx = verify_log(xx,xmin,dx,xlog);
6316  xe = verify_log(xe,xmin,dx,xlog);
6317  yy = verify_log(yy,ymin,dy,ylog);
6318  ye = verify_log(ye,ymin,dy,ylog);
6319 
6320  // Clipping :
6321  if(xx>1) continue;
6322  if(xe<0) continue;
6323  if(xx<0) xx = 0;
6324  if(xe>1) xe = 1;
6325  if(yy>1) continue;
6326  if(ye<0) continue;
6327  if(yy<0) yy = 0;
6328  if(ye>1) ye = 1;
6329 
6330  separator* sep = new separator();
6331  _sep->add(sep);
6332 
6333  //{char s[128];
6334  //::sprintf(s,"%d",index);
6335  //sep->setInfos(s);
6336  //::sprintf(s,"/0x%lx",(unsigned long)sep->getInfos());
6337  //std::string sid = aID;
6338  //sid += std::string(s);
6339  //sep->setString(sid);}
6340 
6341  if(painting==painting_by_value) {
6342  a_cmap.get_color(val,clr);
6343  } else if( (painting==painting_grey_scale) ||
6344  (painting==painting_grey_scale_inverse) ||
6345  (painting==painting_violet_to_red) ){
6346  a_cmap.get_color(rbin.m_ratio,clr);
6347  } else {
6348  clr = a_style.color;
6349  }
6350 
6351  rgba* mat = new rgba();
6352  mat->color = clr;
6353  sep->add(mat);
6354 
6355  vertices* vtxs = new vertices;
6356  vtxs->mode = gl::line_strip();
6357  sep->add(vtxs);
6358 
6359  vtxs->add(xx,yy,a_zz);
6360  vtxs->add(xe,yy,a_zz);
6361  vtxs->add(xe,ye,a_zz);
6362  vtxs->add(xx,ye,a_zz);
6363  vtxs->add(xx,yy,a_zz);
6364 
6365  empty = false;
6366  }
6367 
6368  if(empty) {
6369  delete _sep;
6370  } else {
6371  m_bins_sep.add(_sep);
6372  }
6373  }
6374 
6375  void rep_bins1D_xy_lines_one(const style& a_style,const std::vector<rep_bin1D>& a_bins,
6376  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz/*,const SbString& aID*/) {
6377  // Draw lines connecting top middle of bins.
6378 
6379  //::printf("debug : rep_bins2D_lines_one\n");
6380 
6381  size_t xnbin = a_bins.size();
6382  std::vector<vec3f> points(xnbin);
6383  for(size_t index=0;index<xnbin;index++) {
6384  float x = (a_bins[index].m_x_min + a_bins[index].m_x_max)/2;
6385  float y = a_bins[index].m_val;
6386  points[index] = vec3f(x,y,a_zz);
6387  }
6388 
6389  vertices* vtxs = new vertices;
6390  std::vector<float>& pts = vtxs->xyzs.values(); //npt*3
6391 
6392  clip_polyline_2D(points,a_box_x,a_box_y,pts);
6393  if(pts.size()) {
6395  //separator->setString(aID);
6396 
6397  rgba* mat = new rgba();
6398  mat->color = a_style.color;
6399  separator->add(mat);
6400 
6401  draw_style* ds = new draw_style;
6402  ds->style = draw_lines;
6403  ds->line_pattern = a_style.line_pattern;
6404  ds->line_width = a_style.line_width;
6405  separator->add(ds);
6406 
6407  vtxs->mode = gl::line_strip();
6408  separator->add(vtxs);
6409 
6411  } else {
6412  delete vtxs;
6413  }
6414  }
6415 
6416  void rep_bins1D_xy_curve_one(std::ostream& a_out,const style& a_style,const std::vector<rep_bin1D>& a_bins,
6417  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz/*,const SbString& aID*/){
6418  //::printf("debug : rep_bins1D_curve_one\n");
6419 
6420  size_t number = a_bins.size();
6421  if(!number) return;
6422 
6423  double* xs = new double[number];
6424  double* ys = new double[number];
6425  float x,y;
6426  for(size_t index=0;index<number;index++) {
6427  x = (a_bins[index].m_x_min + a_bins[index].m_x_max)/2;
6428  y = a_bins[index].m_val;
6429  xs[index] = x;ys[index] = y;
6430  }
6431  spline::cubic _spline(a_out,number,xs,ys);
6432  //spline::quintic _spline(a_out,number,xs,ys);
6433  delete [] xs;delete [] ys;
6434 
6435  float xmn = m_x_axis_data.min_value();
6436  float xmx = m_x_axis_data.max_value();
6437  unsigned int nstp = curve_number_of_points;
6438  float step = (xmx - xmn)/nstp;
6439  std::vector<vec3f> points(nstp+1);
6440  for(unsigned int ibin=0;ibin<=nstp;ibin++) {
6441  float xx = xmn + ibin * step;
6442  double val = _spline.eval(xx);
6443  points[ibin].set_value(xx,float(val),a_zz);
6444  }
6445 
6446  vertices* vtxs = new vertices;
6447  std::vector<float>& pts = vtxs->xyzs.values(); //npt*3
6448 
6449  clip_polyline_2D(points,a_box_x,a_box_y,pts);
6450  if(pts.size()) {
6452  //separator->setString(aID);
6453 
6454  rgba* mat = new rgba();
6455  mat->color = a_style.color;
6456  separator->add(mat);
6457 
6458  draw_style* ds = new draw_style;
6459  ds->style = draw_lines;
6460  ds->line_pattern = a_style.line_pattern;
6461  ds->line_width = a_style.line_width;
6462  separator->add(ds);
6463 
6464  vtxs->mode = gl::line_strip();
6465  separator->add(vtxs);
6466 
6468  } else {
6469  delete vtxs;
6470  }
6471 
6472  }
6473 
6474 
6475  void rep_bins2D_xy_box(const style& a_style,const std::vector<rep_bin2D>& a_bins,
6476  const rep_box& a_box_x,const rep_box& a_box_y,float a_bmin,float a_bmax,float a_zz) {
6477  // Draw box of size proportionnal to bin value.
6478 
6479  //std::cout << "debug : tools::sg::plotter::rep_bins2D_xy_box" << std::endl;
6480 
6481  separator* _sep = new separator();
6482 
6483  _sep->add(new normal);
6484 
6485  rgba* mat = new rgba();
6486  mat->color = a_style.color;
6487  _sep->add(mat);
6488 
6489  float xmin = a_box_x.m_pos;
6490  float dx = a_box_x.m_width;
6491  bool xlog = a_box_x.m_log;
6492 
6493  float ymin = a_box_y.m_pos;
6494  float dy = a_box_y.m_width;
6495  bool ylog = a_box_y.m_log;
6496 
6497  bool empty = true;
6498  float range = a_bmax - a_bmin;
6499 
6500  tools_vforcit(rep_bin2D,a_bins,it) {
6501  const rep_bin2D& rbin = *it;
6502 
6503  float xx = rbin.m_x_min;
6504  float xe = rbin.m_x_max;
6505  float yy = rbin.m_y_min;
6506  float ye = rbin.m_y_max;
6507  float val = rbin.m_val;
6508 
6509  float xsize,ysize;
6510  if(range>0) {
6511  // If val = bmax, the box maps the cell.
6512  xsize = (val - a_bmin) * (xe - xx) / range;
6513  ysize = (val - a_bmin) * (ye - yy) / range;
6514  } else {
6515  //If range is 0. ; then all bins that have
6516  // entries have same values. Draw box xdbin * ydbin.
6517  xsize = xe - xx;
6518  ysize = ye - yy;
6519  }
6520 
6521  xx = xx + ((xe-xx) - xsize)/2;
6522  xe = xx + xsize;
6523  yy = yy + ((ye-yy) - ysize)/2;
6524  ye = yy + ysize;
6525 
6526  xx = verify_log(xx ,xmin,dx ,xlog);
6527  xe = verify_log(xe ,xmin,dx ,xlog);
6528  yy = verify_log(yy ,ymin,dy ,ylog);
6529  ye = verify_log(ye ,ymin,dy ,ylog);
6530 
6531  // Clipping :
6532  if(xx>1) continue;
6533  if(xe<0) continue;
6534  if(xx<0) xx = 0;
6535  if(xe>1) xe = 1;
6536  if(yy>1) continue;
6537  if(ye<0) continue;
6538  if(yy<0) yy = 0;
6539  if(ye>1) ye = 1;
6540 
6541  //sg::separator* sep = new separator();
6542  //_sep->add(sep);
6543 
6544  /*{char s[128];
6545  //::sprintf(s,"%d %d",rbin.fI,rbin.fJ);
6546  sep->setInfos(s);
6547  //::sprintf(s,"/0x%lx",(unsigned long)sep->getInfos());
6548  std::string sid = aID;
6549  sid += std::string(s);
6550  sep->setString(sid);}*/
6551 
6552  vertices* vtxs = new vertices;
6553  vtxs->mode = gl::triangle_fan();
6554  //sep->add(vtxs);
6555  _sep->add(vtxs);
6556 
6557  vtxs->add(xx,yy,a_zz);
6558  vtxs->add(xe,yy,a_zz);
6559  vtxs->add(xe,ye,a_zz);
6560  vtxs->add(xx,ye,a_zz);
6561 
6562  empty = false;
6563  }
6564 
6565  if(empty) {
6566  delete _sep;
6567  } else {
6568  m_bins_sep.add(_sep);
6569  }
6570  }
6571 
6572  void rep_bins2D_xy_wire_box(const style& a_style,
6573  const std::vector<rep_bin2D>& a_bins,
6574  const rep_box& a_box_x,const rep_box& a_box_y,
6575  float a_bmin,float a_bmax,float a_zz
6576  /*,const SbString& aID*/){
6577  // Draw box of size proportionnal to bin value.
6578 
6580 
6581  rgba* mat = new rgba();
6582  mat->color = a_style.color;
6583  separator->add(mat);
6584 
6585  draw_style* ds = new draw_style;
6586  ds->style = draw_lines;
6587  ds->line_pattern = a_style.line_pattern;
6588  ds->line_width = a_style.line_width;
6589  separator->add(ds);
6590 
6591  vertices* vtxs = new vertices;
6592  vtxs->mode = gl::lines();
6593  separator->add(vtxs);
6594 
6595  bool empty = true;
6596 
6597  float xmin = a_box_x.m_pos;
6598  float dx = a_box_x.m_width;
6599  bool xlog = a_box_x.m_log;
6600 
6601  float ymin = a_box_y.m_pos;
6602  float dy = a_box_y.m_width;
6603  bool ylog = a_box_y.m_log;
6604 
6605  float range = a_bmax - a_bmin;
6606  size_t number = a_bins.size();
6607  for(size_t index=0;index<number;index++) {
6608 
6609  float xx = a_bins[index].m_x_min;
6610  float xe = a_bins[index].m_x_max;
6611  float yy = a_bins[index].m_y_min;
6612  float ye = a_bins[index].m_y_max;
6613  float val = a_bins[index].m_val;
6614 
6615  float xsize,ysize;
6616  if(range>0) {
6617  // If val = bmax, the box maps the cell.
6618  xsize = (val - a_bmin) * (xe - xx) / range;
6619  ysize = (val - a_bmin) * (ye - yy) / range;
6620  } else {
6621  //If range is 0. ; then all bins that have
6622  // entries have same values. Draw box xdbin * ydbin.
6623  xsize = xe - xx;
6624  ysize = ye - yy;
6625  }
6626 
6627  xx = xx + ((xe-xx) - xsize)/2;
6628  xe = xx + xsize;
6629  yy = yy + ((ye-yy) - ysize)/2;
6630  ye = yy + ysize;
6631 
6632  xx = verify_log(xx ,xmin,dx ,xlog);
6633  xe = verify_log(xe ,xmin,dx ,xlog);
6634  yy = verify_log(yy ,ymin,dy ,ylog);
6635  ye = verify_log(ye ,ymin,dy ,ylog);
6636 
6637  // Clipping :
6638  if(xx>1) continue;
6639  if(xe<0) continue;
6640  if(xx<0) xx = 0;
6641  if(xe>1) xe = 1;
6642  if(yy>1) continue;
6643  if(ye<0) continue;
6644  if(yy<0) yy = 0;
6645  if(ye>1) ye = 1;
6646 
6647  //::printf("debug : zzzzuu : %g %g %g %g\n",xx,xe,yy,ye);
6648 
6649  //{char s[128];
6650  // ::sprintf(s,"%d %d",a_bins[index].fI,a_bins[index].fJ);
6651  // sep->setInfos(s);}
6652  //{std::string sp;
6653  // if(!p2sx(sep->getInfos(),sp)){}
6654  // std::string sid(aID.getString());
6655  // sid += "/"+sp;
6656  // sep->setString(sid.c_str());}
6657 
6658  //vertices* vtxs = new vertices;
6659  //vtxs->mode = gl::line_strip();
6660  //separator->add(vtxs);
6661  //vtxs->add(xx,yy,a_zz);
6662  //vtxs->add(xe,yy,a_zz);
6663  //vtxs->add(xe,ye,a_zz);
6664  //vtxs->add(xx,ye,a_zz);
6665  //vtxs->add(xx,yy,a_zz);
6666 
6667  vtxs->add(xx,yy,a_zz);
6668  vtxs->add(xe,yy,a_zz);
6669 
6670  vtxs->add(xe,yy,a_zz);
6671  vtxs->add(xe,ye,a_zz);
6672 
6673  vtxs->add(xe,ye,a_zz);
6674  vtxs->add(xx,ye,a_zz);
6675 
6676  vtxs->add(xx,ye,a_zz);
6677  vtxs->add(xx,yy,a_zz);
6678 
6679  empty = false;
6680  }
6681 
6682  if(empty) {
6683  delete separator;
6684  } else {
6686  }
6687  }
6688 
6689  void rep_bins2D_xy_solid(const style& a_style,const base_colormap& a_cmap,const std::vector<rep_bin2D>& a_bins,
6690  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz) {
6691  painting_policy painting = a_style.painting;
6692 
6693  separator* _sep = new separator();
6694 
6695  _sep->add(new normal);
6696 
6697  float xmin = a_box_x.m_pos;
6698  float dx = a_box_x.m_width;
6699  bool xlog = a_box_x.m_log;
6700 
6701  float ymin = a_box_y.m_pos;
6702  float dy = a_box_y.m_width;
6703  bool ylog = a_box_y.m_log;
6704 
6705  bool empty = true;
6706  colorf clr;
6707 
6708  tools_vforcit(rep_bin2D,a_bins,it) {
6709  const rep_bin2D& rbin = *it;
6710 
6711  float xx = rbin.m_x_min;
6712  float xe = rbin.m_x_max;
6713  float yy = rbin.m_y_min;
6714  float ye = rbin.m_y_max;
6715  float val = rbin.m_val;
6716 
6717  xx = verify_log(xx ,xmin,dx ,xlog);
6718  xe = verify_log(xe ,xmin,dx ,xlog);
6719  yy = verify_log(yy ,ymin,dy ,ylog);
6720  ye = verify_log(ye ,ymin,dy ,ylog);
6721 
6722  // Clipping :
6723  if(xx>1) continue;
6724  if(xe<0) continue;
6725  if(xx<0) xx = 0;
6726  if(xe>1) xe = 1;
6727  if(yy>1) continue;
6728  if(ye<0) continue;
6729  if(yy<0) yy = 0;
6730  if(ye>1) ye = 1;
6731 
6732  if(painting==painting_by_value) {
6733  a_cmap.get_color(val,clr);
6734  } else if( (painting==painting_grey_scale) ||
6735  (painting==painting_grey_scale_inverse) ||
6736  (painting==painting_violet_to_red) ){
6737  a_cmap.get_color(rbin.m_ratio,clr);
6738  } else {
6739  clr = a_style.color;
6740  }
6741 
6742  rgba* mat = new rgba();
6743  mat->color = clr;
6744  _sep->add(mat);
6745 
6746  vertices* vtxs = new vertices;
6747  vtxs->mode = gl::triangle_fan();
6748  //sep->add(vtxs);
6749  _sep->add(vtxs);
6750 
6751  vtxs->add(xx,yy,a_zz);
6752  vtxs->add(xe,yy,a_zz);
6753  vtxs->add(xe,ye,a_zz);
6754  vtxs->add(xx,ye,a_zz);
6755 
6756  empty = false;
6757  }
6758 
6759  if(empty) {
6760  delete _sep;
6761  } else {
6762  m_bins_sep.add(_sep);
6763  }
6764  }
6765 
6766  void rep_bins2D_xy_random_one(const style& a_style,const std::vector<rep_bin2D>& a_bins,
6767  const rep_box& a_box_x,const rep_box& a_box_y,float a_bmin,float a_bmax,float a_zz
6768  /*,const SbString& aID*/){
6769  //::printf("debug : rep_bins2D_xy_random_one\n");
6770 
6772 
6773  rgba* mat = new rgba();
6774  mat->color = a_style.color;
6775  separator->add(mat);
6776 
6777  draw_style* ds = new draw_style;
6778  ds->style = draw_points;
6779  ds->point_size = a_style.point_size;
6780  separator->add(ds);
6781 
6782  float xmin = a_box_x.m_pos;
6783  float dx = a_box_x.m_width;
6784  bool xlog = a_box_x.m_log;
6785 
6786  float ymin = a_box_y.m_pos;
6787  float dy = a_box_y.m_width;
6788  bool ylog = a_box_y.m_log;
6789 
6790  // Draw for each bins a number of random
6791  // points proportiannal to bins range.
6792 
6793  float range = a_bmax - a_bmin;
6794 
6795  bool empty = true;
6796 
6797  size_t number = a_bins.size();
6798  for(size_t index=0;index<number;index++) {
6799 
6800  float xx = a_bins[index].m_x_min;
6801  float xe = a_bins[index].m_x_max;
6802  float yy = a_bins[index].m_y_min;
6803  float ye = a_bins[index].m_y_max;
6804  float val = a_bins[index].m_val;
6805 
6806  // If range is 0. ; then all bins that have entries
6807  // have same values. Draw one point.
6808 
6809  int nmin = 1;
6810  int nmax = 50;
6811  int npt = range>0. ? (int)((val - a_bmin)*(nmax-nmin)/range + nmin):1;
6812  if(npt>0) {
6813  vertices* vtxs = new vertices;
6814  vtxs->mode = gl::points();
6815  separator->add(vtxs);
6816 
6817  int ipt = 0;
6818  float xdbin = xe - xx;
6819  float ydbin = ye - yy;
6820  for(int count=0;count<npt;count++) {
6821  float xxx = xx + xdbin * m_rtausmef.shoot();
6822  float yyy = yy + ydbin * m_rtausmef.shoot();
6823  xxx = verify_log(xxx ,xmin,dx ,xlog);
6824  yyy = verify_log(yyy ,ymin,dy ,ylog);
6825  if((xxx>=0)&&(xxx<=1) &&
6826  (yyy>=0)&&(yyy<=1) ) {
6827  vtxs->add(xxx,yyy,a_zz);
6828  empty = false;
6829  ipt++;
6830  }
6831  }
6832  }
6833 
6834  }//end for
6835 
6836  if(empty) {
6837  delete separator;
6838  } else {
6840  }
6841  }
6842 
6844  const style& //a_style
6845  ,const std::vector<rep_bin2D>& //a_bins
6846  ,const rep_box& //a_box_x
6847  ,const rep_box& //a_box_y
6848  //,const SbString& aID
6849  ){
6850  //Draw box and text for number of entries.
6851  ::printf("debug : rep_bins2D_xy_text : dummy\n");
6852 
6853  /*
6854  sg::separator* separator = new sg::separator;
6855 
6856  //bool drawWireBoxe = false;
6857 
6858  bool empty = true;
6859 
6860  float xmin = a_box_x.m_pos;
6861  float dx = a_box_x.m_width;
6862  bool xlog = a_box_x.m_log;
6863 
6864  float ymin = a_box_y.m_pos;
6865  float dy = a_box_y.m_width;
6866  bool ylog = a_box_y.m_log;
6867 
6868  vec3f points[5];
6869 
6870  for(unsigned int index=0;index<a_bins.size();index++) {
6871 
6872  float xx = a_bins[index].m_x_min;
6873  float xe = a_bins[index].m_x_max;
6874  float yy = a_bins[index].m_y_min;
6875  float ye = a_bins[index].m_y_max;
6876  float val = a_bins[index].m_val;
6877 
6878  int ival = (int)val;
6879  if(ival==0) continue;
6880 
6881  xx = VerifyLog(xx ,xmin,dx ,xlog);
6882  xe = VerifyLog(xe ,xmin,dx ,xlog);
6883  yy = VerifyLog(yy ,ymin,dy ,ylog);
6884  ye = VerifyLog(ye ,ymin,dy ,ylog);
6885 
6886  // Clipping :
6887  if(xx>1) continue;
6888  if(xe<0) continue;
6889  if(xx<0) xx = 0;
6890  if(xe>1) xe = 1;
6891  if(yy>1) continue;
6892  if(ye<0) continue;
6893  if(yy<0) yy = 0;
6894  if(ye>1) ye = 1;
6895 
6896  char sval[32];
6897  ::sprintf (sval,"%d",ival);
6898  SbString sbval(sval);
6899  int charn = sbval.getLength();
6900  if(charn<=0) continue;
6901 
6902  SoSceneGraph* sep = new SoSceneGraph;
6903  separator->addChild(sep);
6904 
6905  {char s[128];
6906  ::sprintf(s,"%d %d",a_bins[index].fI,a_bins[index].fJ);
6907  sep->setInfos(s);}
6908  {std::string sp;
6909  if(!p2sx(sep->getInfos(),sp)){}
6910  std::string sid(aID.getString());
6911  sid += "/"+sp;
6912  sep->setString(sid.c_str());}
6913 
6914  SoMaterial* material =
6915  fStyleCache->getMaterial(a_style.color.getValue(),
6916  a_style.transparency.getValue());
6917  sep->addChild(material);
6918 
6919  sep->addChild(getLineStyle(a_style));
6920 
6921  float dx = xe-xx;
6922  float dy = ye-yy;
6923 
6924  if(drawWireBoxe) {
6925  LIST_SET(points,0,xx,yy,0);
6926  LIST_SET(points,1,xe,yy,0);
6927  LIST_SET(points,2,xe,ye,0);
6928  LIST_SET(points,3,xx,ye,0);
6929  LIST_SET(points,4,xx,yy,0);
6930  coordIndex[0] = icoord + 0;
6931  coordIndex[1] = icoord + 1;
6932  coordIndex[2] = icoord + 2;
6933  coordIndex[3] = icoord + 3;
6934  coordIndex[4] = icoord + 4;
6935  coordIndex[5] = SO_END_LINE_INDEX;
6936 
6937  coordinate3->point.setValues(icoord,5,points);
6938  icoord += 5;
6939 
6940  SoIndexedLineSet* lineSet = new SoIndexedLineSet;
6941  lineSet->coordIndex.setValues(0,6,coordIndex);
6942  sep->addChild(lineSet);
6943  }
6944 
6945  float x = xx + 0.1F * dx;
6946  float y = yy + 0.1F * dy;
6947  float z = 0;
6948  float w = dx * 0.5F;
6949  float h = dy * 0.5F;
6950 
6951  SoTransform* transform = new SoTransform;
6952  transform->scaleFactor.setValue(vec3f(w/charn,h,1));
6953  transform->translation.setValue(x,y,z);
6954  sep->addChild(transform);
6955 
6956  SoTextHershey* text = new SoTextHershey;
6957  text->string.setValue(sbval);
6958  sep->addChild (text);
6959 
6960  empty = false;
6961  }
6962 
6963  if(empty) {
6964  delete separator;
6965  } else {
6966  m_bins_sep.add(separator);
6967  }
6968  */
6969  }
6970 
6971  void rep_contour_xy(std::ostream& a_out,const style& a_style,painting_policy a_painting,
6972  const base_colormap& a_cmap,clist_contour& a_contour,
6973  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z,float a_zz
6974  /*,const std::string& aID*/){
6975  //a_out << "debug : rep_contour_xy :" << std::endl;
6976 
6977  float xmin = a_box_x.m_pos;
6978  float dx = a_box_x.m_width;
6979  bool xlog = a_box_x.m_log;
6980 
6981  float ymin = a_box_y.m_pos;
6982  float dy = a_box_y.m_width;
6983  bool ylog = a_box_y.m_log;
6984 
6985  float zmin = a_box_z.m_pos;
6986  float dz = a_box_z.m_width;
6987  //bool zlog = a_box_z.m_log;
6988 
6990  //separator->setString(aID);
6991 
6992  draw_style* ds = new draw_style;
6993  ds->style.value(draw_lines);
6994  ds->line_pattern.value(a_style.line_pattern);
6995  ds->line_width.value(a_style.line_width);
6996  separator->add(ds);
6997 
6998  atb_vertices* vtxs = new atb_vertices;
6999  vtxs->mode = gl::lines(); //segments
7000  separator->add(vtxs);
7001 
7002  bool empty = true;
7003 
7004  for (unsigned int i=0;i<a_contour.get_number_of_planes();i++) {
7005  cline_strip_list* pStripList = a_contour.get_lines(i);
7006  if(!pStripList) {
7007  a_out << "tools::sg;:plotter::rep_contour_xy : problem with contour." << std::endl;
7008  delete separator;
7009  return;
7010  }
7011 
7012  //If zlog true, zz is already in log.
7013  float val = (float)a_contour.get_plane(i);
7014  float zz = val;
7015 
7016  zz = verify_log(zz,zmin,dz,false);
7017  if(zz>1) continue;
7018  if(zz<0) continue;
7019 
7020  colorf _color;
7021  if(a_painting==painting_by_value) {
7022  a_cmap.get_color(val,_color);
7023  } else if(a_painting==painting_by_level) {
7024  size_t icol = a_cmap.colorn() ? (i % a_cmap.colorn()) :0;
7025  _color = a_cmap.color(icol);
7026  } else {
7027  _color = a_style.color;
7028  }
7029 
7030  tools_lforcit(cline_strip*,*pStripList,pos) {
7031  cline_strip* pStrip = (*pos);
7032  if(!pStrip) {
7033  a_out << "tools::sg;:plotter::rep_contour_xy : problem with contour." << std::endl;
7034  delete separator;
7035  return;
7036  }
7037  if (pStrip->empty()) continue;
7038 
7041  //unsigned int index=pStrip->front();
7042  //double xb=a_contour.get_xi(index);
7043  //double yb=a_contour.get_yi(index);
7046  //index=pStrip->back();
7047  //double xe=a_contour.get_xi(index);
7048  //double ye=a_contour.get_yi(index);
7049 
7050  bool first = true;
7051  float xprev = 0;
7052  float yprev = 0;
7053  float xx,yy;
7054 
7055  tools_lforcit(unsigned int,*pStrip,pos2) {
7056  xx = (float)a_contour.get_xi(*pos2);
7057  yy = (float)a_contour.get_yi(*pos2);
7058  xx = verify_log(xx,xmin,dx,xlog);
7059  yy = verify_log(yy,ymin,dy,ylog);
7060  if(
7061  (xx<0) || (xx>1) ||
7062  (yy<0) || (yy>1)
7063  ) {
7064  // Throw away this strip :
7065  }
7066  if(first) {
7067  first = false;
7068  } else {
7069  vtxs->add(xprev,yprev,a_zz+zz);
7070  vtxs->add(xx,yy,a_zz+zz);
7071  vtxs->add_color(_color);
7072  vtxs->add_color(_color);
7073  }
7074  xprev = xx;
7075  yprev = yy;
7076 
7077  empty = false;
7078  }
7079  }
7080 
7081  }
7082 
7083  if(empty) {
7084  delete separator;
7085  } else {
7087  }
7088  }
7089 
7090  void rep_contour_xy_filled(std::ostream& a_out,const style& a_style,painting_policy a_painting,
7091  const base_colormap& a_cmap,clist_contour& a_contour,
7092  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z,float a_zz
7093  /*,const std::string& aID*/){
7094  //a_out << "debug : rep_contour_xy_filled :" << std::endl;
7095 
7096  float xmin = a_box_x.m_pos;
7097  float dx = a_box_x.m_width;
7098  bool xlog = a_box_x.m_log;
7099 
7100  float ymin = a_box_y.m_pos;
7101  float dy = a_box_y.m_width;
7102  bool ylog = a_box_y.m_log;
7103 
7104  float zmin = a_box_z.m_pos;
7105  float dz = a_box_z.m_width;
7106  //bool zlog = a_box_z.m_log;
7107 
7109  //separator->setString(aID);
7110 
7111  vec3f AB,BC,vcross;
7112 
7113  {// Draw background :
7115  separator->add(sep);
7116 
7117  float zz = a_zz - 0.01F;
7118 
7119  colorf _color;
7120  if(a_cmap.colorn()) {
7121  _color = a_cmap.color(0);
7122  } else {
7123  _color = a_style.color;
7124  }
7125 
7126  rgba* mat = new rgba();
7127  mat->color = _color;
7128  sep->add(mat);
7129 
7130  float xx = xmin;
7131  float xe = xmin+dx;
7132  float yy = ymin;
7133  float ye = ymin+dy;
7134 
7135  xx = verify_log(xx,xmin,dx,xlog);
7136  xe = verify_log(xe,xmin,dx,xlog);
7137  yy = verify_log(yy,ymin,dy,ylog);
7138  ye = verify_log(ye,ymin,dy,ylog);
7139 
7140  vertices* vtxs = new vertices;
7141  vtxs->mode = gl::triangle_fan();
7142  vtxs->add(xx,yy,zz);
7143  vtxs->add(xe,yy,zz);
7144  vtxs->add(xe,ye,zz);
7145  vtxs->add(xx,ye,zz);
7146  sep->add(vtxs);
7147 
7148  } // End background.
7149 
7150  bool empty = true;
7151 
7152  for (unsigned int i=0;i<a_contour.get_number_of_planes();i++) {
7153 
7154  cline_strip_list* pStripList = a_contour.get_lines(i);
7155  if(!pStripList) {
7156  a_out << "tools::sg;:plotter::rep_contour_xy_filled : problem with contour." << std::endl;
7157  delete separator;
7158  return;
7159  }
7160 
7162  separator->add(sep);
7163 
7164  //If zlog true, zz is already in log.
7165  float val = (float)a_contour.get_plane(i);
7166  float zz = val;
7167 
7168  zz = verify_log(zz,zmin,dz,false);
7169  if(zz>1) continue;
7170  if(zz<0) continue;
7171 
7172  std::vector< std::vector<vec3f> > contourVector;
7173 
7174  tools_lforcit(cline_strip*,*pStripList,pos) {
7175  cline_strip* pStrip = (*pos);
7176  if(pStrip->size() >2) {
7177  std::vector<vec3f> v;
7178  for (cline_strip::iterator pos2=pStrip->begin();pos2 != pStrip->end();pos2++) {
7179  unsigned int index=(*pos2);
7180  float xx = (float)a_contour.get_xi(index);
7181  float yy = (float)a_contour.get_yi(index);
7182  xx = verify_log(xx,xmin,dx,xlog);
7183  yy = verify_log(yy,ymin,dy,ylog);
7184  v.push_back(vec3f(xx,yy,a_zz+zz));
7185  }
7186  contourVector.push_back(v);
7187  }
7188  }
7189 
7190  std::vector<tess_triangle> tris;
7191  tess_contour tessContour(a_out,tris); //we pass a ref to tris.
7192  tessContour.getFilledArea(contourVector);
7193  if(!tris.size()) continue;
7194 
7195  colorf _color;
7196  if(a_painting==painting_by_value) {
7197  a_cmap.get_color(val,_color);
7198  } else if(a_painting==painting_by_level) {
7199  int icol = a_cmap.colorn() ? (i % a_cmap.colorn()) :0;
7200  _color = a_cmap.color(icol);
7201  } else {
7202  _color = a_style.color;
7203  }
7204 
7205  atb_vertices* vtxs = new atb_vertices; //PAW_C/color.kumac. It needs back face.
7206  vtxs->mode = gl::triangles();
7207  sep->add(vtxs);
7208 
7209  for(size_t itri=0;itri<tris.size();itri++) {
7210  tess_triangle& tri = tris[itri];
7211  AB.set_value((float)(tri.pointB[0]-tri.pointA[0]),
7212  (float)(tri.pointB[1]-tri.pointA[1]),
7213  (float)(tri.pointB[2]-tri.pointA[2]));
7214  BC.set_value((float)(tri.pointC[0]-tri.pointB[0]),
7215  (float)(tri.pointC[1]-tri.pointB[1]),
7216  (float)(tri.pointC[2]-tri.pointB[2]));
7217  AB.cross(BC,vcross);
7218  if(vcross.z()>=0) {
7219  vtxs->add((float)tri.pointA[0],(float)tri.pointA[1],(float)tri.pointA[2]);
7220  vtxs->add((float)tri.pointB[0],(float)tri.pointB[1],(float)tri.pointB[2]);
7221  vtxs->add((float)tri.pointC[0],(float)tri.pointC[1],(float)tri.pointC[2]);
7222  } else {
7223  vtxs->add((float)tri.pointA[0],(float)tri.pointA[1],(float)tri.pointA[2]);
7224  vtxs->add((float)tri.pointC[0],(float)tri.pointC[1],(float)tri.pointC[2]);
7225  vtxs->add((float)tri.pointB[0],(float)tri.pointB[1],(float)tri.pointB[2]);
7226  }
7227  vtxs->add_color(_color);
7228  vtxs->add_color(_color);
7229  vtxs->add_color(_color);
7230  }
7231 
7232  empty = false;
7233 
7234  }
7235 
7236  if(empty) {
7237  delete separator;
7238  } else {
7240  }
7241  }
7242 
7243  void rep_errors_plus_xy(std::ostream& /*a_out*/,const style& a_style,const std::vector<rep_bin1D>& a_bins,
7244  const rep_box& a_box_x,const rep_box& a_box_y,const std::vector<float>& a_bars,float aZ) {
7245  //a_out << "debug : rep_erros_plus_xy : begin :" << std::endl;
7246  separator* _sep = new separator();
7247  //_sep->setString(aID);
7248 
7249  rgba* mat = new rgba();
7250  mat->color = a_style.color;
7251  _sep->add(mat);
7252 
7253  draw_style* ds = new draw_style;
7254  ds->style.value(draw_lines);
7255  ds->line_pattern.value(a_style.line_pattern);
7256  ds->line_width.value(a_style.line_width);
7257  _sep->add(ds);
7258 
7259  vertices* vtxs = new vertices;
7260  vtxs->mode = gl::lines();
7261  _sep->add(vtxs);
7262 
7263  float xmin = a_box_x.m_pos;
7264  float dx = a_box_x.m_width;
7265  bool xlog = a_box_x.m_log;
7266 
7267  float ymin = a_box_y.m_pos;
7268  float dy = a_box_y.m_width;
7269  bool ylog = a_box_y.m_log;
7270 
7271  size_t xnbin = a_bins.size();
7272 
7273  for(size_t index=0;index<xnbin;index++) {
7274 
7275  //Need all bins modeled for fitting.
7276 
7277  float val = a_bins[index].m_val;
7278  float bar_height = a_bars[index];
7279 
7280  float bar_min = val - bar_height/2;
7281  float bar_max = val + bar_height/2;
7282 
7283  float xx = a_bins[index].m_x_min;
7284  float xe = a_bins[index].m_x_max;
7285 
7286  xx = verify_log(xx,xmin,dx,xlog);
7287  xe = verify_log(xe,xmin,dx,xlog);
7288  val = verify_log(val,ymin,dy,ylog);
7289 
7290  bar_min = verify_log(bar_min,ymin,dy,ylog);
7291  bar_max = verify_log(bar_max,ymin,dy,ylog);
7292 
7293  if(xe<0) continue;
7294  if(xx>1) continue;
7295  if(xx<0) xx = 0;
7296  if(xe>1) xe = 1;
7297  //if(val<0) val = 0;
7298  //if(val>1) val = 1;
7299 
7300  float ex = (xe+xx)/2;
7301  //if( (ex >=0)&&(ex <=1) ) { //FIXME : have to clip
7302 
7303  float edx = 0.3F * (xe-xx);
7304 
7305  if((val>=0)&&(val<=1)) {
7306  vtxs->add(ex-edx,val,aZ);
7307  vtxs->add(ex+edx,val,aZ);
7308  }
7309 
7310  if(bar_min >1) {
7311  // do nothing
7312  } else if(bar_max <0) {
7313  // do nothing
7314  } else if(bar_min <0) {
7315  if(bar_max >1) {
7316  vtxs->add(ex,0,aZ);
7317  vtxs->add(ex,1,aZ);
7318  } else {
7319  vtxs->add(ex,0,aZ);
7320  vtxs->add(ex,bar_max,aZ);
7321  }
7322  } else if(bar_max >1) {
7323  vtxs->add(ex,bar_min,aZ);
7324  vtxs->add(ex,1,aZ);
7325  } else {
7326  vtxs->add(ex ,bar_min,aZ);
7327  vtxs->add(ex ,bar_max,aZ);
7328  }
7329 
7330  }
7331 
7332  if(vtxs->number()) {
7333  m_errors_sep.add(_sep);
7334  } else {
7335  delete _sep;
7336  }
7337  }
7338 
7339  void rep_errors_I_xy(std::ostream& /*a_out*/,const style& a_style,const std::vector<rep_bin1D>& a_bins,
7340  const rep_box& a_box_x,const rep_box& a_box_y,const std::vector<float>& a_bars,float aZ){
7341  //a_out << "debug : rep_erros_I_xy : begin :" << std::endl;
7342  separator* _sep = new separator();
7343  //_sep->setString(aID);
7344 
7345  rgba* mat = new rgba();
7346  mat->color = a_style.color;
7347  _sep->add(mat);
7348 
7349  draw_style* ds = new draw_style;
7350  ds->style.value(draw_lines);
7351  ds->line_pattern.value(a_style.line_pattern);
7352  ds->line_width.value(a_style.line_width);
7353  _sep->add(ds);
7354 
7355  vertices* vtxs = new vertices;
7356  vtxs->mode = gl::lines();
7357  _sep->add(vtxs);
7358 
7359  float xmin = a_box_x.m_pos;
7360  float dx = a_box_x.m_width;
7361  bool xlog = a_box_x.m_log;
7362 
7363  float ymin = a_box_y.m_pos;
7364  float dy = a_box_y.m_width;
7365  bool ylog = a_box_y.m_log;
7366 
7367  size_t xnbin = a_bins.size();
7368 
7369  for(size_t index=0;index<xnbin;index++) {
7370 
7371  //Need all bins modeled for fitting.
7372 
7373  float val = a_bins[index].m_val;
7374  float bar_height = a_bars[index];
7375 
7376  float bar_min = val - bar_height/2;
7377  float bar_max = val + bar_height/2;
7378 
7379  float xx = a_bins[index].m_x_min;
7380  float xe = a_bins[index].m_x_max;
7381 
7382  xx = verify_log(xx,xmin,dx,xlog);
7383  xe = verify_log(xe,xmin,dx,xlog);
7384  val = verify_log(val,ymin,dy,ylog);
7385 
7386  bar_min = verify_log(bar_min,ymin,dy,ylog);
7387  bar_max = verify_log(bar_max,ymin,dy,ylog);
7388 
7389  if(xe<0) continue;
7390  if(xx>1) continue;
7391  if(xx<0) xx = 0;
7392  if(xe>1) xe = 1;
7393  if(val<0) val = 0;
7394  if(val>1) val = 1;
7395 
7396  float ex = (xe+xx)/2;
7397  //if( (ex >=0)&&(ex <=1) ) { //FIXME : have to clip
7398 
7399  float edx = 0.3F * (xe-xx);
7400 
7401  if(bar_min >1) {
7402  // do nothing
7403  } else if(bar_max <0) {
7404  // do nothing
7405  } else if(bar_min <0) {
7406  if(bar_max >1) {
7407  vtxs->add(ex,0,aZ);
7408  vtxs->add(ex,1,aZ);
7409  } else {
7410  vtxs->add(ex,0,aZ);
7411  vtxs->add(ex,bar_max,aZ);
7412  vtxs->add(ex-edx,bar_max,aZ);
7413  vtxs->add(ex+edx,bar_max,aZ);
7414  }
7415  } else if(bar_max >1) {
7416  vtxs->add(ex-edx,bar_min,aZ);
7417  vtxs->add(ex+edx,bar_min,aZ);
7418  vtxs->add(ex,bar_min,aZ);
7419  vtxs->add(ex,1,aZ);
7420  } else {
7421  vtxs->add(ex-edx,bar_min,aZ);
7422  vtxs->add(ex+edx,bar_min,aZ);
7423  vtxs->add(ex ,bar_min,aZ);
7424  vtxs->add(ex ,bar_max,aZ);
7425  vtxs->add(ex-edx,bar_max,aZ);
7426  vtxs->add(ex+edx,bar_max,aZ);
7427  }
7428 
7429  }
7430 
7431  if(vtxs->number()) {
7432  m_errors_sep.add(_sep);
7433  } else {
7434  delete _sep;
7435  }
7436  }
7437 
7438  void rep_hatch1D_xy(const style& a_style,
7439  const std::vector<rep_bin1D>& a_bins,
7440  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz,
7441  bool a_bar_chart){
7442  //printf("debug : inlib::sg;:plotter::repHatch1D_xy : zz %g barchart %d sw %g\n",a_zz,aBarChart,a_style.stripWidth.getValue());
7443 
7444  separator* _sep = new separator;
7445 
7446  rgba* mat = new rgba();
7447  mat->color = a_style.color;
7448  _sep->add(mat);
7449 
7450  draw_style* ds = new draw_style;
7451  if(a_style.strip_width.value()==0) {
7452  ds->style = draw_lines;
7453  ds->line_pattern = line_solid;
7454  ds->line_width = a_style.line_width;
7455  } else {
7456  ds->style = draw_filled;
7457  //ds->cull_face = true;
7458  }
7459  _sep->add(ds);
7460 
7461  float xmin = a_box_x.m_pos;
7462  float dx = a_box_x.m_width;
7463  bool xlog = a_box_x.m_log;
7464 
7465  float ymin = a_box_y.m_pos;
7466  float dy = a_box_y.m_width;
7467  bool ylog = a_box_y.m_log;
7468 
7469  bool empty = true;
7470 
7471  vec3f points[5];
7472  size_t xnbin = a_bins.size();
7473  for(size_t index=0;index<xnbin;index++) {
7474  float xx = a_bins[index].m_x_min;
7475  float xe = a_bins[index].m_x_max;
7476  float yy = a_bins[index].m_v_min;
7477  float ye = a_bins[index].m_val;
7478  if(ye<yy) {
7479  yy = a_bins[index].m_val;
7480  ye = a_bins[index].m_v_min;
7481  }
7482 
7483  if(a_bar_chart) bar_chart(a_style.bar_offset.value(),a_style.bar_width.value(),xx,xe);
7484 
7485  xx = verify_log(xx,xmin,dx,xlog);
7486  xe = verify_log(xe,xmin,dx,xlog);
7487  yy = verify_log(yy,ymin,dy,ylog);
7488  ye = verify_log(ye,ymin,dy,ylog);
7489 
7490  // Clipping :
7491  if(xx>1) continue;
7492  if(xe<0) continue;
7493  if(xx<0) xx = 0;
7494  if(xe>1) xe = 1;
7495  if(yy>1) continue;
7496  if(ye<0) continue;
7497  if(yy<0) yy = 0;
7498  if(ye>1) ye = 1;
7499 
7500  points[0].set_value(xx,yy,a_zz);
7501  points[1].set_value(xe,yy,a_zz);
7502  points[2].set_value(xe,ye,a_zz);
7503  points[3].set_value(xx,ye,a_zz);
7504  points[4].set_value(xx,yy,a_zz);
7505 
7506  //FIXME : have picking a hatch picks also the bin.
7507 
7508  hatcher _hatcher;
7509  _hatcher.set_offset_point(vec3f(0,0,a_zz));
7510  _hatcher.set_angle(a_style.angle.value());
7511  _hatcher.set_spacing(a_style.spacing.value());
7512  if(!_hatcher.set_strip_width(a_style.strip_width.value())) {}
7513 
7514  bool res = _hatcher.check_polyline(points,4);
7515  if(res) res = _hatcher.compute_polyline(points,4);
7516 
7517  size_t numPoints = _hatcher.points().size();
7518  size_t numVertices = _hatcher.vertices().size();
7519  if((res) && numPoints && numVertices) {
7520 
7521  const std::vector<vec3f>& _points = _hatcher.points();
7522 
7523  if(a_style.strip_width.value()==0) {
7524 
7525  size_t ipt = 0;
7526  tools_vforcit(unsigned int,_hatcher.vertices(),itv) {
7527  vertices* vtxs = new vertices;
7528  vtxs->mode = gl::line_strip();
7529  for(size_t _index=0;_index<(*itv);_index++) {
7530  vtxs->add(_points[ipt]);
7531  ipt++;
7532  }
7533  _sep->add(vtxs);
7534  empty = false;
7535  }
7536 
7537  } else {
7538  size_t ipt = 0;
7539  tools_vforcit(unsigned int,_hatcher.vertices(),itv) {
7540  vertices* vtxs = new vertices;
7541  vtxs->mode = gl::triangle_fan();
7542  for(size_t _index=0;_index<(*itv);_index++) {
7543  vtxs->add(_points[ipt]);
7544  ipt++;
7545  }
7546  _sep->add(vtxs);
7547  empty = false;
7548  }
7549  }
7550 
7551  }
7552  }
7553  if(empty) {
7554  delete _sep;
7555  } else {
7556  m_bins_sep.add(_sep);
7557  }
7558  }
7559 
7560  void rep_points2D_xy_lines(const style& a_style,const points2D& a_points,
7561  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz){
7562  //::printf("debug : rep_points2D_xy_lines\n");
7563  float xmin = a_box_x.m_pos;
7564  float dx = a_box_x.m_width;
7565  bool xlog = a_box_x.m_log;
7566 
7567  float ymin = a_box_y.m_pos;
7568  float dy = a_box_y.m_width;
7569  bool ylog = a_box_y.m_log;
7570 
7571  separator* _sep = new separator();
7572 
7573  rgba* mat = new rgba();
7574  mat->color = a_style.color;
7575  _sep->add(mat);
7576 
7577  draw_style* ds = new draw_style;
7578  ds->style.value(draw_lines);
7579  ds->line_pattern.value(a_style.line_pattern);
7580  ds->line_width.value(a_style.line_width);
7581  _sep->add(ds);
7582 
7583  vertices* vtxs = new vertices;
7584  vtxs->mode = gl::line_strip();
7585  _sep->add(vtxs);
7586 
7587  bool empty = true;
7588 
7589  float x,y;
7590  unsigned int number = a_points.points();
7591  for(unsigned int index=0;index<number;index++) {
7592  a_points.ith_point(index,x,y);
7593  x = verify_log(x,xmin,dx,xlog);
7594  y = verify_log(y,ymin,dy,ylog);
7595  if((x<0)||(x>1)||(y<0)||(y>1)) continue;
7596  vtxs->add(x,y,a_zz);
7597  empty = false;
7598  }
7599 
7600  if(empty) {
7601  delete _sep;
7602  } else {
7603  m_points_sep.add(_sep);
7604  }
7605  }
7606 
7607  void rep_points2D_xy_curve(std::ostream& a_out,const style& a_style,const points2D& a_points,
7608  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz){
7609  //::printf("debug : rep_points2D_xy_curve\n");
7610  unsigned int number = a_points.points();
7611  if(!number) return;
7612 
7613  double* xs = new double[number];
7614  double* ys = new double[number];
7615  float x,y;
7616  {for(unsigned int index=0;index<number;index++) {
7617  a_points.ith_point(index,x,y);
7618  xs[index] = x;ys[index] = y;
7619  }}
7620  spline::cubic _spline(a_out,number,xs,ys);
7621  //spline::quintic _spline(a_out,number,xs,ys);
7622  delete [] xs;delete [] ys;
7623 
7624  float xmn = m_x_axis_data.min_value();
7625  float xmx = m_x_axis_data.max_value();
7626  unsigned int nstp = curve_number_of_points;
7627  float step = (xmx - xmn)/nstp;
7628  std::vector<vec3f> points(nstp+1);
7629  for(unsigned int ibin=0;ibin<=nstp;ibin++) {
7630  float xx = xmn + ibin * step;
7631  double val = _spline.eval(xx);
7632  points[ibin].set_value(xx,float(val),a_zz);
7633  }
7634 
7635  vertices* vtxs = new vertices;
7636  std::vector<float>& pts = vtxs->xyzs.values(); //npt*3
7637 
7638  clip_polyline_2D(points,a_box_x,a_box_y,pts);
7639  if(pts.size()) {
7641  //separator->setString(aID);
7642 
7643  rgba* mat = new rgba();
7644  mat->color = a_style.color;
7645  separator->add(mat);
7646 
7647  draw_style* ds = new draw_style;
7648  ds->style = draw_lines;
7649  ds->line_pattern = a_style.line_pattern;
7650  ds->line_width = a_style.line_width;
7651  separator->add(ds);
7652 
7653  vtxs->mode = gl::line_strip();
7654  separator->add(vtxs);
7655 
7657  } else {
7658  delete vtxs;
7659  }
7660 
7661  }
7662 
7663  void rep_points2D_xy_points(std::ostream& a_out,
7664  const style& a_style,const points2D& a_points,
7665  const rep_box& a_box_x,const rep_box& a_box_y,float a_zz) {
7666  float xmin = a_box_x.m_pos;
7667  float dx = a_box_x.m_width;
7668  bool xlog = a_box_x.m_log;
7669 
7670  float ymin = a_box_y.m_pos;
7671  float dy = a_box_y.m_width;
7672  bool ylog = a_box_y.m_log;
7673 
7674  separator* _sep = new separator();
7675 
7676  rgba* mat = new rgba();
7677  mat->color = a_style.color;
7678  _sep->add(mat);
7679 
7680  mf<float>* _xyzs = 0;
7681 
7682  if(a_style.modeling==modeling_markers()) {
7683  markers* _marks = new markers;
7684  _marks->size = a_style.marker_size;
7685  _marks->style = a_style.marker_style;
7686  _xyzs = &(_marks->xyzs);
7687  _sep->add(_marks);
7688 
7689  } else if(a_style.modeling==modeling_points()) {
7690  draw_style* ds = new draw_style;
7691  ds->style = draw_points;
7692  ds->point_size = a_style.point_size;
7693  _sep->add(ds);
7694 
7695  vertices* vtxs = new vertices;
7696  vtxs->mode = gl::points();
7697  _xyzs = &(vtxs->xyzs);
7698  _sep->add(vtxs);
7699  } else {
7700  a_out << "tools::sg::plotter::rep_points2D_xy_points :"
7701  << " bad modeling style " << tools::sout(a_style.modeling) << std::endl;
7702  delete _sep;
7703  return;
7704  }
7705 
7706  float x,y;
7707 
7708  // first round trip to get number of floats :
7709  size_t npts = 0;
7710  {unsigned int number = a_points.points();
7711  for(unsigned int index=0;index<number;index++) {
7712  a_points.ith_point(index,x,y);
7713  //float val = a_bins[index].m_val;
7714  x = verify_log(x,xmin,dx,xlog);
7715  y = verify_log(y,ymin,dy,ylog);
7716  if((x<0)||(x>1)||(y<0)||(y>1)) continue;
7717  npts += 3;
7718  }}
7719 
7720  _xyzs->values().resize(npts);
7721  size_t xyz_pos = 0;
7722 
7723  bool empty = true;
7724 
7725  {unsigned int number = a_points.points();
7726  for(unsigned int index=0;index<number;index++) {
7727  a_points.ith_point(index,x,y);
7728  //float val = a_bins[index].m_val;
7729  x = verify_log(x,xmin,dx,xlog);
7730  y = verify_log(y,ymin,dy,ylog);
7731  if((x<0)||(x>1)||(y<0)||(y>1)) continue;
7732  _xyzs->add_allocated(xyz_pos,x,y,a_zz);
7733  empty = false;
7734  }}
7735 
7736  if(empty) {
7737  delete _sep;
7738  } else {
7739  m_points_sep.add(_sep);
7740  }
7741  }
7742 
7743  void rep_points3D_xyz_points(std::ostream& a_out,
7744  const style& a_style,const points3D& a_points,
7745  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z) {
7746  float xmin = a_box_x.m_pos;
7747  float dx = a_box_x.m_width;
7748  bool xlog = a_box_x.m_log;
7749 
7750  float ymin = a_box_y.m_pos;
7751  float dy = a_box_y.m_width;
7752  bool ylog = a_box_y.m_log;
7753 
7754  float zmin = a_box_z.m_pos;
7755  float dz = a_box_z.m_width;
7756  bool zlog = a_box_z.m_log;
7757 
7758  separator* _sep = new separator();
7759 
7760  rgba* mat = new rgba();
7761  mat->color = a_style.color;
7762  _sep->add(mat);
7763 
7764  mf<float>* _xyzs = 0;
7765 
7766  if(a_style.modeling==modeling_markers()) {
7767  markers* _marks = new markers;
7768  _marks->size = a_style.marker_size;
7769  _marks->style = a_style.marker_style;
7770  _xyzs = &(_marks->xyzs);
7771  _sep->add(_marks);
7772 
7773  } else if(a_style.modeling==modeling_points()) {
7774  draw_style* ds = new draw_style;
7775  ds->style = draw_points;
7776  ds->point_size = a_style.point_size;
7777  _sep->add(ds);
7778 
7779  vertices* vtxs = new vertices;
7780  vtxs->mode = gl::points();
7781  _xyzs = &(vtxs->xyzs);
7782  _sep->add(vtxs);
7783  } else {
7784  a_out << "tools::sg::plotter::rep_points3D_xy_points :"
7785  << " bad modeling style " << tools::sout(a_style.modeling) << std::endl;
7786  delete _sep;
7787  return;
7788  }
7789 
7790  float x,y,z;
7791 
7792  // first round trip to get number of floats :
7793  size_t npts = 0;
7794  {unsigned int number = a_points.points();
7795  for(unsigned int index=0;index<number;index++) {
7796  a_points.ith_point(index,x,y,z);
7797  //float val = a_bins[index].m_val;
7798  x = verify_log(x,xmin,dx,xlog);
7799  y = verify_log(y,ymin,dy,ylog);
7800  z = verify_log(z,zmin,dz,zlog);
7801  if((x<0)||(x>1)||(y<0)||(y>1)||(z<0)||(z>1)) continue;
7802  npts += 3;
7803  }}
7804 
7805  _xyzs->values().resize(npts);
7806  size_t xyz_pos = 0;
7807 
7808  bool empty = true;
7809 
7810  {unsigned int number = a_points.points();
7811  for(unsigned int index=0;index<number;index++) {
7812  a_points.ith_point(index,x,y,z);
7813  //float val = a_bins[index].m_val;
7814  x = verify_log(x,xmin,dx,xlog);
7815  y = verify_log(y,ymin,dy,ylog);
7816  z = verify_log(z,zmin,dz,zlog);
7817  if((x<0)||(x>1)||(y<0)||(y>1)||(z<0)||(z>1)) continue;
7818  _xyzs->add_allocated(xyz_pos,x,y,z);
7819  empty = false;
7820  }}
7821 
7822  if(empty) {
7823  delete _sep;
7824  } else {
7825  m_points_sep.add(_sep);
7826  }
7827  }
7828 
7829  void rep_bins2D_xyz_box(const style& a_style,const base_colormap& a_cmap,const std::vector<rep_bin2D>& a_bins,
7830  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z,float a_bmin,float /*a_bmax*/){
7831  float xmin = a_box_x.m_pos;
7832  float dx = a_box_x.m_width;
7833  bool xlog = a_box_x.m_log;
7834 
7835  float ymin = a_box_y.m_pos;
7836  float dy = a_box_y.m_width;
7837  bool ylog = a_box_y.m_log;
7838 
7839  float zmin = a_box_z.m_pos;
7840  float dz = a_box_z.m_width;
7841  bool zlog = a_box_z.m_log;
7842 
7843  painting_policy painting = a_style.painting;
7844 
7845  separator* _sep = new separator();
7846 
7847  bool empty = true;
7848  //float range = a_bmax - a_bmin;
7849  colorf clr;
7850 
7851  tools_vforcit(rep_bin2D,a_bins,it) {
7852  const rep_bin2D& rbin = *it;
7853 
7854  float xx = rbin.m_x_min;
7855  float xe = rbin.m_x_max;
7856  float yy = rbin.m_y_min;
7857  float ye = rbin.m_y_max;
7858  float val = rbin.m_val;
7859  float zz = a_bmin;
7860  float ze = val;
7861 
7862  xx = verify_log(xx ,xmin,dx ,xlog);
7863  xe = verify_log(xe ,xmin,dx ,xlog);
7864  yy = verify_log(yy ,ymin,dy ,ylog);
7865  ye = verify_log(ye ,ymin,dy ,ylog);
7866  zz = verify_log(zz ,zmin,dz ,zlog);
7867  ze = verify_log(ze ,zmin,dz ,zlog);
7868 
7869  // Clipping :
7870  if(xx>1) continue;
7871  if(xe<0) continue;
7872  if(xx<0) xx = 0;
7873  if(xe>1) xe = 1;
7874 
7875  if(yy>1) continue;
7876  if(ye<0) continue;
7877  if(yy<0) yy = 0;
7878  if(ye>1) ye = 1;
7879 
7880  if(zz>1) continue;
7881  if(ze<0) continue;
7882  if(zz<0) zz = 0;
7883  if(ze>1) ze = 1;
7884 
7885  if(yy>=ye) continue;
7886  if(xx>=xe) continue;
7887  if(zz>=ze) continue;
7888 
7889  separator* sep = new separator();
7890  _sep->add(sep);
7891 
7892  if(painting==painting_by_value) {
7893  a_cmap.get_color(val,clr);
7894  } else if( (painting==painting_grey_scale) ||
7895  (painting==painting_grey_scale_inverse) ||
7896  (painting==painting_violet_to_red) ){
7897  a_cmap.get_color(rbin.m_ratio,clr);
7898  } else {
7899  clr = a_style.color;
7900  }
7901 
7902  rgba* mat = new rgba();
7903  mat->color = clr;
7904  sep->add(mat);
7905 
7906  /*{char s[128];
7907  //::sprintf(s,"%d %d",rbin.fI,rbin.fJ);
7908  sep->setInfos(s);
7909  //::sprintf(s,"/0x%lx",(unsigned long)sep->getInfos());
7910  std::string sid = aID;
7911  sid += std::string(s);
7912  sep->setString(sid);}*/
7913 
7914  float sx = xe-xx;
7915  float sy = ye-yy;
7916  float sz = ze-zz;
7917 
7918  matrix* _tsf = new matrix;
7919  _tsf->set_translate(xx+sx/2,yy+sy/2,sz/2);
7920  sep->add(_tsf);
7921 
7922  cube* _cube = new cube;
7923  _cube->width = sx;
7924  _cube->height = sy;
7925  _cube->depth = sz;
7926  sep->add(_cube);
7927 
7928  empty = false;
7929  }
7930 
7931  if(empty) {
7932  delete _sep;
7933  } else {
7934  m_bins_sep.add(_sep);
7935  }
7936  }
7937 
7938  void rep_top_face2D_xyz(separator& a_sep,const style& a_style,const base_colormap& a_cmap,
7939  const std::vector<rep_top_face2D>& a_faces,
7940  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z) {
7941  float xmin = a_box_x.m_pos;
7942  float dx = a_box_x.m_width;
7943  bool xlog = a_box_x.m_log;
7944 
7945  float ymin = a_box_y.m_pos;
7946  float dy = a_box_y.m_width;
7947  bool ylog = a_box_y.m_log;
7948 
7949  float zmin = a_box_z.m_pos;
7950  float dz = a_box_z.m_width;
7951  bool zlog = a_box_z.m_log;
7952 
7953  bool empty = true;
7954 
7955  painting_policy painting = a_style.painting;
7956 
7957  separator* _sep = new separator();
7958 
7959  //draw_style* ds = new draw_style;
7960  //ds->style = draw_filled;
7961  //ds->cull_face = true;
7962  //_sep->add(ds);
7963 
7964  atb_vertices* vtxs = new atb_vertices;
7965  vtxs->mode = gl::triangles();
7966  vtxs->do_back = true;
7967  vtxs->epsilon = 1e-6f;
7968  _sep->add(vtxs);
7969 
7970  colorf clr;
7971  vec3f nm;
7972 
7973  size_t number = a_faces.size();
7974  for(size_t index=0;index<number;index++) {
7975  float xx = a_faces[index].m_x_min;
7976  float xe = a_faces[index].m_x_max;
7977  float yy = a_faces[index].m_y_min;
7978  float ye = a_faces[index].m_y_max;
7979  float val1 = a_faces[index].m_v1;
7980  float val2 = a_faces[index].m_v2;
7981  float val3 = a_faces[index].m_v3;
7982  float val4 = a_faces[index].m_v4;
7983 
7984  float val = val1;
7985 
7986  val1 = verify_log(val1,zmin,dz,zlog);
7987  val2 = verify_log(val2,zmin,dz,zlog);
7988  val3 = verify_log(val3,zmin,dz,zlog);
7989  val4 = verify_log(val4,zmin,dz,zlog);
7990  xx = verify_log(xx,xmin,dx,xlog);
7991  xe = verify_log(xe,xmin,dx,xlog);
7992  yy = verify_log(yy,ymin,dy,ylog);
7993  ye = verify_log(ye,ymin,dy,ylog);
7994 
7995  if(val1<0) val1 = 0;
7996  if(val1>1) val1 = 1;
7997 
7998  if(val2<0) val2 = 0;
7999  if(val2>1) val2 = 1;
8000 
8001  if(val3<0) val3 = 0;
8002  if(val3>1) val3 = 1;
8003 
8004  if(val4<0) val4 = 0;
8005  if(val4>1) val4 = 1;
8006 
8007  if((xx>=0)&&(xx<=1) &&
8008  (xe>=0)&&(xe<=1) &&
8009  (yy>=0)&&(yy<=1) &&
8010  (ye>=0)&&(ye<=1) ) {
8011 
8012  if(painting==painting_by_value) {
8013  float v = (zlog?take_log(val):val);
8014  a_cmap.get_color(v,clr);
8015  } else if( (painting==painting_grey_scale) ||
8016  (painting==painting_grey_scale_inverse) ||
8017  (painting==painting_violet_to_red) ){
8018  a_cmap.get_color(a_faces[index].m_ratio,clr);
8019  } else {
8020  clr = a_style.color;
8021  }
8022 
8023  //if(a_style.area_style.getValue()==SoStyle::EDGED) { //OpenPAW.
8024  //}
8025 
8028  vtxs->add(xx,ye,val4);
8029  vtxs->add(xx,yy,val1);
8030  vtxs->add(xe,yy,val2);
8031 
8032  vtxs->add_color(clr);
8033  vtxs->add_color(clr);
8034  vtxs->add_color(clr);
8035 
8036  direction(xx,ye,val4,
8037  xx,yy,val1,
8038  xe,yy,val2,nm);
8039  nm.normalize();
8040  vtxs->add_normal(nm[0],nm[1],nm[2]);
8041  vtxs->add_normal(nm[0],nm[1],nm[2]);
8042  vtxs->add_normal(nm[0],nm[1],nm[2]);
8043 
8046  vtxs->add(xe,yy,val2);
8047  vtxs->add(xe,ye,val3);
8048  vtxs->add(xx,ye,val4);
8049 
8050  vtxs->add_rgba(clr[0],clr[1],clr[2],clr[3]);
8051  vtxs->add_rgba(clr[0],clr[1],clr[2],clr[3]);
8052  vtxs->add_rgba(clr[0],clr[1],clr[2],clr[3]);
8053 
8054  direction(xe,yy,val2,
8055  xe,ye,val3,
8056  xx,ye,val4,nm);
8057  nm.normalize();
8058  vtxs->add_normal(nm[0],nm[1],nm[2]);
8059  vtxs->add_normal(nm[0],nm[1],nm[2]);
8060  vtxs->add_normal(nm[0],nm[1],nm[2]);
8061 
8062  empty = false;
8063  }
8064  }
8065  if(empty) {
8066  delete _sep;
8067  } else {
8068  a_sep.add(_sep);
8069  }
8070  }
8071 
8072  void rep_top_face2D_xyz_line(const style& /*a_style*/,const std::vector<rep_top_face2D>& a_top_faces,
8073  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z/*,const SbString& aID*/){
8074  //::printf("debug : rep_top_face2D_xyz_line\n");
8075 
8076  float xmin = a_box_x.m_pos;
8077  float dx = a_box_x.m_width;
8078  bool xlog = a_box_x.m_log;
8079 
8080  float ymin = a_box_y.m_pos;
8081  float dy = a_box_y.m_width;
8082  bool ylog = a_box_y.m_log;
8083 
8084  float zmin = a_box_z.m_pos;
8085  float dz = a_box_z.m_width;
8086  bool zlog = a_box_z.m_log;
8087 
8089  bool empty = true;
8090 
8091  rgba* mat = new rgba();
8092  mat->color = colorf_black();
8093  separator->add(mat);
8094 
8095  draw_style* ds = new draw_style;
8096  ds->style = draw_lines;
8097  ds->line_pattern = line_solid;
8098  ds->line_width = 1;
8099  separator->add(ds);
8100 
8101  vertices* vtxs = new vertices;
8102  vtxs->mode = gl::lines();
8103  separator->add(vtxs);
8104 
8105  float zepsilon = 0.02f; //for pawex9.kumac top-left and bottom-right.
8106 
8107  size_t number = a_top_faces.size();
8108  for(size_t index=0;index<number;index++) {
8109  float xx = a_top_faces[index].m_x_min;
8110  float xe = a_top_faces[index].m_x_max;
8111  float yy = a_top_faces[index].m_y_min;
8112  float ye = a_top_faces[index].m_y_max;
8113  float val1 = a_top_faces[index].m_v1;
8114  float val2 = a_top_faces[index].m_v2;
8115  float val3 = a_top_faces[index].m_v3;
8116  float val4 = a_top_faces[index].m_v4;
8117 
8118  //float val = val1;
8119 
8120  val1 = verify_log(val1,zmin,dz,zlog);
8121  val2 = verify_log(val2,zmin,dz,zlog);
8122  val3 = verify_log(val3,zmin,dz,zlog);
8123  val4 = verify_log(val4,zmin,dz,zlog);
8124  xx = verify_log(xx,xmin,dx,xlog);
8125  xe = verify_log(xe,xmin,dx,xlog);
8126  yy = verify_log(yy,ymin,dy,ylog);
8127  ye = verify_log(ye,ymin,dy,ylog);
8128 
8129  if(val1<0) val1 = 0;
8130  if(val1>1) val1 = 1;
8131 
8132  if(val2<0) val2 = 0;
8133  if(val2>1) val2 = 1;
8134 
8135  if(val3<0) val3 = 0;
8136  if(val3>1) val3 = 1;
8137 
8138  if(val4<0) val4 = 0;
8139  if(val4>1) val4 = 1;
8140 
8141  if((xx>=0)&&(xx<=1) &&
8142  (xe>=0)&&(xe<=1) &&
8143  (yy>=0)&&(yy<=1) &&
8144  (ye>=0)&&(ye<=1) ) {
8145 
8146  vtxs->add(xx,ye,val4+zepsilon);
8147  vtxs->add(xx,yy,val1+zepsilon);
8148 
8149  vtxs->add(xx,yy,val1+zepsilon);
8150  vtxs->add(xe,yy,val2+zepsilon);
8151 
8152  vtxs->add(xe,yy,val2+zepsilon);
8153  vtxs->add(xe,ye,val3+zepsilon);
8154 
8155  vtxs->add(xe,ye,val3+zepsilon);
8156  vtxs->add(xx,ye,val4+zepsilon);
8157 
8158  empty = false;
8159 
8160  }
8161  }
8162  if(empty) {
8163  delete separator;
8164  } else {
8166  }
8167  }
8168 
8169  void rep_top_face2D_xyz_by_level(const style& /*a_style*/,painting_policy /*a_painting*/,const base_colormap& a_cmap,
8170  const std::vector<rep_top_face2D>& a_top_faces,
8171  const rep_box& a_box_x,const rep_box& a_box_y,const rep_box& a_box_z,
8172  float a_bmin,float a_bmax/*,const SbString& aID*/){
8173  //::printf("debug : rep_top_face2D_xyz_by_level\n");
8174 
8175  size_t ncol = a_cmap.colorn();
8176  if(!ncol) return;
8177 
8178  float xmin = a_box_x.m_pos;
8179  float dx = a_box_x.m_width;
8180  bool xlog = a_box_x.m_log;
8181 
8182  float ymin = a_box_y.m_pos;
8183  float dy = a_box_y.m_width;
8184  bool ylog = a_box_y.m_log;
8185 
8186  float zmin = a_box_z.m_pos;
8187  float dz = a_box_z.m_width;
8188  bool zlog = a_box_z.m_log;
8189 
8190  float zz = a_bmin;
8191  zz = verify_log(zz,zmin,dz,zlog);
8192  float zmx = a_bmax;
8193  zmx = verify_log(zmx,zmin,dz,zlog);
8194 
8195  bool empty = true;
8196 
8198  //separator->setString(aID);
8199 
8200  atb_vertices* tris = new atb_vertices;
8201  tris->mode = gl::triangles();
8202  tris->do_back = true;
8203  tris->epsilon = 1e-6f;
8204  separator->add(tris);
8205 
8206  colorf _color;
8207  vec3f _point;
8208 
8209  float d_z = (zmx-zz)/ncol;
8210 
8211  size_t number = a_top_faces.size();
8212 
8213  for(size_t icol=0;icol<ncol;icol++) {
8214 
8215  //sg::separator* sep = new sg::separator;
8216  //bool sep_empty = true;
8217 
8218  _color = a_cmap.color(icol);
8219 
8220  for(size_t index=0;index<number;index++) {
8221  float xx = a_top_faces[index].m_x_min;
8222  float xe = a_top_faces[index].m_x_max;
8223  float yy = a_top_faces[index].m_y_min;
8224  float ye = a_top_faces[index].m_y_max;
8225  float val1 = a_top_faces[index].m_v1;
8226  float val2 = a_top_faces[index].m_v2;
8227  float val3 = a_top_faces[index].m_v3;
8228  float val4 = a_top_faces[index].m_v4;
8229 
8230  //float val = val1;
8231 
8232  val1 = verify_log(val1,zmin,dz,zlog);
8233  val2 = verify_log(val2,zmin,dz,zlog);
8234  val3 = verify_log(val3,zmin,dz,zlog);
8235  val4 = verify_log(val4,zmin,dz,zlog);
8236  xx = verify_log(xx,xmin,dx,xlog);
8237  xe = verify_log(xe,xmin,dx,xlog);
8238  yy = verify_log(yy,ymin,dy,ylog);
8239  ye = verify_log(ye,ymin,dy,ylog);
8240 
8241  if(val1<0) val1 = 0;
8242  if(val1>1) val1 = 1;
8243 
8244  if(val2<0) val2 = 0;
8245  if(val2>1) val2 = 1;
8246 
8247  if(val3<0) val3 = 0;
8248  if(val3>1) val3 = 1;
8249 
8250  if(val4<0) val4 = 0;
8251  if(val4>1) val4 = 1;
8252 
8253  if((xx>=0)&&(xx<=1) &&
8254  (xe>=0)&&(xe<=1) &&
8255  (yy>=0)&&(yy<=1) &&
8256  (ye>=0)&&(ye<=1) ) {
8257 
8260  {clip<vec3f> clipper;
8261  clipper.add(vec3f(xx,ye,val4));
8262  clipper.add(vec3f(xx,yy,val1));
8263  clipper.add(vec3f(xe,yy,val2));
8264  //val[n] had been z normalized.
8265  float z1 = zz+d_z*icol;
8266  float z2 = z1+d_z;
8267  plane<vec3f> plane_z_bot(vec3f(0,0,1),vec3f(0,0,z1));
8268  plane<vec3f> plane_z_top(vec3f(0,0,-1),vec3f(0,0,z2));
8269  clipper.execute(plane_z_bot);
8270  clipper.execute(plane_z_top);
8271 
8272  const std::vector<vec3f>& result = clipper.result();
8273  if(result.size()) {
8274  plane<vec3f> plane1(vec3f(xx,ye,val4),vec3f(xx,yy,val1),vec3f(xe,yy,val2));
8275  if(result.size()==3) {
8276  tools_vforcit(vec3f,result,it) {
8277  tris->add(*it);
8278  tris->add_color(_color);
8279  tris->add_normal(plane1.normal());
8280  }
8281  } else {
8282  atb_vertices* vtxs = new atb_vertices; //FIXME : ouch! optimize.
8283  vtxs->mode = gl::triangle_fan();
8284  vtxs->do_back = true;
8285  vtxs->epsilon = 1e-6f;
8286  separator->add(vtxs);
8287  tools_vforcit(vec3f,result,it) {
8288  vtxs->add(*it);
8289  vtxs->add_color(_color);
8290  vtxs->add_normal(plane1.normal());
8291  }
8292  }
8293  empty = false;
8294  //sep_empty = false;
8295  }}
8296 
8299  {clip<vec3f> clipper;
8300  clipper.add(vec3f(xe,yy,val2));
8301  clipper.add(vec3f(xe,ye,val3));
8302  clipper.add(vec3f(xx,ye,val4));
8303  //val[n] had been z normalized.
8304  float z1 = zz+d_z*icol;
8305  float z2 = z1+d_z;
8306  plane<vec3f> plane_z_bot(vec3f(0,0,1),vec3f(0,0,z1));
8307  plane<vec3f> plane_z_top(vec3f(0,0,-1),vec3f(0,0,z2));
8308  clipper.execute(plane_z_bot);
8309  clipper.execute(plane_z_top);
8310 
8311  const std::vector<vec3f>& result = clipper.result();
8312  if(result.size()) {
8313  plane<vec3f> plane2(vec3f(xe,yy,val2),vec3f(xe,ye,val3),vec3f(xx,ye,val4));
8314  if(result.size()==3) {
8315  tools_vforcit(vec3f,result,it) {
8316  tris->add(*it);
8317  tris->add_color(_color);
8318  tris->add_normal(plane2.normal());
8319  }
8320  } else {
8321  atb_vertices* vtxs = new atb_vertices; //FIXME : ouch! optimize.
8322  vtxs->mode = gl::triangle_fan();
8323  vtxs->do_back = true;
8324  vtxs->epsilon = 1e-6f;
8325  separator->add(vtxs);
8326  tools_vforcit(vec3f,result,it) {
8327  vtxs->add(*it);
8328  vtxs->add_color(_color);
8329  vtxs->add_normal(plane2.normal());
8330  }
8331  }
8332  empty = false;
8333  //sep_empty = false;
8334  }}
8335  }
8336 
8337  } //index faces
8338 
8339  //if(sep_empty) {
8340  // delete sep;
8341  //} else {
8342  // separator->add(sep);
8343  //}
8344 
8345  } //icol
8346 
8347  if(empty) {
8348  delete separator;
8349  } else {
8351  }
8352  }
8353 
8354  // for OpenPAW /GRAPHICS/PRIMITIVES/TEXT
8355  // for OpenPAW /GRAPHICS/PRIMITIVES/ITX
8357  if(a_obj.m_TEXT.empty()) return;
8358 
8359  float z = xy_depth.value()*1.1F;
8360 
8361  vec3f pos;
8362  axis_2_data_frame(vec3f(a_obj.m_X,a_obj.m_Y,z),pos); //FIXME return FALSE
8363  xx_2_yy(pos,pos);
8364 
8365  separator* sep = new separator;
8366 
8367  rgba* mat = new rgba();
8368  mat->color = a_obj.m_TXCI;
8369  sep->add(mat);
8370 
8371  matrix* _tsf = new matrix;
8372  _tsf->set_translate(pos);
8373  _tsf->mul_rotate(0,0,1,a_obj.m_ANGLE*fpi()/180.0f);
8374  _tsf->mul_scale(a_obj.m_SCALE,a_obj.m_SCALE,1);
8375  sep->add(_tsf);
8376 
8377  //SIZE is in page coordinate YSIZ.
8378  //float YSIZ = height.value();
8379  //if(YSIZ<=0) YSIZ = 1;
8380 
8381  //::printf("debug : tools::sg::plotter::update_primitive_text : %s : X %g Y %g : SCALE %g SIZE %g : pos %g %g %g\n",
8382  // a_obj.m_TEXT.c_str(),a_obj.m_X,a_obj.m_Y,a_obj.m_SCALE,a_obj.m_SIZE,
8383  // pos[0],pos[1],pos[2]);
8384 
8385  if(a_obj.m_text_mode==plottable_text::text_enforce_width) { // not tested yet.
8386 
8387  vec3f pos2;
8388  axis_2_data_frame(vec3f(a_obj.m_X+a_obj.m_SIZE,a_obj.m_Y,z),pos2); //m_SIZE is taken as text width in this text_mode.
8389  xx_2_yy(pos2,pos2);
8390 
8391  float _width = pos2.x()-pos.x();
8392 
8393  text* _text = new text(m_ttf);
8394  _text->enforce_front_width = true; //it will set _text->width, height.
8395  _text->front_width = _width;
8396  _text->back_visible = false;
8397 
8398  _text->encoding = encoding_PAW();
8399  _text->strings.add(a_obj.m_TEXT);
8400  _text->line_width = a_obj.m_line_width;
8401  _text->font = a_obj.m_FONT;
8402  _text->font_modeling = a_obj.m_font_modeling;
8403 
8404  if(a_obj.m_HJUST=='R') {
8405  _text->hjust = right;
8406  } else if(a_obj.m_HJUST=='C') {
8407  _text->hjust = center;
8408  } else {
8409  _text->hjust = left;
8410  }
8411  if(a_obj.m_VJUST=='T') {
8412  _text->vjust = top;
8413  } else if(a_obj.m_VJUST=='M') {
8414  _text->vjust = middle;
8415  } else {
8416  _text->vjust = bottom;
8417  }
8418 
8419  sep->add(_text);
8420 
8421  } else if(a_obj.m_text_mode==plottable_text::text_enforce_height) { // for EsbRootView neard, fard 2D plot.
8422 
8423  vec3f pos2;
8424  axis_2_data_frame(vec3f(a_obj.m_X,a_obj.m_Y+a_obj.m_SIZE,z),pos2); //m_SIZE is taken as text height in this text_mode.
8425  xx_2_yy(pos2,pos2);
8426 
8427  float _height = pos2.y()-pos.y();
8428 
8429  text* _text = new text(m_ttf);
8430  _text->enforce_front_height = true; //it will set _text->width, height.
8431  _text->front_height = _height;
8432  _text->back_visible = false; //if true, we should adapt back_area::width, height to inside text size.
8433 
8434  _text->encoding = encoding_PAW();
8435  _text->strings.add(a_obj.m_TEXT);
8436  _text->line_width = a_obj.m_line_width;
8437  _text->font = a_obj.m_FONT;
8438  _text->font_modeling = a_obj.m_font_modeling;
8439 
8440  if(a_obj.m_HJUST=='R') {
8441  _text->hjust = right;
8442  } else if(a_obj.m_HJUST=='C') {
8443  _text->hjust = center;
8444  } else {
8445  _text->hjust = left;
8446  }
8447  if(a_obj.m_VJUST=='T') {
8448  _text->vjust = top;
8449  } else if(a_obj.m_VJUST=='M') {
8450  _text->vjust = middle;
8451  } else {
8452  _text->vjust = bottom;
8453  }
8454 
8455  sep->add(_text);
8456 
8457  } else { //text_as_it (for gopaw/pagpri.cpp).
8458  _tsf->mul_scale(a_obj.m_SIZE,a_obj.m_SIZE,1);
8459 
8460  if(a_obj.m_FONT==font_hershey()) {
8461  //::printf("debug : tools::sg::plotter::update_primitive_text : hershey\n");
8462  draw_style* ds = new draw_style;
8463  ds->style = draw_lines;
8464  ds->line_pattern = line_solid;
8465  ds->line_width = a_obj.m_line_width;
8466  //ds->line_pattern = m_title_style.line_pattern;
8467  //ds->line_width = m_title_style.line_width;
8468  sep->add(ds);
8469 
8471  text->encoding = encoding_PAW();
8472  text->strings.add(a_obj.m_TEXT);
8473  if(a_obj.m_HJUST=='R') {
8474  text->hjust = right;
8475  } else if(a_obj.m_HJUST=='C') {
8476  text->hjust = center;
8477  } else {
8478  text->hjust = left;
8479  }
8480  if(a_obj.m_VJUST=='T') {
8481  text->vjust = top;
8482  } else if(a_obj.m_VJUST=='M') {
8483  text->vjust = middle;
8484  } else {
8485  text->vjust = bottom;
8486  }
8487  sep->add(text);
8488 
8489  } else {
8490  //::printf("debug : tools::sg::plotter::update_primitive_text : freetype\n");
8492 
8493  text->font = a_obj.m_FONT;
8494  if(a_obj.m_HJUST=='R') {
8495  text->hjust = right;
8496  } else if(a_obj.m_HJUST=='C') {
8497  text->hjust = center;
8498  } else {
8499  text->hjust = left;
8500  }
8501  if(a_obj.m_VJUST=='T') {
8502  text->vjust = top;
8503  } else if(a_obj.m_VJUST=='M') {
8504  text->vjust = middle;
8505  } else {
8506  text->vjust = bottom;
8507  }
8508 
8509  text->modeling = a_obj.m_font_modeling;
8510 
8511  //text->encoding = encoding_PAW()
8512  //text->smooting = a_obj.m_SMOOTHING;
8513  //text->hinting = a_obj.m_HINTING;
8514  text->strings.add(a_obj.m_TEXT);
8515  //text->hjust.value(a_hjust);
8516  //text->vjust.value(a_vjust);
8517 
8518  sep->add(text);
8519  }
8520 
8521  } //text_mode.
8522 
8524  }
8525 
8526  // for OpenPAW /GRAPHICS/PRIMITIVES/BOX
8527  void PAW_hatch(int aHTYP,hatching_policy& a_policy,float& a_spacing,float& a_angle_right,float& a_angle_left) {
8528  // PAW hatching encoding (paw.pdf 1.14(1992) p 174) :
8529 
8530  a_policy = hatching_none;
8531  a_spacing = 0;
8532  a_angle_right = 0;
8533  a_angle_left = 0;
8534 
8535  int code = aHTYP;
8536  if(code==0) return;
8537 
8538  // From PAW FAQ web page.
8539  // special code from code [1,25]
8540  if(code==1) {
8541  a_policy = hatching_left_and_right;
8542  a_spacing = 0.04F;
8543  a_angle_right = 3.0F*fpi()/4.0F;
8544  a_angle_left = fpi()/4.0F;
8545  return;
8546  } else if(code==2) {
8547  a_policy = hatching_left_and_right;
8548  a_spacing = 0.08F;
8549  a_angle_right = 3.0F*fpi()/4.0F;
8550  a_angle_left = fpi()/4.0F;
8551  return;
8552  } else if(code==3) {
8553  a_policy = hatching_left_and_right;
8554  a_spacing = 1.6f*0.07F; //cooking
8555  a_angle_right = 3.0F*fpi()/4.0F;
8556  a_angle_left = fpi()/4.0F;
8557  return;
8558  } else if(code==4) {
8559  code = 354;
8560  } else if(code==5) {
8561  code = 345;
8562  } else if(code==6) {
8563  code = 359;
8564  } else if(code==7) {
8565  code = 350;
8566  } else if(code<=25) {
8567  //FIXME : seems to be done with patterns.
8568  a_policy = hatching_none;
8569  return;
8570  } else if(code<=99) {
8571  //FIXME
8572  a_policy = hatching_none;
8573  return;
8574  }
8575 
8576  //code >=100
8577 
8578  // code = ijk
8579 
8580  int i = code / 100;
8581  int j = (code - i * 100)/10;
8582  int k = code - i * 100 - j * 10;
8583 
8584  // j-hatching on rightHatchStyle :
8585  // k-hatching on leftHatchStyle :
8586 
8587  if((j==5)&&(k==5))
8588  a_policy = hatching_none;
8589  else if((j!=5)&&(k==5))
8590  a_policy = hatching_right;
8591  else if((j==5)&&(k!=5))
8592  a_policy = hatching_left;
8593  else if((j!=5)&&(k!=5))
8594  a_policy = hatching_left_and_right;
8595 
8596  unsigned int NY = 1;
8597 
8598  a_spacing = float(NY) * float(i) * 0.07F; //cooking
8599 
8600  if(j!=5) {
8601  float angle = float(j==4?45:j*10);
8602  angle = 180.0F - angle;
8603  angle *= fpi() / 180.0F;
8604 
8605  a_angle_right = angle;
8606  }
8607 
8608  if(k!=5) {
8609  float angle = float(k==4?45:k*10);
8610  angle *= fpi() / 180.0F;
8611  a_angle_left = angle;
8612  }
8613 
8614  }
8615 
8616  void rep_box_hatch(separator& a_parent,float a_spacing,float a_angle,float a_strip_width,
8617  float xx,float yy,float xe,float ye,float a_zz){
8618 
8619  //printf("debug : SoPlotter::repHatch1D_xy : zz %g\n",a_zz);
8621 
8622  bool empty = true;
8623 
8624  vec3f points[5];
8625 
8626  points[0].set_value(xx,yy,a_zz);
8627  points[1].set_value(xe,yy,a_zz);
8628  points[2].set_value(xe,ye,a_zz);
8629  points[3].set_value(xx,ye,a_zz);
8630  points[4].set_value(xx,yy,a_zz);
8631 
8632  //We can have multiple hatching for a bins ; have a separator :
8633  hatcher _hatcher;
8634  _hatcher.set_offset_point(vec3f(0,0,a_zz));
8635  _hatcher.set_angle(a_angle);
8636  _hatcher.set_spacing(a_spacing);
8637  if(!_hatcher.set_strip_width(a_strip_width)) {}
8638 
8639  bool res = _hatcher.check_polyline(points,4);
8640  if(res) res = _hatcher.compute_polyline(points,4);
8641 
8642  size_t numPoints = _hatcher.points().size();
8643  size_t numVertices = _hatcher.vertices().size();
8644  if((res) && numPoints && numVertices) {
8645 
8646  const std::vector<vec3f>& _points = _hatcher.points();
8647 
8648  if(a_strip_width==0) {
8649  size_t ipt = 0;
8650  tools_vforcit(unsigned int,_hatcher.vertices(),itv) {
8651  vertices* vtxs = new vertices;
8652  vtxs->mode = gl::line_strip();
8653  for(size_t index=0;index<(*itv);index++) {
8654  vtxs->add(_points[ipt]);
8655  ipt++;
8656  }
8657  separator->add(vtxs);
8658  empty = false;
8659  }
8660 
8661  } else {
8662  size_t ipt = 0;
8663  tools_vforcit(unsigned int,_hatcher.vertices(),itv) {
8664  vertices* vtxs = new vertices;
8665  vtxs->mode = gl::triangle_fan();
8666  for(size_t index=0;index<(*itv);index++) {
8667  vtxs->add(_points[ipt]);
8668  ipt++;
8669  }
8670  separator->add(vtxs);
8671  empty = false;
8672  }
8673  }
8674 
8675  empty = false;
8676  }
8677 
8678  if(empty) {
8679  delete separator;
8680  } else {
8681  a_parent.add(separator);
8682  }
8683  }
8684 
8685  void update_primitive_box(std::ostream& a_out,const plottable_box& a_obj){
8686 
8687  float z = xy_depth.value()*1.1F;
8688 
8689  vec3f pos1;
8690  axis_2_data_frame(vec3f(a_obj.m_X1,a_obj.m_Y1,z),pos1);
8691  xx_2_yy(pos1,pos1);
8692 
8693  vec3f pos2;
8694  axis_2_data_frame(vec3f(a_obj.m_X2,a_obj.m_Y2,z),pos2);
8695  xx_2_yy(pos2,pos2);
8696 
8697  z = pos1[2];
8698 
8699 // ::printf("debug : tools::sg::plotter::update_primitive_box : FAIS %d : %g %g %g : %g %g %g\n",a_obj.m_FAIS,
8700 // pos1.x(),pos1.y(),pos1.z(),pos2.x(),pos2.y(),pos2.z());
8701 
8702  if(a_obj.m_FAIS==plottable_box::HOLLOW) {
8703 
8704  separator* sep = new separator;
8705 
8706  rgba* mat = new rgba();
8707  mat->color = a_obj.m_PLCI;
8708  sep->add(mat);
8709 
8710  draw_style* ds = new draw_style;
8711  ds->style = draw_lines;
8712  ds->line_pattern = line_solid;
8713  ds->line_width = a_obj.m_LWID;
8714  sep->add(ds);
8715 
8716  vertices* vtxs = new vertices;
8717  vtxs->mode = gl::line_strip();
8718  sep->add(vtxs);
8719 
8720  vtxs->add(pos1[0],pos1[1],z);
8721  vtxs->add(pos2[0],pos1[1],z);
8722  vtxs->add(pos2[0],pos2[1],z);
8723  vtxs->add(pos1[0],pos2[1],z);
8724  vtxs->add(pos1[0],pos1[1],z);
8725 
8727 
8728  } else if(a_obj.m_FAIS==plottable_box::SOLID) {
8729  separator* sep = new separator;
8730 
8731  rgba* mat = new rgba();
8732  mat->color = a_obj.m_FACI;
8733  sep->add(mat);
8734 
8735  draw_style* ds = new draw_style;
8736  ds->style = draw_filled;
8737  sep->add(ds);
8738 
8739  vertices* vtxs = new vertices;
8740  vtxs->mode = gl::triangle_fan();
8741  sep->add(vtxs);
8742 
8743  vtxs->add(pos1[0],pos1[1],z);
8744  vtxs->add(pos2[0],pos1[1],z);
8745  vtxs->add(pos2[0],pos2[1],z);
8746  vtxs->add(pos1[0],pos2[1],z);
8747 
8749 
8750  } else if(a_obj.m_FAIS==plottable_box::HATCHED) {
8751 
8752  {separator* sep = new separator;
8753 
8754  rgba* mat = new rgba();
8755  mat->color = a_obj.m_FACI;
8756  sep->add(mat);
8757 
8758  hatching_policy hatching;
8759  float spacing;
8760  float angle_right;
8761  float angle_left;
8762  PAW_hatch(a_obj.m_FASI,hatching,spacing,angle_right,angle_left);
8763  float stripWidth = 0;
8764 
8765  if((hatching==hatching_right)||((hatching==hatching_left_and_right))) {
8766  rep_box_hatch(*sep,spacing,angle_right,stripWidth,pos1[0],pos1[1],pos2[0],pos2[1],z);
8767  }
8768  if((hatching==hatching_left)||((hatching==hatching_left_and_right))) {
8769  rep_box_hatch(*sep,spacing,angle_left,stripWidth,pos1[0],pos1[1],pos2[0],pos2[1],z);
8770  }
8771 
8772  if(hatching==hatching_none) {
8773  draw_style* ds = new draw_style;
8774  ds->style = draw_filled;
8775  sep->add(ds);
8776  vertices* vtxs = new vertices;
8777  vtxs->mode = gl::triangle_fan();
8778  sep->add(vtxs);
8779  vtxs->add(pos1[0],pos1[1],z);
8780  vtxs->add(pos2[0],pos1[1],z);
8781  vtxs->add(pos2[0],pos2[1],z);
8782  vtxs->add(pos1[0],pos2[1],z);
8783  }
8784 
8786 
8787  if(a_obj.m_BORD) {
8788  separator* sep = new separator;
8789  rgba* mat = new rgba();
8790  mat->color = a_obj.m_PLCI;
8791  sep->add(mat);
8792 
8793  draw_style* ds = new draw_style;
8794  ds->style = draw_lines;
8795  ds->line_pattern = line_solid;
8796  ds->line_width = 1;
8797  sep->add(ds);
8798 
8799  vertices* vtxs = new vertices;
8800  vtxs->mode = gl::line_strip();
8801  sep->add(vtxs);
8802 
8803  z *= 1.01F;
8804  vtxs->add(pos1[0],pos1[1],z);
8805  vtxs->add(pos2[0],pos1[1],z);
8806  vtxs->add(pos2[0],pos2[1],z);
8807  vtxs->add(pos1[0],pos2[1],z);
8808  vtxs->add(pos1[0],pos1[1],z);
8809 
8811  }
8812 
8813  } else if(a_obj.m_FAIS==plottable_box::PATTERN) {
8814  a_out << "tools::sg::plotter::update_plottable_box FAIS PATTERN not yet handled." << std::endl;
8815  }
8816 
8817  }
8818 
8819  void update_primitive_ellipse(std::ostream& a_out,const plottable_ellipse& a_obj){
8820 
8821  float z = xy_depth.value()*1.1F;
8822 
8823  vec3f pos;
8824  axis_2_data_frame(vec3f(a_obj.m_X,a_obj.m_Y,z),pos);
8825  xx_2_yy(pos,pos);
8826 
8827  vec3f pos2;
8828  axis_2_data_frame(vec3f(a_obj.m_X+a_obj.m_R1,a_obj.m_Y+a_obj.m_R2,z),pos2);
8829  xx_2_yy(pos2,pos2);
8830 
8831  float rx = pos2[0]-pos[0];
8832  float ry = pos2[1]-pos[1];
8833 
8834  z = pos[2];
8835 
8836  //::printf("debug : tools::sg::plotter::update_primitive_ellipse : FAIS %d : %g %g %g : %g %g\n",a_obj.m_FAIS,
8837  // pos.x(),pos.y(),pos.z(),rx,ry);
8838 
8839  if(a_obj.m_FAIS==plottable_ellipse::HOLLOW) {
8840 
8841  separator* sep = new separator;
8842 
8843  matrix* _tsf = new matrix;
8844  _tsf->set_translate(pos);
8845  sep->add(_tsf);
8846 
8847  rgba* mat = new rgba();
8848  mat->color = a_obj.m_PLCI;
8849  sep->add(mat);
8850 
8851  draw_style* ds = new draw_style;
8852  ds->style = draw_lines;
8853  ds->line_pattern = line_solid;
8854  ds->line_width = a_obj.m_LWID;
8855  sep->add(ds);
8856 
8857  ellipse* _ellipse = new ellipse;
8858  _ellipse->rx = rx;
8859  _ellipse->ry = ry;
8860  sep->add(_ellipse);
8861 
8863 
8864 /*
8865  } else if(a_obj.m_FAIS==plottable_ellipse::SOLID) {
8866  separator* sep = new separator;
8867 
8868  rgba* mat = new rgba();
8869  mat->color = a_obj.m_FACI;
8870  sep->add(mat);
8871 
8872  draw_style* ds = new draw_style;
8873  ds->style = draw_filled;
8874  sep->add(ds);
8875 
8876  vertices* vtxs = new vertices;
8877  vtxs->mode = gl::triangle_fan();
8878  sep->add(vtxs);
8879 
8880  vtxs->add(pos1[0],pos1[1],z);
8881  vtxs->add(pos2[0],pos1[1],z);
8882  vtxs->add(pos2[0],pos2[1],z);
8883  vtxs->add(pos1[0],pos2[1],z);
8884 
8885  m_primitives_sep.add(sep);
8886 
8887  } else if(a_obj.m_FAIS==plottable_ellipse::HATCHED) {
8888 
8889  {separator* sep = new separator;
8890 
8891  rgba* mat = new rgba();
8892  mat->color = a_obj.m_FACI;
8893  sep->add(mat);
8894 
8895  hatching_policy hatching;
8896  float spacing;
8897  float angle_right;
8898  float angle_left;
8899  PAW_hatch(a_obj.m_FASI,hatching,spacing,angle_right,angle_left);
8900  float stripWidth = 0;
8901 
8902  if((hatching==hatching_right)||((hatching==hatching_left_and_right))) {
8903  rep_box_hatch(*sep,spacing,angle_right,stripWidth,pos1[0],pos1[1],pos2[0],pos2[1],z);
8904  }
8905  if((hatching==hatching_left)||((hatching==hatching_left_and_right))) {
8906  rep_box_hatch(*sep,spacing,angle_left,stripWidth,pos1[0],pos1[1],pos2[0],pos2[1],z);
8907  }
8908 
8909  if(hatching==hatching_none) {
8910  draw_style* ds = new draw_style;
8911  ds->style = draw_filled;
8912  sep->add(ds);
8913  vertices* vtxs = new vertices;
8914  vtxs->mode = gl::triangle_fan();
8915  sep->add(vtxs);
8916  vtxs->add(pos1[0],pos1[1],z);
8917  vtxs->add(pos2[0],pos1[1],z);
8918  vtxs->add(pos2[0],pos2[1],z);
8919  vtxs->add(pos1[0],pos2[1],z);
8920  }
8921 
8922  m_primitives_sep.add(sep);}
8923 
8924  if(a_obj.m_BORD) {
8925  separator* sep = new separator;
8926  rgba* mat = new rgba();
8927  mat->color = a_obj.m_PLCI;
8928  sep->add(mat);
8929 
8930  draw_style* ds = new draw_style;
8931  ds->style = draw_lines;
8932  ds->line_pattern = line_solid;
8933  ds->line_width = 1;
8934  sep->add(ds);
8935 
8936  vertices* vtxs = new vertices;
8937  vtxs->mode = gl::line_strip();
8938  sep->add(vtxs);
8939 
8940  z *= 1.01F;
8941  vtxs->add(pos1[0],pos1[1],z);
8942  vtxs->add(pos2[0],pos1[1],z);
8943  vtxs->add(pos2[0],pos2[1],z);
8944  vtxs->add(pos1[0],pos2[1],z);
8945  vtxs->add(pos1[0],pos1[1],z);
8946 
8947  m_primitives_sep.add(sep);
8948  }
8949 
8950  } else if(a_obj.m_FAIS==plottable_ellipse::PATTERN) {
8951  a_out << "tools::sg::plotter::update_plottable_box FAIS PATTERN not yet handled." << std::endl;
8952 */
8953  } else {
8954  a_out << "tools::sg::plotter::update_plottable_box FAIS " << a_obj.m_FAIS << " not yet handled." << std::endl;
8955  }
8956 
8957  }
8958 
8959  void update_primitive_img(std::ostream& /*a_out*/,const plottable_img& a_obj){
8960 
8961  float z = xy_depth.value()*1.1F;
8962 
8963  vec3f pos;
8964  axis_2_data_frame(vec3f(a_obj.m_X,a_obj.m_Y,z),pos);
8965  xx_2_yy(pos,pos); //pos = center of image in axes coordinates.
8966  z = pos[2];
8967 
8968  vec3f top;
8969  axis_2_data_frame(vec3f(0,a_obj.m_Y+a_obj.m_HEIGHT*0.5f,0),top);
8970  xx_2_yy(top,top); //top = (o,y-top) of image in axes coordinates.
8971  float scale = 2.0f*(top[1]-pos[1]);
8972  //float scale = a_obj.m_HEIGHT; //m_HEIGHT is then in page coordinate YSIZ.
8973 
8974  const img<byte>& img = a_obj.m_img;
8975 
8976  //::printf("debug : tools::sg::plotter::update_primitive_img : %d %d %d : %g %g %g : %g : %g %g\n",
8977  // img.width(),img.height(),img.bpp(),
8978  // pos.x(),pos.y(),pos.z(),a_obj.m_HEIGHT,a_obj.m_THETA,a_obj.m_PHI);
8979 
8980  separator* sep = new separator;
8981 
8982  rgba* mat = new rgba();
8983  mat->color = colorf_white();
8984  sep->add(mat);
8985 
8986  normal* nm = new normal;
8987  sep->add(nm);
8988 
8989  matrix* _tsf = new matrix;
8990  _tsf->set_translate(pos);
8991  _tsf->mul_rotate(0,1,0,a_obj.m_THETA*fpi()/180.0f);
8992  _tsf->mul_rotate(0,0,1,a_obj.m_PHI*fpi()/180.0f);
8993  _tsf->mul_scale(scale,scale,1);
8994  sep->add(_tsf);
8995 
8996  tex_rect* _img = new tex_rect();
8997  _img->img = img;
8998  sep->add(_img);
8999 
9001 
9002  }
9003 
9004 protected: //etc
9005  // background is at z = 0.
9006  // last z items are text in infos, legend boxes that should be at xy_depth().
9007 
9008  float _zoffset() const {
9009  // first data plane is at _zoffset.
9010  // last one at m_plottables.size()*_zoffset = xy_depth.value()-_zoffset().
9011  return xy_depth.value()/(float(m_plottables.size())+1.0f);
9012  }
9013  float _zaxis() const {return _zoffset();}
9014  float _zgrid() const {return xy_depth.value()-_zoffset()*0.5f;}
9015  float _ztext() const {return 0.01f;} //if text back is visible else 0. (sf<float> zfront ?)
9016  float _zscale_text() const {return _zoffset()*0.4f/_ztext();} //title and infos boxes thickness.
9017  float _zinfos() const {return xy_depth.value()-_zoffset()*0.4f;} //in front _zgrid
9018  float _zhatch() const {return _zoffset()*0.25f;}
9019  float _zerrors() const {return _zoffset()*0.5f;}
9020 
9021  //static void LIST_SET(vec3f a_list[],unsigned int a_index,float x,float y,float z) {a_list[a_index].set_value(x,y,z);}
9022 
9023  static float take_log(float a_x){
9024  if(a_x<=0) {
9025  return -FLT_MAX;
9026  } else {
9027  return flog10(a_x);
9028  }
9029  }
9030 
9031  static float verify_log(float a_val,float a_min,float a_dx,bool a_log){
9032  if(a_log) {
9033  if(a_val>0.0F) {
9034  return (flog10(a_val) - a_min)/a_dx;
9035  } else { // Return a negative large number :
9036  //return -FLT_MAX;
9037  return -100;
9038  }
9039  } else {
9040  // Simple protection against value that could exceed a float :
9041  if(a_val>(a_min+100.0F * a_dx)) return 100;
9042  if(a_val<(a_min-100.0F * a_dx)) return -100;
9043  // Rescale :
9044  return (a_val - a_min)/a_dx;
9045  }
9046  }
9047 
9048  static float verify_log_inv(float a_val,float a_min,float a_dx,bool a_log){
9049  if(a_log) {
9050  return fpow(10,a_val*a_dx+a_min);
9051  } else {
9052  return a_val*a_dx+a_min;
9053  }
9054  }
9055 
9056  style* merge_bins_style(unsigned int a_index,plottable&) {
9057  style& _style = bins_style(a_index);
9058  //uuu merge with a_p.infos().
9059  return new style(_style);
9060  }
9061 
9062  style* merge_left_hatch_style(unsigned int a_index,plottable&) {
9063  style& _style = left_hatch_style(a_index);
9064  //uuu merge with a_p.infos().
9065  return new style(_style);
9066  }
9067 
9068  style* merge_right_hatch_style(unsigned int a_index,plottable&) {
9069  style& _style = right_hatch_style(a_index);
9070  //uuu merge with a_p.infos().
9071  return new style(_style);
9072  }
9073 
9074  style* merge_errors_style(unsigned int a_index,plottable&) {
9075  style& _style = errors_style(a_index);
9076  //uuu merge with a_p.infos().
9077  return new style(_style);
9078  }
9079 
9080  style* merge_func_style(unsigned int a_index,plottable&) {
9081  style& _style = func_style(a_index);
9082  //uuu merge with a_p.infos().
9083  return new style(_style);
9084  }
9085 
9086  style* merge_points_style(unsigned int a_index,plottable&) {
9087  style& _style = points_style(a_index);
9088  //uuu merge with a_p.infos().
9089  return new style(_style);
9090  }
9091 
9092 /*
9093  text_style* merge_legend_style(unsigned int a_index,plottable& a_p) {
9094  if(a_index>=m_legend_style.size()) return new text_style();
9095  return new text_style(m_legend_style[a_index]);
9096  //uuu merge with a_p.infos().
9097  }
9098 */
9099 
9101  if(!shape_automated) return shape.value();
9102 
9103  // Guess XY or XYZ shape :
9104  /*if(f_binsList.size()) { // major bins compells shape type.
9105  if(f_binsList[0]->getDimension()==1) {
9106  return XY;
9107  } else if(f_binsList[0]->getDimension()==2) {
9108  return XY; //lego is not the default.
9109  } else {
9110  return XYZ;
9111  }
9112  } else if(f_pointsList.size()) { // major points compells shape type.
9113  if(f_pointsList[0]->getDimension()==1) { //?
9114  return XY;
9115  } else if(f_pointsList[0]->getDimension()==2) {
9116  return XY;
9117  } else {
9118  return XYZ;
9119  }
9120  } else if(f_functionList.size()) { // major function compell shape type.
9121  if(f_functionList[0]->getDimension()==1) {
9122  return XY;
9123  } else {
9124  return XYZ;
9125  }
9126  } else*/ {
9127  return xy; //Default.
9128  }
9129  }
9130 
9132  //unsigned int objn = m_plottables.size();
9133  {std::vector<plottable*>::iterator it;
9134  for(it=m_plottables.begin();it!=m_plottables.end();++it) delete *it;
9135  m_plottables.clear();}
9136 
9137  /*
9138  if(objn) {
9139  // If a title (logScale) had been given on some axis,
9140  // it is probably no more pertinent for further data.
9141  if(xAxisEnforced.value()==false) {
9142  m_x_axis.title.setValue("");
9143  xAxisLogScale.setValue(false);
9144  }
9145  if(yAxisEnforced.value()==false) {
9146  m_y_axis.title.setValue("");
9147  yAxisLogScale.setValue(false);
9148  }
9149  if(zAxisEnforced.value()==false) {
9150  m_z_axis.title.setValue("");
9151  zAxisLogScale.setValue(false);
9152  }
9153  }
9154  */
9155 
9156  touch();
9157  }
9159  {std::vector<plotprim*>::iterator it;
9160  for(it=m_primitives.begin();it!=m_primitives.end();++it) delete *it;
9161  m_primitives.clear();}
9162  touch();
9163  }
9164 
9166 
9167  bool first_bins(bins1D*& a_1,bins2D*& a_2) const {
9169  plottable* object = *it;
9170  if(!object) continue;
9171  if(bins1D* b1 = safe_cast<plottable,bins1D>(*object)) {
9172  a_1 = b1;
9173  a_2 = 0;
9174  return true;
9175  } else if(bins2D* b2 = safe_cast<plottable,bins2D>(*object)) {
9176  a_1 = 0;
9177  a_2 = b2;
9178  return true;
9179  }
9180  }
9181  a_1 = 0;
9182  a_2 = 0;
9183  return false;
9184  }
9185 
9186  bool first_func(func1D*& a_1,func2D*& a_2) const {
9188  plottable* object = *it;
9189  if(!object) continue;
9190  if(func1D* f1 = safe_cast<plottable,func1D>(*object)) {
9191  a_1 = f1;
9192  a_2 = 0;
9193  return true;
9194  } else if(func2D* f2 = safe_cast<plottable,func2D>(*object)) {
9195  a_1 = 0;
9196  a_2 = f2;
9197  return true;
9198  }
9199  }
9200  a_1 = 0;
9201  a_2 = 0;
9202  return false;
9203  }
9204 
9205  bool first_points(points2D*& a_2,points3D*& a_3) const {
9207  plottable* object = *it;
9208  if(!object) continue;
9209  if(points2D* p2 = safe_cast<plottable,points2D>(*object)) {
9210  a_2 = p2;
9211  a_3 = 0;
9212  return true;
9213  } else if(points3D* p3 = safe_cast<plottable,points3D>(*object)) {
9214  a_2 = 0;
9215  a_3 = p3;
9216  return true;
9217  }
9218  }
9219  a_2 = 0;
9220  a_3 = 0;
9221  return false;
9222  }
9223 
9224  void clear_sg() {
9225  m_bins_sep.clear();
9226  m_errors_sep.clear();
9227  m_func_sep.clear();
9228  m_points_sep.clear();
9229  }
9230 
9231  void DUMP_UPDATE_WHAT(std::ostream&,const std::string&) {}
9232 /*
9233  void DUMP_UPDATE_WHAT(std::ostream& a_out,const std::string& a_msg) {
9234  a_out << "tools::sg::plotter :"
9235  << " " << a_msg
9236  << std::endl;
9237  }
9238 */
9239 
9240  static void add_pt(std::vector<float>& a_pts,float a_x,float a_y,float a_z){
9241  a_pts.push_back(a_x);
9242  a_pts.push_back(a_y);
9243  a_pts.push_back(a_z);
9244  }
9245 
9246  static void clip_points_2D(const std::vector<vec3f>& a_points,
9247  const rep_box& a_box_x,const rep_box& a_box_y,std::vector<float>& a_pts) {
9248  float xmin = a_box_x.m_pos;
9249  float dx = a_box_x.m_width;
9250  bool xlog = a_box_x.m_log;
9251 
9252  float ymin = a_box_y.m_pos;
9253  float dy = a_box_y.m_width;
9254  bool ylog = a_box_y.m_log;
9255 
9256  a_pts.clear();
9257 
9258  float xx,yy,zz;
9259  tools_vforcit(vec3f,a_points,it) {
9260  const vec3f& _point = *it;
9261  xx = _point[0];
9262  yy = _point[1];
9263  zz = _point[2];
9264  xx = verify_log(xx,xmin,dx,xlog);
9265  yy = verify_log(yy,ymin,dy,ylog);
9266  if((xx>=0)&&(xx<=1)&&(yy>=0)&&(yy<=1)) add_pt(a_pts,xx,yy,zz);
9267  }
9268  }
9269 
9270  static void clip_polyline_2D(const std::vector<vec3f>& a_points,
9271  const rep_box& a_box_x,const rep_box& a_box_y,std::vector<float>& a_pts) {
9272  // Clip line in a_box_x, a_box_y.
9273 
9274  //NOTE : it is not a general algorithm.
9275  // It is assumed that a_points are ordered with increasing x.
9276  // And the algorithm clips against up and bottom BoxY lines.
9277  // (Use clip<float> for a more general algorithm ?)
9278 
9279  float xmin = a_box_x.m_pos;
9280  float dx = a_box_x.m_width;
9281  bool xlog = a_box_x.m_log;
9282 
9283  float ymin = a_box_y.m_pos;
9284  float dy = a_box_y.m_width;
9285  bool ylog = a_box_y.m_log;
9286 
9287  a_pts.clear();
9288 
9289  float xprev = 0;
9290  float yprev = 0;
9291 
9292  {unsigned int index = 0;
9293  std::vector<vec3f>::const_iterator it;
9294  for(it=a_points.begin();it!=a_points.end();++it,index++) {
9295  const vec3f& _point = *it;
9296  float xx = _point[0];
9297  float yy = _point[1];
9298  float zz = _point[2];
9299  //add_pt(a_pts,xx,yy,zz);continue; //debug
9300  xx = verify_log(xx,xmin,dx,xlog);
9301  yy = verify_log(yy,ymin,dy,ylog);
9302  if((xx>=0)&&(xx<=1) ) {
9303  if(yy>1) {
9304  if(index==0) {
9305  add_pt(a_pts,xx,1,zz);
9306  } else {
9307  if(yprev>1) {
9308  add_pt(a_pts,xx,1,zz);
9309  } else if(yprev<0) {
9310  float a = (yy - yprev)/(xx - xprev);
9311  float b = yy - a * xx;
9312  add_pt(a_pts,-b/a,0,zz);
9313  add_pt(a_pts,(1 - b)/a,1,zz);
9314  add_pt(a_pts,xx,1,zz);
9315  } else {
9316  float a = (yy - yprev)/(xx - xprev);
9317  float b = yy - a * xx;
9318  add_pt(a_pts,(1 - b)/a,1,zz);
9319  add_pt(a_pts,xx,1,zz);
9320  }
9321  }
9322  } else if (yy < 0) {
9323  if(index==0) {
9324  add_pt(a_pts,xx,0,zz);
9325  } else {
9326  if(yprev<0) {
9327  add_pt(a_pts,xx,0,zz);
9328  } else if(yprev>1) {
9329  float a = (yy - yprev)/(xx - xprev);
9330  float b = yy - a * xx;
9331  add_pt(a_pts,(1 - b)/a,1,zz);
9332  add_pt(a_pts,-b/a,0,zz);
9333  add_pt(a_pts,xx,0,zz);
9334  } else {
9335  float a = (yy - yprev)/(xx - xprev);
9336  float b = yy - a * xx;
9337  add_pt(a_pts,-b/a,0,zz);
9338  add_pt(a_pts,xx,0,zz);
9339  }
9340  }
9341  } else {
9342  if(index==0) {
9343  add_pt(a_pts,xx,yy,zz);
9344  } else if( (yprev>1) || (yprev<0) ) {
9345  // interpolate :
9346  float a = (yy - yprev)/(xx - xprev);
9347  float b = yy - a * xx;
9348  if(yprev>1) {
9349  add_pt(a_pts,(1 - b)/a,1,zz);
9350  } else {
9351  add_pt(a_pts,-b/a,0,zz);
9352  }
9353  add_pt(a_pts,xx,yy,zz);
9354  } else {
9355  add_pt(a_pts,xx,yy,zz);
9356  }
9357  }
9358  }
9359  xprev = xx;
9360  yprev = yy;
9361  }}
9362  }
9363 
9364  bool sto(const std::string& a_s,vec2f& a_v) {
9365  std::vector<std::string> ws;
9366  words(a_s," ",false,ws);
9367  if(ws.size()!=2) return false;
9368  float x = 0;
9369  if(!to<float>(ws[0],x)) return false;
9370  float y = 0;
9371  if(!to<float>(ws[1],x)) return false;
9372  a_v.set_value(x,y);
9373  return true;
9374  }
9375 
9376  bool sto(const std::string& a_s,unit_type& a_v) {
9377  if(a_s=="percent") {a_v = unit_percent;return true;}
9378  else if(a_s=="axis") {a_v = unit_axis;return true;}
9379  return false;
9380  }
9381 
9382  void clear_cmaps() {
9383  {std::vector<base_colormap*>::iterator it;
9384  for(it=m_bins_cmaps.begin();it!=m_bins_cmaps.end();++it) delete *it;
9385  m_bins_cmaps.clear();}
9386 
9387  {std::vector<base_colormap*>::iterator it;
9388  for(it=m_points_cmaps.begin();it!=m_points_cmaps.end();++it) delete *it;
9389  m_points_cmaps.clear();}
9390 
9391  {std::vector<base_colormap*>::iterator it;
9392  for(it=m_func_cmaps.begin();it!=m_func_cmaps.end();++it) delete *it;
9393  m_func_cmaps.clear();}
9394  }
9395 
9396  void bar_chart(float a_bar_offset,float a_bar_width,
9397  float& a_beg,float& a_end){
9398  float xe = (a_end - a_beg)*a_bar_offset;
9399  float xw = (a_end - a_beg)*a_bar_width;
9400  a_end = a_beg + xe + xw;
9401  a_beg = a_beg + xe;
9402  }
9403 
9404 protected:
9406 protected: //fields for skeleton.
9408 
9410 
9416 
9421 
9424 
9426 
9430 
9434 
9438 
9440 
9451 
9452 protected: //fields
9454 
9458 
9459  std::vector<plottable*> m_plottables; //it has ownership.
9460 
9461  std::vector<style> m_bins_style;
9462  std::vector<style> m_errors_style;
9463  std::vector<style> m_func_style;
9464  std::vector<style> m_points_style;
9465  std::vector<style> m_left_hatch_style;
9466  std::vector<style> m_right_hatch_style;
9467  std::vector<style> m_legend_style;
9468 
9473  style m_wall_style; //for gopaw.
9476 
9477 protected:
9478  std::vector<std::string> m_legend_strings;
9479 
9480  std::vector<base_colormap*> m_bins_cmaps;
9481  std::vector<base_colormap*> m_points_cmaps;
9482  std::vector<base_colormap*> m_func_cmaps;
9483 
9485  std::vector<plotprim*> m_primitives;
9488 };
9489 
9490 }}
9491 
9492 #endif
tools::box3::mn
const VEC3 & mn() const
Definition: box3:69
tools::sg::text::vjust
sf_enum< sg::vjust > vjust
Definition: text:49
tools::sg::line_style
Definition: line_style:17
tools::sg::plotter::copy_style
void copy_style(const plotter &a_from)
Definition: plotter:403
tools::sg::points3D::z_axis_min
virtual float z_axis_min() const =0
tools::sg::plotter::set_axes_line_pattern
void set_axes_line_pattern(unsigned short a_v)
Definition: plotter:2119
tools::sg::plotter::SbFunc::m_problem
bool m_problem
Definition: plotter:3863
tools::sg::plotter::data_light
const torche & data_light() const
Definition: plotter:1605
tools::sg::plotter::rep_points2D_xy_points
void rep_points2D_xy_points(std::ostream &a_out, const style &a_style, const points2D &a_points, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:7663
tools::sg::plotter::m_errors_sep
separator m_errors_sep
Definition: plotter:9445
tools::sg::plotter::m_data_light
torche m_data_light
Definition: plotter:9442
tools::sg::style::strip_width
sf< float > strip_width
Definition: style:52
tools::sg::plotter::rep_top_face2D_xyz_line
void rep_top_face2D_xyz_line(const style &, const std::vector< rep_top_face2D > &a_top_faces, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z)
Definition: plotter:8072
tools::sg::plotter::wall_style
style & wall_style()
Definition: plotter:1707
tools::sg::atb_vertices::add_normal
void add_normal(float a_x, float a_y, float a_z)
Definition: atb_vertices:486
tools::sg::plotter::set_from_style
bool set_from_style(std::ostream &a_out, const style_t &a_style)
Definition: plotter:740
tools::direction
void direction(const VEC3 &a_p0, const VEC3 &a_p1, const VEC3 &a_p2, VEC3 &a_value)
Definition: vec3:344
tools::sg::rep_bin1D::m_val
float m_val
Definition: rep:44
tools::sg::axis::reset_touched
virtual void reset_touched()
Definition: axis:116
tools::sg::plottable_box::m_X1
float m_X1
Definition: plottables:314
tools::sg::plotter::rep_points2D_xy_curve
void rep_points2D_xy_curve(std::ostream &a_out, const style &a_style, const points2D &a_points, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:7607
tools::sg::markers::add
void add(const VEC &a_v)
Definition: markers:594
tools::sg::bins2D::bin_upper_edge_y
virtual float bin_upper_edge_y(int) const =0
tools::sg::plotter::m_title_box_style
text_style m_title_box_style
Definition: plotter:9471
tools::sg::style::visible
sf< bool > visible
Definition: style:53
tools::sg::plotter::legends_string
mf_string legends_string
Definition: plotter:141
tools::fdeg2rad
float fdeg2rad()
Definition: mathf:18
tools::sg::markers
Definition: markers:21
tools::sg::text::confine
sf< bool > confine
Definition: text:29
tools::sg::plotter::title_to_axis
sf< float > title_to_axis
Definition: plotter:70
tools::sg::plotter::y_axis_enforced
sf< bool > y_axis_enforced
Definition: plotter:93
tools::sg::plotter::m_z_axis_sep
separator m_z_axis_sep
Definition: plotter:9435
tools::sg::plotter::rep_bins1D_xy_boxes
void rep_bins1D_xy_boxes(const style &a_style, const base_colormap &a_cmap, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:6173
tools::vec2f
Definition: vec2f:13
tools::sg::plotter::update_grid_XYZ
void update_grid_XYZ()
Definition: plotter:5899
tools::sg::bins2D::bins_Sw_range
virtual void bins_Sw_range(float &, float &, bool) const =0
tools::sg::plotter::clear
void clear()
Definition: plotter:1674
tools::sg::plottable::cast
virtual void * cast(const std::string &a_class) const
Definition: plottable:19
tools::mat4::set_translate
void set_translate(const T &a_x, const T &a_y, const T &a_z)
Definition: mat4:60
tools::value
Definition: value:18
tools::sg::plottable_ellipse::m_X
float m_X
Definition: plottables:373
tools::sg::text_style::font
sf_string font
Definition: text_style:28
tools::sg::bins1D
Definition: plottables:13
tools::sg::plotter::m_wall_style
style m_wall_style
Definition: plotter:9473
tools::sg::axis::coords
mf< float > coords
Definition: axis:52
tools::sg::atb_vertices::add_rgba
void add_rgba(float a_r, float a_g, float a_b, float a_a)
Definition: atb_vertices:473
tools::sg::plotter::data_light
torche & data_light()
Definition: plotter:1606
tools::sg::func2D::x_min
virtual float x_min() const =0
tools::sg::plotter::set_axes_modeling
void set_axes_modeling(const std::string &a_v)
Definition: plotter:2068
tools::sg::plottable_box::HOLLOW
@ HOLLOW
Definition: plottables:279
tools::sg::plotter::update_inner_frame_XY
void update_inner_frame_XY()
Definition: plotter:5730
tools::sg::group::search
virtual void search(search_action &a_action)
Definition: group:51
tools::sg::plottable_ellipse::m_R2
float m_R2
Definition: plottables:376
tools::sg::plotter::z_axis
const sg::axis & z_axis() const
Definition: plotter:1699
tools::sg::bins2D
Definition: plottables:42
tools::img< byte >
tools::sg::plotter::m_cmap_matrix
matrix m_cmap_matrix
Definition: plotter:9412
tools::sg::plotter::update_points2D_xy
void update_points2D_xy(std::ostream &a_out, const points2D &a_points, const style &a_style, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:4517
tools::sg::plotter::rep_errors_I_xy
void rep_errors_I_xy(std::ostream &, const style &a_style, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, const std::vector< float > &a_bars, float aZ)
Definition: plotter:7339
tools::sg::plotter::m_func_cmaps
std::vector< base_colormap * > m_func_cmaps
Definition: plotter:9482
tools::sg::plotter::update_infos
void update_infos(std::ostream &)
Definition: plotter:5318
tools::sg::plotter::m_grid_style
style m_grid_style
Definition: plotter:9475
tools::sg::plotter::add_node_todel
void add_node_todel(node *a_node)
Definition: plotter:1670
tools::sg::bins2D::y_axis_max
virtual float y_axis_max() const =0
tools::sg::plotter::m_plottables
std::vector< plottable * > m_plottables
Definition: plotter:9459
tools::sg::axis::tick_up
sf< bool > tick_up
Definition: axis:43
tools::sg::plotter::m_rtausmef
rtausmef m_rtausmef
Definition: plotter:9487
tools::sg::plotter::plotted_object_names
void plotted_object_names(std::vector< std::string > &a_names) const
Definition: plotter:1593
tools::sg::matrix::mul_rotate
void mul_rotate(float a_x, float a_y, float a_z, float a_angle)
Definition: matrix:107
tools::sg::modeling_boxes
const std::string & modeling_boxes()
Definition: strings:64
tools::sg::bins2D::bin_lower_edge_y
virtual float bin_lower_edge_y(int) const =0
tools::sg::plottable_img::m_PHI
float m_PHI
Definition: plottables:433
tools::sg::func1D::x_max
virtual float x_max() const =0
tools::sg::plottable_text::m_X
float m_X
Definition: plottables:251
tools::sg::plotter::add_todel
void add_todel(T *a_obj)
Definition: plotter:1660
tools::spline::cubic::eval
double eval(double x) const
Definition: spline:182
tools::sg::light_model_base_color
const std::string & light_model_base_color()
Definition: strings:174
tools::sg::plottable::legend
virtual const std::string & legend() const =0
tools::sg::plotter::update_primitive_img
void update_primitive_img(std::ostream &, const plottable_img &a_obj)
Definition: plotter:8959
tools::sg::plotter::rep_bins2D_xy_random_one
void rep_bins2D_xy_random_one(const style &a_style, const std::vector< rep_bin2D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_bmin, float a_bmax, float a_zz)
Definition: plotter:6766
tools::sg::plottable_box::m_FAIS
fill_area_style m_FAIS
Definition: plottables:318
tools::hatcher::check_polyline
bool check_polyline(vec3f *listPoints, unsigned int number)
test if the polygone given is correct for hatching
tools::data_axis::set_is_log
bool set_is_log(bool a_v)
Definition: data_axis:28
tools::sg::plotter::vp_2_data_frame
bool vp_2_data_frame(const vec3f &a_vp, vec3f &a_pos) const
Definition: plotter:1897
tools::sg::plotter::m_func_sep
separator m_func_sep
Definition: plotter:9446
tools::sg::plotter::update_bins2D_xyz
void update_bins2D_xyz(std::ostream &a_out, const bins2D &a_bins, unsigned int a_index, const style &a_style, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z)
Definition: plotter:4580
tools::sg::plotter::take_log
static float take_log(float a_x)
Definition: plotter:9023
tools::sg::base_colormap
Definition: colormap:18
tools::sg::plotter::m_legend_strings
std::vector< std::string > m_legend_strings
Definition: plotter:9478
tools::sg::vertices::mode
sf< gl::mode_t > mode
Definition: vertices:26
tools::sg::plotter::y_axis_automated
sf< bool > y_axis_automated
Definition: plotter:94
tools::sg::plotter::y_axis_min
sf< float > y_axis_min
Definition: plotter:95
tools::sg::style::painting
sf_enum< sg::painting_policy > painting
Definition: style:41
tools::sg::plotter::x_axis_min
sf< float > x_axis_min
Definition: plotter:89
tools::sg::plotter::set_axes_font_modeling
void set_axes_font_modeling(font_modeling a_v)
Definition: plotter:2159
tools::sg::rep_box::m_pos
float m_pos
Definition: rep:141
tools::sg::bins1D::bin_error
virtual float bin_error(int) const =0
tools::sg::plotter::rep_bins2D_xy_text
void rep_bins2D_xy_text(const style &, const std::vector< rep_bin2D > &, const rep_box &, const rep_box &)
Definition: plotter:6843
tools::sg::plottable_box::PATTERN
@ PATTERN
Definition: plottables:281
tools::mat4f::mul_3f
void mul_3f(float &a_x, float &a_y, float &a_z) const
Definition: mat4f:58
tools::rotf
Definition: rotf:16
tools::sg::modeling_texts
const std::string & modeling_texts()
Definition: strings:93
tools::sg::plotter::update_z_axis_3D
void update_z_axis_3D()
Definition: plotter:3385
tools::gl::triangles
mode_t triangles()
Definition: glprims:20
tools::sg::plotter::y_axis
const sg::axis & y_axis() const
Definition: plotter:1696
tools::mat4f::set_rotate
void set_rotate(const float &a_x, const float &a_y, const float &a_z, const float &a_angle)
Definition: mat4f:39
tools::sg::painting_policy
painting_policy
Definition: enums:57
tools::sg::plotter::data_frame_2_vp
bool data_frame_2_vp(const vec3f &a_pos, vec3f &a_vp) const
Definition: plotter:1861
tools::tess_contour
Definition: tess_contour:19
tools::sg::bins2D::bin_Sw
virtual float bin_Sw(int, int) const =0
tools::sg::painting_by_level
@ painting_by_level
Definition: enums:60
tools::sg::rep_bin2D::m_x_max
float m_x_max
Definition: rep:68
tools::sg::plottable_img::m_X
float m_X
Definition: plottables:428
tools::sg::plotter::top_axis_visible
sf< bool > top_axis_visible
Definition: plotter:166
tools::data_axis
Definition: data_axis:11
tools::sg::draw_style::line_pattern
sf< lpat > line_pattern
Definition: draw_style:23
tools::sg::style::light_model
sf_string light_model
Definition: style:35
tools::sg::plotter::tau
sf< float > tau
Definition: plotter:124
tools::sg::plotter::clip_points_2D
static void clip_points_2D(const std::vector< vec3f > &a_points, const rep_box &a_box_x, const rep_box &a_box_y, std::vector< float > &a_pts)
Definition: plotter:9246
tools::sg::plotter::rep_bins1D_xy_curve_one
void rep_bins1D_xy_curve_one(std::ostream &a_out, const style &a_style, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:6416
tools::sg::bmf::add
void add(const T &a_value)
Definition: bmf:73
tools::sg::style::color
sf_vec< colorf, float > color
Definition: style:22
tools::sg::axis::sub_coords
mf< float > sub_coords
Definition: axis:53
tools::sg::axis::width
sf< float > width
Definition: axis:34
tools::sg::plotter::update_y_axis_3D
void update_y_axis_3D()
Definition: plotter:3349
tools::sg::plotter::colormap_attached
sf< bool > colormap_attached
Definition: plotter:82
tools::sg::rep_bin1D::m_ratio
float m_ratio
Definition: rep:45
tools::sg::plotter::tsf
matrix & tsf()
Definition: plotter:1608
tools::sg::group::bbox
virtual void bbox(bbox_action &a_action)
Definition: group:42
tools::sg::plotter::plottables
const std::vector< plottable * > & plottables() const
Definition: plotter:1613
tools::sg::plotter::m_primitives
std::vector< plotprim * > m_primitives
Definition: plotter:9485
TOOLS_ARG_FIELD_DESC_ENUMS_BEG
#define TOOLS_ARG_FIELD_DESC_ENUMS_BEG(a__field, a__num)
Definition: field:77
tools::sg::plottable_text::m_font_modeling
font_modeling m_font_modeling
Definition: plottables:264
tools::sg::atb_vertices::add_color
void add_color(const colorf &a_col)
Definition: atb_vertices:479
tools::sg::mf_vec
Definition: mf:200
tools::sg::plotter::transfer_plottables
void transfer_plottables(std::vector< plottable * > &a_to)
Definition: plotter:1627
tools::sg::plotter::legends_origin
mf_vec< vec2f, float > legends_origin
Definition: plotter:134
infos_box
tools::sg::plotter::get_infos_node
sg::infos_box * get_infos_node()
Definition: plotter:5313
tools::sg::plotter::reset_touched
virtual void reset_touched()
Definition: plotter:307
tools::sg::plotter::clear_plottables
void clear_plottables()
Definition: plotter:9131
tools::sg::line_style::pattern
sf< lpat > pattern
Definition: line_style:23
tools::sg::rep_bin2D::m_ratio
float m_ratio
Definition: rep:72
tools::sg::plotter::infos_what
sf_string infos_what
Definition: plotter:112
tools::sg::plottable_text::m_FONT
std::string m_FONT
Definition: plottables:258
tools::sg::modeling_filled_curve
const std::string & modeling_filled_curve()
Definition: strings:101
tools::sg::group::transfer
void transfer(group &a_from)
Definition: group:215
tools::sg::rep_box::m_log
bool m_log
Definition: rep:143
tools::sg::plotter::style_item_t
std::pair< std::string, std::string > style_item_t
Definition: plotter:738
tools::sg::plotter::m_inner_frame_style
style m_inner_frame_style
Definition: plotter:9474
tools::sg::plotter::min_max
@ min_max
Definition: plotter:79
tools::sg::line_style::color
sf_vec< colorf, float > color
Definition: line_style:21
tools::sg::plotter::x_axis
sg::axis & x_axis()
Definition: plotter:1694
tools::ccontour::get_number_of_planes
size_t get_number_of_planes() const
Definition: ccontour:106
tools::sg::draw_style::line_width
sf< float > line_width
Definition: draw_style:22
tools::sg::modeling_plus
const std::string & modeling_plus()
Definition: strings:133
tools::sg::style::area_style
sf_enum< sg::area_style > area_style
Definition: style:33
tools::sg::plotter::bins2D_to_func
static bool bins2D_to_func(const bins2D &a_bins, float a_X, float a_Y, float &a_value)
Definition: plotter:3810
tools::sg::plotter::reset_style
void reset_style(bool a_geom=false)
Definition: plotter:491
tools::sg::plottable
Definition: plottable:15
tools::colorf
Definition: colorf:11
torche
tools::sg::hjust
hjust
Definition: enums:73
tools::sg::plotter::set_font_modeling
void set_font_modeling(font_modeling a_v)
Definition: plotter:2177
tools::vec3::set_value
void set_value(const T &a0, const T &a1, const T &a2)
Definition: vec3:92
tools::sg::plotter::update_legends
void update_legends(std::ostream &a_out)
Definition: plotter:5586
tools::sg::plottable_box::m_Y1
float m_Y1
Definition: plottables:315
tools::sg::plotter::m_todel_group
group m_todel_group
Definition: plotter:9484
tools::plane
Definition: plane:12
tools::data_axis::is_log
bool is_log(bool a_v)
Definition: data_axis:32
tools::sg::plotter::legend_style
style & legend_style(size_t a_index)
Definition: plotter:1785
tools::sg::func2D::x_steps
virtual unsigned int x_steps() const =0
tools::sg::plotter::set_encoding
void set_encoding(const std::string &a_value)
Definition: plotter:1097
tools::sg::line_style::width
sf< float > width
Definition: line_style:22
tools::sg::s_tools_sg_fit2plot
const std::string & s_tools_sg_fit2plot()
Definition: plottables:162
tools::sg::text::font
sf_string font
Definition: text:32
tools::sg::plotter::bins_modelings
void bins_modelings(size_t a_index, std::vector< std::string > &a_opts)
Definition: plotter:1795
tools::sg::holder
Definition: holder:37
tools::sg::plottable_img::m_Y
float m_Y
Definition: plottables:429
tools::sg::painting_by_value
@ painting_by_value
Definition: enums:59
tools::sg::plotter::rep_hatch1D_xy
void rep_hatch1D_xy(const style &a_style, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz, bool a_bar_chart)
Definition: plotter:7438
tools::sg::text_style::line_width
sf< float > line_width
Definition: text_style:44
tools::sg::plottable::infos
virtual void infos(const std::string &, std::string &) const =0
tools::sg::plotter::m_x_axis
sg::axis m_x_axis
Definition: plotter:9429
tools::sg::plotter::z_axis_min
sf< float > z_axis_min
Definition: plotter:101
render_action
tools::sg::text_style::modeling
sf_string modeling
Definition: text_style:27
tools::sg::plotter::prep_plottable
void prep_plottable(plottable *a_p)
Definition: plotter:1621
tools::sg::plotter::touched
virtual bool touched()
Definition: plotter:286
tools::sg::func1D
Definition: plottables:76
tools::sg::points3D::x_axis_max
virtual float x_axis_max() const =0
tools::sg::plotter::first_func
bool first_func(func1D *&a_1, func2D *&a_2) const
Definition: plotter:9186
tools::sg::func2D::y_max
virtual float y_max() const =0
tools::sg::plotter::log_bins2D_to_contour
static double log_bins2D_to_contour(double a_X, double a_Y, void *aData)
Definition: plotter:3878
tools::sg::points2D::x_axis_min
virtual float x_axis_min() const =0
tools::sg::func2D
Definition: plottables:93
tools::gl::triangle_fan
mode_t triangle_fan()
Definition: glprims:22
tools::sg::base_colormap::color
colorf color(size_t a_index) const
Definition: colormap:53
tools::sg::plottable_text::m_ANGLE
float m_ANGLE
Definition: plottables:255
tools::sg::plotter::errors_style
style & errors_style(size_t a_index)
Definition: plotter:1728
tools::sg::plotter::set_encoding_none
void set_encoding_none()
Definition: plotter:1106
tools::sg::style::enforced
sf< bool > enforced
Definition: style:61
tools::sg::plotter::shape
sf_enum< shape_type > shape
Definition: plotter:153
tools::sg::plotter::set_axes_tick_length
void set_axes_tick_length(float a_v)
Definition: plotter:2138
tools::sg::field::reset_touched
void reset_touched()
Definition: field:61
tools::sg::plotter::xy
@ xy
Definition: plotter:150
tools::tess_triangle::pointA
double pointA[3]
Definition: tess_contour:14
tools::plane::intersect
bool intersect(const line< VEC3 > &a_line, VEC3 &a_intersection) const
Definition: plane:63
tools::sg::node
Definition: node:28
tools::sg::plotter::axis_2_data_frame
bool axis_2_data_frame(const vec3f &a_pos, vec3f &aDF) const
Definition: plotter:1970
tools::vec3::size
size_type size() const
Definition: vec3:265
tools::sg::points3D::x_axis_min
virtual float x_axis_min() const =0
tools::sg::plotter::data_light_on_automated
sf< bool > data_light_on_automated
Definition: plotter:160
tools::sg::plotter::bins_style
style & bins_style(size_t a_index)
Definition: plotter:1713
tools::gl::lines
mode_t lines()
Definition: glprims:17
tools::sg::plotter::rep_errors_plus_xy
void rep_errors_plus_xy(std::ostream &, const style &a_style, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, const std::vector< float > &a_bars, float aZ)
Definition: plotter:7243
tools::sg::bbox_action
Definition: bbox_action:15
tools::sg::plotter::m_bins_style
std::vector< style > m_bins_style
Definition: plotter:9461
tools::sg::plotter::m_group
group m_group
Definition: plotter:9407
tools::sg::matrix::set_translate
void set_translate(float a_x, float a_y, float a_z)
Definition: matrix:90
TOOLS_NODE
#define TOOLS_NODE(a__class, a__sclass, a__parent)
Definition: node:324
TOOLS_SG_PLOTTER_NUMBER_OF
#define TOOLS_SG_PLOTTER_NUMBER_OF(a__what)
Definition: plotter:1572
tools::sg::search_action::done
bool done() const
Definition: search_action:68
tools::clip::result
const std::vector< VEC3 > & result() const
Definition: geom3:181
tools::sg::plottable_ellipse::m_LWID
float m_LWID
Definition: plottables:382
tools::sg::plotter::primitives_enforced
sf< bool > primitives_enforced
Definition: plotter:163
tools::sg::encoding_PAW
const std::string & encoding_PAW()
Definition: strings:42
tools::sg::shjust
bool shjust(const std::string &a_s, hjust &a_v)
Definition: senum:26
tools::sg::write_action
Definition: write_action:21
tools::sg::plotter::merge_right_hatch_style
style * merge_right_hatch_style(unsigned int a_index, plottable &)
Definition: plotter:9068
tools::sg::rep_bin2D::m_val
float m_val
Definition: rep:71
tools::mn
T mn(const T &a, const T &b)
Definition: mnmx:10
tools::sg::group
Definition: group:21
tools::sg::rgba
Definition: rgba:16
tools::sg::plottable_text::m_line_width
float m_line_width
Definition: plottables:263
tools::sg::plotter::SbFunc::m_func2D
const func2D * m_func2D
Definition: plotter:3859
tools::sg::group::write
virtual bool write(write_action &a_action)
Definition: group:67
tools::sg::base_colormap::get_color
virtual void get_color(float, colorf &) const =0
tools::sg::plotter::left_margin
sf< float > left_margin
Definition: plotter:60
tools::clist_contour
Definition: clist_contour:26
normal
tools::mat4::mul_translate
void mul_translate(const T &a_x, const T &a_y, const T &a_z)
Definition: mat4:272
tools::sg::text
Definition: text:25
tools::sg::axis::maximum_value
sf< float > maximum_value
Definition: axis:36
tools::mat4f::mul_dir_3f
void mul_dir_3f(float &a_x, float &a_y, float &a_z) const
Definition: mat4f:59
tools::sg::plotter::m_primitives_sep
separator m_primitives_sep
Definition: plotter:9449
tools::mx
T mx(const T &a, const T &b)
Definition: mnmx:13
tools::sg::axis::tick_number
sf< unsigned int > tick_number
Definition: axis:49
tools::sg::plotter::update_title
void update_title()
Definition: plotter:5158
tools::sg::plottable_box::m_BORD
bool m_BORD
Definition: plottables:321
tools::sg::plotter::style_failed
void style_failed(std::ostream &a_out, const std::string &a_key, const std::string &a_value)
Definition: plotter:1176
tools::sg::plotter::cells
@ cells
Definition: plotter:78
tools::sg::plotter::update_cmap
void update_cmap(std::ostream &a_out, const base_colormap &a_cmap)
Definition: plotter:3420
tools::sg::ellipse
Definition: ellipse:21
tools::sg::plotter::add_primitive
void add_primitive(plotprim *a_prim)
Definition: plotter:1651
tools::sg::plottable_text::text_enforce_width
@ text_enforce_width
Definition: plottables:190
tools::sg::plotter::rep_box_hatch
void rep_box_hatch(separator &a_parent, float a_spacing, float a_angle, float a_strip_width, float xx, float yy, float xe, float ye, float a_zz)
Definition: plotter:8616
tools::sg::plotter::merge_left_hatch_style
style * merge_left_hatch_style(unsigned int a_index, plottable &)
Definition: plotter:9062
tools::sg::plotter::m_legend_style
std::vector< style > m_legend_style
Definition: plotter:9467
tools::clip
Definition: geom3:120
tools::sg::right
@ right
Definition: enums:76
tools::sg::ellipse::ry
sf< float > ry
Definition: ellipse:31
tools::sg::style::encoding
sf_string encoding
Definition: style:37
tools::sg::painting_grey_scale
@ painting_grey_scale
Definition: enums:61
tools::sg::plotter::m_grid_sep
separator m_grid_sep
Definition: plotter:9439
tools::sg::plotter::m_errors_style
std::vector< style > m_errors_style
Definition: plotter:9462
tools::sg::base_freetype
Definition: base_freetype:16
tools::data_axis::min_value
bool min_value(float a_v)
Definition: data_axis:33
tools::sg::plotter::m_title_box_sep
separator m_title_box_sep
Definition: plotter:9420
tools::sg::plotter::update_axes_data
void update_axes_data(std::ostream &a_out)
Definition: plotter:2999
tools::sg::plottable_img::m_THETA
float m_THETA
Definition: plottables:432
tools::sg::plotter::legends_origin_unit
mf_enum< unit_type > legends_origin_unit
Definition: plotter:139
tools::sg::bins2D::has_entries_per_bin
virtual bool has_entries_per_bin() const =0
tools::sg::plotprim
Definition: plottable:40
tools::sg::normal::vec
sf_vec3f vec
Definition: normal:19
tools::sg::rep_bin2D::m_y_min
float m_y_min
Definition: rep:69
tools::sg::plotter::title_box_height
sf< float > title_box_height
Definition: plotter:115
tools::sg::plotter::update_layout
void update_layout()
Definition: plotter:2227
tools::sg::plotter::update_y_axis_2D
void update_y_axis_2D()
Definition: plotter:3275
tools::sg::group::empty
bool empty() const
Definition: group:244
tools::sg::func2D::x_max
virtual float x_max() const =0
tools::sg::torche
Definition: torche:18
tools::sg::plotter::update_title_box
void update_title_box()
Definition: plotter:5228
tools::gl::line_strip
mode_t line_strip()
Definition: glprims:19
tools::sg::plotter::update_primitives
void update_primitives(std::ostream &a_out)
Definition: plotter:3598
tools::sg::plotter::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: plotter:181
tools::sg::draw_style
Definition: draw_style:18
tools::sg::bins2D::y_axis_min
virtual float y_axis_min() const =0
tools::sg::text::color
sf_vec< colorf, float > color
Definition: text:31
tools::sg::plotter::SbFunc::m_limits_in
double m_limits_in[4]
Definition: plotter:3862
tools::sg::plotter::curve_number_of_points
sf< unsigned int > curve_number_of_points
Definition: plotter:158
tools::sg::plotter::_zinfos
float _zinfos() const
Definition: plotter:9017
tools::fpi
float fpi()
Definition: mathf:11
tools::sg::plotter::x_axis_is_log
sf< bool > x_axis_is_log
Definition: plotter:91
tools::zb::ZZ
double ZZ
Definition: point:11
tools::sg::text::strings
mf_string strings
Definition: text:28
tools::sg::points2D::points
virtual unsigned int points() const =0
tools::sg::axis::set_from_style
bool set_from_style(std::ostream &a_out, const style_t &a_style)
Definition: axis:706
tools::sg::matrix::set_identity
void set_identity()
Definition: matrix:88
tools::sg::axis::is_log
sf< bool > is_log
Definition: axis:39
tools::sg::plotter::_ztext
float _ztext() const
Definition: plotter:9015
tools::sg::text_style::back_shadow
sf< float > back_shadow
Definition: text_style:25
tools::sg::draw_points
@ draw_points
Definition: enums:191
tools::sg::axis
Definition: axis:30
tools::sg::modeling_top_lines_boxes
const std::string & modeling_top_lines_boxes()
Definition: strings:89
tools::sg::plotter::x_axis_automated
sf< bool > x_axis_automated
Definition: plotter:88
legend
tools::sg::text_style::visible
sf< bool > visible
Definition: text_style:22
tools::sg::text_hershey
Definition: text_hershey:82
tools::sg::plotter::search
virtual void search(search_action &a_action)
Definition: plotter:1197
tools::sg::top
@ top
Definition: enums:82
tools::sg::desc_fields
Definition: field_desc:148
colormap
tools::sg::plotter::remove_plottables
bool remove_plottables()
Definition: plotter:1634
tools::vec3::y
const T & y() const
Definition: vec3:85
tools::sg::plotter::z_axis_enforced
sf< bool > z_axis_enforced
Definition: plotter:99
tools::sg::violet_to_red_colormap
Definition: colormap:361
tools::ccontour::get_plane
double get_plane(unsigned int i) const
Definition: ccontour:654
tools::sg::axis::title_to_axis
sf< float > title_to_axis
Definition: axis:57
tools::sg::plotter::unit_percent
@ unit_percent
Definition: plotter:136
tools::sg::hatching_left
@ hatching_left
Definition: enums:69
tools::sg::rep_box
Definition: rep:126
tools::sg::plotter::PAW_hatch
void PAW_hatch(int aHTYP, hatching_policy &a_policy, float &a_spacing, float &a_angle_right, float &a_angle_left)
Definition: plotter:8527
tools::sg::points3D::ith_point
virtual bool ith_point(unsigned int, float &, float &, float &) const =0
tools::sg::plottable_text::m_SCALE
float m_SCALE
Definition: plottables:260
tools::hatcher::compute_polyline
bool compute_polyline(vec3f *listPoints, unsigned int number)
draw the hatch into the polyline bounding box given in argument You have to get all compute points by...
tools::sg::plottable_box::SOLID
@ SOLID
Definition: plottables:280
tools::sg::plotter::verify_log_inv
static float verify_log_inv(float a_val, float a_min, float a_dx, bool a_log)
Definition: plotter:9048
matrix
tools::sg::plotter::m_tsf
matrix m_tsf
Definition: plotter:9422
tools::sg::plotter::update_axis
void update_axis(std::ostream &a_out, sg::axis &a_axis, data_axis &a_data)
Definition: plotter:3236
tools::sg::points2D::y_axis_min
virtual float y_axis_min() const =0
tools::rtausmef::shoot
float shoot()
Definition: rtausmef:30
tools::sg::plotter::merge_errors_style
style * merge_errors_style(unsigned int a_index, plottable &)
Definition: plotter:9074
tools::sg::bmf::values
const std::vector< T > & values() const
Definition: bmf:71
tools::sg::plotter::update_bins1D_xy
void update_bins1D_xy(std::ostream &a_out, const bins1D &a_bins, const style &a_data_style, const style &a_left_hatch_style, const style &a_right_hatch_style, const style &a_errors_style, int a_index, bool, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:3616
tools::sg::text_style::from_string
bool from_string(std::ostream &a_out, const cmaps_t &a_cmaps, const std::string &a_s)
Definition: text_style:197
tools_lforcit
#define tools_lforcit(a__T, a__l, a__it)
Definition: forit:40
tools::sg::plottable_box
Definition: plottables:267
tools::sg::plotter::m_bins_sep
separator m_bins_sep
Definition: plotter:9444
tools::sg::plotter::operator=
plotter & operator=(const plotter &a_from)
Definition: plotter:1446
tools::sg::plotter::colormap_axis_labeling
sf_enum< colormap_axis_labeling_type > colormap_axis_labeling
Definition: plotter:81
tools::sg::modeling_top_lines
const std::string & modeling_top_lines()
Definition: strings:85
tools::tess_triangle
Definition: tess_contour:13
tools::sg::plotter::m_x_axis_matrix
matrix m_x_axis_matrix
Definition: plotter:9428
tools::hatcher::vertices
const std::vector< unsigned int > & vertices()
vector of numbers of vertices
Definition: hatcher:170
tools::sg::style::bar_width
sf< float > bar_width
Definition: style:55
tools::sg::style::back_color
sf_vec< colorf, float > back_color
Definition: style:24
tools::sg::axis::labels_style
text_style & labels_style()
Definition: axis:334
tools::sg::plotter::legends_automated
sf< bool > legends_automated
legend related :////////////////////////////////////////////
Definition: plotter:129
tools::sg::base_tex::img
sf_img< byte > img
Definition: base_tex:28
tools::sg::plotter::bar_chart
void bar_chart(float a_bar_offset, float a_bar_width, float &a_beg, float &a_end)
Definition: plotter:9396
tools::sg::pick_action
Definition: pick_action:59
tools::plane::normal
const VEC3 & normal() const
Definition: plane:88
tools::sg::plotter::colormap_axis
const sg::axis & colormap_axis() const
Definition: plotter:1702
tools::sg::plotter::infos_style
text_style & infos_style()
Definition: plotter:1710
tools::clist_contour::get_lines
cline_strip_list * get_lines(unsigned int iPlane)
Definition: clist_contour:796
tools::sg::bins2D::bin_upper_edge_x
virtual float bin_upper_edge_x(int) const =0
tools::sg::bins1D::bins_Sw_range
virtual void bins_Sw_range(float &, float &, bool) const =0
tools::sg::axis::label_height
sf< float > label_height
Definition: axis:62
plottables
tools::sg::plotter::y_axis
sg::axis & y_axis()
Definition: plotter:1697
tools::sg::base_colormap::value
float value(size_t a_index) const
Definition: colormap:58
tools::sg::tick_modeling_hippo
const std::string & tick_modeling_hippo()
Definition: strings:19
tools::sg::plotter::phi
sf< float > phi
Definition: plotter:123
tools::vec3::value
void value(T &a0, T &a1, T &a2) const
Definition: vec3:102
tools::sg::plotter::sto
bool sto(const std::string &a_s, vec2f &a_v)
Definition: plotter:9364
tools::sg::grey_scale_colormap
Definition: colormap:292
tools::sg::nodekit_pick
void nodekit_pick(pick_action &a_action, node &a_sg, node *a_node)
Definition: nodekit:13
tools::tess_contour::getFilledArea
void getFilledArea(const std::vector< std::vector< vec3f > > aContour)
Definition: tess_contour:30
tools::sg::plottable_ellipse::HOLLOW
@ HOLLOW
Definition: plottables:338
tools::sg::plotter
Definition: plotter:45
tools::sg::text::enforce_front_width
sf< bool > enforce_front_width
Definition: text:43
tools::sg::func1D::value
virtual bool value(float, float &) const =0
tools::sg::group::render
virtual void render(render_action &a_action)
Definition: group:24
tools::sg::modeling_curve
const std::string & modeling_curve()
Definition: strings:97
tools::box3::extend_by
void extend_by(const VEC3 &a_point)
Definition: box3:94
tools::sg::plotter::update_func2D_xyz
void update_func2D_xyz(std::ostream &a_out, const func2D &a_func, unsigned int a_index, const style &a_style, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z)
Definition: plotter:4849
tools::sg::plotter::update_primitive_box
void update_primitive_box(std::ostream &a_out, const plottable_box &a_obj)
Definition: plotter:8685
tools::sg::bins1D::axis_min
virtual float axis_min() const =0
tools::sg::plottable_text::m_text_mode
text_mode m_text_mode
Definition: plottables:254
tools::sg::plottable_ellipse::m_FAIS
fill_area_style m_FAIS
Definition: plottables:377
tools::sg::bins2D::bin_entries
virtual unsigned int bin_entries(int, int) const =0
tools::vec3::x
const T & x() const
Definition: vec3:84
tools::sg::plotter::shape_type
shape_type
Definition: plotter:149
tools::hatcher
Definition: hatcher:56
tools::sg::style::marker_size
sf< float > marker_size
Definition: style:26
tools::sg::left
@ left
Definition: enums:74
tools::sg::plotter::DUMP_UPDATE_WHAT
void DUMP_UPDATE_WHAT(std::ostream &, const std::string &)
Definition: plotter:9231
tools::sg::plottable_ellipse::m_PLCI
colorf m_PLCI
Definition: plottables:381
tools::sg::mf< float >
tools::sg::plotter::write
virtual bool write(write_action &a_action)
Definition: plotter:1214
tools::snpf
int snpf(char *a_s, size_t a_n, const char *a_fmt,...)
Definition: snpf:27
tools::sg::modeling_lines
const std::string & modeling_lines()
Definition: strings:73
tools::sg::plotter::m_cmap_sep
separator m_cmap_sep
Definition: plotter:9411
tools::sg::func2D::value
virtual bool value(float, float, float &) const =0
tools::sg::func2D::y_steps
virtual unsigned int y_steps() const =0
tools::sg::atb_vertices::epsilon
sf< float > epsilon
Definition: atb_vertices:18
tools::sg::plottable_text::m_TEXT
std::string m_TEXT
Definition: plottables:250
tools::sg::plottable_text::m_SIZE
float m_SIZE
Definition: plottables:253
tools::sg::normal
Definition: normal:16
tools::sg::area_edged
@ area_edged
Definition: enums:46
tools::sg::rep_bin2D
Definition: rep:49
axis
tools::sg::rep_bin1D
Definition: rep:10
tools::sout
Definition: sout:17
tools::sg::plotter::transfer_todels
void transfer_todels(std::vector< node * > &a_to)
Definition: plotter:1667
tools::jpeg::infos
bool infos(std::ostream &a_out, const std::string &a_file, unsigned int &a_width, unsigned int &a_height, unsigned int &a_bpp)
Definition: jpeg:230
tools::sg::plotter::rep_bins1D_xy_points
void rep_bins1D_xy_points(std::ostream &a_out, const style &a_style, const base_colormap &a_cmap, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:6075
tools::sg::plotter::_zaxis
float _zaxis() const
Definition: plotter:9013
tools::sg::plotter::z_axis_automated
sf< bool > z_axis_automated
Definition: plotter:100
tools::sg::plotter::m_z_axis_data
data_axis m_z_axis_data
Definition: plotter:9457
tools::sg::plotter::rep_contour_xy_filled
void rep_contour_xy_filled(std::ostream &a_out, const style &a_style, painting_policy a_painting, const base_colormap &a_cmap, clist_contour &a_contour, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z, float a_zz)
Definition: plotter:7090
tools::sg::style::line_pattern
sf< lpat > line_pattern
Definition: style:31
tools::sg::plotter::verify_log
static float verify_log(float a_val, float a_min, float a_dx, bool a_log)
Definition: plotter:9031
tools::sg::plotter::m_legend_sep
separator m_legend_sep
Definition: plotter:9419
tools::sg::plotter::_zhatch
float _zhatch() const
Definition: plotter:9018
tools::sg::draw_filled
@ draw_filled
Definition: enums:193
tools::sg::plotter::z_axis_is_log
sf< bool > z_axis_is_log
Definition: plotter:103
tools::cline_strip_list
std::list< cline_strip * > cline_strip_list
Definition: clist_contour:22
tools::tess_triangle::pointB
double pointB[3]
Definition: tess_contour:15
tools::sg::axis::title_style
text_style & title_style()
Definition: axis:335
tools::sg::plotter::SbFunc::m_bins2D
const bins2D * m_bins2D
Definition: plotter:3860
tools::hatcher::set_spacing
void set_spacing(float a)
Definition: hatcher:136
tools::sg::plotter::m_infos_title_sep
separator m_infos_title_sep
Definition: plotter:9417
tools::sg::cmaps_t
std::map< std::string, style_colormap > cmaps_t
Definition: style_colormap:536
tools::sg::style
Definition: style:19
tools::sg::plottable_box::m_PLCI
colorf m_PLCI
Definition: plottables:322
tools::sg::plottable_text::m_HJUST
char m_HJUST
Definition: plottables:256
tools::sg::ellipse::rx
sf< float > rx
Definition: ellipse:30
tools::sg::plotter::background_style
style & background_style()
Definition: plotter:1706
tools::sg::plotter::_zerrors
float _zerrors() const
Definition: plotter:9019
tools::sg::plotter::update_x_axis_2D
void update_x_axis_2D()
Definition: plotter:3244
tools::sg::axis::ticks_style
sg::line_style & ticks_style()
Definition: axis:333
tools::sg::plotter::pick
virtual void pick(pick_action &a_action)
Definition: plotter:1190
tools::sg::plotter::title
sf_string title
Definition: plotter:74
tools::sg::plotter::value_bins_with_entries
sf< bool > value_bins_with_entries
Definition: plotter:107
tools::sg::plotter::rep_bins2D_xy_wire_box
void rep_bins2D_xy_wire_box(const style &a_style, const std::vector< rep_bin2D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_bmin, float a_bmax, float a_zz)
Definition: plotter:6572
tools::sg::sf_enum< hjust >
tools::sg::infos_box
Definition: infos_box:22
tools::sg::plottable_box::HATCHED
@ HATCHED
Definition: plottables:282
tools::sg::plotter::SbFunc::m_limits
double m_limits[4]
Definition: plotter:3861
tools::sg::plotter::rep_contour_xy
void rep_contour_xy(std::ostream &a_out, const style &a_style, painting_policy a_painting, const base_colormap &a_cmap, clist_contour &a_contour, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z, float a_zz)
Definition: plotter:6971
tools::sg::plotter::z_axis
sg::axis & z_axis()
Definition: plotter:1700
tools::sg::points2D::ith_point
virtual bool ith_point(unsigned int, float &, float &) const =0
tools::sg::text_style::font_modeling
sf_enum< sg::font_modeling > font_modeling
Definition: text_style:30
tools::sg::bmf::getNum
size_t getNum() const
Definition: bmf:156
tools::sg::plotter::bbox
virtual void bbox(bbox_action &a_action)
Definition: plotter:1206
tools::sg::bins2D::bin_lower_edge_x
virtual float bin_lower_edge_x(int) const =0
tools::sg::markers::size
sf< float > size
Definition: markers:26
tools::sg::modeling_markers
const std::string & modeling_markers()
Definition: strings:137
tools::sg::text_style::smoothing
sf< bool > smoothing
Definition: text_style:32
tools::sg::plottable_box::m_X2
float m_X2
Definition: plottables:316
tools::sg::font_modeling
font_modeling
Definition: enums:91
tools::sg::plotter::width
sf< float > width
Definition: plotter:58
tools::sg::plotter::title_box_x_margin
sf< float > title_box_x_margin
Definition: plotter:116
tools::sg::plotter::clear_cmaps
void clear_cmaps()
Definition: plotter:9382
tools::sg::group::add
void add(node *a_node)
Definition: group:96
tools::sg::text::line_width
sf< float > line_width
Definition: text:36
tools::sg::plotter::m_func_style
std::vector< style > m_func_style
Definition: plotter:9463
tools::vec4::size
size_type size() const
Definition: vec4:259
tools::sg::grey_scale_inverse_colormap
Definition: colormap:326
tools::sg::painting_violet_to_red
@ painting_violet_to_red
Definition: enums:62
tools::sg::const_colormap
Definition: colormap:415
tools::sg::plotter::update_primitive_text
void update_primitive_text(const plottable_text &a_obj)
Definition: plotter:8356
tools::sg::axis::label_to_axis
sf< float > label_to_axis
Definition: axis:61
tools::ccontour::get_yi
double get_yi(int i) const
Definition: ccontour:660
tools::sg::text::font_modeling
sf_enum< sg::font_modeling > font_modeling
Definition: text:33
tools::sg::plotter::add_pt
static void add_pt(std::vector< float > &a_pts, float a_x, float a_y, float a_z)
Definition: plotter:9240
tools::sg::cube::depth
sf< float > depth
Definition: cube:22
tools::sg::plotter::m_points_style
std::vector< style > m_points_style
Definition: plotter:9464
tools::sg::plotter::m_title_style
text_style m_title_style
Definition: plotter:9469
tools::sg::plotter::rep_bins2D_xyz_box
void rep_bins2D_xyz_box(const style &a_style, const base_colormap &a_cmap, const std::vector< rep_bin2D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z, float a_bmin, float)
Definition: plotter:7829
tools::sg::bins2D::x_axis_max
virtual float x_axis_max() const =0
tools::sg::plotter::update_bins2D_xy
void update_bins2D_xy(std::ostream &a_out, const bins2D &a_bins, const style &a_data_style, int a_index, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z, float a_zz)
Definition: plotter:3890
tools::ccontour::set_limits
void set_limits(double pLimits[4])
Definition: ccontour:635
tools::sg::plotter::m_background_sep
separator m_background_sep
Definition: plotter:9409
tools::sg::plotter::clear_primitives
void clear_primitives()
Definition: plotter:9158
tools::gl::points
mode_t points()
Definition: glprims:16
tools::sg::search_action
Definition: search_action:19
tools::sg::encoding_none
const std::string & encoding_none()
Definition: strings:38
tools::sg::plotter::m_inner_frame_sep
separator m_inner_frame_sep
Definition: plotter:9448
tools::sg::axis::tick_length
sf< float > tick_length
Definition: axis:44
tools::sg::line_style::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: line_style:25
tools::sg::modeling_bar_chart
const std::string & modeling_bar_chart()
Definition: strings:105
tools::sg::plotter::title_automated
sf< bool > title_automated
Definition: plotter:72
tools::sg::back_area::height
sf< float > height
Definition: back_area:31
tools::sg::plotter::colormap_axis_labeling_type
colormap_axis_labeling_type
Definition: plotter:77
tools::flog10
float flog10(const float &x)
Definition: mathf:53
tools::sg::vjust
vjust
Definition: enums:79
tools::sg::bsf::getValue
const T & getValue() const
Definition: bsf:118
tools::sg::plotter::theta
sf< float > theta
Definition: plotter:122
tools::ccontour::get_xi
double get_xi(int i) const
Definition: ccontour:111
tools::sg::infos_modeling_ROOT
const std::string & infos_modeling_ROOT()
Definition: strings:31
tools::sg::points2D::y_axis_max
virtual float y_axis_max() const =0
tools::sg::style_default_colormap
Definition: style_colormap:90
tools::sg::plotter::rep_bins2D_xy_box
void rep_bins2D_xy_box(const style &a_style, const std::vector< rep_bin2D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_bmin, float a_bmax, float a_zz)
Definition: plotter:6475
tools::sg::points2D::x_axis_max
virtual float x_axis_max() const =0
tools::sg::plottable_img::m_img
img< byte > m_img
Definition: plottables:427
tools::to
std::vector< std::string > to(int a_argc, char **a_argv)
Definition: args:507
tools::sg::axis::update_sg
void update_sg(std::ostream &a_out)
Definition: axis:346
tools::sg::plotter::unit_axis
@ unit_axis
Definition: plotter:137
tools::sg::axis::reset_style
void reset_style(bool a_geom=false)
Definition: axis:612
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
tools::vec3f
Definition: vec3f:13
tools::sg::plotter::number_of_plottables
size_t number_of_plottables() const
Definition: plotter:1560
tools::sg::node::search
virtual void search(search_action &a_action)
Definition: node:56
tools::sg::cube
Definition: cube:17
tools::sg::render_action
Definition: render_action:24
tools::sg::plotter::m_x_axis_sep
separator m_x_axis_sep
Definition: plotter:9427
tools::sg::plotter::legends_size
mf_vec< vec2f, float > legends_size
Definition: plotter:140
tools::sg::plotter::sto
bool sto(const std::string &a_s, unit_type &a_v)
Definition: plotter:9376
tools::sg::style::options
sf_string options
Definition: style:59
tools::sg::plotter::bins2D_to_contour
static double bins2D_to_contour(double a_X, double a_Y, void *aData)
Definition: plotter:3866
tools::sg::plotter::merge_func_style
style * merge_func_style(unsigned int a_index, plottable &)
Definition: plotter:9080
tools::sg::separator
Definition: separator:15
tools::sg::line_style::from_string
bool from_string(std::ostream &a_out, const cmaps_t &a_cmaps, const std::string &a_s)
Definition: line_style:73
tools::sg::plotter::etc_sep
const separator & etc_sep() const
Definition: plotter:1610
tools::sg::base_colormap::colorn
size_t colorn() const
Definition: colormap:51
tools::sg::style::modeling
sf_string modeling
Definition: style:34
tools::sg::bottom
@ bottom
Definition: enums:80
tools::sg::plotter::rep_points2D_xy_lines
void rep_points2D_xy_lines(const style &a_style, const points2D &a_points, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:7560
tools::sg::plotter::update_inner_frame_XYZ
void update_inner_frame_XYZ()
Definition: plotter:5756
tools::vec3::cross
void cross(const vec3< T > &aV, vec3< T > &a_value) const
Definition: vec3:131
text
tools::sg::matrix::set_rotate
void set_rotate(float a_x, float a_y, float a_z, float a_angle)
Definition: matrix:96
tools::sg::middle
@ middle
Definition: enums:81
tools::sg::plottable_img::m_HEIGHT
float m_HEIGHT
Definition: plottables:431
tools::sg::mf_string
Definition: mf:76
tools::sg::plotter::m_infos_sep
separator m_infos_sep
Definition: plotter:9418
tools::sg::bins1D::is_profile
virtual bool is_profile() const =0
tools::sg::plotter::z_axis_max
sf< float > z_axis_max
Definition: plotter:102
tools::sg::plotter::rep_points3D_xyz_points
void rep_points3D_xyz_points(std::ostream &a_out, const style &a_style, const points3D &a_points, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z)
Definition: plotter:7743
tools::sg::style::marker_style
sf_enum< sg::marker_style > marker_style
Definition: style:32
tools::sg::points3D::y_axis_max
virtual float y_axis_max() const =0
tools::sg::bins1D::bin_lower_edge
virtual float bin_lower_edge(int) const =0
tools::sg::hatching_none
@ hatching_none
Definition: enums:67
tools::sg::plotter::infos_x_margin
sf< float > infos_x_margin
Definition: plotter:110
tools::sg::plotter::title_box_style
text_style & title_box_style()
Definition: plotter:1711
tools::sg::plotter::title_style
text_style & title_style()
Definition: plotter:1705
tools::sg::text_style::color
sf_vec< colorf, float > color
Definition: text_style:23
tools::sg::plotter::down_margin
sf< float > down_margin
Definition: plotter:66
tools::sg::plotter::rep_top_face2D_xyz
void rep_top_face2D_xyz(separator &a_sep, const style &a_style, const base_colormap &a_cmap, const std::vector< rep_top_face2D > &a_faces, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z)
Definition: plotter:7938
tools::sg::plotter::gopaw_reset_style
void gopaw_reset_style()
Definition: plotter:720
tools::hatcher::set_angle
void set_angle(float a)
Definition: hatcher:137
tools::sg::plotter::get_value_axis_min_max
void get_value_axis_min_max(float a_Sw_mn, float a_Sw_mx, bool a_is_log, float &a_min, float &a_max, bool a_min_visible)
Definition: plotter:2936
tools::sg::plotter::xy_depth
sf< float > xy_depth
Definition: plotter:156
ellipse
tools::sg::plotter::right_axis_visible
sf< bool > right_axis_visible
Definition: plotter:167
noderef
tools::sg::plotter::data_frame_2_axis
bool data_frame_2_axis(const vec3f &aDF, vec3f &a_pos) const
Definition: plotter:1934
tools::sg::bins1D::bin_upper_edge
virtual float bin_upper_edge(int) const =0
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::mat4f::mul_rotate
void mul_rotate(const float &a_x, const float &a_y, const float &a_z, const float &a_angle)
Definition: mat4f:43
tools::sg::field_desc
Definition: field_desc:21
tools::sg::style::color_mapping
sf_string color_mapping
Definition: style:60
tools::sg::matrix::mtx
sf_mat4f mtx
Definition: matrix:22
tools::sg::plotter::title_hjust
sf_enum< hjust > title_hjust
Definition: plotter:73
tools::mat4::mul_scale
void mul_scale(const T &a_sx, const T &a_sy, const T &a_sz)
Definition: mat4:234
tools::ccontour::set_planes
void set_planes(const std::vector< double > &vPlanes)
Definition: ccontour:606
style
tools::sg::rep_bin2D::m_y_max
float m_y_max
Definition: rep:70
tools::sg::plotter::print_available_customization
void print_available_customization(std::ostream &a_out) const
Definition: plotter:1108
tools::sg::plotter::get_infos
void get_infos(std::string &a_s)
Definition: plotter:5267
tools::sg::plottable_text
Definition: plottables:177
tools::sg::bmf::clear
void clear()
Definition: bmf:108
tools::sg::plotter::m_ttf
const base_freetype & m_ttf
Definition: plotter:9405
tools::sg::plotter::clear_todels
void clear_todels()
Definition: plotter:9165
tools::sg::text_style::line_pattern
sf< lpat > line_pattern
Definition: text_style:45
tools::sg::painting_uniform
@ painting_uniform
Definition: enums:58
tools::sg::plotter::function_to_contour
static double function_to_contour(double a_X, double a_Y, void *aData)
Definition: plotter:4250
tools::sg::plotter::transfer_primitives
void transfer_primitives(std::vector< plotprim * > &a_to)
Definition: plotter:1653
tools::sg::plottable::name
virtual const std::string & name() const =0
tools::tess_triangle::pointC
double pointC[3]
Definition: tess_contour:16
tools::words
void words(const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words, bool a_clear=true)
Definition: words:12
tools::sg::style::bar_offset
sf< float > bar_offset
Definition: style:54
tools::sg::plottable_ellipse::m_Y
float m_Y
Definition: plottables:374
tools::sg::hatching_left_and_right
@ hatching_left_and_right
Definition: enums:70
tools::sg::plotter::m_infos_style
text_style m_infos_style
Definition: plotter:9470
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
tools::sg::base_freetype::create
static base_freetype * create(const base_freetype &a_ttf)
Definition: base_freetype:108
tools::sg::plotter::title_height
sf< float > title_height
Definition: plotter:71
tools::sg::matrix
Definition: matrix:19
holder
tools::sg::style::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: style:66
tools::sg::plotter::_zscale_text
float _zscale_text() const
Definition: plotter:9016
atb_vertices
tools::sg::plotter::m_cmap_axis_matrix
matrix m_cmap_axis_matrix
Definition: plotter:9414
tools::sg::rep_bin2D::m_x_min
float m_x_min
Definition: rep:67
tools::sg::plottable_ellipse
Definition: plottables:326
tools::sg::bins1D::bins
virtual unsigned int bins() const =0
tools::sg::plottable_text::m_Y
float m_Y
Definition: plottables:252
tools::sg::modeling_points
const std::string & modeling_points()
Definition: strings:81
tools::sg::plotter::m_z_axis_matrix
matrix m_z_axis_matrix
Definition: plotter:9436
tools::sg::plotter::m_data_matrix
matrix m_data_matrix
Definition: plotter:9443
tools::sg::plotter::x_axis_enforced
sf< bool > x_axis_enforced
Definition: plotter:87
tools::sg::plotter::shape_automated
sf< bool > shape_automated
Definition: plotter:147
tools::sg::add_string
void add_string(separator &a_sep, const std::string &a_font, font_modeling &a_font_modeling, const std::string &a_encoding, bool, const std::string &a_string, float a_x, float a_y, float a_z, const vec3f &a_X, const vec3f &a_Y, float a_size, hjust a_hjust, vjust a_vjust, const base_freetype &a_ttf)
Definition: tools:19
tools::sg::plotter::etc_sep
separator & etc_sep()
Definition: plotter:1611
tools::sg::plotter::get_infos_matrix
matrix * get_infos_matrix()
Definition: plotter:5309
tools::sg::group::children
const std::vector< node * > & children() const
Definition: group:249
tools::fhalf_pi
float fhalf_pi()
Definition: mathf:13
tools::sg::plotter::rep_bins1D_xy_lines_one
void rep_bins1D_xy_lines_one(const style &a_style, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:6375
tools::sg::plotter::m_points_cmaps
std::vector< base_colormap * > m_points_cmaps
Definition: plotter:9481
tools::sg::plotter::number_of_levels
sf< unsigned int > number_of_levels
Definition: plotter:171
tools::sg::plotter::rep_bins1D_xy_top_lines
void rep_bins1D_xy_top_lines(const style &a_style, const base_colormap &a_cmap, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:5971
tools::sg::plotter::height
sf< float > height
Definition: plotter:59
tools::sg::plotter::m_shape
shape_type m_shape
Definition: plotter:9453
tools::sg::plotter::set_from_string
bool set_from_string(std::ostream &a_out, cmaps_t &a_cmaps, const std::string &a_field, const std::string &a_value)
Definition: plotter:987
tools::sg::text::enforce_front_height
sf< bool > enforce_front_height
Definition: text:41
tools::sg::plotter::m_title_sep
separator m_title_sep
Definition: plotter:9425
tools::sg::text_style
Definition: text_style:19
tools::data_axis::adjust
void adjust()
Definition: data_axis:40
tools::sg::modeling_solid
const std::string & modeling_solid()
Definition: strings:109
tools::sg::plotter::clip_polyline_2D
static void clip_polyline_2D(const std::vector< vec3f > &a_points, const rep_box &a_box_x, const rep_box &a_box_y, std::vector< float > &a_pts)
Definition: plotter:9270
tools::sg::plotter::m_y_axis_sep
separator m_y_axis_sep
Definition: plotter:9431
tools::sg::line_dashed
@ line_dashed
Definition: enums:12
tools::sg::vertices::add_dashed_line
bool add_dashed_line(float a_bx, float a_by, float a_bz, float a_ex, float a_ey, float a_ez, unsigned int a_num_dash)
Definition: vertices:187
tools::sg::style::angle
sf< float > angle
Definition: style:49
tools::sg::plotter::init_sg
void init_sg()
Definition: plotter:2184
tools::box3::mx
const VEC3 & mx() const
Definition: box3:70
tools::sg::draw_style::point_size
sf< float > point_size
Definition: draw_style:24
tools::sg::plotter::left_hatch_style
style & left_hatch_style(size_t a_index)
Definition: plotter:1763
tools::sg::bins1D::axis_max
virtual float axis_max() const =0
tools::data_axis::max_value
bool max_value(float a_v)
Definition: data_axis:34
tools::rotf::value
bool value(vec3f &a_from, float &a_a) const
Definition: rotf:48
tools::sg::plotter::m_left_hatch_style
std::vector< style > m_left_hatch_style
Definition: plotter:9465
tools::sg::matrix::mul_translate
void mul_translate(float a_x, float a_y, float a_z)
Definition: matrix:102
tools::sg::by_value_colormap
Definition: colormap:105
tools::sg::plotter::xyz
@ xyz
Definition: plotter:151
tools::sg::plotter::merge_points_style
style * merge_points_style(unsigned int a_index, plottable &)
Definition: plotter:9086
tools::sg::text_style::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: text_style:54
tools::mat4f
Definition: mat4f:12
tools::sg::plotter::update_primitive_ellipse
void update_primitive_ellipse(std::ostream &a_out, const plottable_ellipse &a_obj)
Definition: plotter:8819
tools::sg::plotter::top_margin
sf< float > top_margin
Definition: plotter:63
tools::sg::tick_modeling_none
const std::string & tick_modeling_none()
Definition: strings:15
tools::sg::plotter::unit_type
unit_type
Definition: plotter:135
tools::sg::hatching_right
@ hatching_right
Definition: enums:68
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::plotter::func_style
style & func_style(size_t a_index)
Definition: plotter:1739
tools::sg::axis::labels
mf_string labels
Definition: axis:50
tools::mat
Definition: mat:19
tools::sg::line_solid
@ line_solid
Definition: enums:11
tools::sg::plotter::m_right_hatch_style
std::vector< style > m_right_hatch_style
Definition: plotter:9466
tools::sg::bins2D::x_axis_min
virtual float x_axis_min() const =0
tools::ccontour::set_first_grid
void set_first_grid(int iCol, int iRow)
Definition: ccontour:620
tools::hatcher::points
const std::vector< vec3f > & points()
vector of compute points Be careful with this function because it can return a set of non convex pol...
Definition: hatcher:166
tools::sg::plottable_text::text_enforce_height
@ text_enforce_height
Definition: plottables:191
tools::sg::vertices::xyzs
mf< float > xyzs
Definition: vertices:27
tools::sg::plotter::superpose_bins
sf< bool > superpose_bins
Definition: plotter:168
tools::clist_contour::compact_strips
bool compact_strips()
Definition: clist_contour:374
tools::sg::plotter::title_up
sf< bool > title_up
Definition: plotter:69
tools::sg::func1D::x_steps
virtual unsigned int x_steps() const =0
tools::sg::cube::width
sf< float > width
Definition: cube:20
tools::sg::text::hjust
sf_enum< sg::hjust > hjust
Definition: text:48
tools::sg::text::front_height
sf< float > front_height
Definition: text:42
tools::sg::bmf::add_allocated
void add_allocated(size_t &a_pos, const T &a_1, const T &a_2, const T &a_3)
Definition: bmf:85
tools::sg::func2D::y_min
virtual float y_min() const =0
TOOLS_ARG_ENUM
#define TOOLS_ARG_ENUM(a__value)
Definition: field:85
tools::sg::plottable::is_valid
virtual bool is_valid() const =0
tools::sg::plotter::m_cmap_axis
sg::axis m_cmap_axis
Definition: plotter:9415
tools::sg::plottable_box::m_FACI
colorf m_FACI
Definition: plottables:319
tools::sg::plotter::m_etc_sep
separator m_etc_sep
Definition: plotter:9450
tools::clip::add
void add(const VEC3 &a_point)
Definition: geom3:136
tools::sg::rep_bin1D::m_x_max
float m_x_max
Definition: rep:42
tools::sg::text_style::scale
sf< float > scale
Definition: text_style:36
tools::file::found
bool found(const std::string &a_file, const std::string &a_what, std::vector< std::string > &a_found)
Definition: file:507
tools::sg::plotter::update_grid_XY
void update_grid_XY()
Definition: plotter:5792
tools::sg::group::clear
void clear()
Definition: group:235
tools::sg::plottable_text::m_TXCI
colorf m_TXCI
Definition: plottables:259
tools::sg::plotter::m_layout
matrix m_layout
Definition: plotter:9423
tools::sg::torche::direction
sf_vec3f direction
Definition: torche:22
tools::sg::sf_string
Definition: sf_string:15
tools::sg::plotter::m_cmap_cells_sep
separator m_cmap_cells_sep
Definition: plotter:9413
tools::sg::style::line_width
sf< float > line_width
Definition: style:25
tools::sg::bmf::setValue
bool setValue(const T &a_value)
Definition: bmf:150
tools::sg::noderef
Definition: noderef:14
tools::sg::atb_vertices
Definition: atb_vertices:12
tools::sg::plotter::rep_bins2D_xy_solid
void rep_bins2D_xy_solid(const style &a_style, const base_colormap &a_cmap, const std::vector< rep_bin2D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:6689
tools::sg::bins2D::x_bins
virtual unsigned int x_bins() const =0
tools::rtausmef
Definition: rtausmef:14
tools::sg::plotter::right_hatch_style
style & right_hatch_style(size_t a_index)
Definition: plotter:1774
tools::sg::plotter::m_y_axis
sg::axis m_y_axis
Definition: plotter:9433
tools::sg::plotter::update_points3D_xyz
void update_points3D_xyz(std::ostream &a_out, const points3D &a_points, const style &a_style, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z)
Definition: plotter:4538
tools::sg::plotter::first_bins
bool first_bins(bins1D *&a_1, bins2D *&a_2) const
Definition: plotter:9167
tools::ccontour::set_field_fcn
void set_field_fcn(double(*_pFieldFcn)(double, double, void *), void *)
Definition: ccontour:614
tools::sg::plotter::inner_frame_style
style & inner_frame_style()
Definition: plotter:1708
tools::sg::plotter::title_box_y_margin
sf< float > title_box_y_margin
Definition: plotter:117
rep
tools::sg::base_colormap::valn
size_t valn() const
Definition: colormap:52
tools::sg::plotter::m_cmaps
cmaps_t m_cmaps
Definition: plotter:9486
tools::fpow
float fpow(const float &x, const float &y)
Definition: mathf:50
tools::sg::plotter::m_points_sep
separator m_points_sep
Definition: plotter:9447
tools::sg::plotter::m_data_sep
separator m_data_sep
Definition: plotter:9441
tools::sg::points3D::z_axis_max
virtual float z_axis_max() const =0
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::plotter::m_y_axis_data
data_axis m_y_axis_data
Definition: plotter:9456
tools::sg::action::out
std::ostream & out() const
Definition: action:51
tools::sg::plottable_img
Definition: plottables:393
tools::sg::plotter::~plotter
virtual ~plotter()
Definition: plotter:1321
tools::vec3::z
const T & z() const
Definition: vec3:86
tools::sg::rep_bin1D::m_x_min
float m_x_min
Definition: rep:41
tools::line
Definition: line:13
tools::sg::func1D::x_min
virtual float x_min() const =0
tools::sg::plotter::depth
sf< float > depth
Definition: plotter:65
tools::sg::plotter::get_title
void get_title(std::string &a_s)
Definition: plotter:4551
tools::sg::points3D::points
virtual unsigned int points() const =0
tools::data_axis::set_min_value
bool set_min_value(float a_v)
Definition: data_axis:29
tools::sg::plotter::clear_sg
void clear_sg()
Definition: plotter:9224
tools::sg::bmf::size
size_t size() const
Definition: bmf:69
tools::sg::axis::title
sf_string title
Definition: axis:56
tools::sg::bins2D::y_bins
virtual unsigned int y_bins() const =0
tools::sg::plotter::infos_y_margin
sf< float > infos_y_margin
Definition: plotter:111
tools::sg::plotter::m_z_axis
sg::axis m_z_axis
Definition: plotter:9437
tools::sg::axis::title_hjust
sf_enum< hjust > title_hjust
Definition: axis:59
tools::sg::plotter::_zgrid
float _zgrid() const
Definition: plotter:9014
tools::sg::plotter::get_shape
shape_type get_shape() const
Definition: plotter:9100
tools::sg::plotter::first_points
bool first_points(points2D *&a_2, points3D *&a_3) const
Definition: plotter:9205
tools::sg::font_hershey
const std::string & font_hershey()
Definition: strings:186
tools::sg::rep_bin1D::m_v_min
float m_v_min
Definition: rep:43
tools::sg::axis::line_style
sg::line_style & line_style()
Definition: axis:332
tools::sg::atb_vertices::do_back
sf< bool > do_back
Definition: atb_vertices:17
tools::sep
const std::string & sep()
Definition: sep:11
tools::sg::back_area::width
sf< float > width
Definition: back_area:30
tools::sg::plotter::update_background
void update_background()
Definition: plotter:5672
tools::vec3f::normalize
float normalize()
Definition: vec3f:74
tools::sg::plotter::value_top_margin
sf< float > value_top_margin
Definition: plotter:105
tools::sg::plotter::vp_2_axis
bool vp_2_axis(const vec3f &a_vp, vec3f &a_pos) const
Definition: plotter:2059
tools::sg::axis::mag_style
text_style & mag_style()
Definition: axis:336
tools::sg::plotter::func2D_borders_visible
sf< bool > func2D_borders_visible
Definition: plotter:119
tools::data_axis::set_max_value
bool set_max_value(float a_v)
Definition: data_axis:30
tools::sg::plotter::update_z_axis_2D
void update_z_axis_2D()
Definition: plotter:3311
tools::sg::plotter::set_axes_color
void set_axes_color(const colorf &a_color)
Definition: plotter:2075
tools::sg::center
@ center
Definition: enums:75
tools::sg::matrix::mul_scale
void mul_scale(float a_x, float a_y, float a_z)
Definition: matrix:104
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::sg::plotter::update_func2D_xy
void update_func2D_xy(std::ostream &a_out, const func2D &a_func, int a_index, style &a_data_style, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z, float a_zz)
Definition: plotter:4273
tools::sg::plotter::add_plottable
void add_plottable(plottable *a_p)
Definition: plotter:1615
tools::sg::plotter::value_bottom_margin
sf< float > value_bottom_margin
Definition: plotter:106
tools::sg::plotter::colormap_visible
sf< bool > colormap_visible
Definition: plotter:76
tools::sg::plotter::levels
mf< float > levels
Definition: plotter:172
tools::sg::plottable_box::m_Y2
float m_Y2
Definition: plottables:317
tools::sg::plotter::x_axis
const sg::axis & x_axis() const
Definition: plotter:1693
tools::sg::plotter::plotter
plotter(const plotter &a_from)
Definition: plotter:1327
tools::sg::plotter::title_box_width
sf< float > title_box_width
Definition: plotter:114
tools::sg::text::front_width
sf< float > front_width
Definition: text:44
tools::sg::hatching_policy
hatching_policy
Definition: enums:66
tools::sg::plottable::title
virtual const std::string & title() const =0
tools::sg::plotter::SbFunc
Definition: plotter:3858
tools::sg::font_filled
@ font_filled
Definition: enums:93
tools::spline::cubic
Definition: spline:145
tools::sg::plotter::m_background_style
style m_background_style
Definition: plotter:9472
tools::sg::plottable_ellipse::m_R1
float m_R1
Definition: plottables:375
tools::sg::points2D
Definition: plottables:120
tools::sg::plotter::right_margin
sf< float > right_margin
Definition: plotter:61
tools::sg::plotter::set_axes_title_height
void set_axes_title_height(float a_v)
Definition: plotter:2145
tools::sg::plotter::log_function_to_contour
static double log_function_to_contour(double a_X, double a_Y, void *aData)
Definition: plotter:4261
tools::sg::plotter::up_margin
sf< float > up_margin
Definition: plotter:67
tools::ccontour::set_secondary_grid
void set_secondary_grid(int iCol, int iRow)
Definition: ccontour:626
tools::sg::plotter::_zoffset
float _zoffset() const
Definition: plotter:9008
tools::sg::style::hatching
sf_enum< sg::hatching_policy > hatching
Definition: style:42
tools::sg::plotter::x_axis_max
sf< float > x_axis_max
Definition: plotter:90
tools::sg::plotter::m_bins_cmaps
std::vector< base_colormap * > m_bins_cmaps
Definition: plotter:9480
tools::box3f
Definition: box3f:13
tools::sg::draw_style::style
sf_enum< draw_type > style
Definition: draw_style:21
tools::sg::plotter::style_t
std::vector< style_item_t > style_t
Definition: plotter:739
tools::sg::points3D
Definition: plottables:140
tools::sg::tex_rect
Definition: tex_rect:26
tools::sg::plotter::inner_frame_enforced
sf< bool > inner_frame_enforced
Definition: plotter:164
tools::sg::text::encoding
sf_string encoding
Definition: text:35
tools::sg::text::back_visible
sf< bool > back_visible
Definition: text:39
tools::sg::legend
Definition: legend:23
tools::vec2::set_value
void set_value(const T &a0, const T &a1)
Definition: vec2:78
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::sg::modeling_wire_boxes
const std::string & modeling_wire_boxes()
Definition: strings:69
tools::sg::plotter::grid_style
style & grid_style()
Definition: plotter:1709
tools::sg::plotter::y_axis_max
sf< float > y_axis_max
Definition: plotter:96
tools::sg::plotter::m_y_axis_matrix
matrix m_y_axis_matrix
Definition: plotter:9432
tools::sg::rep_top_face2D
Definition: rep:77
tools::sg::plotter::plotter
plotter(const base_freetype &a_ttf)
Definition: plotter:1223
tools::sg::style::font
sf_string font
Definition: style:44
tools::sg::points3D::y_axis_min
virtual float y_axis_min() const =0
tools::sg::vertices::number
size_t number() const
Definition: vertices:184
tools::sg::plotter::bottom_margin
sf< float > bottom_margin
Definition: plotter:62
tools::hatcher::set_strip_width
bool set_strip_width(float a)
Definition: hatcher:142
tools::sg::style::point_size
sf< float > point_size
Definition: style:27
tools::sg::plotter::colormap_axis
sg::axis & colormap_axis()
Definition: plotter:1703
tools::sg::plotter::render
virtual void render(render_action &a_action)
Definition: plotter:1183
tools::sg::draw_lines
@ draw_lines
Definition: enums:192
tools::sg::vertices::add
void add(const VEC &a_v)
Definition: vertices:155
tools::sg::painting_grey_scale_inverse
@ painting_grey_scale_inverse
Definition: enums:63
tools::sg::plotter::rep_bins1D_xy_wire_boxes
void rep_bins1D_xy_wire_boxes(const style &a_style, const base_colormap &a_cmap, const std::vector< rep_bin1D > &a_bins, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz, bool a_bar_chart)
Definition: plotter:6273
tools::sg::plotter::remove_todels
void remove_todels()
Definition: plotter:1664
tools::sg::plottable_box::m_FASI
int m_FASI
Definition: plottables:320
tools::sg::axis::minimum_value
sf< float > minimum_value
Definition: axis:35
tools::sg::torche::on
sf< bool > on
Definition: torche:23
tools::sg::style::font_modeling
sf_enum< sg::font_modeling > font_modeling
Definition: style:29
tools::sg::plotter::infos_width
sf< float > infos_width
Definition: plotter:109
tools::sg::plotter::set_axes_label_height
void set_axes_label_height(float a_v)
Definition: plotter:2152
tools::sg::axis::modeling
sf_string modeling
Definition: axis:38
tools::sg::sf< float >
tools::sg::plotter::s2axis
bool s2axis(const std::string &a_s, sg::axis *&a_axis)
Definition: plotter:976
tools::sg::plotter::update_func1D_xy
void update_func1D_xy(std::ostream &a_out, const func1D &a_func, const style &a_style, const rep_box &a_box_x, const rep_box &a_box_y, float a_zz)
Definition: plotter:4139
tools::hatcher::set_offset_point
void set_offset_point(vec3f a)
Definition: hatcher:139
tools::sg::plotter::points_style
style & points_style(size_t a_index)
Definition: plotter:1749
tools::sg::node::touch
void touch()
Definition: node:233
tools::sg::cube::height
sf< float > height
Definition: cube:21
tools::sg::plotter::set_axes_text_scale
void set_axes_text_scale(float a_v)
Definition: plotter:2101
tools::cline_strip
std::list< unsigned int > cline_strip
Definition: clist_contour:21
tools::sg::plotter::merge_bins_style
style * merge_bins_style(unsigned int a_index, plottable &)
Definition: plotter:9056
tools::clip::execute
void execute(const plane< VEC3 > &plane)
Definition: geom3:138
tools::sg::plotter::colormap_axis_visible
sf< bool > colormap_axis_visible
Definition: plotter:83
tools::sg::markers::style
sf_enum< marker_style > style
Definition: markers:24
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::plotter::update_sg
void update_sg(std::ostream &a_out)
Definition: plotter:2350
tools::sg::axis::title_height
sf< float > title_height
Definition: axis:58
tools::sg::plotter::m_x_axis_data
data_axis m_x_axis_data
Definition: plotter:9455
cube
tools::sg::bins1D::bin_Sw
virtual float bin_Sw(int) const =0
tools::sg::plotter::set_axes_line_width
void set_axes_line_width(int a_v)
Definition: plotter:2126
tools::sg::plotter::y_axis_is_log
sf< bool > y_axis_is_log
Definition: plotter:97
tools::sg::plotter::update_x_axis_3D
void update_x_axis_3D()
Definition: plotter:3316
tools::sg::plottable_box::m_LWID
float m_LWID
Definition: plottables:323
tools::sg::node::reset_touched
virtual void reset_touched()
Definition: node:102
tools::sg::plotter::update_shape
void update_shape()
Definition: plotter:3229
tools::sg::plotter::xx_2_yy
bool xx_2_yy(const vec3f &a_pos, vec3f &a_out) const
Definition: plotter:1838
tools::sg::plotter::axis_2_vp
bool axis_2_vp(const vec3f &a_pos, vec3f &a_vp) const
Definition: plotter:2051
tex_rect
tools::sg::rep_box::m_width
float m_width
Definition: rep:142
tools::sg::text_style::encoding
sf_string encoding
Definition: text_style:31
tools::sg::markers::xyzs
mf< float > xyzs
Definition: markers:25
tools::sg::style::spacing
sf< float > spacing
Definition: style:48
tools::sg::axis::set_encoding
void set_encoding(const std::string &a_value)
Definition: axis:794
tools::sg::plottable_text::m_VJUST
char m_VJUST
Definition: plottables:257
tools::sg::mf_enum< unit_type >
tools::sg::plotter::rep_top_face2D_xyz_by_level
void rep_top_face2D_xyz_by_level(const style &, painting_policy, const base_colormap &a_cmap, const std::vector< rep_top_face2D > &a_top_faces, const rep_box &a_box_x, const rep_box &a_box_y, const rep_box &a_box_z, float a_bmin, float a_bmax)
Definition: plotter:8169
TOOLS_ARG_FIELD_DESC_ENUMS_END
#define TOOLS_ARG_FIELD_DESC_ENUMS_END
Definition: field:83
tools::sg::text_style::back_color
sf_vec< colorf, float > back_color
Definition: text_style:24
tools::sg::vertices
Definition: vertices:22