Class InfoLine
In: infoline.rb
Parent: Object

Line object

Methods

checknewstatus   create   deselect   hide   new   refdeselect   refselect   reset   select   show   showp0   showp1   update   writemesh   writemeshcont  

Included Modules

CommonTasks Mesh

Attributes

changed  [RW]  interaction attributes
child  [RW]  interaction attributes
csys  [RW] 
defaultprefix  [RW]  for the write2table method
firstpoint  [RW] 
flipdir  [RW]  flip dir
futureref  [RW]  ref attributes
futurerefed  [RW]  ref attributes
imesh  [RW]  mesh attributes
info  [RW]  interaction attributes
l  [RW]  mesh,l an array with the LiteLines
lastpoint  [RW] 
meshNoFromRow  [RW]  mesh attributes
meshdens  [RW]  mesh attributes
meshnum  [RW]  mesh attributes
p0  [RW]  ref attributes
p1  [RW]  ref attributes
parent  [RW]  interaction attributes
radius  [RW]  attribute attributes, often from dialog
ref  [RW]  ref attributes
refattr  [RW]  ref attributes
refcol  [RW]  table attributes
reflist  [RW]  for the write2table method
reforder  [RW]  for the write2table method
reftype  [RW]  ref attributes
row  [RW]  table attributes
selected  [RW]  interaction attributes
v  [RW]  mesh,l an array with the LiteLines
viewerobj  [RW]  interaction attributes
visible  [RW] 
x  [RW]  mesh,l an array with the LiteLines
xaxis  [RW]  attribute attributes, often from dialog
xvec  [RW]  attribute attributes, often from dialog
y  [RW]  mesh,l an array with the LiteLines
yaxis  [RW]  attribute attributes, often from dialog
yvec  [RW]  attribute attributes, often from dialog
z  [RW]  mesh,l an array with the LiteLines
zaxis  [RW]  attribute attributes, often from dialog
zvec  [RW]  attribute attributes, often from dialog

Public Class methods

new initialize procedure def initialize(@reftype,@csys,@ref(s),*args) appies to Info[Line,Face,Cube] info if info == nil

[Source]

# File infoline.rb, line 65
   def initialize(reftype, csys, ref, parent, info, *args)
      @imesh = nil
      @child = Array.new
      @changed = false
      @defaultprefix = "line"
      @futurerefed = false
      @futureref = nil
      @reftype = reftype
      @csys = csys
      @ref = ref
      @parent = parent
      @parent ==nil ? @parent= self:nil
      info == nil ? @info=[@parent, self, "l#{@@count}"]:@info=[@parent, self, info]
      @red,@green,@blue = 1.0, 0.0, 0.0
      @radius = nil
      @selected = false
      @row = nil
      @refcol = nil
      @visible = false
      @meshNoFromRow = nil
      @meshnum = 5
      @flipdir = 0
      @meshdens = nil
      @l = Array.new
      @v = Array.new
      # if independent line is created
      # InfoLine.new
      case @reftype
         #
         # InfoLine.new(reftype, csys, ref, parent, info, xvec, yvec, zvec, meshnum)
         #
         when "1p"
            @xvec, @yvec, @zvec, @meshnum = args
            @reflist = { "xvec"=>@xvec, "yvec"=>@yvec, "zvec"=>@zvec, "refattr"=>@refattr, "radius"=>@radius, 
                  "xaxis"=>@xaxis, "yaxis"=>@yaxis, "zaxis"=>@zaxis, "meshnum"=>@meshnum, "flipdir" => @flipdir }
            @reforder = [ "xvec", "yvec", "zvec", "meshnum"]
            @p0 = @ref
            @p1 = InfoPoint.new(@csys, 0.0, 0.0, 0.0, @parent,"p1")
            @firstpoint = @p0
            @lastpoint = @p1
         #
         # InfoLine.new(reftype, csys, ref, parent, info, meshnum)
         #
         when "2p"
            @meshnum, @flipdir = args[0], args[1]
            @reflist = { "xvec"=>@xvec, "yvec"=>@yvec, "zvec"=>@zvec, "refattr"=>@refattr, "radius"=>@radius, 
                  "xaxis"=>@xaxis, "yaxis"=>@yaxis, "zaxis"=>@zaxis, "meshnum"=>@meshnum, "flipdir" => @flipdir }
            @reforder = [  "meshnum", "flipdir"]
            @p0 = @ref[0]
            @p1 = @ref[1]
            @firstpoint = @p0
            @lastpoint = @p1
      end
      #create
      @oldcsyspos = @csys.getpos
      @@count += 1
    end

Public Instance methods

[Source]

# File infoline.rb, line 186
    def checknewstatus
??
       @newstatus = { "xvec"=>@xvec, "yvec"=>@yvec, "zvec"=>@zvec, "refattr"=>@refattr, "radius"=>@radius, 
                  "xaxis"=>@xaxis, "yaxis"=>@yaxis, "zaxis"=>@zaxis, "meshnum"=>@meshnum, "flipdir" => @flipdir }
    end

Create the FXGLViewer instances.

[Source]

# File infoline.rb, line 126
    def create
      # puts "from infoline #{@info[2]} meshnum #{@meshnum}"
      # check if meshnum is overridden in $meshref
       if @info[0] == @info[1] # extra check (not needed?)
??
          if imesh != nil
             @meshnum = imesh
          end
       end
      case @reftype
         when "1p"
            @p0.pos[@csys.count] = invPositionInCsys(@csys, @p0.pos[0])
            @p1.pos[0] = positionInCsys(@csys, 
               [@xvec+@p0.pos[@csys.count][0], @yvec+@p0.pos[@csys.count][1], @zvec+@p0.pos[@csys.count][2]])
            @p1.pos[@csys.count] = [@xvec+@p0.pos[@csys.count][0], @yvec+@p0.pos[@csys.count][1], @zvec+@p0.pos[@csys.count][2]]
            #puts "tmp pos #{tmp[0]}, #{tmp[1]}, #{tmp[2]}"
            #puts "p1 pos #{@p1.pos[0]}, #{@p1.pos[1]}, #{@p1.pos[2]}" 
         when "2p"
            @p0.pos[@csys.count] = invPositionInCsys(@csys, @p0.pos[0])
            @p1.pos[@csys.count] = invPositionInCsys(@csys, @p1.pos[0])
       end 
      #update
      @l=Array.new
#      @v=Array.new
      @x = Array.new
      @y = Array.new
      @z = Array.new
 
      # want to have the pos[@csys.count] from meshline. I have it in the created v which 
      # holds the InfoPoints with pos[@csys.count]
      # New approach
      # create linear spacing between @p0.pos[@csys.count] and @p1.pos[@csys.count]
      if @radius == nil
         if @flipdir == 0 
            @x[@csys.count], @y[@csys.count], @z[@csys.count] = linearspace(@p0.pos[@csys.count], @p1.pos[@csys.count], @meshnum)
         else
            # fix the flip dir spacing
            @x[@csys.count], @y[@csys.count], @z[@csys.count] = flipspace(@p0.pos[@csys.count], @p1.pos[@csys.count], @meshnum, @csys)
         end
         @x[0], @y[0], @z[0] = spaceinreal(@csys, @x[@csys.count], @y[@csys.count], @z[@csys.count])
      else
         xtmp, ytmp, ztmp = linearspace(@p0.pos[0], @p1.pos[0], @meshnum)
         # radiusadjust(xvec, yvec, zvec, radius, xaxis, yaxis, zaxis,meshnum, refattr)
         @x[0], @y[0], @z[0] = radiusadjust(xtmp, ytmp, ztmp, @radius,  @xaxis, @yaxis, @zaxis, @refattr)
         #}
      end
      #@l = createline(@x[0], @y[0], @z[0], @parent, self)
      @l = LiteLine2.new(@x[0], @y[0], @z[0], @parent, self, @info[2])
      #test4 = Benchmark.realtime {
      # @v,@l = meshline(@csys,@p0,@p1,@meshnum,@radius,@xaxis,@yaxis,@zaxis,@refattr,@parent,self)
      #}
      #puts "linearspace #{test1}, spaceinreal #{test2}, createline #{test5}" if @radius == nil
      #puts "radius linearspace #{test3}, radiusadjust #{test4}, createline #{test5}" if @radius != nil
       @currentstatus = { "xvec"=>@xvec, "yvec"=>@yvec, "zvec"=>@zvec, "refattr"=>@refattr, "radius"=>@radius, 
                  "xaxis"=>@xaxis, "yaxis"=>@yaxis, "zaxis"=>@zaxis, "meshnum"=>@meshnum, "flipdir" => @flipdir }
    end

[Source]

# File infoline.rb, line 299
   def deselect
      @l.deselect
      @selected = false
      if @reftype == "1p"
         @p1.deselect
     end
   end

[Source]

# File infoline.rb, line 278
   def hide
      @visible = false
      @l.hide
      if @reftype == "1p"
         # scene.remove(@p0)
         $globalscene.remove(@p1)
      end
   end

[Source]

# File infoline.rb, line 309
   def refdeselect
      @l.refdeselect
   end

[Source]

# File infoline.rb, line 306
   def refselect
      @l.refselect
   end

[Source]

# File infoline.rb, line 312
   def reset
      @@count = 0
   end

[Source]

# File infoline.rb, line 292
   def select
      @l.select
      @selected = true
      if @reftype == "1p"
         @p1.select
      end
   end

[Source]

# File infoline.rb, line 254
   def show
      @visible = true
      # this can't be necessary
      #@l.each do |line|
      #   scene.remove(line)
      #end
      #if self.ref.size == 1
      #scene.remove(@p0)
      #scene.remove(@p1)
      #case $reftype
      #   when "1p"
      if $pointvisibility
         $globalscene.append(@p0)
         $globalscene.append(@p1)
      end
            #@p0.visible ?  scene.append(@p0):scene.remove(@p0)
      #         when "2p"
      #            "do nothing"
      #         end

      if $linevisibility
         @l.show
      end
   end

[Source]

# File infoline.rb, line 286
   def showp0
      $globalscene.append(@p0)
   end

[Source]

# File infoline.rb, line 289
   def showp1
      $globalscene.append(@p1)
   end

[Source]

# File infoline.rb, line 195
    def update
       #scene.remove(@p0)
       #scene.remove(@p1)
       # check meshref
       if @futurerefed
          @radius = @futureref.radius
          @xaxis = @futureref.xaxis
          @yaxis = @futureref.yaxis
          @zaxis = @futureref.zaxis
          @refattr = @futureref.refattr
       else
          @radius, @xaxis, @yaxis, @zaxis = nil, nil, nil, nil
       end
       @reflist = { "xvec"=>@xvec, "yvec"=>@yvec, "zvec"=>@zvec, "refattr"=>@refattr, "radius"=>@radius, 
                  "xaxis"=>@xaxis, "yaxis"=>@yaxis, "zaxis"=>@zaxis, "meshnum"=>@meshnum, "flipdir" => @flipdir }
       unless @newstatus == @currentstatus && ( @csys.count == 0 || @oldcsyspos == @csys.getpos) && false # always update right now
          @l.hide
          #$globalviewer.update
          create
          @l.show
         if @csys.count != 0
            @oldcsyspos = @csys.getpos
         end
         @changed = true
       end
       #scene.append(@p1)
       # scene.append(@p0)
    end

def update

   recreate($globalscene)

end

[Source]

# File infoline.rb, line 229
    def writemesh
       writemeshcont(0,0)
    end

write the line mesh points and cell definitions, beginning att vertex number maxv and cell number maxc

[Source]

# File infoline.rb, line 233
    def writemeshcont(maxv,maxc)
      if @radius == 0.0
         x,y,z = linemeshpoints(@p0,@p1,@meshnum)
      else
         radiusmin = vectLength([@p0.pos[0]-@p1.pos[0],@p0.pos[1]-@p1.pos[1],@p0.pos[2]-@p1.pos[2]])/2
         radius = [radiusmin, @radius.to_f].max
         x,y,z = linemeshpoints(@p0,@p1,@meshnum)
         x,y,z = radiusadjust(x,y,z, radius, @xaxis, @yaxis, @zaxis,@meshnum, @refattr) 
      end
       puts "vert       x       y      z"
       (0..(@meshnum-1)).each do |i|
          puts "#{i+maxv+1}   #{x[i]}   #{y[i]}   #{z[i]}"
       end
       puts "cell   vertex 1   vertex2"
       (0..(@meshnum-1)-1).each do |i|
          puts "#{i+maxc+1}      #{i+maxv+1}          #{i+maxv+2}"
       end
    end

[Validate]