Class Csys
In: csys.rb
Parent: Object

A coordinate system class

Methods

count   create   csystext   deselect   getpos   hide   new   reset   select   show   update  

Included Modules

CommonTasks

Attributes

changed  [RW]  interaction attributes color is "X", "Y" or "Z"
color  [RW]  interaction attributes color is "X", "Y" or "Z"
csystype  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
defaultprefix  [RW]  for the write2table method
info  [RW]  interaction attributes color is "X", "Y" or "Z"
parent  [RW]  interaction attributes color is "X", "Y" or "Z"
ref  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
refcol  [RW]  table attributes
reflist  [RW]  for the write2table method
reforder  [RW]  for the write2table method
reftype  [RW]  interaction attributes color is "X", "Y" or "Z"
row  [RW]  table attributes
selected  [RW]  interaction attributes color is "X", "Y" or "Z"
size  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
v0  [RW]  the vectors which will be CsysLines
v1  [RW]  the vectors which will be CsysLines
v2  [RW]  the vectors which will be CsysLines
v3  [RW]  the vectors which will be CsysLines
viewerobj  [RW]  interaction attributes color is "X", "Y" or "Z"
visible  [RW] 
x  [RW] 
xpos  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
xrot  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
y  [RW] 
ypos  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
yrot  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
z  [RW] 
zpos  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used
zrot  [RW]  [x,y,z]pos is the position of the coordinate system [x,y,z]rot is the rotation of the coordinate system type is "normal", "cyl" or "spherical" or 0, 1 and 2 size is the length of the coordinate vectors ref is the reference, if nothing is selected point 0,0,0 will be used

Public Class methods

[Source]

# File csys.rb, line 48
   def initialize(*args)
      @changed = false
      @defaultprefix = "csys"
      @reforder = ["xpos", "ypos", "zpos", "xrot", "yrot", "zrot", "size", "type"]
      @reftype = nil
      @parent = self
      @red,@green,@blue = 1.0, 0.0, 0.0
      @radius = 0.0
      @selected = false
      @row = nil
      @refs = nil
      @refcol = nil
      @visible = false
      @size = 10.0
      @info=[@parent, self, "csys#{@@count}"]
      if args.length == 8
         @xpos = args[0]
         @ypos = args[1]
         @zpos = args[2]
         @xrot = args[3]
         # puts "xrot is now #{@xrot}"
         @yrot = args[4]
         @zrot = args[5]
         @csystype = args[6]
         @size = args[7]
         # puts "args 7"
         @x = CsysLine.new(@xpos, @ypos, @zpos, @size +@xpos, @ypos, @zpos, self, self, "X")
         @y = CsysLine.new(@xpos, @ypos, @zpos, @xpos, @size +@ypos, @zpos, self, self, "Y")
         @z = CsysLine.new(@xpos, @ypos, @zpos, @xpos, @ypos, @size +@zpos, self, self, "Z")
         @@count += 1
      elsif args.length == 0
         puts "no csys created"
      end
      update
   end

Public Instance methods

[Source]

# File csys.rb, line 155
   def count
      return @@count - 1
      #return @info[2].split("csys").last.to_i
   end

[Source]

# File csys.rb, line 165
   def create
   end

[Source]

# File csys.rb, line 133
   def csystext(csysno)
      case csysno
         when 0
            return "normal"
         when 1
            return "cyl"
         when 2
            return "spherical"
      end
   end

[Source]

# File csys.rb, line 149
   def deselect
      @x.deselect
      @y.deselect
      @z.deselect
      @selected = false
   end

[Source]

# File csys.rb, line 162
   def getpos
      return @xpos, @ypos, @zpos, @xrot, @yrot, @zrot, @csystype
   end

[Source]

# File csys.rb, line 127
   def hide
      $globalscene.remove(@x)
      $globalscene.remove(@y)
      $globalscene.remove(@z)
      @visible = false
   end

[Source]

# File csys.rb, line 159
   def reset
      @@count = 0
   end

[Source]

# File csys.rb, line 143
   def select
      @x.select
      @y.select
      @z.select
      @selected = true
   end

[Source]

# File csys.rb, line 118
   def show
      $globalscene.remove(@x)
      $globalscene.remove(@y)
      $globalscene.remove(@z)
      $globalscene.append(@x)
      $globalscene.append(@y)
      $globalscene.append(@z)
      @visible = true
   end

Create the FXGLViewer instances.

[Source]

# File csys.rb, line 86
   def update
      p = [@xpos, @ypos, @zpos]
      vx = [@xpos+@size, @ypos, @zpos]
      vy = [@xpos, @ypos+@size, @zpos]
      vz = [@xpos, @ypos, @zpos+@size]
      # transform x-axis
      # rotateX(p,ang,v)
      vx = rotateX(p, @xrot, vx).to_a
      vx = rotateY(p, @yrot, vx).to_a
      vx = rotateZ(p, @zrot, vx).to_a
      # transform x-axis
      vy = rotateX(p, @xrot, vy).to_a
      vy = rotateY(p, @yrot, vy).to_a
      vy = rotateZ(p, @zrot, vy).to_a
      # transform x-axis
      vz = rotateX(p, @xrot, vz).to_a
      vz = rotateY(p, @yrot, vz).to_a
      vz = rotateZ(p, @zrot, vz).to_a
      @x.x0, @x.y0, @x.z0 = @xpos, @ypos, @zpos
      @y.x0, @y.y0, @y.z0 = @xpos, @ypos, @zpos
      @z.x0, @z.y0, @z.z0 = @xpos, @ypos, @zpos
      @x.x1, @x.y1, @x.z1 = vx[0], vx[1], vx[2]
      @y.x1, @y.y1, @y.z1 = vy[0], vy[1], vy[2]
      @z.x1, @z.y1, @z.z1 = vz[0], vz[1], vz[2]
      @oldreflist = @reflist
      @reflist = { "xpos" => @xpos, "ypos" => @ypos, "zpos" => @zpos, "xrot" => @xrot, "yrot" => @yrot, "zrot" => @zrot,
                "type" => csystext(@csystype), "size" => @size }
      unless @oldreflist == @reflist
         @changed = true
      end
   end

[Validate]