Class: VORuby::STC::V1_30::PixelFrameType

Inherits:
GenericCoordFrameType show all
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

A pixel coordinate frame (which may be 1-D, 2-D, or 3-D) consists of a coordinate frame, a reference position, a flavor, a reference pixel array and the order in which the pixel axes appear in the pixel array.

Direct Known Subclasses

PixelCoordFrame

Instance Attribute Summary collapse

Attributes inherited from GenericCoordFrameType

#coord_flavor, #coord_ref_frame, #coord_ref_pos

Attributes inherited from CoordFrameType

#name

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GenericCoordFrameType

generic_coord_frame_from_xml

Methods inherited from CoordFrameType

coord_frame_from_xml

Methods inherited from STCBaseType

stc_base_from_xml

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(reference_pixel, axis1_order, axis2_order, axis3_order, coord_ref_frame, coord_ref_pos, coord_flavor, options = {}) ⇒ PixelFrameType

Returns a new instance of PixelFrameType.



7566
7567
7568
7569
7570
7571
7572
7573
# File 'lib/voruby/stc/1.30/stc.rb', line 7566

def initialize(reference_pixel, axis1_order, axis2_order, axis3_order, coord_ref_frame, coord_ref_pos, coord_flavor, options={})
  super(coord_ref_frame, coord_ref_pos, coord_flavor, options[:name], options)
  self.reference_pixel = reference_pixel
  self.axis1_order = axis1_order
  self.axis2_order = axis2_order
  self.axis3_order = axis3_order
  self.ref_frame_id = options[:ref_frame_id]
end

Instance Attribute Details

#axis1_orderObject

Returns the value of attribute axis1_order.



7564
7565
7566
# File 'lib/voruby/stc/1.30/stc.rb', line 7564

def axis1_order
  @axis1_order
end

#axis2_orderObject

Returns the value of attribute axis2_order.



7564
7565
7566
# File 'lib/voruby/stc/1.30/stc.rb', line 7564

def axis2_order
  @axis2_order
end

#axis3_orderObject

Returns the value of attribute axis3_order.



7564
7565
7566
# File 'lib/voruby/stc/1.30/stc.rb', line 7564

def axis3_order
  @axis3_order
end

#ref_frame_idObject

Returns the value of attribute ref_frame_id.



7564
7565
7566
# File 'lib/voruby/stc/1.30/stc.rb', line 7564

def ref_frame_id
  @ref_frame_id
end

#reference_pixelObject

Returns the value of attribute reference_pixel.



7564
7565
7566
# File 'lib/voruby/stc/1.30/stc.rb', line 7564

def reference_pixel
  @reference_pixel
end

Class Method Details

.from_xml(xml) ⇒ Object



7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
# File 'lib/voruby/stc/1.30/stc.rb', line 7624

def self.from_xml(xml)
  root = element_from(xml)
  
  ref_pixel = REXML::XPath.first(root, 'x:ReferencePixel', {'x' => obj_ns.uri})
  
  coord_ref_frame, coord_ref_pos, coord_flavor, name, options = GenericCoordFrameType.generic_coord_frame_from_xml(root)
  options ||= {}
  
  rfi = root.attributes.get_attribute_ns(obj_ns.uri, 'ref_frame_id')
  options[:ref_frame_id] = rfi ? IdRef.new(rfi.value) : nil
  
  a2_order = root.attributes.get_attribute_ns(obj_ns.uri, 'axis2_order')
  a3_order = root.attributes.get_attribute_ns(obj_ns.uri, 'axis3_order')
  
  self.new(
    ref_pixel ? PixelType.from_xml(ref_pixel) : nil,
    Integer(root.attributes.get_attribute_ns(obj_ns.uri, 'axis1_order').value),
    a2_order ? Integer(a2_order.value) : nil,
    a3_order ? Integer(a3_order.value) : nil,
    coord_ref_frame, coord_ref_pos, coord_flavor,
    options
  )
end

Instance Method Details

#==(f) ⇒ Object



7601
7602
7603
7604
7605
7606
7607
7608
# File 'lib/voruby/stc/1.30/stc.rb', line 7601

def ==(f)
  super(f) and
  self.reference_pixel == f.reference_pixel and
  self.axis1_order == f.axis1_order and
  self.axis2_order == f.axis2_order and
  self.axis3_order == f.axis3_order and
  self.ref_frame_id == f.ref_frame_id
end

#to_xml(name = nil) ⇒ Object



7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
# File 'lib/voruby/stc/1.30/stc.rb', line 7610

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.reference_pixel.to_xml('ReferencePixel')) if self.reference_pixel
  
  el.attributes["#{obj_ns.prefix}:axis1_order"] = self.axis1_order.to_s
  el.attributes["#{obj_ns.prefix}:axis2_order"] = self.axis2_order.to_s if self.axis2_order
  el.attributes["#{obj_ns.prefix}:axis3_order"] = self.axis3_order.to_s if self.axis3_order
  el.attributes["#{obj_ns.prefix}:ref_frame_id"] = self.ref_frame_id.to_s if self.ref_frame_id
  
  collapse_namespaces(el)
  el
end