g4tools  5.4.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
tools::sg::text_valop Class Reference
Inheritance diagram for tools::sg::text_valop:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::text_valop:
Collaboration graph
[legend]

Public Member Functions

virtual const desc_fieldsnode_desc_fields () const
 
virtual void render (render_action &a_action)
 
virtual void pick (pick_action &a_action)
 
virtual void bbox (bbox_action &a_action)
 
virtual void search (search_action &a_action)
 
 text_valop (const base_freetype &a_ttf)
 
virtual ~text_valop ()
 
 text_valop (const text_valop &a_from)
 
text_valopoperator= (const text_valop &a_from)
 
virtual void get_bounds (float, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z) const
 
virtual float ascent (float) const
 
virtual float y_advance (float) const
 
virtual float descent (float) const
 
virtual bool truncate (const std::string &, float, float, std::string &) const
 
- Public Member Functions inherited from tools::sg::base_text
 base_text ()
 
virtual ~base_text ()
 
- Public Member Functions inherited from tools::sg::node
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
virtual nodecopy () const =0
 
virtual unsigned int cls_version () const
 
virtual void get_matrix (get_matrix_action &a_action)
 
virtual bool write (write_action &a_action)
 
virtual void event (event_action &)
 
virtual bool read (read_action &a_action)
 
virtual void is_visible (visible_action &)
 
virtual void protocol_one_fields (std::vector< field * > &a_fields) const
 
virtual bool draw_in_frame_buffer () const
 
virtual bool touched ()
 
virtual void reset_touched ()
 
 node ()
 
virtual ~node ()
 
void touch ()
 
fieldfield_from_desc (const field_desc &a_desc) const
 
void dump_field_descs (std::ostream &a_out) const
 
fieldfind_field_by_name (const std::string &a_name) const
 

Public Attributes

sf_string encoding
 
sf_string font
 
sf_enum< sg::font_modelingfont_modeling
 
- Public Attributes inherited from tools::sg::base_text
mf_string strings
 
sf< float > height
 
sf_enum< sg::hjusthjust
 
sf_enum< sg::vjustvjust
 

Protected Member Functions

void update_sg (std::ostream &a_out)
 
- Protected Member Functions inherited from tools::sg::base_text
 base_text (const base_text &a_from)
 
base_textoperator= (const base_text &a_from)
 
- Protected Member Functions inherited from tools::sg::node
 node (const node &)
 
nodeoperator= (const node &)
 
void add_field (field *a_field)
 
bool write_fields (write_action &a_action)
 
bool read_fields (read_action &a_action)
 
field_desc::offset_t field_offset (const field *a_field) const
 
fieldfind_field (const field_desc &a_rdesc) const
 
void check_fields (std::ostream &a_out) const
 

Protected Attributes

const base_freetypem_ttf
 
separator m_sep
 
nostream m_out
 

Detailed Description

Definition at line 17 of file text_valop.

Constructor & Destructor Documentation

◆ text_valop() [1/2]

tools::sg::text_valop::text_valop ( const base_freetype a_ttf)
inline

Definition at line 79 of file text_valop.

80  :parent()
82  ,font(font_hershey())
84  ,m_ttf(a_ttf)
85  {
86  add_fields();
87  }

◆ ~text_valop()

virtual tools::sg::text_valop::~text_valop ( )
inlinevirtual

Definition at line 88 of file text_valop.

88 {}

◆ text_valop() [2/2]

tools::sg::text_valop::text_valop ( const text_valop a_from)
inline

Definition at line 90 of file text_valop.

91  :parent(a_from)
92  ,encoding(a_from.encoding)
93  ,font(a_from.font)
94  ,font_modeling(a_from.font_modeling)
95  ,m_ttf(a_from.m_ttf)
96  {
97  add_fields();
98  }

Member Function Documentation

◆ ascent()

virtual float tools::sg::text_valop::ascent ( float  ) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 121 of file text_valop.

121 {return 1;}

◆ bbox()

virtual void tools::sg::text_valop::bbox ( bbox_action a_action)
inlinevirtual

Reimplemented from tools::sg::node.

Definition at line 59 of file text_valop.

59  {
60  if(touched()) {
61  update_sg(a_action.out());
62  reset_touched();
63  }
64  m_sep.bbox(a_action);
65  }

◆ descent()

virtual float tools::sg::text_valop::descent ( float  ) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 123 of file text_valop.

123 {return 0;}

◆ get_bounds()

virtual void tools::sg::text_valop::get_bounds ( float  ,
float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z 
) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 107 of file text_valop.

109  {
110  text_valop& self = const_cast<text_valop&>(*this);
111  if(self.touched()) {
112  self.update_sg(self.m_out);
113  self.reset_touched();
114  }
115  vec3f mn,mx;
116  mnmx(self.m_out,self.m_sep,mn,mx);
117  a_mn_x = mn[0];a_mn_y = mn[1];a_mn_z = mn[2];
118  a_mx_x = mx[0];a_mx_y = mx[1];a_mx_z = mx[2];
119  //::printf("debug : get_bounds : %g %g %g : %g %g %g\n",a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z);
120  }

◆ node_desc_fields()

virtual const desc_fields& tools::sg::text_valop::node_desc_fields ( ) const
inlinevirtual

Reimplemented from tools::sg::base_text.

Definition at line 25 of file text_valop.

◆ operator=()

text_valop& tools::sg::text_valop::operator= ( const text_valop a_from)
inline

Definition at line 99 of file text_valop.

99  {
100  parent::operator=(a_from);
101  encoding = a_from.encoding;
102  font = a_from.font;
103  font_modeling = a_from.font_modeling;
104  return *this;
105  }

◆ pick()

virtual void tools::sg::text_valop::pick ( pick_action a_action)
inlinevirtual

Reimplemented from tools::sg::node.

Definition at line 52 of file text_valop.

52  {
53  if(touched()) {
54  update_sg(a_action.out());
55  reset_touched();
56  }
57  nodekit_pick(a_action,m_sep,this);
58  }

◆ render()

virtual void tools::sg::text_valop::render ( render_action a_action)
inlinevirtual

Reimplemented from tools::sg::node.

Definition at line 45 of file text_valop.

45  {
46  if(touched()) {
47  update_sg(a_action.out());
48  reset_touched();
49  }
50  m_sep.render(a_action);
51  }

◆ search()

virtual void tools::sg::text_valop::search ( search_action a_action)
inlinevirtual

Reimplemented from tools::sg::node.

Definition at line 66 of file text_valop.

66  {
67  if(touched()) {
68  update_sg(a_action.out());
69  reset_touched();
70  }
71  parent::search(a_action);
72  if(a_action.done()) return;
73  if(a_action.do_path()) a_action.path_push(this);
74  m_sep.search(a_action);
75  if(a_action.done()) return;
76  if(a_action.do_path()) a_action.path_pop();
77  }

◆ truncate()

virtual bool tools::sg::text_valop::truncate ( const std::string &  ,
float  ,
float  ,
std::string &   
) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 124 of file text_valop.

124 {return false;}

◆ update_sg()

void tools::sg::text_valop::update_sg ( std::ostream &  a_out)
inlineprotected

Definition at line 126 of file text_valop.

126  {
127  m_sep.clear();
128  matrix* tsf = new matrix;
129  m_sep.add(tsf);
130  tools_vforcit(std::string,strings.values(),it) {
131  valop* _valop = new valop(valop::STRING,*it);
132  valop2sg v(a_out,m_sep,m_ttf);
133  if(!v.visit(*_valop)) {
134  a_out << "tools::sg::text_valop::upate_sg : valop2sg.visit() failed." << std::endl;
135  m_sep.clear();
136  delete _valop;
137  return;
138  }
139  delete _valop;
140  }
141  vec3f mn,mx;
142  mnmx(a_out,m_sep,mn,mx);
143  float h = mx[1]-mn[1];
144  if(!h) {
145  a_out << "tools::sg::text_valop::upate_sg : valop has null height." << std::endl;
146  m_sep.clear();
147  return;
148  }
149  float scale = height.value()/h;
150  tsf->set_scale(scale,scale,1);
151  }

◆ y_advance()

virtual float tools::sg::text_valop::y_advance ( float  ) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 122 of file text_valop.

122 {return 1;}

Member Data Documentation

◆ encoding

sf_string tools::sg::text_valop::encoding

Definition at line 21 of file text_valop.

◆ font

sf_string tools::sg::text_valop::font

Definition at line 22 of file text_valop.

◆ font_modeling

sf_enum<sg::font_modeling> tools::sg::text_valop::font_modeling

Definition at line 23 of file text_valop.

◆ m_out

nostream tools::sg::text_valop::m_out
protected

Definition at line 155 of file text_valop.

◆ m_sep

separator tools::sg::text_valop::m_sep
protected

Definition at line 154 of file text_valop.

◆ m_ttf

const base_freetype& tools::sg::text_valop::m_ttf
protected

Definition at line 153 of file text_valop.


The documentation for this class was generated from the following file:
tools::sg::font_pixmap
@ font_pixmap
Definition: enums:94
tools::mnmx
bool mnmx(std::ostream &a_out, sg::node &a_node, vec3f &a_mn, vec3f &a_mx)
Definition: mnmx:12
tools::sg::group::search
virtual void search(search_action &a_action)
Definition: group:51
tools::sg::text_valop::m_out
nostream m_out
Definition: text_valop:155
TOOLS_ARG_FIELD_DESC_ENUMS_BEG
#define TOOLS_ARG_FIELD_DESC_ENUMS_BEG(a__field, a__num)
Definition: field:77
tools::sg::base_text::height
sf< float > height
Definition: base_text:30
tools::mn
T mn(const T &a, const T &b)
Definition: mnmx:10
tools::mx
T mx(const T &a, const T &b)
Definition: mnmx:13
tools::sg::text_valop::encoding
sf_string encoding
Definition: text_valop:21
tools::sg::node::operator=
node & operator=(const node &)
Definition: node:124
tools::sg::bmf::values
const std::vector< T > & values() const
Definition: bmf:71
tools::sg::separator::bbox
virtual void bbox(bbox_action &a_action)
Definition: separator:38
tools::sg::text_valop::update_sg
void update_sg(std::ostream &a_out)
Definition: text_valop:126
tools::sg::nodekit_pick
void nodekit_pick(pick_action &a_action, node &a_sg, node *a_node)
Definition: nodekit:13
tools::sg::text_valop::font
sf_string font
Definition: text_valop:22
tools::sg::group::add
void add(node *a_node)
Definition: group:96
tools::sg::font_outline
@ font_outline
Definition: enums:92
tools::sg::encoding_none
const std::string & encoding_none()
Definition: strings:38
tools::sg::node::search
virtual void search(search_action &a_action)
Definition: node:56
tools::sg::text_valop::m_ttf
const base_freetype & m_ttf
Definition: text_valop:153
tools::sg::node::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: node:48
tools::sg::separator::render
virtual void render(render_action &a_action)
Definition: separator:18
tools::sg::text_valop::text_valop
text_valop(const base_freetype &a_ttf)
Definition: text_valop:79
tools::sg::text_valop::font_modeling
sf_enum< sg::font_modeling > font_modeling
Definition: text_valop:23
tools::sg::base_text::strings
mf_string strings
Definition: base_text:29
tools::sg::text_valop
Definition: text_valop:17
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::valop::STRING
@ STRING
Definition: valop:37
TOOLS_ARG_ENUM
#define TOOLS_ARG_ENUM(a__value)
Definition: field:85
tools::sg::group::clear
void clear()
Definition: group:235
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::font_hershey
const std::string & font_hershey()
Definition: strings:186
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::sg::font_filled
@ font_filled
Definition: enums:93
tools::sg::node::touched
virtual bool touched()
Definition: node:96
tools::sg::text_valop::m_sep
separator m_sep
Definition: text_valop:154
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::node::reset_touched
virtual void reset_touched()
Definition: node:102
TOOLS_ARG_FIELD_DESC_ENUMS_END
#define TOOLS_ARG_FIELD_DESC_ENUMS_END
Definition: field:83