Geant4-11
Data Structures | Functions
G4ToolsSGSceneHandler.cc File Reference
#include "G4ToolsSGSceneHandler.hh"
#include "G4ToolsSGNode.hh"
#include "G4TransportationManager.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4Polyhedron.hh"
#include "G4Text.hh"
#include "G4PlotterManager.hh"
#include <tools/sg/separator>
#include <tools/sg/matrix>
#include <tools/sg/rgba>
#include <tools/sg/draw_style>
#include <tools/sg/atb_vertices>
#include <tools/sg/markers>
#include <tools/sg/dummy_freetype>
#include <tools/sg/text_hershey_marker>
#include <tools/sg/light_off>
#include <tools/sg/plots>
#include <tools/sg/h2plot_cp>
#include <tools/sg/plotter_style>
#include <tools/sg/event_dispatcher>
#include <tools/sg/path>
#include <tools/sg/search>
#include <tools/histo/h1d>
#include <tools/histo/h2d>
#include <tools/sg/plotter_some_styles>
#include <utility>
#include "G4UImanager.hh"

Go to the source code of this file.

Data Structures

class  plots_cbk
 

Functions

tools::xml::styles::style_t * find_style (tools::xml::styles &a_styles, const std::string &a_name)
 
void SetPlotterParameters (tools::sg::cmaps_t &a_cmaps, tools::sg::plots &a_plots, const std::vector< G4Plotter::RegionParameter > &a_region_parameters)
 
void SetPlotterStyles (tools::sg::plots &a_plots, const std::vector< G4String > &a_plotter_styles, const std::vector< G4Plotter::RegionStyle > &a_region_styles)
 
void SetRegionStyles (tools::xml::styles &a_styles, tools::sg::plots &a_plots, tools::sg::plotter &a_plotter, const G4String &a_style)
 

Function Documentation

◆ find_style()

tools::xml::styles::style_t * find_style ( tools::xml::styles &  a_styles,
const std::string &  a_name 
)
inline

Definition at line 592 of file G4ToolsSGSceneHandler.cc.

592 {
593 tools_vforit(tools::xml::styles::named_style_t,a_styles.named_styles(),it){
594 if((*it).first==a_name) return &((*it).second);
595 }
596 return 0;
597}

Referenced by SetPlotterStyles().

◆ SetPlotterParameters()

void SetPlotterParameters ( tools::sg::cmaps_t &  a_cmaps,
tools::sg::plots &  a_plots,
const std::vector< G4Plotter::RegionParameter > &  a_region_parameters 
)
inline

Definition at line 659 of file G4ToolsSGSceneHandler.cc.

660 {
661 // parameter/field examples :
662 // title_automated
663 // title
664 // bins_style.0.color
665 // x_axis.divisions
666 // x_axis.line_style.color
667 // background_style.back_color
668 tools_vforcit(G4Plotter::RegionParameter,a_region_parameters,it) {
669 tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
670 if(_plotter) {
671 const G4String& parameter = (*it).second.first;
672 const G4String& value = (*it).second.second;
673 tools::sg::field* fd = _plotter->find_field_by_name(parameter);
674 if(!fd) fd = _plotter->find_field_by_name(_plotter->s_cls()+"."+parameter);
675 if(fd) {if(fd->s2value(value)) continue;}
676 // look for sf_enum for which value is given with a string, or
677 // for sf<bool> for which value given with true/false, or
678 // for a style, for example: bins_style.0.color:
679 if(!_plotter->set_from_string(G4cout,a_cmaps,parameter,value)) {
680 G4cout << "G4ToolsSGSceneHandler::SetPlotterParameters: plotter.set_from_string() failed for field "
681 << tools::sout(parameter) << ", and value " << tools::sout(value) << "."
682 << std::endl;
683 }
684 }
685 }
686}
G4GLOB_DLL std::ostream G4cout
std::pair< unsigned int, Parameter > RegionParameter
Definition: G4Plotter.hh:44

References G4cout.

Referenced by G4ToolsSGSceneHandler::AddPrimitive().

◆ SetPlotterStyles()

void SetPlotterStyles ( tools::sg::plots &  a_plots,
const std::vector< G4String > &  a_plotter_styles,
const std::vector< G4Plotter::RegionStyle > &  a_region_styles 
)
inline

Definition at line 599 of file G4ToolsSGSceneHandler.cc.

601 {
602
604
605 tools::xml::styles _tools_styles(G4cout);
606 _tools_styles.add_colormap("default",tools::sg::style_default_colormap());
607 _tools_styles.add_colormap("ROOT",tools::sg::style_ROOT_colormap());
608
609 {tools_vforcit(G4PlotterManager::NamedStyle,_styles,it) {
610 tools::xml::styles::style_t _tools_style;
611 tools_vforcit(G4PlotterManager::StyleItem,(*it).second,its) {
612 const G4String& param = (*its).first;
613 if(param.find('.')==std::string::npos) {
614 const G4String& value = (*its).second;
615 _tools_style.push_back(tools::xml::styles::style_item_t(param,value));
616 }
617 }
618 _tools_styles.add_style((*it).first,_tools_style);
619 }}
620
621 // sub styles:
622 {tools_vforcit(G4PlotterManager::NamedStyle,_styles,it) {
623 tools_vforcit(G4PlotterManager::StyleItem,(*it).second,its) {
624 const G4String& param = (*its).first;
625 std::string::size_type pos = param.rfind('.');
626 if(pos!=std::string::npos) {
627 std::string sub_style = (*it).first+"."+param.substr(0,pos);
628 G4String parameter = param.substr(pos+1,param.size()-pos);
629 const G4String& value = (*its).second;
630 tools::xml::styles::style_t* _tools_style = find_style(_tools_styles,sub_style);
631 if(_tools_style) {
632 _tools_style->push_back(tools::xml::styles::style_item_t(parameter,value));
633 } else {
634 tools::xml::styles::style_t _tools_style_2;
635 _tools_style_2.push_back(tools::xml::styles::style_item_t(parameter,value));
636 _tools_styles.add_style(sub_style,_tools_style_2);
637 }
638 }
639 }
640 }}
641
642 {unsigned int number = a_plots.number();
643 for(unsigned int index=0;index<number;index++) {
644 tools::sg::plotter* _plotter = a_plots.find_plotter(index);
645 if(_plotter) {
646 tools_vforcit(G4String,a_plotter_styles,it) {
647 SetRegionStyles(_tools_styles,a_plots,*_plotter,*it);
648 }
649 }
650 }}
651 {tools_vforcit(G4Plotter::RegionStyle,a_region_styles,it) {
652 tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
653 if(_plotter) {
654 SetRegionStyles(_tools_styles,a_plots,*_plotter,(*it).second);
655 }
656 }}
657}
static const G4double pos
void SetRegionStyles(tools::xml::styles &a_styles, tools::sg::plots &a_plots, tools::sg::plotter &a_plotter, const G4String &a_style)
tools::xml::styles::style_t * find_style(tools::xml::styles &a_styles, const std::string &a_name)
std::vector< NamedStyle > Styles
std::pair< G4String, Style > NamedStyle
std::pair< G4String, G4String > StyleItem
static G4PlotterManager & GetInstance()
const Styles & GetStyles() const
std::pair< unsigned int, G4String > RegionStyle
Definition: G4Plotter.hh:42

References find_style(), G4cout, G4PlotterManager::GetInstance(), G4PlotterManager::GetStyles(), pos, and SetRegionStyles().

Referenced by G4ToolsSGSceneHandler::AddPrimitive().

◆ SetRegionStyles()

void SetRegionStyles ( tools::xml::styles &  a_styles,
tools::sg::plots &  a_plots,
tools::sg::plotter &  a_plotter,
const G4String a_style 
)
inline

Definition at line 574 of file G4ToolsSGSceneHandler.cc.

577 {
578 if(a_style=="reset") {
579 a_plotter.reset_style(true);
580 a_plots.touch(); //to apply indirectly plots::set_plotter_layout() on _plotter.
581 } else if( (a_style=="inlib_default")|| (a_style=="default")) {
582 tools::sg::set_inlib_default_style(G4cout,a_styles.cmaps(),a_plotter,tools::sg::font_hershey());
583 } else if(a_style=="ROOT_default") {
584 tools::sg::set_ROOT_default_style(G4cout,a_styles.cmaps(),a_plotter,tools::sg::font_roboto_bold_ttf());
585 } else if(a_style=="hippodraw") {
586 tools::sg::set_hippodraw_style(G4cout,a_styles.cmaps(),a_plotter,tools::sg::font_lato_regular_ttf());
587 } else {
588 tools::sg::style_from_res(a_styles,a_style,a_plotter,false);
589 }
590}

References G4cout.

Referenced by SetPlotterStyles().