Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
+120 -34
View File
@@ -10,9 +10,12 @@
#include "matrix"
#include "text_hershey"
#include "base_freetype"
#include "markers"
#include "enums"
#include "../colorf"
//#include "../paw2stix"
#include "text_valop"
namespace tools {
namespace sg {
@@ -35,6 +38,9 @@ public:
sf_enum<hjust> lhjust;
sf_enum<hjust> rhjust;
//sf<bool> confine;
sf_enum<sg::marker_style> marker_style;
sf<float> marker_size;
public:
virtual const std::vector<field_desc>& node_fields() const {
TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::legend)
@@ -50,6 +56,8 @@ public:
TOOLS_ADD_FIELD_DESC(hmargin_factor)
TOOLS_ADD_FIELD_DESC(lhjust)
TOOLS_ADD_FIELD_DESC(rhjust)
TOOLS_ADD_FIELD_DESC(marker_style)
TOOLS_ADD_FIELD_DESC(marker_size)
}
return s_v;
}
@@ -66,6 +74,8 @@ private:
add_field(&hmargin_factor);
add_field(&lhjust);
add_field(&rhjust);
add_field(&marker_style);
add_field(&marker_size);
}
public:
virtual void render(render_action& a_action) {
@@ -125,6 +135,9 @@ public:
,lhjust(left)
,rhjust(right)
,marker_style(marker_dot)
,marker_size(10)
//,confine(false)
,m_ttf(a_ttf)
@@ -149,6 +162,9 @@ public:
,lhjust(a_from.lhjust)
,rhjust(a_from.rhjust)
,marker_style(a_from.marker_style)
,marker_size(a_from.marker_size)
//,confine(a_from.confine)
,m_ttf(a_from.m_ttf)
@@ -171,6 +187,9 @@ public:
lhjust = a_from.lhjust;
rhjust = a_from.rhjust;
marker_style = a_from.marker_style;
marker_size = a_from.marker_size;
//confine = a_from.confine;
return *this;
@@ -200,36 +219,68 @@ public:
//sf<float> zfront ?
float zz = back_visible.value()?0.01f:0;
float fw = width * wmargin_factor;
//bool rep_line = false;
//rep_line = true;
/*
float fw = 0;
float fh = 0;
float lw = 0;
float rw = 0;
if(rep_line) {
fw = width * wmargin_factor;
fh = height * hmargin_factor;
lw = fw*0.5f*0.95f;
rw = fw*0.5f;
}*/
////////////////////////////////////////////////////////////
/// rep at left ////////////////////////////////////////////
////////////////////////////////////////////////////////////
matrix* ltsf = 0;
float lw = fw*0.5f*0.95f;
{separator* _sep = new separator;
m_sep.add(_sep);
ltsf = new matrix;
_sep->add(ltsf);
rgba* mat = new rgba();
mat->color = color;
_sep->add(mat);
draw_style* ds = new draw_style;
ds->style = draw_style::lines;
_sep->add(ds);
/* if(rep_line) {
matrix* ltsf = new matrix;
float xx = -fw*0.5F; //left justified.
ltsf->set_translate(xx,0,zz);
_sep->add(ltsf);
vertices* vtxs = new vertices;
vtxs->mode = gl::line_strip();
_sep->add(vtxs);
draw_style* ds = new draw_style;
ds->style = draw_style::lines;
_sep->add(ds);
vtxs->add( 0,0,zz);
vtxs->add(lw,0,zz);}
vertices* vtxs = new vertices;
vtxs->mode = gl::line_strip();
vtxs->add( 0,0,zz);
vtxs->add(lw,0,zz);
_sep->add(vtxs);
} else*/ { // rep marker :
if(marker_style.value()==marker_dot) {
draw_style* ds = new draw_style;
ds->style = draw_style::points;
ds->point_size = marker_size;
_sep->add(ds);
vertices* vtxs = new vertices;
vtxs->mode = gl::points();
vtxs->add(-width*0.5f+height*0.5f,0,zz);
_sep->add(vtxs);
} else {
markers* vtxs = new markers;
vtxs->size = marker_size;
vtxs->style = marker_style;
vtxs->add(-width*0.5f+height*0.5f,0,zz);
_sep->add(vtxs);
}
}
}
////////////////////////////////////////////////////////////
/// right text /////////////////////////////////////////////
@@ -254,25 +305,32 @@ public:
_sep->add(rtsf);
if(font==font_hershey()) {
text_hershey* text = new text_hershey;
rtext = text;
text->encoding = encoding;
text->strings = strings;
_sep->add(text);
} else {
base_freetype* text = base_freetype::create(m_ttf);
rtext = text;
text->font = font;
_sep->add(text);
} else {
if(encoding==encoding_PAW()) {
text_valop* text = new text_valop(m_ttf);
text->font = font;
text->strings = strings;
_sep->add(text);
rtext = text;
} else {
base_freetype* text = base_freetype::create(m_ttf);
text->font = font;
text->strings = strings;
_sep->add(text);
rtext = text;
}
}
rtext->strings = strings;
rtext->hjust = rhjust;}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//if(confine) {
float fh = height * hmargin_factor;
float rw = fw*0.5f;
/* if(rep_line) {
// adjust width :
float th = fh;
@@ -280,20 +338,18 @@ public:
float mx_x,mx_y,mx_z;
rtext->get_bounds(th,mn_x,mn_y,mn_z,mx_x,mx_y,mx_z);
float bxw = mx_x-mn_x;
// adjust box width :
// fh -> bxw then to have rw :
if(!bxw) {
m_sep.clear();
parent::update_sg();
return;
}
th = rw*fh/bxw;}
// adjust box width :
// fh -> bxw then to have rw :
float max_width = rw;
if(bxw>max_width) th = max_width*fh/bxw;}
rtext->height = th;
{float xx = -fw*0.5F; //left justified.
ltsf->set_translate(xx,0,zz);}
{float mn_x,mn_y,mn_z;
float mx_x,mx_y,mx_z;
rtext->get_bounds(th,mn_x,mn_y,mn_z,mx_x,mx_y,mx_z);
@@ -302,10 +358,40 @@ public:
float yy = -(mn_y+mx_y)*0.5F;
rtsf->set_translate(xx,yy,zz);}
parent::update_sg();
} else*/ { //rep mark :
//} else {
//}
// adjust width :
float th = height;
{float mn_x,mn_y,mn_z;
float mx_x,mx_y,mx_z;
rtext->get_bounds(th,mn_x,mn_y,mn_z,mx_x,mx_y,mx_z);
float bxw = mx_x-mn_x;
if(!bxw) {
m_sep.clear();
parent::update_sg();
return;
}
// adjust box width :
// height -> bxw then to have a wanted width :
float max_width = (width-height)*wmargin_factor;
if(bxw>max_width) th = max_width*height/bxw;
if(th<0) {
m_sep.clear();
parent::update_sg();
return;
}}
rtext->height = th;
{float mn_x,mn_y,mn_z;
float mx_x,mx_y,mx_z;
rtext->get_bounds(th,mn_x,mn_y,mn_z,mx_x,mx_y,mx_z);
rtext->hjust = left;
float yy = -(mn_y+mx_y)*0.5F;
rtsf->set_translate(-width*0.5f+height,yy,zz);}
}
parent::update_sg();
}
protected: