Example #1
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)
Example #2
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)
Example #3
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()
Example #5
0
    def draw_after_highlighting(self, glpane, dispdef, pickCheckOnly=False):
        """
        Things to draw after highlighting. Subclasses can override this 
        method. This API method ensures that, when user clicks on the filled
        area of a plane, the plane gets selected. 
                
        @param pickCheckOnly: This flag in conjunction with this API method
                allows selection of the plane when you click inside the plane 
                 (i.e. not along the highlighted plane borders) . 
                 (Note: flag copied over from the old implementation 
                 before 2008-06-20)
        @type pickCheckOnly: boolean
        
        @return: A boolean flag 'anythingDrawn' that tells whether this method
                 drew something. 
        @rtype: boolean
        
        @see: Node.draw_after_highlighting() which is overridden here   
        """
        #This implementation fixes bug 2900
        anythingDrawn = False

        if self.hidden:
            return anythingDrawn

        self.pickCheckOnly = pickCheckOnly

        try:
            anythingDrawn = True

            glPushName(self.glname)
            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)

            if dot(self.getaxis(), glpane.lineOfSight) < 0:
                fill_color = brown  #backside
            else:
                fill_color = self.fill_color

            # Urmi-20080613: display grid lines on the plane

            if env.prefs[PlanePM_showGrid_prefs_key]:
                drawGPGridForPlane(self.glpane, self.gridColor,
                                   self.gridLineType, self.width, self.height,
                                   self.gridXSpacing, self.gridYSpacing,
                                   self.quat.unrot(self.glpane.up),
                                   self.quat.unrot(self.glpane.right),
                                   env.prefs[PlanePM_showGridLabels_prefs_key],
                                   self.originLocation, self.displayLabelStyle)

            textureReady = False

            if self.display_image and \
               self.tex_image:
                textureReady = True
                glBindTexture(GL_TEXTURE_2D, self.tex_image)
                fill_color = [1.0, 1.0, 1.0]

            if self.display_heightfield:
                if self.heightfield and \
                   self.image:
                    if not self.heightfield_use_texture:
                        textureReady = False
                    drawHeightfield(fill_color,
                                    self.width,
                                    self.height,
                                    textureReady,
                                    self.opacity,
                                    SOLID=True,
                                    pickCheckOnly=self.pickCheckOnly,
                                    hf=self.heightfield)
            else:
                drawPlane(fill_color,
                          self.width,
                          self.height,
                          textureReady,
                          self.opacity,
                          SOLID=True,
                          pickCheckOnly=self.pickCheckOnly,
                          tex_coords=self.tex_coords)

            glPopMatrix()

        except:
            anythingDrawn = False
            glPopName()
            print_compact_traceback(
                "ignoring exception when drawing Plane %r: " % self)
        else:
            glPopName()

        return anythingDrawn
Example #6
0
 def draw_after_highlighting(self,  glpane, dispdef, pickCheckOnly = False):
     """
     Things to draw after highlighting. Subclasses should override this 
     method. This API method ensures that , when user clicks on the filled
     area of a plane, the plane gets selected. 
             
     @param pickCheckOnly: This flag in conjunction with this API method
             allows selection of the plane when you click inside the plane 
              (i.e. not along the highlighted plane borders) . 
              (Note flag copied over from the old implementation 
              before 2008-06-20)
     @type pickCheckOnly: boolean
     
     @return: A boolean flag 'anythingDrawn' that tells whether this method
              drew something. 
     @rtype: boolean
     
     @see: GraphicsMode.Draw_after_highlighting()
     @see: Node.draw_after_highlighting() which is overridden here   
     """      
     #This implementation fixes bug 2900
     anythingDrawn = False
     
     if self.hidden:
         return False
     
     self.pickCheckOnly = pickCheckOnly
     
     try:
         anythingDrawn = True
         
         glPushName(self.glname)
         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)   
    
         if dot(self.getaxis(), glpane.lineOfSight) < 0:
             fill_color = brown #backside
         else:
             fill_color = self.fill_color
          
         # Urmi-20080613: display grid lines on the plane
 
         if env.prefs[PlanePM_showGrid_prefs_key]:
             drawGPGridForPlane(self.glpane, self.gridColor, self.gridLineType, 
                                self.width, self.height, 
                                self.gridXSpacing, self.gridYSpacing,
                                self.quat.unrot(self.glpane.up), 
                                self.quat.unrot(self.glpane.right), 
                                env.prefs[PlanePM_showGridLabels_prefs_key], 
                                self.originLocation, 
                                self.displayLabelStyle)
             
         textureReady = False
 
         if self.display_image and \
            self.tex_image:
             textureReady = True
             glBindTexture(GL_TEXTURE_2D, self.tex_image)
             fill_color = [1.0,1.0,1.0]
             
         if self.display_heightfield:
             if self.heightfield and \
                self.image:
                 if not self.heightfield_use_texture:
                     textureReady = False
                 drawHeightfield(fill_color, 
                           self.width, 
                           self.height, 
                           textureReady,
                           self.opacity, 
                           SOLID=True, 
                           pickCheckOnly=self.pickCheckOnly,
                           hf=self.heightfield)
         else:
             drawPlane(fill_color, 
                       self.width, 
                       self.height, 
                       textureReady,
                       self.opacity, 
                       SOLID=True, 
                       pickCheckOnly=self.pickCheckOnly,
                       tex_coords=self.tex_coords)
  
         glPopMatrix()
         
     except:
         anythingDrawn = False
         glPopName()
         print_compact_traceback(
             "ignoring exception when drawing Plane %r: " % self)
     else:
         glPopName()
     
     return anythingDrawn