Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
+323 -213
View File
@@ -36,30 +36,43 @@ public:
sf<float> horizontal_spacing;
sf<float> vertical_spacing;
public:
virtual const std::vector<field_desc>& node_fields() const {
virtual const desc_fields& node_desc_fields() const {
TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::plots)
static std::vector<field_desc> s_v;
if(s_v.empty()) {
s_v = parent::node_fields();
TOOLS_ADD_FIELD_DESC(width)
TOOLS_ADD_FIELD_DESC(height)
TOOLS_ADD_FIELD_DESC(cols)
TOOLS_ADD_FIELD_DESC(rows)
TOOLS_ADD_FIELD_DESC(view_border)
TOOLS_ADD_FIELD_DESC(plotter_scale)
TOOLS_ADD_FIELD_DESC(border_visible)
TOOLS_ADD_FIELD_DESC(border_width)
TOOLS_ADD_FIELD_DESC(border_height)
TOOLS_ADD_FIELD_DESC(border_color)
TOOLS_ADD_FIELD_DESC(left_margin)
TOOLS_ADD_FIELD_DESC(right_margin)
TOOLS_ADD_FIELD_DESC(top_margin)
TOOLS_ADD_FIELD_DESC(bottom_margin)
TOOLS_ADD_FIELD_DESC(horizontal_spacing)
TOOLS_ADD_FIELD_DESC(vertical_spacing)
}
static const desc_fields s_v(parent::node_desc_fields(),16, //WARNING : take care of count.
TOOLS_ARG_FIELD_DESC(width),
TOOLS_ARG_FIELD_DESC(height),
TOOLS_ARG_FIELD_DESC(cols),
TOOLS_ARG_FIELD_DESC(rows),
TOOLS_ARG_FIELD_DESC(view_border),
TOOLS_ARG_FIELD_DESC(plotter_scale),
TOOLS_ARG_FIELD_DESC(border_visible),
TOOLS_ARG_FIELD_DESC(border_width),
TOOLS_ARG_FIELD_DESC(border_height),
TOOLS_ARG_FIELD_DESC(border_color),
TOOLS_ARG_FIELD_DESC(left_margin),
TOOLS_ARG_FIELD_DESC(right_margin),
TOOLS_ARG_FIELD_DESC(top_margin),
TOOLS_ARG_FIELD_DESC(bottom_margin),
TOOLS_ARG_FIELD_DESC(horizontal_spacing),
TOOLS_ARG_FIELD_DESC(vertical_spacing)
);
return s_v;
}
virtual bool touched() {
if(parent::touched()) return true;
if(m_sep.empty()) return true;
if(m_extras.size()!=m_extras_sep.size()) return true;
//{size_t _number = m_sep.size();
// for(size_t index=0;index<_number;index++) {
// separator* sep = (separator*)m_sep[index];
// plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
// if(_plotter->shape.touched()) return true;
// }}
return false;
}
private:
void add_fields(){
add_field(&width);
@@ -88,6 +101,7 @@ private:
typedef std::vector<plottable*> ptbs_t;
typedef std::vector<node*> todels_t;
typedef std::vector<plotprim*> prims_t;
public:
/*
class updater {
@@ -100,53 +114,35 @@ public:
*/
public:
virtual void render(render_action& a_action) {
if(touched()) {
update_sg();
reset_touched();
}
update_if_touched();
m_group.render(a_action);
}
virtual void pick(pick_action& a_action) {
if(touched()) {
update_sg();
reset_touched();
}
update_if_touched();
nodekit_pick(a_action,m_group,this);
//m_group.pick(a_action);
}
virtual void search(search_action& a_action) {
parent::search(a_action);
if(a_action.done()) return;
if(touched()) {
update_sg();
reset_touched();
}
update_if_touched();
if(a_action.do_path()) a_action.path_push(this);
m_group.search(a_action);
if(a_action.done()) return;
if(a_action.do_path()) a_action.path_pop();
}
virtual void bbox(bbox_action& a_action) {
if(touched()) {
update_sg();
reset_touched();
}
update_if_touched();
m_group.bbox(a_action);
}
virtual void event(event_action& a_action) {
if(touched()) {
update_sg();
reset_touched();
}
update_if_touched();
m_group.event(a_action);
if(a_action.done()) return;
}
virtual bool write(write_action& a_action) {
if(touched()) {
update_sg();
reset_touched();
}
update_if_touched();
return m_group.write(a_action);
}
public:
@@ -215,8 +211,8 @@ public:
{
add_fields();
init_sg();
//m_updater = a_from.m_updater?a_from.m_updater->copy():0;
if(!copy_plotters(a_from)) {}
}
plots& operator=(const plots& a_from){
parent::operator=(a_from);
@@ -252,6 +248,8 @@ public:
m_current = a_from.m_current;
m_extras = a_from.m_extras;
if(!copy_plotters(a_from)) {}
return *this;
}
public:
@@ -262,19 +260,14 @@ public:
if(!a_ww||!a_wh) return;
float aspect = float(a_ww)/float(a_wh);
width = height * aspect;
//wps : cooking to avoid seeing a line for left border.
width = width * 1.001f;
update_sg();
reset_touched();
}
//void update_now() { //for gopaw.
//void enforce_update() { //used in geant4 plotting.
// update_sg();
// reset_touched();
//}
const base_freetype& ttf() const {return m_ttf;}
public:
/*
void set_updater(updater* a_updater) {
@@ -284,7 +277,7 @@ public:
}
*/
void clear() {
if(to_update()) update_sg();
update_if_touched();
{size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
@@ -299,7 +292,7 @@ public:
}
bool has_data() {
if(to_update()) update_sg();
update_if_touched();
{size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
@@ -315,7 +308,7 @@ public:
}
void touch_plotters() { //used in exlib/geant4/session.
if(to_update()) update_sg();
update_if_touched();
{size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
@@ -330,7 +323,7 @@ public:
}
void next() {
if(to_update()) update_sg();
update_if_touched();
size_t _number = m_sep.size();
if(m_current>=(uint32(_number)-1)) {
m_current = 0;
@@ -341,7 +334,7 @@ public:
}
bool set_current_plotter(unsigned int a_index) {
if(to_update()) update_sg();
update_if_touched();
if(a_index>=m_sep.size()) return false;
m_current = a_index;
update_current_border();
@@ -349,7 +342,7 @@ public:
}
bool set_current(plotter* a_plotter) { //for popup.
if(to_update()) update_sg();
update_if_touched();
size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
@@ -364,7 +357,7 @@ public:
}
// torche* current_torche() {
// if(to_update()) update_sg();
// update_if_touched();
// separator* sep = (separator*)m_sep[m_current];
// return safe_cast<node,torche>(*((*sep)[LIGHT()]));
// }
@@ -375,7 +368,7 @@ public:
if(_plotter.shape.value()==plotter::xyz) {
return &(_plotter.tsf());
} else {
if(to_update()) update_sg();
update_if_touched();
separator* sep = (separator*)m_sep[m_current];
return safe_cast<node,matrix>(*((*sep)[TSF()]));
}
@@ -383,12 +376,12 @@ public:
*/
plotter& current_plotter() {
if(to_update()) update_sg();
update_if_touched();
separator* sep = (separator*)m_sep[m_current];
return *((plotter*)(*sep)[PLOTTER()]);
}
plotter* find_plotter(unsigned int a_index) {
if(to_update()) update_sg();
update_if_touched();
if(a_index>=m_sep.size()) return 0;
separator* sep = (separator*)m_sep[a_index];
return (plotter*)(*sep)[PLOTTER()];
@@ -398,11 +391,7 @@ public:
bool find_plotter(unsigned int a_ww,unsigned int a_wh,
float a_x,float a_y,
unsigned int& a_index) {
if(touched()) {
update_sg();
reset_touched();
}
if(to_update()) update_sg();
update_if_touched();
a_index = 0;
@@ -447,70 +436,68 @@ public:
unsigned int oldn = cols*rows;
std::vector<ptbs_t> ptbss;
std::vector<prims_t> primss;
std::vector<todels_t> tdlss;
std::vector< plotter > pls;
std::vector<plotter> pls;
if(a_transfer) {
ptbss.resize(oldn);
primss.resize(oldn);
tdlss.resize(oldn);
pls.resize(oldn,plotter(m_ttf));
for(unsigned int index=0;index<oldn;index++) {
plotter* p = find_plotter(index);
p->transfer_plottables(ptbss[index]);
p->transfer_primitives(primss[index]);
p->transfer_todels(tdlss[index]);
pls[index] = *p; //have a copy (of styles).
pls[index] = *p; //to copy styles.
}
}
cols = a_cols?a_cols:1;
rows = a_rows?a_rows:1;
touch();
if(view_border.value()) {view_border = (number()==1?false:true);}
update_sg();
set_current_plotter(0);
clear();
if(view_border.value()) {
view_border = (number()==1?false:true);
}
if(a_transfer) {
//fill new plotters with old data :
unsigned int num = min_of(oldn,cols*rows);
for(unsigned int index=0;index<num;index++) {
plotter* p = find_plotter(index);
*p = pls[index];
p->copy_style(pls[index]); //it must not touch p width, height, depth.
{const ptbs_t& ptbs = ptbss[index];
ptbs_t::const_iterator it;
for(it=ptbs.begin();it!=ptbs.end();++it) p->add_plottable(*it);}
tools_vforcit(plottable*,ptbs,it) p->add_plottable(*it);}
{const prims_t& prims = primss[index];
tools_vforcit(plotprim*,prims,it) p->add_primitive(*it);}
{const todels_t& todels = tdlss[index];
todels_t::const_iterator it;
for(it=todels.begin();it!=todels.end();++it) p->add_node_todel(*it);}
tools_vforcit(node*,todels,it) p->add_node_todel(*it);}
}
}
reset_touched();
}
void current_to_one() {
ptbs_t ptbs;
current_plotter().transfer_plottables(ptbs);
todels_t tdls;
current_plotter().transfer_todels(tdls);
plotter pl = current_plotter(); //have a copy (of styles).
ptbs_t ptbs;current_plotter().transfer_plottables(ptbs);
prims_t prims;current_plotter().transfer_primitives(prims);
todels_t tdls;current_plotter().transfer_todels(tdls);
plotter pl = current_plotter(); //to copy styles.
set_regions(1,1,false);
plotter& p = current_plotter();
p = pl; //copy styles.
p.copy_style(pl); //copy styles.
{ptbs_t::const_iterator it;
for(it=ptbs.begin();it!=ptbs.end();++it) p.add_plottable(*it);}
{todels_t::const_iterator it;
for(it=tdls.begin();it!=tdls.end();++it) p.add_node_todel(*it);}
{tools_vforcit(plottable*,ptbs,it) p.add_plottable(*it);}
{tools_vforcit(plotprim*,prims,it) p.add_primitive(*it);}
{tools_vforcit(node*,tdls,it) p.add_node_todel(*it);}
}
void plotters(std::vector<plotter*>& a_vec) { //a_vec do NOT get ownership of sg::plotter objects.
void plotters(std::vector<plotter*>& a_vec) { //a_vec do NOT get ownership of sg::plotter objects. Use in G4Analysis.
a_vec.clear();
if(to_update()) update_sg();
update_if_touched();
size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
@@ -518,7 +505,124 @@ public:
a_vec.push_back(_plotter);
}
}
//////////////////////////////////////////////////////////////////////
//// styling methods : ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void set_line_width(float a_line_width) {
update_if_touched();
size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
_plotter->bins_style(0).line_width = a_line_width;
_plotter->inner_frame_style().line_width = a_line_width;
_plotter->grid_style().line_width = a_line_width;
_plotter->x_axis().line_style().width = a_line_width;
_plotter->x_axis().ticks_style().width = a_line_width;
_plotter->y_axis().line_style().width = a_line_width;
_plotter->y_axis().ticks_style().width = a_line_width;
_plotter->z_axis().line_style().width = a_line_width;
_plotter->z_axis().ticks_style().width = a_line_width;
_plotter->colormap_axis().line_style().width = a_line_width;
_plotter->colormap_axis().ticks_style().width = a_line_width;
// needed if font is hershey :
_plotter->title_style().line_width = a_line_width;
_plotter->infos_style().line_width = a_line_width;
_plotter->title_box_style().line_width = a_line_width;
_plotter->x_axis().labels_style().line_width = a_line_width;
_plotter->x_axis().mag_style().line_width = a_line_width;
_plotter->x_axis().title_style().line_width = a_line_width;
_plotter->y_axis().labels_style().line_width = a_line_width;
_plotter->y_axis().mag_style().line_width = a_line_width;
_plotter->y_axis().title_style().line_width = a_line_width;
_plotter->z_axis().labels_style().line_width = a_line_width;
_plotter->z_axis().mag_style().line_width = a_line_width;
_plotter->z_axis().title_style().line_width = a_line_width;
_plotter->colormap_axis().labels_style().line_width = a_line_width;
_plotter->colormap_axis().mag_style().line_width = a_line_width;
_plotter->colormap_axis().title_style().line_width = a_line_width;
}
}
/*
void set_border_style() {
update_if_touched();
size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
_plotter->background_style().visible = true;
_plotter->background_style().color = colorf_black();
_plotter->background_style().line_width = 0.003;
}
border_visible = true;
}
*/
void set_grids_visibility(bool a_visible = false) {
update_if_touched();
size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
_plotter->grid_style().visible = a_visible;
}
border_visible = true;
}
void adjust_scales(float a_plotter_scale = 1) {
// Rescale some plotter parameters (for example margins) according to the number of plots.
// We assume that these parameters had been set previously according to one plot per page.
// Then this function must be applied after all the styles had been applied (because
// a plotting style may set these parameters).
float ww_wc = width.value();
float wh_wc = height.value();
float rw_wc = ww_wc/cols.value();
float rh_wc = wh_wc/rows.value();
float cooking = 1.2f; //if increased the data area is diminished.
float wfac = (rw_wc/ww_wc)*cooking;
float hfac = (rh_wc/wh_wc)*cooking;
float label_cooking = 1.6f; //if increased the labels are bigger.
if((cols.value()>=4)&&(cols.value()>rows.value())) label_cooking = 0.9f;
float title_cooking = 1.1f; //extra title cooking.
plotter_scale = a_plotter_scale;
update_if_touched();
{size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* sep = (separator*)m_sep[index];
plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
_plotter->left_margin = _plotter->left_margin * wfac;
_plotter->right_margin = _plotter->right_margin * wfac;
_plotter->bottom_margin = _plotter->bottom_margin * hfac;
_plotter->top_margin = _plotter->top_margin * hfac;
_plotter->x_axis().tick_length = _plotter->x_axis().tick_length * wfac;
_plotter->y_axis().tick_length = _plotter->y_axis().tick_length * hfac;
_plotter->title_to_axis = _plotter->title_to_axis * hfac;
_plotter->title_height = _plotter->title_height * hfac * title_cooking;
_plotter->x_axis().label_height = _plotter->x_axis().label_height * hfac * label_cooking;
_plotter->y_axis().label_height = _plotter->y_axis().label_height * hfac * label_cooking;
}}
}
//gopaw:
void configure_grid_PAW(unsigned int a_ww,unsigned int a_wh) {
@@ -762,21 +866,26 @@ public:
void configure_PAW(unsigned int a_ww,unsigned int a_wh) {
configure_grid_PAW(a_ww,a_wh);
configure_extras_PAW(a_ww,a_wh);
touch();
update_if_touched();
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//gopaw:
void delete_extras() {
m_extras_sep.clear();
m_extras.clear();
}
plotter* create_extra_plotter(unsigned int a_cols,unsigned int a_rows,unsigned int a_index) {
// Create a plotter with size and position as if in a grid of a_colsxa_rows and at position a_index.
// The index numbering being for example for a grid of 3x2 :
// 0 1 2
// 3 4 5
// 3 4 5
m_extras.push_back(extra(a_cols,a_rows,a_index));
update_sg();
update_if_touched();
separator* sep = m_extras.back().m_sep;
return (plotter*)(*sep)[PLOTTER()];
}
@@ -786,7 +895,7 @@ public:
return (plotter*)(*sep)[PLOTTER()];
}
public:
void init_sg() {
void init_sg() { // used also in gopaw::base_viewer::clean_gstos().
m_group.clear();
m_sep.clear();
m_border_sep.clear();
@@ -795,11 +904,18 @@ public:
m_group.add(new noderef(m_border_sep));
m_group.add(new noderef(m_extras_sep));
}
void clear_sg() { //used in GL_plots_viewer.
m_group.clear();
m_sep.clear();
m_border_sep.clear();
m_extras_sep.clear();
}
protected:
bool to_update() {
if(m_sep.empty()) return true;
if(m_extras.size()!=m_extras_sep.size()) return true;
return false;
void update_if_touched() {
if(touched()) {
update_sg();
reset_touched();
}
}
void update_sg(){
@@ -851,68 +967,55 @@ protected:
float wh_wc = height;
// plotter size in window wc :
float rw_wc = ww_wc/cols;
float rh_wc = wh_wc/rows;
//float rw_wc = ww_wc/cols;
//float rh_wc = wh_wc/rows;
for(size_t index=0;index<_number;index++) {
size_t row = index/cols.value();
size_t col = index-cols.value()*row;
separator* sep = (separator*)m_sep[index];
matrix* _matrix = (matrix*)(*sep)[MATRIX()];
plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
if(configure) {
_plotter->width = m_sizes[index].x();
_plotter->height = m_sizes[index].y();
float x = -ww_wc*0.5f + m_origins[index].x() + _plotter->width*0.5f;
float y = -wh_wc*0.5f + m_origins[index].y() + _plotter->height*0.5f;
_matrix->set_translate(x,y,0);
} else {
float x = -ww_wc*0.5f + col * rw_wc + rw_wc * 0.5f;
float y = wh_wc*0.5f - row * rh_wc - rh_wc * 0.5f;
_matrix->set_translate(x,y,0);
}
_matrix->mul_scale(plotter_scale.value(),plotter_scale.value(),1); //applied first.
{_switch* _border = (_switch*)(*sep)[BORDER()];
create_plotter_border(*_border,rw_wc,rh_wc);
_border->which = view_border.value()?(index==m_current?0:1):1;}
if(_plotter->shape.value()==plotter::xy) {
_plotter->depth = min_of(rw_wc,rh_wc);
} else {
//if((rw_wc/rh_wc)>=1.0f) {
// _plotter->depth = rh_wc;
//} else {
// _plotter->depth = rh_wc;
//}
_plotter->depth = rh_wc;
}
if(configure) {
} else {
if(_plotter->shape.value()==plotter::xy) {
_plotter->width = rw_wc;
_plotter->height = rh_wc;
} else {
if((rw_wc/rh_wc)>=1.0f) {
_plotter->width = rh_wc;
_plotter->height = rh_wc;
} else {
_plotter->width = rw_wc;
_plotter->height = rw_wc;
}
}
}
set_plotter_layout(*sep,index,configure,cols.value(),rows.value(),
ww_wc,wh_wc,m_origins,m_sizes,plotter_scale.value());
}
}
update_extras();
}
bool copy_plotters(const plots& a_from) {
update_if_touched();
if(m_sep.size()==a_from.m_sep.size()) {
size_t _number = m_sep.size();
for(size_t index=0;index<_number;index++) {
separator* _from_sep = (separator*)a_from.m_sep[index];
matrix* _from_matrix = (matrix*)(*_from_sep)[MATRIX()];
//_switch* _border = (_switch*)(*_sep)[BORDER()];
plotter* _from_plotter = (plotter*)(*_from_sep)[PLOTTER()];
separator* _sep = (separator*)m_sep[index];
matrix* _matrix = (matrix*)(*_sep)[MATRIX()];
plotter* _plotter = (plotter*)(*_sep)[PLOTTER()];
_matrix->operator=(*_from_matrix);
_plotter->operator=(*_from_plotter);
}
}
if(m_extras_sep.size()==a_from.m_extras_sep.size()) {
size_t _number = m_extras_sep.size();
for(size_t index=0;index<_number;index++) {
separator* _from_sep = (separator*)a_from.m_extras_sep[index];
matrix* _from_matrix = (matrix*)(*_from_sep)[MATRIX()];
plotter* _from_plotter = (plotter*)(*_from_sep)[PLOTTER()];
separator* _sep = (separator*)m_extras_sep[index];
matrix* _matrix = (matrix*)(*_sep)[MATRIX()];
plotter* _plotter = (plotter*)(*_sep)[PLOTTER()];
_matrix->operator=(*_from_matrix);
_plotter->operator=(*_from_plotter);
}
}
return true;
}
static void create_plotter_border(_switch& a_parent,float a_w,float a_h) {
a_parent.clear();
@@ -926,7 +1029,7 @@ protected:
sep->add(mat);
draw_style* ds = new draw_style;
ds->style = draw_style::lines;
ds->style = draw_lines;
ds->line_width = 4;
sep->add(ds);
@@ -1118,65 +1221,72 @@ protected:
unsigned int index = _extra.m_index;
if(index>=(m_extras_sep.size())) index = 0;
size_t row = index/_extra.m_cols;
size_t col = index-_extra.m_cols*row;
float rw_wc = ww_wc/_extra.m_cols;
float rh_wc = wh_wc/_extra.m_rows;
separator* sep = _extra.m_sep;
matrix* _matrix = (matrix*)(*sep)[MATRIX()];
plotter* _plotter = (plotter*)(*sep)[PLOTTER()];
if(configure) {
_plotter->width = m_extras_sizes[index].x();
_plotter->height = m_extras_sizes[index].y();
float x = -ww_wc*0.5f + m_extras_origins[index].x() + _plotter->width*0.5f;
float y = -wh_wc*0.5f + m_extras_origins[index].y() + _plotter->height*0.5f;
_matrix->set_translate(x,y,0);
} else {
float x = -ww_wc*0.5f + col * rw_wc + rw_wc * 0.5f;
float y = wh_wc*0.5f - row * rh_wc - rh_wc * 0.5f;
_matrix->set_translate(x,y,0);
}
_matrix->mul_scale(plotter_scale.value(),plotter_scale.value(),1); //applied first.
{_switch* _border = (_switch*)(*sep)[BORDER()];
create_plotter_border(*_border,rw_wc,rh_wc);
//_border->which = view_border.value()?(index==m_current?0:1):1;
_border->which = 1;
}
if(_plotter->shape.value()==plotter::xy) {
_plotter->depth = min_of(rw_wc,rh_wc);
} else {
//if((rw_wc/rh_wc)>=1.0f) {
// _plotter->depth = rh_wc;
//} else {
// _plotter->depth = rh_wc;
//}
_plotter->depth = rh_wc;
}
if(configure) {
} else {
if(_plotter->shape.value()==plotter::xy) {
_plotter->width = rw_wc;
_plotter->height = rh_wc;
} else {
if((rw_wc/rh_wc)>=1.0f) {
_plotter->width = rh_wc;
_plotter->height = rh_wc;
} else {
_plotter->width = rw_wc;
_plotter->height = rw_wc;
}
}
}
set_plotter_layout(*sep,index,configure,_extra.m_cols,_extra.m_rows,
ww_wc,wh_wc,m_extras_origins,m_extras_sizes,plotter_scale.value());
}
}
}
protected:
static void set_plotter_layout(separator& a_sep,size_t a_index,bool a_configure,
unsigned int a_cols,unsigned int a_rows,
float a_ww_wc,float a_wh_wc,
const std::vector<vec2f>& a_origins,const std::vector<vec2f>& a_sizes,float a_scale) {
size_t row = a_index/a_cols;
size_t col = a_index-a_cols*row;
float rw_wc = a_ww_wc/a_cols;
float rh_wc = a_wh_wc/a_rows;
matrix* _matrix = (matrix*)(a_sep)[MATRIX()];
plotter* _plotter = (plotter*)(a_sep)[PLOTTER()];
if(a_configure) {
_plotter->width = a_sizes[a_index].x();
_plotter->height = a_sizes[a_index].y();
float x = -a_ww_wc*0.5f + a_origins[a_index].x() + _plotter->width*0.5f;
float y = -a_wh_wc*0.5f + a_origins[a_index].y() + _plotter->height*0.5f;
_matrix->set_translate(x,y,0);
} else {
float x = -a_ww_wc*0.5f + col * rw_wc + rw_wc * 0.5f;
float y = a_wh_wc*0.5f - row * rh_wc - rh_wc * 0.5f;
_matrix->set_translate(x,y,0);
}
_matrix->mul_scale(a_scale,a_scale,1); //applied first.
{_switch* _border = (_switch*)(a_sep)[BORDER()];
create_plotter_border(*_border,rw_wc,rh_wc);
//_border->which = view_border.value()?(a_index==m_current?0:1):1;
_border->which = 1;
}
if(_plotter->shape.value()==plotter::xy) {
_plotter->depth = min_of(rw_wc,rh_wc);
} else {
//if((rw_wc/rh_wc)>=1.0f) {
// _plotter->depth = rh_wc;
//} else {
// _plotter->depth = rh_wc;
//}
_plotter->depth = rh_wc;
}
if(a_configure) {
} else {
if(_plotter->shape.value()==plotter::xy) {
_plotter->width = rw_wc;
_plotter->height = rh_wc;
} else {
if((rw_wc/rh_wc)>=1.0f) {
_plotter->width = rh_wc;
_plotter->height = rh_wc;
} else {
_plotter->width = rw_wc;
_plotter->height = rw_wc;
}
}
}
}
protected:
const base_freetype& m_ttf;