Class LiteLine
In: liteline.rb
Parent: FXGLObject

Methods

bounds   deselect   draw   hide   hit   new   refdeselect   refselect   select   show  

Attributes

info  [RW]  interaction attributes
p0  [RW]  ref attributes
p1  [RW]  ref attributes
pointref  [RW] 
selected  [RW]  interaction attributes
visible  [RW] 

Public Class methods

[Source]

# File liteline.rb, line 115
   def initialize(*args)
      super()
      @red,@green,@blue = 1.0, 0.0, 0.0
      @selected = false
      @visible = false
      #
      # if independent line is created
      # LiteLine is created with LiteLine.new[InfoPoint,InfoPoint,@info]
      # LiteLine.new(p0, p1, parent, viewerobj, text)
      #
      if args.length == 5 && args[0].class == InfoPoint && args[1].class == InfoPoint
         @pointref = true
         @p0 = args[0]
         @p1 = args[1]
         @parent = args[2]
         @viewerobj = args[3]
         @text = args[4]
         @info = [@parent, @viewerobj, @text]
      #
      # when point input is just an array like: [x0, y0, z0]
      # LiteLine.new([x0,y0,z0], [x1,y1,z1], parent, (viewerobj), text)
      #
      elsif args.length == 5 && args[0].class == Array && args[1].class == Array
         @pointref = false
         @p0 = args[0]
         @p1 = args[1]
         @parent = args[2]
         @viewerobj = args[3]
         @text = args[4]
         @info = [@parent, @viewerobj, @text]
      else
         FXMessageBox.error(self,MBOX_OK,"Error",
         "Problem with creation of LiteLine.\nAbort current object creation")
      end
   end

Public Instance methods

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

[Source]

# File liteline.rb, line 154
   def bounds
      if @pointref
         FXRangef.new([@p0.pos[0][0], @p1.pos[0][0]].min,
                      [@p0.pos[0][0], @p1.pos[0][0]].max,
                      [@p0.pos[0][1], @p1.pos[0][1]].min,
                      [@p0.pos[0][1], @p1.pos[0][1]].max,
                      [@p0.pos[0][2], @p1.pos[0][2]].min,
                      [@p0.pos[0][2], @p1.pos[0][2]].max)
      else
         FXRangef.new([@p0[0], @p1[0]].min,
                      [@p0[0], @p1[0]].max,
                      [@p0[1], @p1[1]].min,
                      [@p0[1], @p1[1]].max,
                      [@p0[2], @p1[2]].min,
                      [@p0[2], @p1[2]].max)
      end
   end

[Source]

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

Draw this line into viewer (an FXGLViewer instance).

[Source]

# File liteline.rb, line 175
   def draw(viewer)
      GL::Color(@red, @green, @blue)
      GL::PointSize(HANDLE_SIZE)
      GL::Begin(GL::LINES)
      if @pointref
         GL::Vertex(@p0.pos[0])
         GL::Vertex(@p1.pos[0])
      else
         GL::Vertex([@p0[0],@p0[1],@p0[2]])
         GL::Vertex([@p1[0],@p1[1],@p1[2]])
      end
      GL::End()
   end

[Source]

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

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

[Source]

# File liteline.rb, line 192
   def hit(viewer)
      GL::Begin(GL::LINES)
      if @pointref
         GL::Vertex(@p0.pos[0])
         GL::Vertex(@p1.pos[0])
      else
         GL::Vertex([@p0[0],@p0[1],@p0[2]])
         GL::Vertex([@p1[0],@p1[1],@p1[2]])
      end
      GL::End()
   end

[Source]

# File liteline.rb, line 229
   def refdeselect
      @red = 1.0
      @green = 0.0
      @blue = 0.0
   end

[Source]

# File liteline.rb, line 224
   def refselect
      @red = 0.0
      @green = 1.0
      @blue = 0.0
   end

[Source]

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

[Source]

# File liteline.rb, line 203
   def show
      @visible = true
      $globalscene.remove(self)
      $globalscene.append(self)
   end

[Validate]