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