Class LitePoint
In: litepoint.rb
Parent: FXGLObject

InfoPoint class

Methods

bounds   count   deselect   draw   hide   hit   new   reset   select   show   update  

Included Modules

CommonTasks

Attributes

csys  [RW]  attribute attributes, often from dialog
defaultprefix  [RW]  for the write2table method
info  [RW]  table attributes
name  [RW]  table attributes
pos  [RW] 
ref  [RW]  attribute attributes, often from dialog
refcol  [RW] 
reflist  [RW]  for the write2table method
reforder  [RW]  for the write2table method
row  [RW] 
selected  [RW]  ref attributes none interaction attributes
visible  [RW] 
xpos  [RW]  attribute attributes, often from dialog
ypos  [RW]  attribute attributes, often from dialog
zpos  [RW]  attribute attributes, often from dialog

Public Class methods

 Point position, in model coordinates (a 3-element array)

 Returns an initialized InfoPoint instance.

4 args

 aPoint = InfoPoint.new(Csys, 3.0, 3.0, 0.0)
 a new point at position (3.0, 3.0, 0.0), @info = [@parent, self, "p#{@@count}"]
 where @parent = self

5 args

 aPoint = InfoPoint.new(Csys, 3.0, 3.0, 0.0, [info0, info1, info2])

6 args

 aPoint = InfoPoint.new(Csys, 3.0, 3.0, 0.0, @parent, @text)

 Should InfoPoint have the same initialization as Lines?
 def initialize(@parent, @ref, *args)
 only possible reference is csys?

[Source]

# File litepoint.rb, line 65
   def initialize(*args)
      super()
      @defaultprefix = "point"
      @parent=self
      @red, @green, @blue = 0.0, 0.0, 1.0
      @selected = false
      @row = nil
      @refcol = nil
      @csys = $csysdefault
      @ref = @csys 
      @pos = Array.new
      @visible = false
      @csys = args[0]
      @ref = @csys 
      @xpos, @ypos, @zpos = args[1], args[2], args[3]
      @pos[@csys.count] = [args[1], args[2], args[3]]
      if @csys.count == 0
         @pos[0] = [@xpos, @ypos, @zpos]
      else
         @pos[0] = positionInCsys(@csys, @pos[@csys.count])
      end
      #
      # InfoPoint.new(csys, xpos, ypos, zpos)
      #
      if args.length == 4
         # puts "InfoPoint 4 args"
         # initialize with xpos, ypos and zpos
         @info = [self, self, "p#{@@count}"]
      #
      # InfoPoint.new(csys, xpos, ypos, zpos, info)
      #
      elsif args.length == 5
         @info = args[4]
      #
      # InfoPoint.new(csys, xpos, ypos, zpos, parent, text)
      #
      elsif args.length == 6
         @parent=args[4]
         @text = args[5]
         @info = [@parent, self, @text]
      #
      # was InfoPoint.new(csys, pos]
      #
      else
         # puts "InfoPoint else args"
         # nothing else right now
         #@pos[0] = args[1]
         #@pos[@csys.count] = @pos[0]
         puts "not a good InfoPoint initialization"
      end
      @reforder = ["xpos", "ypos", "zpos"]
      @reflist = { "xpos" => @xpos, "ypos" => @ypos, "zpos" => @zpos }
      @pos[@csys.count] = [@xpos, @ypos, @zpos]
      if @csys.count != 0
         # xpos, :ypos, :zpos, :xrot, :yrot, :zrot, :csystype, :size, :ref
         @oldcsyspos = @csys.getpos
      end
      @@count += 1
   end

Public Instance methods

[Source]

# File litepoint.rb, line 145
   def bounds
      FXRangef.new(@pos[0][0], @pos[0][0], @pos[0][1], @pos[0][1], @pos[0][2], @pos[0][2])
   end

Return the number of created objects of this class

[Source]

# File litepoint.rb, line 195
   def count
      return @@count - 1
   end

Deselect method. Sets the color to blue and make attribute accessor @selected true.

[Source]

# File litepoint.rb, line 174
   def deselect
      @red = 0.0
      @green = 0.0
      @blue = 1.0
      @selected = false
   end

Draw this point into viewer (an FXGLViewer instance).

[Source]

# File litepoint.rb, line 151
   def draw(viewer)
      GL::Color(@red, @green, @blue)
      GL::PointSize(HANDLE_SIZE)
      GL::Begin(GL::POINTS)
      GL::Vertex(@pos[0])
      GL::End()
   end

Remove the point from $globalscene and set attribute accessor @visible to true

[Source]

# File litepoint.rb, line 190
   def hide
      @visible = false
      $globalscene.remove(self)
   end

Perform hit test for this point in viewer (an FXGLViewer instance).

[Source]

# File litepoint.rb, line 161
   def hit(viewer)
      GL::Begin(GL::POINTS)
      GL::Vertex(@pos[0])
      GL::End()
   end

Reset the number of objects of this class

[Source]

# File litepoint.rb, line 199
   def reset
      @@count = 0
   end

Select method. Sets the color to yellow and make attribute accessor @selected true.

[Source]

# File litepoint.rb, line 167
   def select
      @red = 1.0
      @green = 1.0
      @blue = 0.0
      @selected = true
   end

Append the point to $globalscene and set attribute accessor @visible to true. Check if global $pointvisibility is true

[Source]

# File litepoint.rb, line 181
   def show
      @visible = true
      if $pointvisibility
         $globalscene.append(self)
      else
         $globalscene.remove(self)
      end
   end

Return the bounding box (an FXRangef instance) for this point.

[Source]

# File litepoint.rb, line 128
   def update
      # determine if it needs to be updated
      @oldreflist = @reflist
      @reflist = { "xpos" => @xpos, "ypos" => @ypos, "zpos" => @zpos }
      unless @oldreflist == @reflist && ( @csys.count == 0 || @oldcsyspos == @csys.getpos )
         if @csys.count == 0
            @pos[0] = [@xpos, @ypos, @zpos]
         else
            @pos[0] = positionInCsys(@csys, [@xpos, @ypos, @zpos])
            @pos[@csys.count] = [@xpos, @ypos, @zpos]
         end
         if @csys.count != 0
            # xpos, :ypos, :zpos, :xrot, :yrot, :zrot, :csystype, :size, :ref
            @oldcsyspos = @csys.getpos
         end
      end
   end

[Validate]