| Class | LiteLine2 |
| In: |
liteline.rb
|
| Parent: | FXGLObject |
| info | [RW] | interaction attributes |
| pointref | [RW] | |
| selected | [RW] | interaction attributes |
| visible | [RW] | |
| x | [RW] | ref attributes |
| y | [RW] | ref attributes |
| z | [RW] | ref attributes |
# 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
Return the bounding box (an FXRangef instance) for this line.
# File liteline.rb, line 274 def bounds FXRangef.new(@x.min, @x.max, @y.min, @y.max, @z.min, @z.max) end
Draw this line into viewer (an FXGLViewer instance).
# 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
# 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
Perform hit-test for this line in viewer (an FXGLViewer instance).
# 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