Class LiteFace
In: liteface.rb
Parent: FXGLShape

Methods

canDrag   deselect   drawshape   hide   new   select   show  

Attributes

info  [RW]  interaction attributes
p0  [RW]  ref attributes
p1  [RW]  ref attributes
p2  [RW]  ref attributes
p3  [RW]  ref attributes
selected  [RW]  interaction attributes

Public Class methods

[Source]

# File liteface.rb, line 71
    def initialize(*args)
    # if independent line is created
    # LiteFace is created with LiteFace.new[InfoPoint,InfoPoint,InfoPoint,InfoPoint,@parent,@viewerobj,@text,true]
      if args.length == 8 && args[0].class == InfoPoint && args[1].class == InfoPoint  && args[2].class == InfoPoint && args[3].class == InfoPoint 
        super(args[0].pos[0],args[0].pos[1],args[0].pos[2], SHADING_FLAT|STYLE_SURFACE)
        @nopointref = false
        @p0 = args[0]
        @p1 = args[1]
        @p2 = args[2]
        @p3 = args[3]
        @parent = args[4]
        @viewerobj = args[5]
        #@viewerobj = self
        @text = args[6]
        @info = [@parent, @viewerobj, @text]
        @dimmed = args[7]
        @xlow = [@p0.pos[0], @p1.pos[0], @p2.pos[0], @p3.pos[0]].min
        @xhigh = [@p0.pos[0], @p1.pos[0], @p2.pos[0], @p3.pos[0]].max
        @ylow = [@p0.pos[1], @p1.pos[1], @p2.pos[1], @p3.pos[1]].min
        @yhigh = [@p0.pos[1], @p1.pos[1], @p2.pos[1], @p3.pos[1]].max
        @zlow = [@p0.pos[2], @p1.pos[2], @p2.pos[2], @p3.pos[2]].min
        @zhigh = [@p0.pos[2], @p1.pos[2], @p2.pos[2], @p3.pos[2]].max
        p0tmp=Vector.elements(@p0.pos)
        p1tmp=Vector.elements(@p1.pos)
        p3tmp=Vector.elements(@p3.pos)
        @normal=crossNormal((p1tmp-p0tmp).to_a,(p3tmp-p0tmp).to_a)
      elsif args.length == 16
      # initialize with positions, set nopointref=true
        super(0.0,0.0,0.0, SHADING_SMOOTH|STYLE_SURFACE)
        @nopointref = true
        @p0 = [args[0],args[1],args[2]]
        @p1 = [args[3],args[4],args[5]]
        @p2 = [args[6],args[7],args[8]]
        @p3 = [args[9],args[10],args[11]]
        @parent = args[12]
        #@viewerobj = args[5]
        @viewerobj = args[13]
        @text = args[14]
        @info = [@parent, @viewerobj, @text]
        @dimmed = args[15]
        @xlow = [@p0[0], @p1[0], @p2[0], @p3[0]].min
        @xhigh = [@p0[0], @p1[0], @p2[0], @p3[0]].max
        @ylow = [@p0[1], @p1[1], @p2[1], @p3[1]].min
        @yhigh = [@p0[1], @p1[1], @p2[1], @p3[1]].max
        @zlow = [@p0[2], @p1[2], @p2[2], @p3[2]].min
        @zhigh = [@p0[2], @p1[2], @p2[2], @p3[2]].max
        p0tmp=Vector.elements(@p0)
        p1tmp=Vector.elements(@p1)
        p3tmp=Vector.elements(@p3)
        @normal=crossNormal((p1tmp-p0tmp).to_a,(p3tmp-p0tmp).to_a)
??
         if @dimmed
            self.setMaterial(0,$dark)
            self.setMaterial(1,$dark)
         else
            self.setMaterial(0,$gray)
            self.setMaterial(1,$gray)
         end
      else
         FXMessageBox.error(self,MBOX_OK,"Error",
         "Problem with creation of FaceLine.\nAbort current object creation")
      end
      @selected = false
      @n0, @n1, @n2 = @normal[0],@normal[1],@normal[2]
      if @nopointref
         @p00, @p01, @p02 = @p0[0], @p0[1], @p0[2]
         @p10, @p11, @p12 = @p1[0], @p1[1], @p1[2]
         @p30, @p31, @p32 = @p3[0], @p3[1], @p3[2]
         @p20, @p21, @p22 = @p2[0], @p2[1], @p2[2]
      else 
         @p00, @p01, @p02 = @p0.pos[0], @p0.pos[1], @p0.pos[2]
         @p10, @p11, @p12 = @p1.pos[0], @p1.pos[1], @p1.pos[2]
         @p30, @p31, @p32 = @p3.pos[0], @p3.pos[1], @p3.pos[2]
         @p20, @p21, @p22 = @p2.pos[0], @p2.pos[1], @p2.pos[2]
      end
      # Now the range is not set, don't now all implications of disabling this
      #setRange(FXRangef.new(@xlow,@xhigh,@ylow,@yhigh,@zlow,@zhigh))
      # @color01 = FXMaterial.new
??
    end

Public Instance methods

[Source]

# File liteface.rb, line 247
   def canDrag
      false
   end

[Source]

# File liteface.rb, line 216
   def deselect
??
      if @dimmed
         self.setMaterial(0,$dark)
         self.setMaterial(1,$dark)
      else
         self.setMaterial(0,$gray)
         self.setMaterial(1,$gray)
      end
      @selected = false
   end

Draws this face into viewer (an FXGLViewer instance).

[Source]

# File liteface.rb, line 182
   def drawshape(viewer)
      GL::Begin(GL::QUAD_STRIP)
         GL::Normal(@n0,@n1,@n2)
         GL::Vertex(@p00, @p01, @p02)
         GL::Vertex(@p10, @p11, @p12)
         GL::Vertex(@p30, @p31, @p32)
         GL::Vertex(@p20, @p21, @p22)
      GL::End()
   end

[Source]

# File liteface.rb, line 244
   def hide
      $globalscene.remove(self)
   end

[Source]

# File liteface.rb, line 192
   def select
??
      if @dimmed
         self.setMaterial(0,$seldark)
         self.setMaterial(1,$seldark)
      else
         self.setMaterial(0,$selgray)
         self.setMaterial(1,$selgray)
      end
      @selected = true
   end

[Source]

# File liteface.rb, line 240
   def show
      #$globalscene.remove(self)
      $globalscene.append(self)
   end

[Validate]