Class LiteLine2
In: liteline.rb
Parent: FXGLObject

Methods

bounds   deselect   draw   drawline   hide   hit   new   refdeselect   refselect   select   show  

Attributes

info  [RW]  interaction attributes
pointref  [RW] 
selected  [RW]  interaction attributes
visible  [RW] 
x  [RW]  ref attributes
y  [RW]  ref attributes
z  [RW]  ref attributes

Public Class methods

[Source]

# File liteline.rb, line 243
   def initialize(*args)
      super()
      @firstinit = true
      @firsthitinit = true
      @selected = false
      @refselected = false
      @visible = false
      #
      #
      begin
         @pointref = true
         @x = args[0]
         @y = args[1]
         @z = args[2]
         @parent = args[3]
         @viewerobj = args[4]
         @text = args[5]
         @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)
      #
      rescue
         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 274
   def bounds
      FXRangef.new(@x.min,
                   @x.max,
                   @y.min,
                   @y.max,
                   @z.min,
                   @z.max)
   end

[Source]

# File liteline.rb, line 348
   def deselect
      @currentlist = @line1
      @selected = false
   end

Draw this line into viewer (an FXGLViewer instance).

[Source]

# File liteline.rb, line 295
   def draw(viewer)
      if @firstinit
         @line1 = GL.GenLists(1)
         GL.NewList(@line1, GL::COMPILE)
         # create red line
         drawline(1.0,0.0,0.0)
         GL.EndList()
         @line2 = GL.GenLists(2)
         GL.NewList(@line2, GL::COMPILE)
         # yellow line
         drawline(1.0,1.0,0.0)
         GL.EndList()
         @line3 = GL.GenLists(3)
         GL.NewList(@line3, GL::COMPILE)
         # green line
         drawline(0.0,1.0,0.0)
         GL.EndList()
         @currentlist = @line1
         @firstinit = false
      end
      GL.CallList(@currentlist)
   end

[Source]

# File liteline.rb, line 282
   def drawline(red,green,blue) 
      GL::Color(red, green, blue)
      GL::PointSize(HANDLE_SIZE)
      GL::Begin(GL::LINES)
      (0..x.size - 2).each do |idx|
         GL::Vertex([@x[idx], @y[idx], @z[idx]])
         GL::Vertex([@x[idx + 1], @y[idx + 1], @z[idx + 1]])
      end
      GL::End()
   end

[Source]

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

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

[Source]

# File liteline.rb, line 321
   def hit(viewer)
      if @firsthitinit
         @hit1 = GL.GenLists(4)
         GL.NewList(@hit1, GL::COMPILE)
         GL::Begin(GL::LINES)
         (0..x.size - 2).each do |idx|
            GL::Vertex([@x[idx], @y[idx], @z[idx]])
            GL::Vertex([@x[idx + 1], @y[idx + 1], @z[idx + 1]])
         end
         GL::End()
         GL::EndList()
         @firsthitinit = false
      end
      GL.CallList(@hit1)
   end

[Source]

# File liteline.rb, line 356
   def refdeselect
      @currentlist = @line1
      @refselected = false
   end

[Source]

# File liteline.rb, line 352
   def refselect
      @currentlist = @line3
      @refselected = true
   end

[Source]

# File liteline.rb, line 344
   def select
      @currentlist = @line2
      @selected = true
   end

[Source]

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

[Validate]