Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/offscreen/sg_viewer is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_offscreen_sg_viewer
0005 #define tools_offscreen_sg_viewer
0006 
0007 #include "session"
0008 
0009 #include "../sg/viewer"
0010 #include "../sg/zb_manager"
0011 #include "../sg/gl2ps_manager"
0012 #include "../sg/write_paper"
0013 
0014 namespace tools {namespace sg {class device_interactor;}}
0015 
0016 namespace tools {
0017 namespace offscreen {
0018 
0019 class sg_viewer : public sg::viewer, public offscreen::viewer {
0020   typedef sg::viewer parent;
0021 protected:
0022   virtual void render() {write_paper();}
0023 public:
0024   sg_viewer(session& a_session,
0025             int /*a_x*/ = 0,int /*a_y*/ = 0,
0026             unsigned int a_width = 500,unsigned int a_height = 500,
0027             const std::string& /*a_win_title*/ = "")
0028   :parent(a_session.out(),a_width,a_height)
0029   ,m_session(a_session)
0030   ,m_file_format("zb_ps")
0031   ,m_file_name("out_zb.ps")
0032   ,m_png_writer(0)
0033   ,m_jpeg_writer(0)
0034   ,m_do_transparency(true)
0035   ,m_top_to_bottom(true)
0036   {}
0037   virtual ~sg_viewer() {}
0038 protected:
0039   sg_viewer(const sg_viewer& a_from)
0040   :parent(a_from)
0041   ,offscreen::viewer(a_from)
0042   ,m_session(a_from.m_session)
0043   ,m_zb_mgr(a_from.m_zb_mgr)
0044   ,m_gl2ps_mgr(a_from.m_gl2ps_mgr)
0045   ,m_file_format(a_from.m_file_format)
0046   ,m_file_name(a_from.m_file_name)
0047   ,m_png_writer(a_from.m_png_writer)
0048   ,m_jpeg_writer(a_from.m_jpeg_writer)
0049   ,m_do_transparency(a_from.m_do_transparency)
0050   ,m_top_to_bottom(a_from.m_top_to_bottom)
0051   ,m_opts_1(a_from.m_opts_1)
0052   ,m_opts_2(a_from.m_opts_2)
0053   {}
0054   sg_viewer& operator=(const sg_viewer& a_from){
0055     parent::operator=(a_from);
0056     m_file_format = a_from.m_file_format;
0057     m_file_name = a_from.m_file_name;
0058     m_png_writer = a_from.m_png_writer;
0059     m_jpeg_writer = a_from.m_jpeg_writer;
0060     m_do_transparency = a_from.m_do_transparency;
0061     m_top_to_bottom = a_from.m_top_to_bottom;
0062     m_opts_1 = a_from.m_opts_1;
0063     m_opts_2 = a_from.m_opts_2;
0064     return *this;
0065   }
0066 public:
0067   bool has_window() const {return true;}
0068 
0069   bool show() {
0070     m_session.to_render(this);
0071     return true;
0072   }
0073   
0074   void win_render() {
0075     m_session.to_render(this);
0076   }
0077 
0078   void set_device_interactor(sg::device_interactor*) {}
0079 
0080 public:
0081   void set_file_format(const std::string& a_file_format) {m_file_format = a_file_format;}
0082   void set_file_name(const std::string& a_file_name) {m_file_name = a_file_name;}
0083   const std::string& file_format() const {return m_file_format;}
0084   const std::string& file_name() const {return m_file_name;}
0085   void set_png_writer(sg::png_writer a_png_writer) {m_png_writer = a_png_writer;}
0086   void set_jpeg_writer(sg::jpeg_writer a_jpeg_writer) {m_jpeg_writer = a_jpeg_writer;}
0087   void set_do_transparency(bool a_do_transparency) {m_do_transparency = a_do_transparency;}
0088   void set_top_to_bottom(bool a_top_to_bottom) {m_top_to_bottom = a_top_to_bottom;}
0089   void set_opts_1(const std::string& a_opts) {m_opts_1 = a_opts;}
0090   void set_opts_2(const std::string& a_opts) {m_opts_2 = a_opts;}
0091 
0092   bool write_paper() {
0093     if(!m_ww) return false;
0094     if(!m_wh) return false;
0095     return sg::write_paper(m_out,m_gl2ps_mgr,m_zb_mgr,
0096                            m_png_writer,m_jpeg_writer,
0097                            m_clear_color.r(),
0098                            m_clear_color.g(),
0099                            m_clear_color.b(),
0100                            m_clear_color.a(),
0101                            m_sg,m_ww,m_wh,
0102                            m_file_name,m_file_format,
0103                            m_do_transparency,m_top_to_bottom,
0104                            m_opts_1,m_opts_2);
0105   }
0106 protected:
0107   session& m_session;
0108   sg::zb_manager m_zb_mgr;
0109   sg::gl2ps_manager m_gl2ps_mgr;
0110   std::string m_file_format;
0111   std::string m_file_name;
0112   sg::png_writer m_png_writer;
0113   sg::jpeg_writer m_jpeg_writer;
0114   bool m_do_transparency;
0115   bool m_top_to_bottom;
0116   std::string m_opts_1;
0117   std::string m_opts_2;
0118 };
0119 
0120 }}
0121 
0122 #endif
0123