Class: ChemScanner::ChemDraw::ChemGeometry
- Defined in:
- lib/chem_scanner/chem_draw/node/chem_geometry.rb
Overview
Geometry parser
Constant Summary
Constants included from BaseValue
BaseValue::ARROW_NOGO_CROSS, BaseValue::CDXML_ARROW_TYPE, BaseValue::CDXML_ATOM_EXTERNAL_CONNECTION_TYPE, BaseValue::CDXML_CDX_POINT, BaseValue::CDXML_GRAPHIC_TYPE, BaseValue::CDXML_LINE_TYPE, BaseValue::CDXML_NODE_TYPE, BaseValue::CDXML_ORBITAL_TYPE, BaseValue::CDXML_OVAL_TYPE, BaseValue::TEXT_ATTRIBUTES
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#head_type ⇒ Object
readonly
Returns the value of attribute head_type.
-
#line_type ⇒ Object
readonly
Returns the value of attribute line_type.
-
#nogo ⇒ Object
readonly
Returns the value of attribute nogo.
-
#tail ⇒ Object
readonly
Returns the value of attribute tail.
Attributes inherited from BaseNode
#id, #parser, #parser_type, #polygon
Instance Method Summary collapse
- #cross? ⇒ Boolean
- #headless ⇒ Object
-
#initialize(parser, parser_type, id) ⇒ ChemGeometry
constructor
A new instance of ChemGeometry.
- #line ⇒ Object
-
#parse_node(tag, _nid, data) ⇒ Object
NOTE: head —-> tail (head at tail).
- #segment ⇒ Object
- #vector ⇒ Object
Methods inherited from BaseNode
#assign_center, #bounding_box, #cdx_read, #cdxml_read, #center_x, #center_y, #get_tempid, #post_parse_node, #pre_parse_node, #read, #set_cdx, #set_cdxml
Methods included from BaseValue
#binary_chunks, #cdx_styles, #cdx_text, #cdxml_text, #do_unhandled, #point_2d, #point_3d, #polygon_from_bb, #read_bounding_box, #read_ids, #read_int, #read_type, #read_value
Constructor Details
#initialize(parser, parser_type, id) ⇒ ChemGeometry
Returns a new instance of ChemGeometry.
9 10 11 12 13 14 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 9 def initialize(parser, parser_type, id) super(parser, parser_type, id) @middle_points = [] @line_type = 0 end |
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
7 8 9 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 7 def head @head end |
#head_type ⇒ Object (readonly)
Returns the value of attribute head_type.
7 8 9 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 7 def head_type @head_type end |
#line_type ⇒ Object (readonly)
Returns the value of attribute line_type.
7 8 9 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 7 def line_type @line_type end |
#nogo ⇒ Object (readonly)
Returns the value of attribute nogo.
7 8 9 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 7 def nogo @nogo end |
#tail ⇒ Object (readonly)
Returns the value of attribute tail.
7 8 9 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 7 def tail @tail end |
Instance Method Details
#cross? ⇒ Boolean
53 54 55 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 53 def cross? !@nogo.nil? end |
#headless ⇒ Object
49 50 51 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 49 def headless @arrow_head != 2 end |
#line ⇒ Object
45 46 47 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 45 def line segment.to_line end |
#parse_node(tag, _nid, data) ⇒ Object
NOTE: head —-> tail (head at tail)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 17 def parse_node(tag, _nid, data) case @props_ref[tag] when "3DTail" x, y = read_value(tag, data) @tail = { x: x, y: y } when "3DHead" x, y = read_value(tag, data) @head = { x: x, y: y } when "Arrow_ArrowHead_Head" @arrow_head = read_type(tag, data, CDXML_ARROW_TYPE) when "Arrow_NoGo" then @nogo = read_value(tag, data) when "Line_Type" @line_type = read_type(tag, data, CDXML_LINE_TYPE) else do_unhandled(tag) end end |
#segment ⇒ Object
34 35 36 37 38 39 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 34 def segment Geometry::Segment.new_by_arrays( [@tail[:x], @tail[:y]], [@head[:x], @head[:y]], ) end |
#vector ⇒ Object
41 42 43 |
# File 'lib/chem_scanner/chem_draw/node/chem_geometry.rb', line 41 def vector segment.to_vector end |