Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_viewplot 4 #ifndef tools_viewplot 5 #define tools_viewplot 5 #define tools_viewplot 6 6 7 #include "sg/plots_viewer" 7 #include "sg/plots_viewer" 8 8 9 #include "sg/dummy_freetype" 9 #include "sg/dummy_freetype" 10 #include "sg/plotter_style" 10 #include "sg/plotter_style" 11 11 12 #include "wps" 12 #include "wps" 13 13 14 namespace tools { 14 namespace tools { 15 15 16 class viewplot : public sg::plots_viewer { 16 class viewplot : public sg::plots_viewer { 17 typedef sg::plots_viewer parent; 17 typedef sg::plots_viewer parent; 18 public: 18 public: 19 viewplot(std::ostream& a_out, 19 viewplot(std::ostream& a_out, 20 unsigned int a_cols = 1,unsigned in 20 unsigned int a_cols = 1,unsigned int a_rows = 1, 21 unsigned int a_width = 500,unsigned 21 unsigned int a_width = 500,unsigned int a_height = 500) 22 :parent(a_out,m_ttf,a_cols,a_rows,a_width,a_ 22 :parent(a_out,m_ttf,a_cols,a_rows,a_width,a_height) 23 ,m_wps(a_out) 23 ,m_wps(a_out) 24 ,m_ttf() 24 ,m_ttf() 25 ,m_styles(a_out) 25 ,m_styles(a_out) 26 {} 26 {} 27 viewplot(std::ostream& a_out,const sg::base_ 27 viewplot(std::ostream& a_out,const sg::base_freetype& a_ttf, 28 unsigned int a_cols = 1,unsigned in 28 unsigned int a_cols = 1,unsigned int a_rows = 1, 29 unsigned int a_width = 500,unsigned 29 unsigned int a_width = 500,unsigned int a_height = 500) 30 :parent(a_out,a_ttf,a_cols,a_rows,a_width,a_ 30 :parent(a_out,a_ttf,a_cols,a_rows,a_width,a_height) 31 ,m_wps(a_out) 31 ,m_wps(a_out) 32 ,m_ttf() 32 ,m_ttf() 33 ,m_styles(a_out) 33 ,m_styles(a_out) 34 {} 34 {} 35 virtual ~viewplot() {} 35 virtual ~viewplot() {} 36 public: 36 public: 37 viewplot(const viewplot& a_from) 37 viewplot(const viewplot& a_from) 38 :parent(a_from) 38 :parent(a_from) 39 ,m_wps(a_from.m_out) 39 ,m_wps(a_from.m_out) 40 ,m_styles(a_from.m_styles) 40 ,m_styles(a_from.m_styles) 41 {} 41 {} 42 viewplot& operator=(const viewplot& a_from){ 42 viewplot& operator=(const viewplot& a_from){ 43 parent::operator=(a_from); 43 parent::operator=(a_from); 44 m_styles = a_from.m_styles; 44 m_styles = a_from.m_styles; 45 return *this; 45 return *this; 46 } 46 } 47 public: 47 public: 48 #ifdef tools_viewplot 48 #ifdef tools_viewplot 49 //deprecated, use set_current_plotter_style( 49 //deprecated, use set_current_plotter_style(). 50 void style_from_res(const std::string& a_pat 50 void style_from_res(const std::string& a_path,bool a_verbose = false) { 51 style_from_res(a_path,m_plots.current_plot 51 style_from_res(a_path,m_plots.current_plotter(),a_verbose); 52 } 52 } 53 #endif 53 #endif 54 void set_current_plotter_style(const std::st 54 void set_current_plotter_style(const std::string& a_path,bool a_verbose = false) { 55 style_from_res(a_path,m_plots.current_plot 55 style_from_res(a_path,m_plots.current_plotter(),a_verbose); 56 } 56 } 57 57 58 public: 58 public: 59 void set_cols_rows(unsigned int a_cols,unsig 59 void set_cols_rows(unsigned int a_cols,unsigned int a_rows) { 60 m_plots.cols = a_cols; 60 m_plots.cols = a_cols; 61 m_plots.rows = a_rows; 61 m_plots.rows = a_rows; 62 m_plots.adjust_size(width(),height()); 62 m_plots.adjust_size(width(),height()); 63 } 63 } 64 64 65 //#ifdef tools_viewplot 65 //#ifdef tools_viewplot 66 bool write(const std::string& a_file,bool a_ 66 bool write(const std::string& a_file,bool a_anonymous = false) { 67 return parent::write_inzb_ps(a_file,a_anon 67 return parent::write_inzb_ps(a_file,a_anonymous); 68 } 68 } 69 bool open_file(const std::string& a_file,boo 69 bool open_file(const std::string& a_file,bool a_anonymous = false) {return open_inzb_ps_file(a_file,a_anonymous);} 70 bool write_page() {return write_inzb_ps_page 70 bool write_page() {return write_inzb_ps_page();} 71 bool close_file() {return close_inzb_ps_file 71 bool close_file() {return close_inzb_ps_file();} 72 //#endif 72 //#endif 73 73 74 74 75 const xml::styles& styles() const {return m_ 75 const xml::styles& styles() const {return m_styles;} 76 xml::styles& styles() {return m_styles;} 76 xml::styles& styles() {return m_styles;} 77 77 78 protected: 78 protected: 79 void style_from_res(const std::string& a_pat 79 void style_from_res(const std::string& a_path,sg::plotter& a_plotter,bool a_verbose) { 80 sg::style_from_res(m_styles,a_path,a_plott 80 sg::style_from_res(m_styles,a_path,a_plotter,a_verbose); 81 } 81 } 82 82 83 protected: 83 protected: 84 sg::zb_manager m_mgr; 84 sg::zb_manager m_mgr; 85 wps m_wps; 85 wps m_wps; 86 sg::dummy_freetype m_ttf; 86 sg::dummy_freetype m_ttf; 87 xml::styles m_styles; 87 xml::styles m_styles; 88 }; 88 }; 89 89 90 } 90 } 91 91 92 #endif 92 #endif 93 93