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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_sg_text_hershey_marker
  5 #define tools_sg_text_hershey_marker
  6 
  7 #include "text_hershey"
  8 
  9 namespace tools {
 10 namespace sg {
 11 
 12 class text_hershey_marker : public text_hershey {
 13   TOOLS_NODE(text_hershey_marker,tools::sg::text_hershey_marker,text_hershey)
 14 public:
 15   virtual bool draw_in_frame_buffer() const {return true;}
 16 
 17   virtual void render(render_action& a_action) {
 18     //Same logic as Inventor SoLightModel.model = BASE_COLOR.
 19     a_action.set_lighting(false);
 20     a_action.set_depth_test(false);
 21 
 22     float x,y,z;
 23     a_action.projected_origin(x,y,z);
 24 
 25     const state& state = a_action.state();
 26 
 27     float sy = 2.0f*float(height.value())/float(state.m_wh); //in [-1,1]
 28 
 29     float old_height = height.value();
 30     height.value_no_cmp(sy);
 31 
 32     std::vector<float> segs;
 33     get_segments(segs); //must be after changing the height.
 34 
 35     a_action.load_matrices_to_identity();
 36     
 37    {tools::mat4f _mtx;
 38     _mtx.set_translate(x,y,0);
 39     if(state.m_ww) _mtx.mul_scale(float(state.m_wh)/float(state.m_ww),1,1);
 40     a_action.load_proj_matrix(_mtx);}
 41     
 42     a_action.draw_vertex_array_xy(gl::lines(),segs);
 43 
 44     a_action.load_matrices_from_state();
 45 
 46     height.value_no_cmp(old_height);
 47 
 48     a_action.set_depth_test(state.m_GL_DEPTH_TEST);
 49     a_action.set_lighting(a_action.state().m_GL_LIGHTING);
 50 
 51   }
 52 
 53   virtual void pick(pick_action& a_action) {
 54     float x,y,z;
 55     a_action.projected_origin(x,y,z);
 56 
 57     const state& state = a_action.state();
 58 
 59     float sy = 2.0f*float(height.value())/float(state.m_wh); //in [-1,1]
 60 
 61     float old_height = height.value();
 62     height.value_no_cmp(sy);
 63 
 64     std::vector<float> segs;
 65     get_segments(segs);
 66 
 67     a_action.set_matrices_to_identity();
 68     
 69    {tools::mat4f& _mtx = a_action.model_matrix();
 70     _mtx.set_translate(x,y,0);
 71     if(state.m_ww) _mtx.mul_scale(float(state.m_wh)/float(state.m_ww),1,1);}
 72 
 73     a_action.add__lines_xy(*this,segs);
 74 
 75     a_action.set_matrices_from_state();
 76 
 77     height.value_no_cmp(old_height);
 78   }
 79 
 80   virtual void bbox(bbox_action& a_action) {
 81     a_action.add_one_point(0,0,0);
 82   }
 83 public:
 84   text_hershey_marker()
 85   :parent()
 86   {
 87     height = 10; //in pixels
 88   }
 89   virtual ~text_hershey_marker(){}
 90 public:
 91   text_hershey_marker(const text_hershey_marker& a_from)
 92   :parent(a_from)
 93   {}
 94   text_hershey_marker& operator=(const text_hershey_marker& a_from){
 95     parent::operator=(a_from);
 96     return *this;
 97   }
 98 };
 99 
100 }}
101 
102 #endif