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
0113 class points2D : public virtual plottable {
0114 public:
0115 TOOLS_SCLASS(tools::sg::points2D)
0116 public:
0117 virtual void* cast(const std::string& a_class) const {
0118 if(void* p = cmp_cast<points2D>(this,a_class)) {return p;}
0119 return plottable::cast(a_class);
0120 }
0121 public:
0122 virtual ~points2D(){}
0123 public:
0124 virtual float x_axis_min() const = 0;
0125 virtual float x_axis_max() const = 0;
0126 virtual float y_axis_min() const = 0;
0127 virtual float y_axis_max() const = 0;
0128
0129 virtual unsigned int points() const = 0;
0130 virtual bool ith_point(unsigned int,float&,float&) const = 0;
0131 };
0132
0133 class points3D : public virtual plottable {
0134 public:
0135 TOOLS_SCLASS(tools::sg::points3D)
0136 public:
0137 virtual void* cast(const std::string& a_class) const {
0138 if(void* p = cmp_cast<points3D>(this,a_class)) {return p;}
0139 return plottable::cast(a_class);
0140 }
0141 public:
0142 virtual ~points3D(){}
0143 public:
0144 virtual float x_axis_min() const = 0;
0145 virtual float x_axis_max() const = 0;
0146 virtual float y_axis_min() const = 0;
0147 virtual float y_axis_max() const = 0;
0148 virtual float z_axis_min() const = 0;
0149 virtual float z_axis_max() const = 0;
0150
0151 virtual unsigned int points() const = 0;
0152 virtual bool ith_point(unsigned int,float&,float&,float&) const = 0;
0153 };
0154
0155 inline const std::string& s_tools_sg_fit2plot() {
0156 static const std::string s_v("tools::sg::fit2plot");
0157 return s_v;
0158 }
0159
0160 }}
0161
0162 ////////////////////////////////////////////////////////////////////////////////
0163 /// primitives : ///////////////////////////////////////////////////////////////
0164 ////////////////////////////////////////////////////////////////////////////////
0165 #include "../colorf"
0166
0167 namespace tools {
0168 namespace sg {
0169
0170 class plottable_text : public virtual plotprim {
0171 typedef plotprim parent;
0172 public:
0173 TOOLS_SCLASS(plottable_text)
0174 public: //tools::sg::plotprim
0175 virtual void* cast(const std::string& a_class) const {
0176 if(void* p = cmp_cast<plottable_text>(this,a_class)) {return p;}
0177 return 0;
0178 }
0179 virtual plotprim* copy() const {return new plottable_text(*this);}
0180 public:
0181 enum text_mode {
0182 text_as_it,
0183 text_enforce_width,
0184 text_enforce_height
0185 };
0186 public:
0187 plottable_text(const std::string& a_TEXT,float a_X,float a_Y,
0188 float a_SIZE,text_mode a_text_mode,
0189 float a_ANGLE,
0190 char a_HJUST,char a_VJUST,
0191 const std::string& a_FONT,const colorf& a_TXCI,
0192 float a_SCALE,bool a_SMOOTHING,bool a_HINTING,float a_line_width,
0193 font_modeling a_font_modeling
0194 )
0195 :m_TEXT(a_TEXT),m_X(a_X),m_Y(a_Y)
0196 ,m_SIZE(a_SIZE),m_text_mode(a_text_mode)
0197 ,m_ANGLE(a_ANGLE)
0198 ,m_HJUST(a_HJUST)
0199 ,m_VJUST(a_VJUST)
0200 ,m_FONT(a_FONT),m_TXCI(a_TXCI)
0201 ,m_SCALE(a_SCALE),m_SMOOTHING(a_SMOOTHING),m_HINTING(a_HINTING),m_line_width(a_line_width)
0202 ,m_font_modeling(a_font_modeling)
0203 {}
0204 public:
0205 plottable_text(const plottable_text& a_from)
0206 :parent(a_from)
0207 ,m_TEXT(a_from.m_TEXT)
0208 ,m_X(a_from.m_X),m_Y(a_from.m_Y)
0209 ,m_SIZE(a_from.m_SIZE),m_text_mode(a_from.m_text_mode)
0210 ,m_ANGLE(a_from.m_ANGLE)
0211 ,m_HJUST(a_from.m_HJUST)
0212 ,m_VJUST(a_from.m_VJUST)
0213 ,m_FONT(a_from.m_FONT),m_TXCI(a_from.m_TXCI)
0214 ,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)
0215 ,m_font_modeling(a_from.m_font_modeling)
0216 {}
0217 plottable_text& operator=(const plottable_text& a_from) {
0218 m_TEXT = a_from.m_TEXT;
0219 m_X = a_from.m_X;
0220 m_Y = a_from.m_Y;
0221 m_SIZE = a_from.m_SIZE;
0222 m_text_mode = a_from.m_text_mode;
0223 m_ANGLE = a_from.m_ANGLE;
0224 m_HJUST = a_from.m_HJUST;
0225 m_VJUST = a_from.m_VJUST;
0226 m_FONT = a_from.m_FONT;
0227 m_TXCI = a_from.m_TXCI;
0228 m_SCALE = a_from.m_SCALE;
0229 m_SMOOTHING = a_from.m_SMOOTHING;
0230 m_HINTING = a_from.m_HINTING;
0231 m_line_width = a_from.m_line_width;
0232 m_font_modeling = a_from.m_font_modeling;
0233 return *this;
0234 }
0235 public:
0236 std::string m_TEXT;
0237 float m_X;
0238 float m_Y;
0239 float m_SIZE;
0240 text_mode m_text_mode;
0241 float m_ANGLE;
0242 char m_HJUST;
0243 char m_VJUST;
0244 std::string m_FONT;
0245 colorf m_TXCI;
0246 float m_SCALE;
0247 bool m_SMOOTHING;
0248 bool m_HINTING;
0249 float m_line_width; //used if font is hershey.
0250 font_modeling m_font_modeling;
0251 };
0252
0253 class plottable_box : public virtual plotprim {
0254 typedef plotprim parent;
0255 public:
0256 TOOLS_SCLASS(plottable_box)
0257 public: //tools::sg::plotprim
0258 virtual void* cast(const std::string& a_class) const {
0259 if(void* p = cmp_cast<plottable_box>(this,a_class)) {return p;}
0260 return 0;
0261 }
0262 virtual plotprim* copy() const {return new plottable_box(*this);}
0263 public:
0264 enum fill_area_style {
0265 HOLLOW = 0,
0266 SOLID = 1,
0267 PATTERN = 2,
0268 HATCHED = 3
0269 };
0270 public:
0271 plottable_box(float a_X1,float a_Y1,float a_X2,float a_Y2,
0272 fill_area_style a_FAIS,const colorf& a_FACI,
0273 int a_FASI,
0274 bool a_BORD,const colorf& a_PLCI,float a_LWID)
0275 :m_X1(a_X1),m_Y1(a_Y1),m_X2(a_X2),m_Y2(a_Y2)
0276 ,m_FAIS(a_FAIS),m_FACI(a_FACI),m_FASI(a_FASI),m_BORD(a_BORD),m_PLCI(a_PLCI),m_LWID(a_LWID)
0277 {}
0278 public:
0279 plottable_box(const plottable_box& a_from)
0280 :parent(a_from)
0281 ,m_X1(a_from.m_X1),m_Y1(a_from.m_Y1)
0282 ,m_X2(a_from.m_X2),m_Y2(a_from.m_Y2)
0283 ,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)
0284 ,m_LWID(a_from.m_LWID)
0285 {}
0286 plottable_box& operator=(const plottable_box& a_from) {
0287 m_X1 = a_from.m_X1;
0288 m_Y1 = a_from.m_Y1;
0289 m_X2 = a_from.m_X2;
0290 m_Y2 = a_from.m_Y2;
0291 m_FAIS = a_from.m_FAIS;
0292 m_FACI = a_from.m_FACI;
0293 m_FASI = a_from.m_FASI;
0294 m_BORD = a_from.m_BORD;
0295 m_PLCI = a_from.m_PLCI;
0296 m_LWID = a_from.m_LWID;
0297 return *this;
0298 }
0299 public:
0300 float m_X1;
0301 float m_Y1;
0302 float m_X2;
0303 float m_Y2;
0304 fill_area_style m_FAIS;
0305 colorf m_FACI;
0306 int m_FASI;
0307 bool m_BORD;
0308 colorf m_PLCI;
0309 float m_LWID;
0310 };
0311
0312 class plottable_ellipse : public virtual plotprim {
0313 typedef plotprim parent;
0314 public:
0315 TOOLS_SCLASS(plottable_ellipse)
0316 public: //tools::sg::plotprim
0317 virtual void* cast(const std::string& a_class) const {
0318 if(void* p = cmp_cast<plottable_ellipse>(this,a_class)) {return p;}
0319 return 0;
0320 }
0321 virtual plotprim* copy() const {return new plottable_ellipse(*this);}
0322 public:
0323 enum fill_area_style {
0324 HOLLOW = 0,
0325 SOLID = 1,
0326 PATTERN = 2,
0327 HATCHED = 3
0328 };
0329 public:
0330 plottable_ellipse(float a_X,float a_Y,float a_R1,float a_R2,
0331 fill_area_style a_FAIS,const colorf& a_FACI,
0332 int a_FASI,
0333 bool a_BORD,const colorf& a_PLCI,float a_LWID)
0334 :m_X(a_X),m_Y(a_Y),m_R1(a_R1),m_R2(a_R2)
0335 ,m_FAIS(a_FAIS),m_FACI(a_FACI),m_FASI(a_FASI),m_BORD(a_BORD),m_PLCI(a_PLCI),m_LWID(a_LWID)
0336 {}
0337 public:
0338 plottable_ellipse(const plottable_ellipse& a_from)
0339 :parent(a_from)
0340 ,m_X(a_from.m_X),m_Y(a_from.m_Y)
0341 ,m_R1(a_from.m_R1),m_R2(a_from.m_R2)
0342 ,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)
0343 ,m_LWID(a_from.m_LWID)
0344 {}
0345 plottable_ellipse& operator=(const plottable_ellipse& a_from) {
0346 m_X = a_from.m_X;
0347 m_Y = a_from.m_Y;
0348 m_R1 = a_from.m_R1;
0349 m_R2 = a_from.m_R2;
0350 m_FAIS = a_from.m_FAIS;
0351 m_FACI = a_from.m_FACI;
0352 m_FASI = a_from.m_FASI;
0353 m_BORD = a_from.m_BORD;
0354 m_PLCI = a_from.m_PLCI;
0355 m_LWID = a_from.m_LWID;
0356 return *this;
0357 }
0358 public:
0359 float m_X;
0360 float m_Y;
0361 float m_R1;
0362 float m_R2;
0363 fill_area_style m_FAIS;
0364 colorf m_FACI;
0365 int m_FASI;
0366 bool m_BORD;
0367 colorf m_PLCI;
0368 float m_LWID;
0369 };
0370
0371 }}
0372
0373 #include "../img"
0374 #include "../typedefs"
0375
0376 namespace tools {
0377 namespace sg {
0378
0379 class plottable_img : public virtual plotprim {
0380 typedef plotprim parent;
0381 public:
0382 TOOLS_SCLASS(plottable_img)
0383 public: //tools::sg::plotprim
0384 virtual void* cast(const std::string& a_class) const {
0385 if(void* p = cmp_cast<plottable_img>(this,a_class)) {return p;}
0386 return 0;
0387 }
0388 virtual plotprim* copy() const {return new plottable_img(*this);}
0389 public:
0390 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)
0391 :m_img(a_img)
0392 ,m_X(a_X),m_Y(a_Y)
0393 ,m_WIDTH(a_WIDTH),m_HEIGHT(a_HEIGHT),m_THETA(a_THETA),m_PHI(a_PHI)
0394 {}
0395 public:
0396 plottable_img(const plottable_img& a_from)
0397 :parent(a_from)
0398 ,m_img(a_from.m_img)
0399 ,m_X(a_from.m_X),m_Y(a_from.m_Y)
0400 ,m_WIDTH(a_from.m_WIDTH),m_HEIGHT(a_from.m_HEIGHT),m_THETA(a_from.m_THETA),m_PHI(a_from.m_PHI)
0401 {}
0402 plottable_img& operator=(const plottable_img& a_from) {
0403 m_img = a_from.m_img;
0404 m_X = a_from.m_X;
0405 m_Y = a_from.m_Y;
0406 m_WIDTH = a_from.m_WIDTH;
0407 m_HEIGHT = a_from.m_HEIGHT;
0408 m_THETA = a_from.m_THETA;
0409 m_PHI = a_from.m_PHI;
0410 return *this;
0411 }
0412 public:
0413 img<byte> m_img;
0414 float m_X;
0415 float m_Y;
0416 float m_WIDTH;
0417 float m_HEIGHT;
0418 float m_THETA;
0419 float m_PHI;
0420 };
0421
0422 }}
0423
0424
0425 #endif