Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/text_hershey_marker 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_sg_text_hershey_marker
0005 #define tools_sg_text_hershey_marker
0006 
0007 #include "text_hershey"
0008 
0009 namespace tools {
0010 namespace sg {
0011 
0012 class text_hershey_marker : public text_hershey {
0013   TOOLS_NODE(text_hershey_marker,tools::sg::text_hershey_marker,text_hershey)
0014 public:
0015   virtual bool draw_in_frame_buffer() const {return true;}
0016 
0017   virtual void render(render_action& a_action) {
0018     //Same logic as Inventor SoLightModel.model = BASE_COLOR.
0019     a_action.set_lighting(false);
0020     a_action.set_depth_test(false);
0021 
0022     float x,y,z;
0023     a_action.projected_origin(x,y,z);
0024 
0025     const state& state = a_action.state();
0026 
0027     float sy = 2.0f*float(height.value())/float(state.m_wh); //in [-1,1]
0028 
0029     float old_height = height.value();
0030     height.value_no_cmp(sy);
0031 
0032     std::vector<float> segs;
0033     get_segments(segs); //must be after changing the height.
0034 
0035     a_action.load_matrices_to_identity();
0036     
0037    {tools::mat4f _mtx;
0038     _mtx.set_translate(x,y,0);
0039     if(state.m_ww) _mtx.mul_scale(float(state.m_wh)/float(state.m_ww),1,1);
0040     a_action.load_proj_matrix(_mtx);}
0041     
0042     a_action.draw_vertex_array_xy(gl::lines(),segs);
0043 
0044     a_action.load_matrices_from_state();
0045 
0046     height.value_no_cmp(old_height);
0047 
0048     a_action.set_depth_test(state.m_GL_DEPTH_TEST);
0049     a_action.set_lighting(a_action.state().m_GL_LIGHTING);
0050 
0051   }
0052 
0053   virtual void pick(pick_action& a_action) {
0054     float x,y,z;
0055     a_action.projected_origin(x,y,z);
0056 
0057     const state& state = a_action.state();
0058 
0059     float sy = 2.0f*float(height.value())/float(state.m_wh); //in [-1,1]
0060 
0061     float old_height = height.value();
0062     height.value_no_cmp(sy);
0063 
0064     std::vector<float> segs;
0065     get_segments(segs);
0066 
0067     a_action.set_matrices_to_identity();
0068     
0069    {tools::mat4f& _mtx = a_action.model_matrix();
0070     _mtx.set_translate(x,y,0);
0071     if(state.m_ww) _mtx.mul_scale(float(state.m_wh)/float(state.m_ww),1,1);}
0072 
0073     a_action.add__lines_xy(*this,segs);
0074 
0075     a_action.set_matrices_from_state();
0076 
0077     height.value_no_cmp(old_height);
0078   }
0079 
0080   virtual void bbox(bbox_action& a_action) {
0081     a_action.add_one_point(0,0,0);
0082   }
0083 public:
0084   text_hershey_marker()
0085   :parent()
0086   {
0087     height = 10; //in pixels
0088   }
0089   virtual ~text_hershey_marker(){}
0090 public:
0091   text_hershey_marker(const text_hershey_marker& a_from)
0092   :parent(a_from)
0093   {}
0094   text_hershey_marker& operator=(const text_hershey_marker& a_from){
0095     parent::operator=(a_from);
0096     return *this;
0097   }
0098 };
0099 
0100 }}
0101 
0102 #endif