indexing description: "[ 3D representation of a string, including visual attributes like color, point-size, and font used for rendering. ]" author: "" date: "$Date$" revision: "$Revision$" class EM3D_STRING inherit EMGL_VIEW export {NONE} all end create make, make_with_color, make_with_format feature -- Initialization make (a_value: STRING; a_font: EM3D_FONT) is -- Make new 3d string representing `a_value' that will be rendered using `a_font' require font_exists: a_font /= Void do make_with_format (a_value, create {EM3D_FONT_FORMAT}.make (a_font)) end make_with_color (a_value: STRING; a_font: EM3D_FONT; a_color: EM_COLOR) is -- Make new 3d string representing `a_value' that will be rendered using `a_font', of `a_color' require font_exists: a_font /= Void do make_with_format (a_value, create {EM3D_FONT_FORMAT}.make_with_color (a_font, a_color)) end make_with_format (a_value: STRING; a_format: EM3D_FONT_FORMAT) is -- require value_exists: a_value /= Void format_exists: a_format /= Void do value := a_value format := a_format ensure all_set: value = a_value and format = a_format end feature -- Access value: STRING -- Actual string format: EM3D_FONT_FORMAT -- Color of text feature -- Element change set_value (a_value: like value) is -- require value_exists: a_value /= Void do value := a_value ensure set: value = a_value end set_format (a_format: like format) is -- require format_exists: a_format /= Void do format := a_format ensure set: format = a_format end feature -- Status report feature -- Status setting feature -- Measurement height: DOUBLE is -- Height of string do Result := format.font.string_height (value, format.point_size) end width: DOUBLE is -- Width of string do Result := format.font.string_width (value, format.point_size) end bounding_box: EM_INTERVAL_2D is -- local bl_off: DOUBLE do bl_off := format.baseline_offset Result.set ([0.0, -bl_off], [width, height - bl_off]) end feature -- Rendering cache is -- Cache rendering information do format.font.cache_string (value) end render (a_pos: EM_VECTOR3D) is -- Render current string at `a_pos' do if format.use_point_snapping then format.font.render_string_point_snapped (value, a_pos, format.point_size, format.color) else format.font.render_string (value, a_pos, format.point_size, format.color) end end render_aligned (a_pos: EM_VECTOR3D; an_alignment: EM_ALIGNMENT_2D) is -- Render current string at `a_pos', with `an_alignment' local aligned_pos: EM_VECTOR3D do -- ... align ... aligned_pos := a_pos - bounding_box.align_value ([0, 0], an_alignment).to_vector3d -- ... render render (aligned_pos) end render_rotated_and_aligned (a_pos: EM_VECTOR3D; a_degrees: DOUBLE; an_alignment: EM_ALIGNMENT_2D) is -- Render current string at `a_pos', rotated by `a_degrees', with `an_alignment' do emgl_push_matrix if format.use_point_snapping then emgl_translated (a_pos.x.rounded, a_pos.y.rounded, a_pos.z.rounded) else emgl_translate (a_pos) end emgl_rotated (a_degrees, 0.0, 0.0, 1.0) render_aligned (a_pos.zero, an_alignment) emgl_pop_matrix end end