Class: RTP::ControlPoint
- Defined in:
- lib/rtp-connect/control_point.rb
Overview
Relations:
-
Parent: Field
-
Children: none
The ControlPoint class.
Constant Summary collapse
- NR_SURPLUS_ATTRIBUTES =
The number of attributes not having their own variable for this record (200 - 2).
198
Instance Attribute Summary collapse
-
#collimator_angle ⇒ Object
Returns the value of attribute collimator_angle.
-
#collimator_dir ⇒ Object
Returns the value of attribute collimator_dir.
-
#collimator_x1 ⇒ Object
Returns the value of attribute collimator_x1.
-
#collimator_x2 ⇒ Object
Returns the value of attribute collimator_x2.
-
#collimator_y1 ⇒ Object
Returns the value of attribute collimator_y1.
-
#collimator_y2 ⇒ Object
Returns the value of attribute collimator_y2.
-
#control_pt_number ⇒ Object
Returns the value of attribute control_pt_number.
-
#couch_angle ⇒ Object
Returns the value of attribute couch_angle.
-
#couch_dir ⇒ Object
Returns the value of attribute couch_dir.
-
#couch_lateral ⇒ Object
Returns the value of attribute couch_lateral.
-
#couch_longitudinal ⇒ Object
Returns the value of attribute couch_longitudinal.
-
#couch_ped_dir ⇒ Object
Returns the value of attribute couch_ped_dir.
-
#couch_pedestal ⇒ Object
Returns the value of attribute couch_pedestal.
-
#couch_vertical ⇒ Object
Returns the value of attribute couch_vertical.
-
#doserate ⇒ Object
Returns the value of attribute doserate.
-
#energy ⇒ Object
Returns the value of attribute energy.
-
#field_id ⇒ Object
Returns the value of attribute field_id.
-
#field_x ⇒ Object
Returns the value of attribute field_x.
-
#field_x_mode ⇒ Object
Returns the value of attribute field_x_mode.
-
#field_y ⇒ Object
Returns the value of attribute field_y.
-
#field_y_mode ⇒ Object
Returns the value of attribute field_y_mode.
-
#gantry_angle ⇒ Object
Returns the value of attribute gantry_angle.
-
#gantry_dir ⇒ Object
Returns the value of attribute gantry_dir.
-
#iso_pos_x ⇒ Object
Returns the value of attribute iso_pos_x.
-
#iso_pos_y ⇒ Object
Returns the value of attribute iso_pos_y.
-
#iso_pos_z ⇒ Object
Returns the value of attribute iso_pos_z.
-
#mlc_leaves ⇒ Object
Returns the value of attribute mlc_leaves.
-
#mlc_lp_a ⇒ Object
Note: This attribute contains an array of all MLC LP A values (leaves 1..100).
-
#mlc_lp_b ⇒ Object
Note: This attribute contains an array of all MLC LP B values (leaves 1..100).
-
#mlc_shape ⇒ Object
readonly
The MLC shape record (if any) that belongs to this ControlPoint.
-
#mlc_type ⇒ Object
Returns the value of attribute mlc_type.
-
#monitor_units ⇒ Object
Returns the value of attribute monitor_units.
-
#mu_convention ⇒ Object
Returns the value of attribute mu_convention.
-
#parent ⇒ Object
The Record which this instance belongs to.
-
#scale_convention ⇒ Object
Returns the value of attribute scale_convention.
-
#ssd ⇒ Object
Returns the value of attribute ssd.
-
#total_control_points ⇒ Object
Returns the value of attribute total_control_points.
-
#wedge_position ⇒ Object
Returns the value of attribute wedge_position.
Attributes inherited from Record
Class Method Summary collapse
-
.load(string, parent) ⇒ ControlPoint
Creates a new ControlPoint by parsing a RTPConnect string line.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks for equality.
-
#children ⇒ Array
As of now, gives an empty array.
-
#dcm_collimator_x1(scale = nil) ⇒ Float
Converts the collimator_x1 attribute to proper DICOM format.
-
#dcm_collimator_x2(scale = nil) ⇒ Float
Converts the collimator_x2 attribute to proper DICOM format.
-
#dcm_collimator_y1(scale = nil) ⇒ Float
Converts the collimator_y1 attribute to proper DICOM format.
-
#dcm_collimator_y2(scale = nil) ⇒ Float
Converts the collimator_y2 attribute to proper DICOM format.
-
#dcm_mlc_positions(scale = nil) ⇒ String
Converts the mlc_lp_a & mlc_lp_b attributes to a proper DICOM formatted string.
-
#hash ⇒ Fixnum
Computes a hash code for this object.
-
#index ⇒ Fixnum
Gives the index of this ControlPoint (i.e. its index among the control points belonging to the parent Field).
-
#initialize(parent) ⇒ ControlPoint
constructor
Creates a new ControlPoint.
-
#to_control_point ⇒ ControlPoint
Returns self.
-
#values ⇒ Array<String>
(also: #state)
Collects the values (attributes) of this instance.
Methods inherited from Record
#encode, #get_parent, #load, #to_record, #to_s
Constructor Details
#initialize(parent) ⇒ ControlPoint
Creates a new ControlPoint.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rtp-connect/control_point.rb', line 73 def initialize(parent) super('CONTROL_PT_DEF', 233, 236) # Child: @mlc_shape = nil # Parent relation (may get more than one type of record here): @parent = get_parent(parent.to_record, Field) @parent.add_control_point(self) @mlc_lp_a = Array.new(100) @mlc_lp_b = Array.new(100) @attributes = [ # Required: :keyword, :field_id, :mlc_type, :mlc_leaves, :total_control_points, :control_pt_number, :mu_convention, :monitor_units, :wedge_position, :energy, :doserate, :ssd, :scale_convention, :gantry_angle, :gantry_dir, :collimator_angle, :collimator_dir, :field_x_mode, :field_x, :collimator_x1, :collimator_x2, :field_y_mode, :field_y, :collimator_y1, :collimator_y2, :couch_vertical, :couch_lateral, :couch_longitudinal, :couch_angle, :couch_dir, :couch_pedestal, :couch_ped_dir, :iso_pos_x, :iso_pos_y, :iso_pos_z, :mlc_lp_a, :mlc_lp_b ] end |
Instance Attribute Details
#collimator_angle ⇒ Object
Returns the value of attribute collimator_angle.
32 33 34 |
# File 'lib/rtp-connect/control_point.rb', line 32 def collimator_angle @collimator_angle end |
#collimator_dir ⇒ Object
Returns the value of attribute collimator_dir.
33 34 35 |
# File 'lib/rtp-connect/control_point.rb', line 33 def collimator_dir @collimator_dir end |
#collimator_x1 ⇒ Object
Returns the value of attribute collimator_x1.
36 37 38 |
# File 'lib/rtp-connect/control_point.rb', line 36 def collimator_x1 @collimator_x1 end |
#collimator_x2 ⇒ Object
Returns the value of attribute collimator_x2.
37 38 39 |
# File 'lib/rtp-connect/control_point.rb', line 37 def collimator_x2 @collimator_x2 end |
#collimator_y1 ⇒ Object
Returns the value of attribute collimator_y1.
40 41 42 |
# File 'lib/rtp-connect/control_point.rb', line 40 def collimator_y1 @collimator_y1 end |
#collimator_y2 ⇒ Object
Returns the value of attribute collimator_y2.
41 42 43 |
# File 'lib/rtp-connect/control_point.rb', line 41 def collimator_y2 @collimator_y2 end |
#control_pt_number ⇒ Object
Returns the value of attribute control_pt_number.
22 23 24 |
# File 'lib/rtp-connect/control_point.rb', line 22 def control_pt_number @control_pt_number end |
#couch_angle ⇒ Object
Returns the value of attribute couch_angle.
45 46 47 |
# File 'lib/rtp-connect/control_point.rb', line 45 def couch_angle @couch_angle end |
#couch_dir ⇒ Object
Returns the value of attribute couch_dir.
46 47 48 |
# File 'lib/rtp-connect/control_point.rb', line 46 def couch_dir @couch_dir end |
#couch_lateral ⇒ Object
Returns the value of attribute couch_lateral.
43 44 45 |
# File 'lib/rtp-connect/control_point.rb', line 43 def couch_lateral @couch_lateral end |
#couch_longitudinal ⇒ Object
Returns the value of attribute couch_longitudinal.
44 45 46 |
# File 'lib/rtp-connect/control_point.rb', line 44 def couch_longitudinal @couch_longitudinal end |
#couch_ped_dir ⇒ Object
Returns the value of attribute couch_ped_dir.
48 49 50 |
# File 'lib/rtp-connect/control_point.rb', line 48 def couch_ped_dir @couch_ped_dir end |
#couch_pedestal ⇒ Object
Returns the value of attribute couch_pedestal.
47 48 49 |
# File 'lib/rtp-connect/control_point.rb', line 47 def couch_pedestal @couch_pedestal end |
#couch_vertical ⇒ Object
Returns the value of attribute couch_vertical.
42 43 44 |
# File 'lib/rtp-connect/control_point.rb', line 42 def couch_vertical @couch_vertical end |
#doserate ⇒ Object
Returns the value of attribute doserate.
27 28 29 |
# File 'lib/rtp-connect/control_point.rb', line 27 def doserate @doserate end |
#energy ⇒ Object
Returns the value of attribute energy.
26 27 28 |
# File 'lib/rtp-connect/control_point.rb', line 26 def energy @energy end |
#field_id ⇒ Object
Returns the value of attribute field_id.
18 19 20 |
# File 'lib/rtp-connect/control_point.rb', line 18 def field_id @field_id end |
#field_x ⇒ Object
Returns the value of attribute field_x.
35 36 37 |
# File 'lib/rtp-connect/control_point.rb', line 35 def field_x @field_x end |
#field_x_mode ⇒ Object
Returns the value of attribute field_x_mode.
34 35 36 |
# File 'lib/rtp-connect/control_point.rb', line 34 def field_x_mode @field_x_mode end |
#field_y ⇒ Object
Returns the value of attribute field_y.
39 40 41 |
# File 'lib/rtp-connect/control_point.rb', line 39 def field_y @field_y end |
#field_y_mode ⇒ Object
Returns the value of attribute field_y_mode.
38 39 40 |
# File 'lib/rtp-connect/control_point.rb', line 38 def field_y_mode @field_y_mode end |
#gantry_angle ⇒ Object
Returns the value of attribute gantry_angle.
30 31 32 |
# File 'lib/rtp-connect/control_point.rb', line 30 def gantry_angle @gantry_angle end |
#gantry_dir ⇒ Object
Returns the value of attribute gantry_dir.
31 32 33 |
# File 'lib/rtp-connect/control_point.rb', line 31 def gantry_dir @gantry_dir end |
#iso_pos_x ⇒ Object
Returns the value of attribute iso_pos_x.
49 50 51 |
# File 'lib/rtp-connect/control_point.rb', line 49 def iso_pos_x @iso_pos_x end |
#iso_pos_y ⇒ Object
Returns the value of attribute iso_pos_y.
50 51 52 |
# File 'lib/rtp-connect/control_point.rb', line 50 def iso_pos_y @iso_pos_y end |
#iso_pos_z ⇒ Object
Returns the value of attribute iso_pos_z.
51 52 53 |
# File 'lib/rtp-connect/control_point.rb', line 51 def iso_pos_z @iso_pos_z end |
#mlc_leaves ⇒ Object
Returns the value of attribute mlc_leaves.
20 21 22 |
# File 'lib/rtp-connect/control_point.rb', line 20 def mlc_leaves @mlc_leaves end |
#mlc_lp_a ⇒ Object
Note: This attribute contains an array of all MLC LP A values (leaves 1..100).
53 54 55 |
# File 'lib/rtp-connect/control_point.rb', line 53 def mlc_lp_a @mlc_lp_a end |
#mlc_lp_b ⇒ Object
Note: This attribute contains an array of all MLC LP B values (leaves 1..100).
55 56 57 |
# File 'lib/rtp-connect/control_point.rb', line 55 def mlc_lp_b @mlc_lp_b end |
#mlc_shape ⇒ Object (readonly)
The MLC shape record (if any) that belongs to this ControlPoint.
17 18 19 |
# File 'lib/rtp-connect/control_point.rb', line 17 def mlc_shape @mlc_shape end |
#mlc_type ⇒ Object
Returns the value of attribute mlc_type.
19 20 21 |
# File 'lib/rtp-connect/control_point.rb', line 19 def mlc_type @mlc_type end |
#monitor_units ⇒ Object
Returns the value of attribute monitor_units.
24 25 26 |
# File 'lib/rtp-connect/control_point.rb', line 24 def monitor_units @monitor_units end |
#mu_convention ⇒ Object
Returns the value of attribute mu_convention.
23 24 25 |
# File 'lib/rtp-connect/control_point.rb', line 23 def mu_convention @mu_convention end |
#parent ⇒ Object
The Record which this instance belongs to.
15 16 17 |
# File 'lib/rtp-connect/control_point.rb', line 15 def parent @parent end |
#scale_convention ⇒ Object
Returns the value of attribute scale_convention.
29 30 31 |
# File 'lib/rtp-connect/control_point.rb', line 29 def scale_convention @scale_convention end |
#ssd ⇒ Object
Returns the value of attribute ssd.
28 29 30 |
# File 'lib/rtp-connect/control_point.rb', line 28 def ssd @ssd end |
#total_control_points ⇒ Object
Returns the value of attribute total_control_points.
21 22 23 |
# File 'lib/rtp-connect/control_point.rb', line 21 def total_control_points @total_control_points end |
#wedge_position ⇒ Object
Returns the value of attribute wedge_position.
25 26 27 |
# File 'lib/rtp-connect/control_point.rb', line 25 def wedge_position @wedge_position end |
Class Method Details
.load(string, parent) ⇒ ControlPoint
Creates a new ControlPoint by parsing a RTPConnect string line.
64 65 66 67 |
# File 'lib/rtp-connect/control_point.rb', line 64 def self.load(string, parent) cp = self.new(parent) cp.load(string) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Checks for equality.
Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.
132 133 134 135 136 |
# File 'lib/rtp-connect/control_point.rb', line 132 def ==(other) if other.respond_to?(:to_control_point) other.send(:state) == state end end |
#children ⇒ Array
As of now, gives an empty array. However, by definition, this record may have an mlc shape record as child, but this is not implemented yet.
145 146 147 148 |
# File 'lib/rtp-connect/control_point.rb', line 145 def children #return [@mlc_shape] return Array.new end |
#dcm_collimator_x1(scale = nil) ⇒ Float
Converts the collimator_x1 attribute to proper DICOM format.
155 156 157 |
# File 'lib/rtp-connect/control_point.rb', line 155 def dcm_collimator_x1(scale=nil) dcm_collimator_1(scale, default_axis=:x) end |
#dcm_collimator_x2(scale = nil) ⇒ Float
Converts the collimator_x2 attribute to proper DICOM format.
164 165 166 167 |
# File 'lib/rtp-connect/control_point.rb', line 164 def dcm_collimator_x2(scale=nil) axis = (scale == :elekta ? :y : :x) dcm_collimator(axis, coeff=1, side=2) end |
#dcm_collimator_y1(scale = nil) ⇒ Float
Converts the collimator_y1 attribute to proper DICOM format.
174 175 176 |
# File 'lib/rtp-connect/control_point.rb', line 174 def dcm_collimator_y1(scale=nil) dcm_collimator_1(scale, default_axis=:y) end |
#dcm_collimator_y2(scale = nil) ⇒ Float
Converts the collimator_y2 attribute to proper DICOM format.
183 184 185 186 |
# File 'lib/rtp-connect/control_point.rb', line 183 def dcm_collimator_y2(scale=nil) axis = (scale == :elekta ? :x : :y) dcm_collimator(axis, coeff=1, side=2) end |
#dcm_mlc_positions(scale = nil) ⇒ String
Converts the mlc_lp_a & mlc_lp_b attributes to a proper DICOM formatted string.
193 194 195 196 197 198 199 |
# File 'lib/rtp-connect/control_point.rb', line 193 def dcm_mlc_positions(scale=nil) coeff = (scale == :elekta ? -1 : 1) # As with the collimators, the first side (1/a) may need scale invertion: pos_a = @mlc_lp_a.collect{|p| (p.to_f * 10 * coeff).round(1) unless p.empty?}.compact pos_b = @mlc_lp_b.collect{|p| (p.to_f * 10).round(1) unless p.empty?}.compact (pos_a + pos_b).join("\\") end |
#hash ⇒ Fixnum
Two objects with the same attributes will have the same hash code.
Computes a hash code for this object.
207 208 209 |
# File 'lib/rtp-connect/control_point.rb', line 207 def hash state.hash end |
#index ⇒ Fixnum
Gives the index of this ControlPoint (i.e. its index among the control points belonging to the parent Field).
216 217 218 |
# File 'lib/rtp-connect/control_point.rb', line 216 def index @parent.control_points.index(self) end |
#to_control_point ⇒ ControlPoint
Returns self.
271 272 273 |
# File 'lib/rtp-connect/control_point.rb', line 271 def to_control_point self end |
#values ⇒ Array<String> Also known as: state
The CRC is not considered part of the actual values and is excluded.
Collects the values (attributes) of this instance.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/rtp-connect/control_point.rb', line 225 def values [ @keyword, @field_id, @mlc_type, @mlc_leaves, @total_control_points, @control_pt_number, @mu_convention, @monitor_units, @wedge_position, @energy, @doserate, @ssd, @scale_convention, @gantry_angle, @gantry_dir, @collimator_angle, @collimator_dir, @field_x_mode, @field_x, @collimator_x1, @collimator_x2, @field_y_mode, @field_y, @collimator_y1, @collimator_y2, @couch_vertical, @couch_lateral, @couch_longitudinal, @couch_angle, @couch_dir, @couch_pedestal, @couch_ped_dir, @iso_pos_x, @iso_pos_y, @iso_pos_z, *@mlc_lp_a, *@mlc_lp_b ] end |