Warning, /include/Geant4/tools/sg/plottables is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_plottables
0005 #define tools_sg_plottables
0006
0007 #include "plottable"
0008 #include "enums"
0009
0010 namespace tools {
0011 namespace sg {
0012
0013 class bins1D : public virtual plottable {
0014 public:
0015 TOOLS_SCLASS(tools::sg::bins1D)
0016 public:
0017 virtual void* cast(const std::string& a_class) const {
0018 if(void* p = cmp_cast<bins1D>(this,a_class)) {return p;}
0019 return plottable::cast(a_class);
0020 }
0021 public:
0022 virtual ~bins1D(){}
0023 public:
0024 virtual void bins_Sw_range(float&,float&,bool) const = 0;
0025 public:
0026 // axis :
0027 virtual unsigned int bins() const = 0;
0028 virtual float axis_min() const = 0;
0029 virtual float axis_max() const = 0;
0030 // bins on axis :
0031 virtual float bin_lower_edge(int) const = 0;
0032 virtual float bin_upper_edge(int) const = 0;
0033 // bins :
0034 virtual bool has_entries_per_bin() const = 0;
0035 virtual unsigned int bin_entries(int) const = 0;
0036 virtual float bin_Sw(int) const = 0;
0037 virtual float bin_error(int) const = 0;
0038 public:
0039 virtual bool is_profile() const = 0;
0040 };
0041
0042 class bins2D : public virtual plottable {
0043 public:
0044 TOOLS_SCLASS(tools::sg::bins2D)
0045 public:
0046 virtual void* cast(const std::string& a_class) const {
0047 if(void* p = cmp_cast<bins2D>(this,a_class)) {return p;}
0048 return plottable::cast(a_class);
0049 }
0050 public:
0051 virtual ~bins2D(){}
0052 public:
0053 virtual void bins_Sw_range(float&,float&,bool) const = 0;
0054 public:
0055 // x axis :
0056 virtual unsigned int x_bins() const = 0;
0057 virtual float x_axis_min() const = 0;
0058 virtual float x_axis_max() const = 0;
0059 // y axis :
0060 virtual unsigned int y_bins() const = 0;
0061 virtual float y_axis_min() const = 0;
0062 virtual float y_axis_max() const = 0;
0063 // bins on x axis :
0064 virtual float bin_lower_edge_x(int) const = 0;
0065 virtual float bin_upper_edge_x(int) const = 0;
0066 // bins on y axis :
0067 virtual float bin_lower_edge_y(int) const = 0;
0068 virtual float bin_upper_edge_y(int) const = 0;
0069 // bins :
0070 virtual bool has_entries_per_bin() const = 0;
0071 virtual unsigned int bin_entries(int,int) const = 0;
0072 virtual float bin_Sw(int,int) const = 0;
0073 virtual float bin_error(int,int) const = 0;
0074 };
0075
0076 class func1D : public virtual plottable {
0077 public:
0078 TOOLS_SCLASS(tools::sg::func1D)
0079 public:
0080 virtual void* cast(const std::string& a_class) const {
0081 if(void* p = cmp_cast<func1D>(this,a_class)) {return p;}
0082 return plottable::cast(a_class);
0083 }
0084 public:
0085 virtual ~func1D(){}
0086 public:
0087 virtual bool value(float,float&) const = 0;
0088 virtual unsigned int x_steps() const = 0;
0089 virtual float x_min() const = 0;
0090 virtual float x_max() const = 0;
0091 };
0092
0093 class func2D : public virtual plottable {
0094 public:
0095 TOOLS_SCLASS(tools::sg::func2D)
0096 public:
0097 virtual void* cast(const std::string& a_class) const {
0098 if(void* p = cmp_cast<func2D>(this,a_class)) {return p;}
0099 return plottable::cast(a_class);
0100 }
0101 public:
0102 virtual ~func2D(){}
0103 public:
0104 virtual bool value(float,float,float&) const = 0;
0105 virtual unsigned int x_steps() const = 0;
0106 virtual float x_min() const = 0;
0107 virtual float x_max() const = 0;
0108 virtual unsigned int y_steps() const = 0;
0109 virtual float y_min() const = 0;
0110 virtual float y_max() const = 0;
0111 /*
0112 //For "inside" functions :
0113 virtual unsigned int number_of_points() const = 0;
0114 virtual bool ith_point(int,float&,float&,bool&) const = 0;
0115 virtual bool set_ith_point(int,float,float) = 0;
0116 virtual bool dragger_update_points() const = 0;
0117 */
0118 };
0119
0120 class points2D : public virtual plottable {
0121 public:
0122 TOOLS_SCLASS(tools::sg::points2D)
0123 public:
0124 virtual void* cast(const std::string& a_class) const {
0125 if(void* p = cmp_cast<points2D>(this,a_class)) {return p;}
0126 return plottable::cast(a_class);
0127 }
0128 public:
0129 virtual ~points2D(){}
0130 public:
0131 virtual float x_axis_min() const = 0;
0132 virtual float x_axis_max() const = 0;
0133 virtual float y_axis_min() const = 0;
0134 virtual float y_axis_max() const = 0;
0135
0136 virtual unsigned int points() const = 0;
0137 virtual bool ith_point(unsigned int,float&,float&) const = 0;
0138 };
0139
0140 class points3D : public virtual plottable {
0141 public:
0142 TOOLS_SCLASS(tools::sg::points3D)
0143 public:
0144 virtual void* cast(const std::string& a_class) const {
0145 if(void* p = cmp_cast<points3D>(this,a_class)) {return p;}
0146 return plottable::cast(a_class);
0147 }
0148 public:
0149 virtual ~points3D(){}
0150 public:
0151 virtual float x_axis_min() const = 0;
0152 virtual float x_axis_max() const = 0;
0153 virtual float y_axis_min() const = 0;
0154 virtual float y_axis_max() const = 0;
0155 virtual float z_axis_min() const = 0;
0156 virtual float z_axis_max() const = 0;
0157
0158 virtual unsigned int points() const = 0;
0159 virtual bool ith_point(unsigned int,float&,float&,float&) const = 0;
0160 };
0161
0162 inline const std::string& s_tools_sg_fit2plot() {
0163 static const std::string s_v("tools::sg::fit2plot");
0164 return s_v;
0165 }
0166
0167 }}
0168
0169 ////////////////////////////////////////////////////////////////////////////////
0170 /// primitives : ///////////////////////////////////////////////////////////////
0171 ////////////////////////////////////////////////////////////////////////////////
0172 #include "../colorf"
0173
0174 namespace tools {
0175 namespace sg {
0176
0177 class plottable_text : public virtual plotprim {
0178 typedef plotprim parent;
0179 public:
0180 TOOLS_SCLASS(plottable_text)
0181 public: //tools::sg::plotprim
0182 virtual void* cast(const std::string& a_class) const {
0183 if(void* p = cmp_cast<plottable_text>(this,a_class)) {return p;}
0184 return 0;
0185 }
0186 virtual plotprim* copy() const {return new plottable_text(*this);}
0187 public:
0188 enum text_mode {
0189 text_as_it,
0190 text_enforce_width,
0191 text_enforce_height
0192 };
0193 public:
0194 plottable_text(const std::string& a_TEXT,float a_X,float a_Y,
0195 float a_SIZE,text_mode a_text_mode,
0196 /*
0197 float a_ANGLE = 0,
0198 char a_HJUST = 'L',char a_VJUST = 'B',
0199 const std::string& a_FONT = "Hershey",const colorf& a_TXCI = colorf(0,0,0,1),
0200 float a_SCALE = 1,bool a_SMOOTHING = false,bool a_HINTING = false,float a_line_width = 1,
0201 font_modeling a_font_modeling = font_filled
0202 */
0203 float a_ANGLE,
0204 char a_HJUST,char a_VJUST,
0205 const std::string& a_FONT,const colorf& a_TXCI,
0206 float a_SCALE,bool a_SMOOTHING,bool a_HINTING,float a_line_width,
0207 font_modeling a_font_modeling
0208 )
0209 :m_TEXT(a_TEXT),m_X(a_X),m_Y(a_Y)
0210 ,m_SIZE(a_SIZE),m_text_mode(a_text_mode)
0211 ,m_ANGLE(a_ANGLE)
0212 ,m_HJUST(a_HJUST)
0213 ,m_VJUST(a_VJUST)
0214 ,m_FONT(a_FONT),m_TXCI(a_TXCI)
0215 ,m_SCALE(a_SCALE),m_SMOOTHING(a_SMOOTHING),m_HINTING(a_HINTING),m_line_width(a_line_width)
0216 ,m_font_modeling(a_font_modeling)
0217 {}
0218 public:
0219 plottable_text(const plottable_text& a_from)
0220 :parent(a_from)
0221 ,m_TEXT(a_from.m_TEXT)
0222 ,m_X(a_from.m_X),m_Y(a_from.m_Y)
0223 ,m_SIZE(a_from.m_SIZE),m_text_mode(a_from.m_text_mode)
0224 ,m_ANGLE(a_from.m_ANGLE)
0225 ,m_HJUST(a_from.m_HJUST)
0226 ,m_VJUST(a_from.m_VJUST)
0227 ,m_FONT(a_from.m_FONT),m_TXCI(a_from.m_TXCI)
0228 ,m_SCALE(a_from.m_SCALE),m_SMOOTHING(a_from.m_SMOOTHING),m_HINTING(a_from.m_HINTING),m_line_width(a_from.m_line_width)
0229 ,m_font_modeling(a_from.m_font_modeling)
0230 {}
0231 plottable_text& operator=(const plottable_text& a_from) {
0232 m_TEXT = a_from.m_TEXT;
0233 m_X = a_from.m_X;
0234 m_Y = a_from.m_Y;
0235 m_SIZE = a_from.m_SIZE;
0236 m_text_mode = a_from.m_text_mode;
0237 m_ANGLE = a_from.m_ANGLE;
0238 m_HJUST = a_from.m_HJUST;
0239 m_VJUST = a_from.m_VJUST;
0240 m_FONT = a_from.m_FONT;
0241 m_TXCI = a_from.m_TXCI;
0242 m_SCALE = a_from.m_SCALE;
0243 m_SMOOTHING = a_from.m_SMOOTHING;
0244 m_HINTING = a_from.m_HINTING;
0245 m_line_width = a_from.m_line_width;
0246 m_font_modeling = a_from.m_font_modeling;
0247 return *this;
0248 }
0249 public:
0250 std::string m_TEXT;
0251 float m_X;
0252 float m_Y;
0253 float m_SIZE;
0254 text_mode m_text_mode;
0255 float m_ANGLE;
0256 char m_HJUST;
0257 char m_VJUST;
0258 std::string m_FONT;
0259 colorf m_TXCI;
0260 float m_SCALE;
0261 bool m_SMOOTHING;
0262 bool m_HINTING;
0263 float m_line_width; //used if font is hershey.
0264 font_modeling m_font_modeling;
0265 };
0266
0267 class plottable_box : public virtual plotprim {
0268 typedef plotprim parent;
0269 public:
0270 TOOLS_SCLASS(plottable_box)
0271 public: //tools::sg::plotprim
0272 virtual void* cast(const std::string& a_class) const {
0273 if(void* p = cmp_cast<plottable_box>(this,a_class)) {return p;}
0274 return 0;
0275 }
0276 virtual plotprim* copy() const {return new plottable_box(*this);}
0277 public:
0278 enum fill_area_style {
0279 HOLLOW = 0,
0280 SOLID = 1,
0281 PATTERN = 2,
0282 HATCHED = 3
0283 };
0284 public:
0285 plottable_box(float a_X1,float a_Y1,float a_X2,float a_Y2,
0286 fill_area_style a_FAIS,const colorf& a_FACI,
0287 int a_FASI,
0288 bool a_BORD,const colorf& a_PLCI,float a_LWID)
0289 :m_X1(a_X1),m_Y1(a_Y1),m_X2(a_X2),m_Y2(a_Y2)
0290 ,m_FAIS(a_FAIS),m_FACI(a_FACI),m_FASI(a_FASI),m_BORD(a_BORD),m_PLCI(a_PLCI),m_LWID(a_LWID)
0291 {}
0292 public:
0293 plottable_box(const plottable_box& a_from)
0294 :parent(a_from)
0295 ,m_X1(a_from.m_X1),m_Y1(a_from.m_Y1)
0296 ,m_X2(a_from.m_X2),m_Y2(a_from.m_Y2)
0297 ,m_FAIS(a_from.m_FAIS),m_FACI(a_from.m_FACI),m_FASI(a_from.m_FASI),m_BORD(a_from.m_BORD),m_PLCI(a_from.m_PLCI)
0298 ,m_LWID(a_from.m_LWID)
0299 {}
0300 plottable_box& operator=(const plottable_box& a_from) {
0301 m_X1 = a_from.m_X1;
0302 m_Y1 = a_from.m_Y1;
0303 m_X2 = a_from.m_X2;
0304 m_Y2 = a_from.m_Y2;
0305 m_FAIS = a_from.m_FAIS;
0306 m_FACI = a_from.m_FACI;
0307 m_FASI = a_from.m_FASI;
0308 m_BORD = a_from.m_BORD;
0309 m_PLCI = a_from.m_PLCI;
0310 m_LWID = a_from.m_LWID;
0311 return *this;
0312 }
0313 public:
0314 float m_X1;
0315 float m_Y1;
0316 float m_X2;
0317 float m_Y2;
0318 fill_area_style m_FAIS;
0319 colorf m_FACI;
0320 int m_FASI;
0321 bool m_BORD;
0322 colorf m_PLCI;
0323 float m_LWID;
0324 };
0325
0326 class plottable_ellipse : public virtual plotprim {
0327 typedef plotprim parent;
0328 public:
0329 TOOLS_SCLASS(plottable_ellipse)
0330 public: //tools::sg::plotprim
0331 virtual void* cast(const std::string& a_class) const {
0332 if(void* p = cmp_cast<plottable_ellipse>(this,a_class)) {return p;}
0333 return 0;
0334 }
0335 virtual plotprim* copy() const {return new plottable_ellipse(*this);}
0336 public:
0337 enum fill_area_style {
0338 HOLLOW = 0,
0339 SOLID = 1,
0340 PATTERN = 2,
0341 HATCHED = 3
0342 };
0343 public:
0344 plottable_ellipse(float a_X,float a_Y,float a_R1,float a_R2,
0345 fill_area_style a_FAIS,const colorf& a_FACI,
0346 int a_FASI,
0347 bool a_BORD,const colorf& a_PLCI,float a_LWID)
0348 :m_X(a_X),m_Y(a_Y),m_R1(a_R1),m_R2(a_R2)
0349 ,m_FAIS(a_FAIS),m_FACI(a_FACI),m_FASI(a_FASI),m_BORD(a_BORD),m_PLCI(a_PLCI),m_LWID(a_LWID)
0350 {}
0351 public:
0352 plottable_ellipse(const plottable_ellipse& a_from)
0353 :parent(a_from)
0354 ,m_X(a_from.m_X),m_Y(a_from.m_Y)
0355 ,m_R1(a_from.m_R1),m_R2(a_from.m_R2)
0356 ,m_FAIS(a_from.m_FAIS),m_FACI(a_from.m_FACI),m_FASI(a_from.m_FASI),m_BORD(a_from.m_BORD),m_PLCI(a_from.m_PLCI)
0357 ,m_LWID(a_from.m_LWID)
0358 {}
0359 plottable_ellipse& operator=(const plottable_ellipse& a_from) {
0360 m_X = a_from.m_X;
0361 m_Y = a_from.m_Y;
0362 m_R1 = a_from.m_R1;
0363 m_R2 = a_from.m_R2;
0364 m_FAIS = a_from.m_FAIS;
0365 m_FACI = a_from.m_FACI;
0366 m_FASI = a_from.m_FASI;
0367 m_BORD = a_from.m_BORD;
0368 m_PLCI = a_from.m_PLCI;
0369 m_LWID = a_from.m_LWID;
0370 return *this;
0371 }
0372 public:
0373 float m_X;
0374 float m_Y;
0375 float m_R1;
0376 float m_R2;
0377 fill_area_style m_FAIS;
0378 colorf m_FACI;
0379 int m_FASI;
0380 bool m_BORD;
0381 colorf m_PLCI;
0382 float m_LWID;
0383 };
0384
0385 }}
0386
0387 #include "../img"
0388 #include "../typedefs"
0389
0390 namespace tools {
0391 namespace sg {
0392
0393 class plottable_img : public virtual plotprim {
0394 typedef plotprim parent;
0395 public:
0396 TOOLS_SCLASS(plottable_img)
0397 public: //tools::sg::plotprim
0398 virtual void* cast(const std::string& a_class) const {
0399 if(void* p = cmp_cast<plottable_img>(this,a_class)) {return p;}
0400 return 0;
0401 }
0402 virtual plotprim* copy() const {return new plottable_img(*this);}
0403 public:
0404 plottable_img(const img<byte>& a_img,float a_X,float a_Y,float a_WIDTH,float a_HEIGHT,float a_THETA,float a_PHI)
0405 :m_img(a_img)
0406 ,m_X(a_X),m_Y(a_Y)
0407 ,m_WIDTH(a_WIDTH),m_HEIGHT(a_HEIGHT),m_THETA(a_THETA),m_PHI(a_PHI)
0408 {}
0409 public:
0410 plottable_img(const plottable_img& a_from)
0411 :parent(a_from)
0412 ,m_img(a_from.m_img)
0413 ,m_X(a_from.m_X),m_Y(a_from.m_Y)
0414 ,m_WIDTH(a_from.m_WIDTH),m_HEIGHT(a_from.m_HEIGHT),m_THETA(a_from.m_THETA),m_PHI(a_from.m_PHI)
0415 {}
0416 plottable_img& operator=(const plottable_img& a_from) {
0417 m_img = a_from.m_img;
0418 m_X = a_from.m_X;
0419 m_Y = a_from.m_Y;
0420 m_WIDTH = a_from.m_WIDTH;
0421 m_HEIGHT = a_from.m_HEIGHT;
0422 m_THETA = a_from.m_THETA;
0423 m_PHI = a_from.m_PHI;
0424 return *this;
0425 }
0426 public:
0427 img<byte> m_img;
0428 float m_X;
0429 float m_Y;
0430 float m_WIDTH;
0431 float m_HEIGHT;
0432 float m_THETA;
0433 float m_PHI;
0434 };
0435
0436 }}
0437
0438
0439 #endif