示例#1
0
    def _draw_jig(self, glpane, color, highlighted = False):
        """
        Draw a Grid Plane jig as a set of grid lines.
        """
        glPushMatrix()

        glTranslatef( self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef( q.angle*180.0/math.pi, q.x, q.y, q.z)

        hw = self.width/2.0; hh = self.height/2.0
        corners_pos = [V(-hw, hh, 0.0), V(-hw, -hh, 0.0), V(hw, -hh, 0.0), V(hw, hh, 0.0)]
        
        if highlighted:
            grid_color = color
        else:
            grid_color = self.grid_color
        
        if self.picked:
            drawLineLoop(self.color, corners_pos)
        else:
            drawLineLoop(color, corners_pos)
            
        if self.grid_type == SQUARE_GRID:
            drawGPGrid(glpane, grid_color, self.line_type, self.width, self.height, self.x_spacing, self.y_spacing,
                       q.unrot(self.assy.o.up), q.unrot(self.assy.o.right))
        else:
            drawSiCGrid(grid_color, self.line_type, self.width, self.height,
                        q.unrot(self.assy.o.up), q.unrot(self.assy.o.right))
        
        glPopMatrix()
示例#2
0
    def _draw_jig(self, glpane, color, highlighted=False):
        """
        Draw a ESP Image jig as a plane with an edge and a bounding box.
        """
        glPushMatrix()

        glTranslatef(self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef(q.angle * 180.0 / math.pi, q.x, q.y, q.z)

        #bruce 060207 extensively revised texture code re fixing bug 1059
        if self.tex_name is not None and self.image_obj:  # self.image_obj condition is needed, for clear_esp_image() to work
            textureReady = True
            glBindTexture(
                GL_TEXTURE_2D, self.tex_name
            )  # maybe this belongs in draw_plane instead? Put it there later. ##e
            self._initTextureEnv()  # sets texture params the way we want them
        else:
            textureReady = False
        drawPlane(self.fill_color,
                  self.width,
                  self.width,
                  textureReady,
                  self.opacity,
                  SOLID=True,
                  pickCheckOnly=self.pickCheckOnly)

        hw = self.width / 2.0
        corners_pos = [
            V(-hw, hw, 0.0),
            V(-hw, -hw, 0.0),
            V(hw, -hw, 0.0),
            V(hw, hw, 0.0)
        ]
        drawLineLoop(color, corners_pos)

        # Draw the ESP Image bbox.
        if self.show_esp_bbox:
            wo = self.image_offset
            eo = self.edge_offset
            drawwirecube(color, V(0.0, 0.0, 0.0), V(hw + eo, hw + eo, wo),
                         1.0)  #drawwirebox

            # This is for debugging purposes.  This draws a green normal vector using
            # local space coords.  Mark 050930
            if 0:
                from graphics.drawing.CS_draw_primitives import drawline
                drawline(green, V(0.0, 0.0, 0.0), V(0.0, 0.0, 1.0), 0, 3)

        glPopMatrix()

        # This is for debugging purposes. This draws a yellow normal vector using
        # model space coords.  Mark 050930
        if 0:
            from graphics.drawing.CS_draw_primitives import drawline
            from utilities.constants import yellow
            drawline(yellow, self.center, self.center + self.planeNorm, 0, 3)
示例#3
0
    def _draw_jig(self, glpane, color, highlighted = False):
        """
        Draw an ESPImage jig (self) as a plane with an edge and a bounding box.

        @note: this is not called during graphicsMode.Draw_model as with most
            Jigs, but during graphicsMode.Draw_after_highlighting.
        """
        glPushMatrix()

        glTranslatef( self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef( q.angle*180.0/math.pi, q.x, q.y, q.z) 

        #bruce 060207 extensively revised texture code re fixing bug 1059
        if self.tex_name is not None and self.image_obj: 
            # self.image_obj cond is needed, for clear_esp_image() to work
            textureReady = True
            glBindTexture(GL_TEXTURE_2D, self.tex_name)
                # review: maybe this belongs in draw_plane instead?
            self._initTextureEnv() # sets texture params the way we want them
        else:
            textureReady = False
        drawPlane(self.fill_color, self.width, self.width, textureReady,
                  self.opacity, SOLID = True, 
                  pickCheckOnly = self.pickCheckOnly )

        hw = self.width/2.0
        corners_pos = [V(-hw,  hw, 0.0), 
                       V(-hw, -hw, 0.0), 
                       V( hw, -hw, 0.0), 
                       V( hw,  hw, 0.0)]
        drawLineLoop(color, corners_pos)  

        # Draw the ESP Image bbox.
        if self.show_esp_bbox:
            wo = self.image_offset
            eo = self.edge_offset
            drawwirecube(color, V(0.0, 0.0, 0.0), V(hw + eo, hw + eo, wo), 1.0) 
                #drawwirebox

            # This is for debugging purposes. This draws a green normal vector
            # using local space coords. [Mark 050930]
            if 0:
                from graphics.drawing.CS_draw_primitives import drawline
                drawline(green, V(0.0, 0.0, 0.0), V(0.0, 0.0, 1.0), 0, 3)

        glpane.kluge_reset_texture_mode_to_work_around_renderText_bug()

        glPopMatrix()

        # This is for debugging purposes. This draws a yellow normal vector
        # using model space coords. [Mark 050930]
        if 0:
            from graphics.drawing.CS_draw_primitives import drawline
            from utilities.constants import yellow
            drawline(yellow, self.center, self.center + self.planeNorm, 0, 3)
示例#4
0
    def _draw_jig(self, glpane, color, highlighted=False):
        """
        Draw a Grid Plane jig as a set of grid lines.
        """
        glPushMatrix()

        glTranslatef(self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef(q.angle * 180.0 / math.pi, q.x, q.y, q.z)

        hw = self.width / 2.0
        hh = self.height / 2.0
        corners_pos = [
            V(-hw, hh, 0.0),
            V(-hw, -hh, 0.0),
            V(hw, -hh, 0.0),
            V(hw, hh, 0.0)
        ]

        if highlighted:
            grid_color = color
        else:
            grid_color = self.grid_color

        if self.picked:
            drawLineLoop(self.color, corners_pos)
        else:
            drawLineLoop(color, corners_pos)

        if self.grid_type == SQUARE_GRID:
            drawGPGrid(glpane, grid_color, self.line_type, self.width,
                       self.height, self.x_spacing, self.y_spacing,
                       q.unrot(self.assy.o.up), q.unrot(self.assy.o.right))
        else:
            drawSiCGrid(grid_color, self.line_type, self.width, self.height,
                        q.unrot(self.assy.o.up), q.unrot(self.assy.o.right))

        glPopMatrix()
示例#5
0
 def _draw(self, hCenter = None, highlighted = False):
     """
     Draw the resize handle. It does the actual drawing work. 
     
     @param hCenter: The center of the handle. If None, use the handle's 
                     I{center} property.
     @type  hCenter: L{V} or None
     
     @param highlighted: This argument determines if the handle is 
                         drawn in the highlighted color.
     @type  highlighted: bool
     @see: {self.draw} where this method is called. 
     """        
     
     if hCenter:
         if self.center != hCenter:
             self.center = hCenter    
                
     #Use glpane's scale for drawing the handle. This makes sure that
     # the handle is non-zoomable. 
     side = self.glpane.scale * 0.018                
     glPushMatrix() 
     
     
     #Translate to the center of the handle
     glTranslatef(self.center[0], 
                  self.center[1], 
                  self.center[2])  
                     
     #Bruce suggested undoing the glpane.quat rotation and plane quat 
     #rotation  before drawing the handle geometry. -- ninad 20070525
     
     parent_q = self.parent.quat 
     
     if parent_q:
         glRotatef(-parent_q.angle * ONE_RADIAN,
                    parent_q.x, 
                    parent_q.y, 
                    parent_q.z)
         
     glpane_q = self.glpane.quat
     glRotatef(-glpane_q.angle * ONE_RADIAN, 
                glpane_q.x, 
                glpane_q.y, 
                glpane_q.z) 
    
     drawPlane(env.prefs[selectionColor_prefs_key], 
               side, 
               side, 
               self.textureReady,
               0.9, 
               SOLID         = True, 
               pickCheckOnly = self.pickCheckOnly)         
     
     handle_hw = side/2.0 #handle's half width
     handle_hh = side/2.0 #handle's half height        
     handle_corner = [V(-handle_hw,  handle_hh, 0.0), 
                      V(-handle_hw, -handle_hh, 0.0), 
                      V( handle_hw, -handle_hh, 0.0), 
                      V( handle_hw,  handle_hh, 0.0)]   
     
     if highlighted:    
         drawLineLoop(orange, handle_corner, width = 6)
     else:
         drawLineLoop( black, handle_corner, width = 2)                
     glPopMatrix()
    def _draw(self, hCenter=None, highlighted=False):
        """
        Draw the resize handle. It does the actual drawing work. 
        
        @param hCenter: The center of the handle. If None, use the handle's 
                        I{center} property.
        @type  hCenter: L{V} or None
        
        @param highlighted: This argument determines if the handle is 
                            drawn in the highlighted color.
        @type  highlighted: bool
        @see: {self.draw} where this method is called. 
        """

        if hCenter:
            if self.center != hCenter:
                self.center = hCenter

        #Use glpane's scale for drawing the handle. This makes sure that
        # the handle is non-zoomable.
        side = self.glpane.scale * 0.018
        glPushMatrix()

        #Translate to the center of the handle
        glTranslatef(self.center[0], self.center[1], self.center[2])

        #Bruce suggested undoing the glpane.quat rotation and plane quat
        #rotation  before drawing the handle geometry. -- ninad 20070525

        parent_q = self.parent.quat

        if parent_q:
            glRotatef(-parent_q.angle * ONE_RADIAN, parent_q.x, parent_q.y,
                      parent_q.z)

        glpane_q = self.glpane.quat
        glRotatef(-glpane_q.angle * ONE_RADIAN, glpane_q.x, glpane_q.y,
                  glpane_q.z)

        drawPlane(env.prefs[selectionColor_prefs_key],
                  side,
                  side,
                  self.textureReady,
                  0.9,
                  SOLID=True,
                  pickCheckOnly=self.pickCheckOnly)

        handle_hw = side / 2.0  #handle's half width
        handle_hh = side / 2.0  #handle's half height
        handle_corner = [
            V(-handle_hw, handle_hh, 0.0),
            V(-handle_hw, -handle_hh, 0.0),
            V(handle_hw, -handle_hh, 0.0),
            V(handle_hw, handle_hh, 0.0)
        ]

        if highlighted:
            drawLineLoop(orange, handle_corner, width=6)
        else:
            drawLineLoop(black, handle_corner, width=2)
        glPopMatrix()
示例#7
0
    def _draw_geometry(self, glpane, color, highlighted=False):
        """
        Draw the Plane.

        @param glpane: The 3D graphics area to draw it in.
        @type  glpane: L{GLPane}

        @param color: The color of the plane.
        @type  color: tuple

        @param highlighted: This argument determines if the plane is 
                            drawn in the highlighted color.
        @type  highlighted: bool
        
        @see: self.draw_after_highlighting() which draws things like filled 
            plane, grids etc after the main drawing code is finished.
        """
        #IMPORTANT NOTE: self.draw_after_highlighting makes sure that
        #plane get selected even when you click
        #on the filled portion of it. -- Ninad 2008-06-20

        glPushMatrix()
        glTranslatef(self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef(q.angle * ONE_RADIAN, q.x, q.y, q.z)

        hw = self.width * 0.5
        hh = self.height * 0.5

        bottom_left = V(-hw, -hh, 0.0)
        bottom_right = V(+hw, -hh, 0.0)
        top_right = V(+hw, +hh, 0.0)
        top_left = V(-hw, +hh, 0.0)

        corners_pos = [bottom_left, bottom_right, top_right, top_left]

        if self.picked:
            drawLineLoop(self.color, corners_pos)
            if highlighted:
                drawLineLoop(color, corners_pos, width=2)
                pass
            self._draw_handles(corners_pos)
        else:
            if highlighted:
                drawLineLoop(color, corners_pos, width=2)
            else:
                #Following draws the border of the plane in orange color
                #for its front side (side that was in front
                #when the plane was created) and a brown border for the backside.
                if dot(self.getaxis(), glpane.lineOfSight) < 0:
                    bordercolor = brown  #backside
                else:
                    bordercolor = self.border_color  #frontside

                drawLineLoop(bordercolor, corners_pos)

        if self.directionArrow.isDrawRequested():
            self.directionArrow.draw()

        glPopMatrix()
        return
示例#8
0
    def _draw_geometry(self, glpane, color, highlighted = False):
        """
        Draw the Plane.

        @param glpane: The 3D graphics area to draw it in.
        @type  glpane: L{GLPane}

        @param color: The color of the plane.
        @type  color: tuple

        @param highlighted: This argument determines if the plane is 
                            drawn in the highlighted color.
        @type  highlighted: bool
        
        @see: self.draw_after_highlighting() which draws things like filled 
        plane , grids etc after the main drawing code is finished.
        """
        
        #IMPORTANT NOTE: See also self.draw_after_highlighting() which draws 
        #some more things suxh as filled plane etc after the main drawing code
        #is finished. It makes sure that plane get selected even when you click
        #on the filled portion of it. -- Ninad 2008-06-20
        
        glPushMatrix()
        glTranslatef( self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef( q.angle * ONE_RADIAN, 
                   q.x,
                   q.y,
                   q.z)   

        hw = self.width  * 0.5
        hh = self.height * 0.5

        bottom_left  = V(- hw, - hh, 0.0)                       
        bottom_right = V(+ hw, - hh, 0.0)        
        top_right    = V(+ hw, + hh, 0.0)
        top_left     = V(- hw, + hh, 0.0)

        corners_pos = [bottom_left, bottom_right, top_right, top_left]


        if self.picked:
            drawLineLoop(self.color, corners_pos)  
            if highlighted:
                drawLineLoop(color, corners_pos, width = 2)            
                pass
            self._draw_handles(corners_pos)    
        else:
            if highlighted:
                drawLineLoop(color, corners_pos, width = 2)
            else:  
                #Following draws the border of the plane in orange color 
                #for it's front side (side that was in front 
                #when the plane was created and a brown border for the backside.
                if dot(self.getaxis(), glpane.lineOfSight) < 0:
                    bordercolor = brown #backside
                else:
                    bordercolor = self.border_color #frontside
                    
                drawLineLoop(bordercolor, corners_pos)


        if self.directionArrow.isDrawRequested():
            self.directionArrow.draw()

        glPopMatrix()
        return