예제 #1
0
    def render(self, glcanvas):
        if not self.message == '':
            glDisable(GL_LIGHTING)
            glPushMatrix()
            glLoadIdentity()

            glOrtho(-1, 1, -1, 1, -1, 1)
            # def glut_print(x, y, font, text, r, g, b, a):

            # blending = False
            # if glIsEnabled(GL_BLEND):
            #     blending = True

            # glEnable(GL_BLEND)
            glColor3f(1, 1, 1)
            glRasterPos2f(self.x, self.y)
            # on windows we must have a glutInit call
            # on mac this seems not absolutely vital
            GLUT.glutInit()
            for ch in self.message:
                GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_9_BY_15,
                                         ctypes.c_int(ord(ch)))

            # GLUT.glutBitmapString(GLUT.GLUT_BITMAP_9_BY_15, ctypes.c_char_p(self.message))

            # if not blending:
            #     glDisable(GL_BLEND)

            glPopMatrix()
            glEnable(GL_LIGHTING)
예제 #2
0
    def drawString(self, string_data):
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()

        gl.glOrtho(0, self.width, 0, self.height, -1, 1)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glPushMatrix()
        gl.glLoadIdentity()

        gl.glDisable(gl.GL_DEPTH_TEST)

        gl.glDisable(gl.GL_LIGHTING)
        gl.glColor3f(1, 0, 0)

        pos = 20
        gl.glRasterPos2i(10, self.height - pos)

        for ch in string_data:
            if ch == '\n':
                pos = pos + self.line_height
                gl.glRasterPos2i(10, self.height - pos)
            else:
                glut.glutBitmapCharacter(self._font, ord(ch))

        gl.glEnable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glPopMatrix()
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPopMatrix()
예제 #3
0
def draw_text(origin: array, text):
    GL.glColor3f(0, 0, 0)
    GL.glRasterPos2f(*origin)

    for c in text:
        GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_10,
                                 ctypes.c_int(ord(c)))
예제 #4
0
    def draw_text(self, canvas, x,y,text,align,valign):
        apply(glColor3f, self.textcolor)
        size = self.GetClientSize()
        w,h = float(size.x), float(size.y)
        glRasterPos2f(x/w,y/h)
        for char in text:
#            print x,y,self.font,char
            GLUT.glutBitmapCharacter(self.font,ord(char)) #text[0]) #self.font,text)
예제 #5
0
    def draw_text(self, canvas, x,y,text,align,valign):
        apply(glColor3f, self.textcolor)
        size = self.GetClientSize()
        w,h = float(size.x), float(size.y)
        glRasterPos2f(x/w,y/h)
        for char in text:
#            print x,y,self.font,char
            GLUT.glutBitmapCharacter(self.font,ord(char)) #text[0]) #self.font,text)
예제 #6
0
def drawGlutText(text, font):
    """Draw a text in given font at the current rasterpoint.

    font should be one  of the legal fonts returned by glutFont().
    If text is not a string, it will be formatted to a string
    before drawing.
    After drawing, the rasterpos will have been updated!
    """
    for character in str(text):
        GLUT.glutBitmapCharacter(font, ord(character))
예제 #7
0
    def display_signal_prototype(
            self, signal_dict):  #signal_dict: key -> item: signal (list)

        init_y = 0
        for key in signal_dict:
            x_pos = 10
            y_pos = init_y + 75

            text = key

            GL.glColor3f(0.0, 0.0, 0.0)  # text is black
            GL.glRasterPos2f(x_pos, y_pos)
            font = GLUT.GLUT_BITMAP_HELVETICA_12

            for character in text:
                if character == '\n':
                    y_pos = y_pos - 20
                    GL.glRasterPos2f(x_pos, y_pos)
                else:
                    GLUT.glutBitmapCharacter(font, ord(character))
            x = 30

            for signal in signal_dict[key]:

                GL.glColor3f(*self.color[key])  # signal trace is blue
                GL.glBegin(GL.GL_LINE_STRIP)

                if signal == "BLANK":
                    x += 20

                elif signal == "HIGH":
                    y = 100
                    GL.glVertex2f(x, y + init_y)
                    GL.glVertex2f(x + 20, y + init_y)

                    x += 20

                elif signal == "LOW":
                    y = 75
                    GL.glVertex2f(x, y + init_y)
                    GL.glVertex2f(x + 20, y + init_y)

                    x += 20

                elif signal == "RISING":
                    GL.glVertex2f(x, 75 + init_y)
                    GL.glVertex2f(x, 100 + init_y)

                elif signal == "FALLING":
                    GL.glVertex2f(x, 100 + init_y)
                    GL.glVertex2f(x, 75 + init_y)

                GL.glEnd()

            init_y += 50
    def paint_coordinates(self, x, y):
        GL.glBegin(GL.GL_POINTS)
        GL.glVertex3f(x, y, 0.0)
        GL.glEnd()

        string = '(' + str(x) + ',' + str(y) + ')'
        length = len(string) - 3

        GL.glRasterPos3f(x - (0.25 + length * 0.07), y - 0.15, 0.0)
        for i in range(0, len(string)):
            GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_18, ord(string[i]))
예제 #9
0
    def render_text(self, text, x_pos, y_pos):
        """Handle text drawing operations."""
        GL.glColor3f(0.0, 0.0, 0.0)  # text is black
        GL.glRasterPos2f(x_pos, y_pos)

        for character in text:
            if character == '\n':
                y_pos = y_pos - 20
                GL.glRasterPos2f(x_pos, y_pos)
            else:
                GLUT.glutBitmapCharacter(self.font, ord(character))
예제 #10
0
    def _render_text(self, text, x_pos, y_pos, z_pos):
        """Handle text drawing operations."""
        GL.glDisable(GL.GL_LIGHTING)
        GL.glRasterPos3f(x_pos, y_pos, z_pos)
        font = GLUT.GLUT_BITMAP_HELVETICA_10
        for character in text:
            if character == '\n':
                y_pos = y_pos - 20
                GL.glRasterPos3f(x_pos, y_pos, z_pos)
            else:
                GLUT.glutBitmapCharacter(font, ord(character))

        GL.glEnable(GL.GL_LIGHTING)
예제 #11
0
    def _render_text(self, text, x_pos, y_pos):
        """Handle text drawing operations."""
        GL.glColor3f(0.0, 0.0, 0.0)  # text is black
        GL.glRasterPos2f(x_pos, y_pos)
        font = GLUT.GLUT_BITMAP_HELVETICA_10

        # Format and display each character in text.
        for character in text:
            if character == '\n':
                GL.glColor3f(1.0, 0.0, 0.0)
                y_pos = y_pos - 20
                GL.glRasterPos2f(x_pos, y_pos)
            else:
                GLUT.glutBitmapCharacter(font, ord(character))
예제 #12
0
    def render_text_2D(self, text, x_pos, y_pos, colour=[1.0, 1.0, 1.0]):
        """Handle text drawing operations in 2D view."""

        GL.glColor3f(0.0, 0.0, 0.0)  # Text is black
        GL.glRasterPos2f(x_pos, y_pos)
        font = GLUT.GLUT_BITMAP_HELVETICA_12

        for character in text:
            if character == '\n':
                y_pos = y_pos - 20
                GL.glRasterPos2f(x_pos, y_pos)
            else:
                GLUT.glutBitmapCharacter(font, ord(character))

        GL.glColor3fv(colour)  # Restore colour used before function call.
예제 #13
0
    def render_text_3D(self, text, x_pos, y_pos, z_pos, colour):
        """Handle text drawing operations in 3D view."""
        GL.glDisable(GL.GL_LIGHTING)
        GL.glRasterPos3f(x_pos, y_pos, z_pos)
        font = GLUT.GLUT_BITMAP_HELVETICA_10

        for character in text:
            if character == '\n':
                y_pos = y_pos - 20
                GL.glRasterPos3f(x_pos, y_pos, z_pos)
            else:
                GLUT.glutBitmapCharacter(font, ord(character))

        GL.glEnable(GL.GL_LIGHTING)
        GL.glColor3fv(colour)  # Restore pre-function-call colour
예제 #14
0
파일: gui.py 프로젝트: ip342/GF2
    def render_text(self, text, x_pos, y_pos, font=12):
        """Handle text drawing operations."""
        GL.glColor3f(0.0, 0.0, 0.0)  # text is black
        GL.glRasterPos2f(x_pos, y_pos)
        if font == 24:
            font = GLUT.GLUT_BITMAP_HELVETICA_18
        else:
            font = GLUT.GLUT_BITMAP_HELVETICA_12

        for character in text:
            if character == '\n':
                y_pos = y_pos - 20
                GL.glRasterPos2f(x_pos, y_pos)
            else:
                GLUT.glutBitmapCharacter(font, ord(character))
예제 #15
0
def glutRenderText(text, font, gravity=''):
    """Draw a text in given font at the current rasterpoint.

    font should be one  of the legal fonts returned by glutFont().
    If text is not a string, it will be formatted to a string
    before drawing.
    After drawing, the rasterpos will have been updated!
    """
    if type(font) == str:
        font = glutFont(font)
    if gravity:
        curpos = GL.glGetFloatv(GL.GL_CURRENT_RASTER_POSITION)
        #print curpos
        GL.glRasterPos2f(curpos[0] - 20., curpos[1])
    for character in str(text):
        GLUT.glutBitmapCharacter(font, ord(character))
예제 #16
0
파일: gluttext.py 프로젝트: dladd/pyFormex
def glutRenderText(text,font,gravity=''):
    """Draw a text in given font at the current rasterpoint.

    font should be one  of the legal fonts returned by glutFont().
    If text is not a string, it will be formatted to a string
    before drawing.
    After drawing, the rasterpos will have been updated!
    """
    if type(font) == str:
        font = glutFont(font)
    if gravity:
        curpos = GL.glGetFloatv(GL.GL_CURRENT_RASTER_POSITION)
        #print curpos
        GL.glRasterPos2f(curpos[0]-20.,curpos[1])
    for character in str(text):
        GLUT.glutBitmapCharacter(font, ord(character))
예제 #17
0
파일: gui.py 프로젝트: suton5/logicsim
    def render_text(self, text, x_pos, y_pos, colour=0):
        """Handle text drawing operations."""
        if colour == 0:
            GL.glColor3f(0.0, 0.0, 0.0)  # text is black
        elif colour == 1:
            GL.glColor3f(1.0, 0.0, 0.0)
        elif colour == 2:
            GL.glColor3f(0.0, 1.0, 0.0)
        GL.glRasterPos2f(x_pos, y_pos)
        font = GLUT.GLUT_BITMAP_HELVETICA_12

        for character in text:
            if character == '\n':
                y_pos = y_pos - 20
                GL.glRasterPos2f(x_pos, y_pos)
            else:
                GLUT.glutBitmapCharacter(font, ord(character))
예제 #18
0
파일: v.py 프로젝트: mcolom/pvflip
 def drawHud(str,color=(0,1,0)):
    import OpenGL.GLUT as glut
    #  A pointer to a font style..
    #  Fonts supported by GLUT are: GLUT_BITMAP_8_BY_13,
    #  GLUT_BITMAP_9_BY_15, GLUT_BITMAP_TIMES_ROMAN_10,
    #  GLUT_BITMAP_TIMES_ROMAN_24, GLUT_BITMAP_HELVETICA_10,
    #  GLUT_BITMAP_HELVETICA_12, and GLUT_BITMAP_HELVETICA_18.
    font_style = glut.GLUT_BITMAP_8_BY_13;
    glColor3f(color[0], color[1], color[2]);
    line=0;
    glRasterPos3f (8, 13+13*line,.5)
    for i in str:
       if  i=='\n':
          line=line+1
          glRasterPos3f (8, 13+13*line,.5)
       else:
          glut.glutBitmapCharacter(font_style, ord(i))
예제 #19
0
파일: label.py 프로젝트: fos/fos-pyglet
    def init(self):


        self.list_index = gl.glGenLists(1)

        gl.glNewList( self.list_index, gl.GL_COMPILE)

        gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)

        #gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1)

        gl.glDisable(gl.GL_LIGHTING)

        gl.glColor3f(1,1,0)
        
        glut.glutSolidSphere(50.,50,50)
        
        for i in range(len(self.points)):


            r,g,b = self.colors[i]

            print r,g,b

            gl.glColor3f(r,g,b)

            x,y,z = self.points[i]

            print x,y,z

            gl.glRasterPos3f(x,y,z)

            label = self.labels[i]

            print label

            for c in label:

                print c

                glut.glutBitmapCharacter(glut.GLUT_BITMAP_TIMES_ROMAN_24, ord(c))

        gl.glEnable(gl.GL_LIGHTING)

        gl.glEnd()
예제 #20
0
def _draw_fps():
    """Dessine les fps à l'écran"""
    if not _draw_fps_bool:
        return
    gl.glColor3ui(0, 255, 0)

    t = time.time()
    elapsed = t - _StaticVars.last_time
    fps = str(math.floor(1 / elapsed))
    _StaticVars.last_time = t

    gl.glPushMatrix()
    gl.glLoadIdentity()
    gl.glRasterPos2f(-1, 0.9)
    for ch in fps:
        glut.glutBitmapCharacter(glut.GLUT_BITMAP_8_BY_13,
                                 ctypes.c_int(ord(ch)))
    gl.glPopMatrix()
예제 #21
0
파일: main.py 프로젝트: jpkell05/hyperdim
def renderString(x, y, font, s, rgb):
	GL.glViewport(0, 0, int(800), int(600))
	GL.glClearColor(0.0, 0.0, 0.0, 0.0)
	GL.glClear(GL.GL_COLOR_BUFFER_BIT)
	GL.glColor4f(1.0, 1.0, 0.5, 1.0)
	
	GL.glMatrixMode(GL.GL_PROJECTION)
	GL.glLoadIdentity()
	GL.glMatrixMode(GL.GL_MODELVIEW)
	GL.glLoadIdentity()
	GL.glTranslate(-1.0, 1.0, 0.0)
	scale = 1.0/800.0
	GL.glScale(scale, -scale*800.0/640.0, 1.0)
	GL.glTranslate(1.0, 1.0, 0.0)
	
	GL.glColor3f(rgb[0], rgb[1], rgb[2]); 	
	GL.glRasterPos(x, y)		
	for c in s:
		GLUT.glutBitmapCharacter(font, ord(c))
예제 #22
0
파일: v.py 프로젝트: carlodef/pvflip
 def drawHud(str, color=(0, 1, 0), pos=(8, 13)):
     #import OpenGL.GLUT as glut
     #  A pointer to a font style..
     #  Fonts supported by GLUT are: GLUT_BITMAP_8_BY_13,
     #  GLUT_BITMAP_9_BY_15, GLUT_BITMAP_TIMES_ROMAN_10,
     #  GLUT_BITMAP_TIMES_ROMAN_24, GLUT_BITMAP_HELVETICA_10,
     #  GLUT_BITMAP_HELVETICA_12, and GLUT_BITMAP_HELVETICA_18.
     font_style = glut.GLUT_BITMAP_8_BY_13
     if display_scale > 1:  # RETINA
         font_style = glut.GLUT_BITMAP_HELVETICA_18
     glColor3f(color[0], color[1], color[2])
     line = 0
     glRasterPos3f(pos[0], pos[1] + 13 * line, .5)
     for i in str:
         if i == '\n':
             line = line + 1
             glRasterPos3f(pos[0], pos[1] + 13 * line, .5)
         else:
             glut.glutBitmapCharacter(font_style, ord(i))
예제 #23
0
 def createChar(self, char, mode=None):
     """Create the single-character display list
     """
     metrics = font.CharacterMetrics(
         char, GLUT.glutBitmapWidth(self.specifier, ord(char)),
         self.charHeight)
     list = glGenLists(1)
     glNewList(list, GL_COMPILE)
     try:
         try:
             if metrics.char != ' ':
                 GLUT.glutBitmapCharacter(self.specifier, ord(char))
             else:
                 glBitmap(0, 0, 0, 0, metrics.width, 0, None)
         except Exception:
             glDeleteLists(list, 1)
             list = None
     finally:
         glEndList()
     return list, metrics
예제 #24
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_BLEND)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],self.parameters.lowerleft[1],0.0)

                c = self.parameters.color

                if len(c)==3:
                    gl.glColor3f(*c)
                elif len(c)==4:
                    gl.glColor4f(*c)
                gl.glDisable(gl.GL_TEXTURE_2D)

                gl.glRasterPos3f(0.0,0.0,0.0)
                for char in self.parameters.text:
                    glut.glutBitmapCharacter(self.parameters.font,ord(char))
                gl.glPopMatrix()
예제 #25
0
 def createChar( self, char, mode=None ):
     """Create the single-character display list
     """
     metrics = font.CharacterMetrics(
         char,
         GLUT.glutBitmapWidth(self.specifier, ord(char)),
         self.charHeight
     )
     list = glGenLists (1)
     glNewList( list, GL_COMPILE )
     try:
         try:
             if metrics.char != ' ':
                 GLUT.glutBitmapCharacter( self.specifier, ord(char) )
             else:
                 glBitmap( 0,0,0,0, metrics.width, 0, None )
         except Exception:
             glDeleteLists( list, 1 )
             list = None
     finally:
         glEndList()
     return list, metrics
예제 #26
0
def drawText(value,
             x,
             y,
             windowHeight,
             windowWidth,
             color=(1, 1, 1),
             font=GLUT.GLUT_BITMAP_HELVETICA_18,
             step=18):
    """Draw the given text at given 2D position in window
       http://www.math.uiuc.edu/~gfrancis/illimath/windows/aszgard_mini/pylibs/OpenGLContext/tests/glutbitmapcharacter.py
    """
    glMatrixMode(GL_PROJECTION)
    # For some reason the GL_PROJECTION_MATRIX is overflowing with a single push!
    # glPushMatrix()
    matrix = glGetDouble(GL_PROJECTION_MATRIX)

    glDisable(GL_DEPTH_TEST)
    glLoadIdentity()
    glOrtho(0.0, windowHeight or 32, 0.0, windowWidth or 32, -1.0, 1.0)
    glMatrixMode(GL_MODELVIEW)
    glPushMatrix()
    glLoadIdentity()
    glRasterPos2i(int(x), int(y))
    glColor3f(color[0], color[1], color[2])
    lines = 0
    for character in value:
        if character == '\n':
            glRasterPos2i(int(x), int(y) - (lines * step))
        else:
            GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_18,
                                     ord(character))
    glPopMatrix()
    glMatrixMode(GL_PROJECTION)
    # For some reason the GL_PROJECTION_MATRIX is overflowing with a single push!
    # glPopMatrix();
    glLoadMatrixd(matrix)  # should have un-decorated alias for this...

    glMatrixMode(GL_MODELVIEW)
예제 #27
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_BLEND)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],
                               self.parameters.lowerleft[1], 0.0)

                c = self.parameters.color

                if len(c) == 3:
                    gl.glColor3f(*c)
                elif len(c) == 4:
                    gl.glColor4f(*c)
                gl.glDisable(gl.GL_TEXTURE_2D)

                gl.glRasterPos3f(0.0, 0.0, 0.0)
                for char in self.parameters.text:
                    glut.glutBitmapCharacter(self.parameters.font, ord(char))
                gl.glPopMatrix()
예제 #28
0
def drawText(text, x,y, font='9x15', adjust='left'):
    """Draw the given text at given 2D position in window.

    If adjust == 'center', the text will be horizontally centered on
    the insertion point.
    If adjust == 'right', the text will be right aligned on the point.
    Any other setting will align the text left.
    Default is to center.
    """
    if type(font) == str:
        font = glutFont(font)
    #print "font = ",font
    if adjust != 'left':
        len1 = myBitmapLength(font, text)
        len2 = GLUT.glutBitmapLength(font, text)
        if len1 != len2:
            print "incorrect glutBitmapLength",len1,len2
        if adjust == 'center':
            x -= len1/2
        elif adjust == 'right':
            x -= len1 
    GL.glRasterPos2f(float(x),float(y));
    for character in text:
        GLUT.glutBitmapCharacter(font, ord(character));
예제 #29
0
파일: VueOpenGL.py 프로젝트: python4d/imd
  def mDrawAxes(self):
    _anti_zoom=self.pz*0.1
    _flag_texture=gl.glIsEnabled(gl.GL_TEXTURE_2D)
    _flag_color_mat=gl.glIsEnabled(gl.GL_COLOR_MATERIAL)
    _flag_lighting=gl.glIsEnabled(gl.GL_LIGHTING)
    gl.glDisable(gl.GL_TEXTURE_2D)  
    gl.glDisable(gl.GL_DEPTH_TEST)
    gl.glDisable(gl.GL_COLOR_MATERIAL)
    gl.glDisable(gl.GL_LIGHTING)
    
    gl.glPushMatrix ()    
    gl.glTranslate(0,0,0)
    gl.glScalef(_anti_zoom,_anti_zoom,_anti_zoom)

    gl.glLineWidth (2.0)

    gl.glBegin (gl.GL_LINES)
    gl.glColor3d(1,0,0) # X axis is red.
    gl.glVertex3d(0,0,0)
    gl.glVertex3d(1,0,0 )
    gl.glEnd()
    gl.glRasterPos3f(1.2, 0.0, 0.0)
    glut.glutBitmapCharacter(glut.GLUT_BITMAP_9_BY_15, ord('x'))
    gl.glBegin (gl.GL_LINES)
    gl.glColor3d(0,1,0) # Y axis is green.
    gl.glVertex3d(0,0,0)
    gl.glVertex3d(0,1,0)
    gl.glEnd()    
    gl.glRasterPos3f(0.0, 1.2, 0.0)
    glut.glutBitmapCharacter(glut.GLUT_BITMAP_9_BY_15, ord('y'))
    gl.glBegin (gl.GL_LINES)    
    gl.glColor3d(0,0,1); # z axis is blue.
    gl.glVertex3d(0,0,0)
    gl.glVertex3d(0,0,1)
    gl.glEnd()    
    gl.glRasterPos3f(0.0, 0.0, 1.2)
    glut.glutBitmapCharacter(glut.GLUT_BITMAP_9_BY_15, ord('z'))
    gl.glPopMatrix()   

    if _flag_texture==True: gl.glEnable(gl.GL_TEXTURE_2D)
    gl.glEnable(gl.GL_DEPTH_TEST)
    if _flag_color_mat==True:gl.glEnable(gl.GL_COLOR_MATERIAL)
    if _flag_lighting==True:gl.glEnable(gl.GL_LIGHTING)
예제 #30
0
    def create_axes_list(self):
        '''Creates display lists to render unit length x,y,z axes.'''
        import OpenGL.GL as gl
        gl.glNewList(self.gllist_id, gl.GL_COMPILE)
        gl.glBegin(gl.GL_LINES)
        gl.glColor3f(1.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(1.0, 0.0, 0.0)
        gl.glColor3f(0.0, 1.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 1.0, 0.0)
        gl.glColor3f(-.0, 0.0, 1.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 1.0)

        gl.glColor3f(1.0, 1.0, 1.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(-1.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, -1.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, -1.0)
        gl.glEnd()

        if self._have_glut:
            try:
                import OpenGL.GLUT as glut
                if bool(glut.glutBitmapCharacter):
                    gl.glRasterPos3f(1.05, 0.0, 0.0)
                    glut.glutBitmapCharacter(glut.GLUT_BITMAP_HELVETICA_18,
                                             ord('x'))
                    gl.glRasterPos3f(0.0, 1.05, 0.0)
                    glut.glutBitmapCharacter(glut.GLUT_BITMAP_HELVETICA_18,
                                             ord('y'))
                    gl.glRasterPos3f(0.0, 0.0, 1.05)
                    glut.glutBitmapCharacter(glut.GLUT_BITMAP_HELVETICA_18,
                                             ord('z'))
            except:
                pass
        gl.glEndList()
예제 #31
0
    def paint_exit(self):
        """
        Implements the GLNodeAdapter's paint_exit method for an OpenGL Render operation.
        """
        with GLAttribScope(GL.GL_ENABLE_BIT | GL.GL_CURRENT_BIT):
            with GLColorScope( QtCore.Qt.GlobalColor.white ):
                GL.glDisable(GL.GL_DEPTH_TEST)

                GL.glRasterPos3fv(self._node.xaxis.data())
                GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_12, ord('X'))

                GL.glRasterPos3fv(self._node.yaxis.data())
                GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_12, ord('Y'))
                
                GL.glRasterPos3fv(self._node.zaxis.data())
                GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_12, ord('Z'))
                #curpos = GL.glGetFloatv(GL.GL_CURRENT_RASTER_POSITION)
                #textWidth = GLUT.glutBitmapWidth(GLUT.GLUT_BITMAP_HELVETICA_12, ord('Z'))
                #GL.glRasterPos2f(curpos[0],curpos[1])

        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPopMatrix()
 def paint_string(self, string, x, y):
     GL.glWindowPos2s(x, y)
     for i in range(0, len(string)):
         GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_HELVETICA_12, ord(string[i]))
예제 #33
0
 def text(x, y, text):
     GL.glRasterPos2f(x, y)
     for ch in text:
         GLUT.glutBitmapCharacter(GLUT.GLUT_BITMAP_9_BY_15, ord(ch))
예제 #34
0
파일: tracks.py 프로젝트: arokem/Fos
    def display(self):


        if self.near_pick!= None:

            #print self.near_pick

            if np.sum(np.equal(self.near_pick, self.near_pick_prev))< 3:        

                self.process_picking(self.near_pick, self.far_pick)             
              
                self.near_pick_prev = self.near_pick

                self.far_pick_prev = self.far_pick
      

                
        
    
        x,y,z=self.position

        if self.orbit_demo and self.angle_table == None:

            gl.glPushMatrix()

            self.orbit_anglex+=self.orbit_anglex_rate
            
            gl.glRotatef(self.orbit_anglex,1,0,0)

            gl.glPushMatrix()

            self.orbit_anglez+=self.orbit_anglez_rate

            x,y,z=self.position

           

            gl.glRotatef(self.orbit_anglez,0,0,1)

            gl.glTranslatef(x,y,z) 


            #gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)

            gl.glCallList(self.list_index)

            gl.glFinish()

            gl.glPopMatrix()

            gl.glPopMatrix()


        elif self.orbit_demo == True and self.angle_table != None:

            
            
            gl.glPushMatrix()

            #print angle_table

            #print table_ind

            global angle_table_index

            table_ind=angle_table_index

            anglex=angle_table[table_ind,0]

            #print anglex

            gl.glRotatef(anglex,1,0,0)
            
            
            gl.glPushMatrix()

            angley=angle_table[table_ind,1]

            gl.glRotatef(angley,0,1,0)
            

            gl.glPushMatrix()

            anglez=angle_table[table_ind,2]

            gl.glRotatef(anglez,0,0,1)


            gl.glTranslate(x,y,z)
            
            gl.glCallList(self.list_index)

            gl.glFinish()

            gl.glPopMatrix()

            gl.glPopMatrix()

            gl.glPopMatrix()

            angle_table_index += 1

            if angle_table_index >= angle_table.shape[0]:
                
                angle_table_index = angle_table.shape[0] - 1

            

            '''

            gl.glPushMatrix()

            gl.glRotatef(self.angle_table[self.angle_table_index,0],1,0,0)

            #x,y,z = self.position
            
            gl.glPushMatrix()

            gl.glRotatef(self.angle_table[self.angle_table_index,1],0,1,0)

            gl.glPushMatrix()

            gl.glRotatef(self.angle_table[self.angle_table_index,2],0,0,1)

            gl.glTranslate(x,y,z)
            
            gl.glCallList(self.list_index)

            gl.glFinish()

            gl.glPopMatrix()

            gl.glPopMatrix()

            gl.glPopMatrix()

            self.angle_table_index += 1

            if self.angle_table_index >= self.angle_table.shape[0]:
                
                self.angle_table_index = self.angle_table.shape[0] - 1

            '''
            
        else:

            gl.glCallList(self.list_index)




            if self.picked_track != None:

                self.display_one_track(self.picked_track)



            if self.yellow_indices != None:

                for i in self.yellow_indices:


                    self.display_one_track(i)


        if self.text != None:

            gl.glDisable(gl.GL_LIGHTING)
            
            gl.glColor3f(0.,0.47,.76)

            for (i,t) in enumerate(self.data):

                #gl.glRasterPos3f(t[0][0],t[0][1],t[0][2])
            
                label = self.text+str(i)

                t2=tm.downsample(t,3)

                gl.glRasterPos3f(t2[1][0],t2[1][1],t2[1][2])
                
                for c in label:

                    glut.glutBitmapCharacter(glut.GLUT_BITMAP_TIMES_ROMAN_24, ord(c))
                

                '''

                if i == 22: #cortico spinal track

                    gl.glRasterPos3f(t[0][0],t[0][1],t[0][2])


                    label='spine'

                    for c in label:

                        glut.glutBitmapCharacter(glut.GLUT_BITMAP_TIMES_ROMAN_24, ord(c))

                    gl.glRasterPos3f(t[-1][0],t[-1][1],t[-1][2])


                    label='motor'

                    for c in label:

                        glut.glutBitmapCharacter(glut.GLUT_BITMAP_TIMES_ROMAN_24, ord(c))

                    

                    label='corticospinal'

                    t2=tm.downsample(t,len(label)+3)

                    for (ci,c) in enumerate(label[::-1]):
                        
                        gl.glRasterPos3f(t2[ci+2][0],t2[ci+2][1],t2[ci+2][2])

                        glut.glutBitmapCharacter(glut.GLUT_BITMAP_TIMES_ROMAN_24, ord(c))

                else:

                    pass

                '''
                

                '''

                    gl.glRasterPos3f(t[0][0],t[0][1],t[0][2])

                    for c in label:

                        glut.glutBitmapCharacter(glut.GLUT_BITMAP_TIMES_ROMAN_24, ord(c))

                '''
                
            gl.glEnable(gl.GL_LIGHTING)

        gl.glFinish()        
예제 #35
0
 def draw_text(self, pos, text, font=GLUT.GLUT_BITMAP_HELVETICA_18):
     self.push()
     GL.glRasterPos(*pos)
     for c in text:
         GLUT.glutBitmapCharacter(font, ord(c))
     self.pop()
예제 #36
0
 def draw_text(self, pos, text, font=GLUT.GLUT_BITMAP_HELVETICA_18):
     self.push()
     GL.glRasterPos(*pos)
     for c in text:
         GLUT.glutBitmapCharacter(font, ord(c))
     self.pop()
예제 #37
0
    def DrawColony(self,
                   colony,
                   xangle,
                   yangle,
                   size=0.1,
                   color=(1.0, 1.0, 0.0),
                   show_index=False,
                   single_object_mode=True):
        # print "draw colony:"#, object.objname
        #original_color = color
        # i = 0
        gl.glColor3f(color[0], color[1], color[2])
        gl.glLoadIdentity()
        gl.glPushMatrix()
        # glTranslate(0, 0, self.offset)
        gl.glRotatef(yangle, 1.0, 0.0, 0.0)
        gl.glRotatef(xangle, 0.0, 1.0, 0.0)

        #    single_object_mode = True
        if not single_object_mode:
            # print "point size, glbegin"
            gl.glPointSize(5)
            gl.glDisable(gl.GL_LIGHTING)
            gl.glBegin(gl.GL_POINTS)

        for cr in colony.polyp_list:
            if cr.dead:
                # continue
                # glColor3f( self.color.selected_landmark[0], self.color.selected_landmark[1], self.color.selected_landmark[2] )
                gl.glColor3f(0.1, 0.1, 0.1)
            elif cr.selected:
                # print cr.id, "selected"
                gl.glColor3f(0.5, 0.5, 0.0)
            elif cr.is_neighbor:
                # print cr.id, "neighbor"
                gl.glColor3f(0.2, 0.2, 0.5)
            else:
                gl.glColor3f(color[0], color[1], color[2])

            if single_object_mode:
                gl.glPushMatrix()
                gl.glTranslate(cr.pos[0], cr.pos[1], cr.pos[2])
                if cr.dead:
                    glut.glutSolidSphere(1, 20, 20)  # glutSolidCube( size )
                else:
                    glut.glutSolidSphere(1, 20, 20)  # glutSolidCube( size )

                gl.glPopMatrix()
            else:
                gl.glVertex3f(cr.pos[0], cr.pos[1], cr.pos[2])

        if not single_object_mode:
            # print "glend"
            gl.glEnd()
            gl.glEnable(gl.GL_LIGHTING)

        if show_index:
            i = 0
            for cr in colony.polyp_list:
                i += 1
                if cr.dead: continue
                gl.glDisable(gl.GL_LIGHTING)
                gl.glColor3f(.5, .5, 1.0)
                gl.glRasterPos3f(cr.pos[0], cr.pos[1] + size * 2, cr.pos[2])
                for letter in list(str(i)):
                    glut.glutBitmapCharacter(glut.GLUT_BITMAP_HELVETICA_18,
                                             ord(letter))
                gl.glEnable(gl.GL_LIGHTING)
        gl.glPopMatrix()
예제 #38
0
    def drawCornerAxis(self):
        # The viewport and the scissor are changed to fit the lower left
        # corner. Original values are saved.
        viewport = ogl.glGetIntegerv(ogl.GL_VIEWPORT)
        scissor = ogl.glGetIntegerv(ogl.GL_SCISSOR_BOX)

        # Axis viewport size, in pixels
        size = 150
        ogl.glViewport(0, 0, size, size)
        ogl.glScissor(0, 0, size, size)

        # The Z-buffer is cleared to make the axis appear over the
        # original image.
        ogl.glClear(ogl.GL_DEPTH_BUFFER_BIT)

        # Tune for best line rendering
        ogl.glDisable(ogl.GL_LIGHTING)
        ogl.glLineWidth(3.0)

        ogl.glMatrixMode(ogl.GL_PROJECTION)
        ogl.glPushMatrix()
        ogl.glLoadIdentity()
        ogl.glOrtho(-1, 1, -1, 1, -1, 1)

        ogl.glMatrixMode(ogl.GL_MODELVIEW)
        ogl.glPushMatrix()
        ogl.glLoadIdentity()
        ogl.glMultMatrixd(self.camera().orientation().inverse().matrix())

        ogl.glBegin(ogl.GL_LINES)
        ogl.glColor3f(1.0, 0.0, 0.0)
        ogl.glVertex3f(0.0, 0.0, 0.0)
        ogl.glVertex3f(0.5, 0.0, 0.0)

        ogl.glColor3f(0.0, 1.0, 0.0)
        ogl.glVertex3f(0.0, 0.0, 0.0)
        ogl.glVertex3f(0.0, 0.5, 0.0)

        ogl.glColor3f(0.0, 0.0, 1.0)
        ogl.glVertex3f(0.0, 0.0, 0.0)
        ogl.glVertex3f(0.0, 0.0, 0.5)
        ogl.glEnd()

        oglut.glutInit()
        ogl.glColor(1, 0, 0)
        ogl.glRasterPos3f(0.6, 0.0, 0.0)
        oglut.glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 88)  # ascii x
        ogl.glColor(0, 1, 0)
        ogl.glRasterPos3f(0.0, 0.6, 0.0)
        oglut.glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 89)  # ascii y
        ogl.glColor(0, 0, 1)
        ogl.glRasterPos3f(0.0, 0.0, 0.6)
        oglut.glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 90)  # ascii z

        ogl.glMatrixMode(ogl.GL_PROJECTION)
        ogl.glPopMatrix()

        ogl.glMatrixMode(ogl.GL_MODELVIEW)
        ogl.glPopMatrix()

        ogl.glEnable(ogl.GL_LIGHTING)

        # The viewport and the scissor are restored.
        ogl.glScissor(*scissor)
        ogl.glViewport(*viewport)
예제 #39
0
    def drawCornerAxis(self):
        # The viewport and the scissor are changed to fit the lower left
        # corner. Original values are saved.
        viewport = ogl.glGetIntegerv(ogl.GL_VIEWPORT)
        scissor = ogl.glGetIntegerv(ogl.GL_SCISSOR_BOX)

        # Axis viewport size, in pixels
        size = 150
        ogl.glViewport(0, 0, size, size)
        ogl.glScissor(0, 0, size, size)

        # The Z-buffer is cleared to make the axis appear over the
        # original image.
        ogl.glClear(ogl.GL_DEPTH_BUFFER_BIT)

        # Tune for best line rendering
        ogl.glDisable(ogl.GL_LIGHTING)
        ogl.glLineWidth(3.0)

        ogl.glMatrixMode(ogl.GL_PROJECTION)
        ogl.glPushMatrix()
        ogl.glLoadIdentity()
        ogl.glOrtho(-1, 1, -1, 1, -1, 1)

        ogl.glMatrixMode(ogl.GL_MODELVIEW)
        ogl.glPushMatrix()
        ogl.glLoadIdentity()
        ogl.glMultMatrixd(self.camera().orientation().inverse().matrix())

        ogl.glBegin(ogl.GL_LINES)
        ogl.glColor3f(1.0, 0.0, 0.0)
        ogl.glVertex3f(0.0, 0.0, 0.0)
        ogl.glVertex3f(0.5, 0.0, 0.0)

        ogl.glColor3f(0.0, 1.0, 0.0)
        ogl.glVertex3f(0.0, 0.0, 0.0)
        ogl.glVertex3f(0.0, 0.5, 0.0)

        ogl.glColor3f(0.0, 0.0, 1.0)
        ogl.glVertex3f(0.0, 0.0, 0.0)
        ogl.glVertex3f(0.0, 0.0, 0.5)
        ogl.glEnd()

        oglut.glutInit()
        ogl.glColor(1, 0, 0)
        ogl.glRasterPos3f(0.6, 0.0, 0.0)
        oglut.glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 88)  #ascii x
        ogl.glColor(0, 1, 0)
        ogl.glRasterPos3f(0.0, 0.6, 0.0)
        oglut.glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 89)  #ascii y
        ogl.glColor(0, 0, 1)
        ogl.glRasterPos3f(0.0, 0.0, 0.6)
        oglut.glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 90)  #ascii z

        ogl.glMatrixMode(ogl.GL_PROJECTION)
        ogl.glPopMatrix()

        ogl.glMatrixMode(ogl.GL_MODELVIEW)
        ogl.glPopMatrix()

        ogl.glEnable(ogl.GL_LIGHTING)

        # The viewport and the scissor are restored.
        ogl.glScissor(*scissor)
        ogl.glViewport(*viewport)
예제 #40
0
파일: gldraw.py 프로젝트: smeng9/Klampt
def glutBitmapString(font, string):
    """Renders a string using GLUT characters"""
    for c in string:
        GLUT.glutBitmapCharacter(font, ctypes.c_int(ord(c)))
예제 #41
0
    def DrawColony(self, colony, xangle, yangle, size=0.1, color=(1.0, 1.0, 0.0), show_index=False,
                                 single_object_mode=True):
        # print "draw colony:"#, object.objname
        #original_color = color
        # i = 0
        gl.glColor3f(color[0], color[1], color[2])
        gl.glLoadIdentity()
        gl.glPushMatrix()
        # glTranslate(0, 0, self.offset)
        gl.glRotatef(yangle, 1.0, 0.0, 0.0)
        gl.glRotatef(xangle, 0.0, 1.0, 0.0)

        #    single_object_mode = True
        if not single_object_mode:
            # print "point size, glbegin"
            gl.glPointSize(5)
            gl.glDisable(gl.GL_LIGHTING)
            gl.glBegin(gl.GL_POINTS)

        for cr in colony.polyp_list:
            if cr.dead:
                # continue
                # glColor3f( self.color.selected_landmark[0], self.color.selected_landmark[1], self.color.selected_landmark[2] )
                gl.glColor3f(0.1, 0.1, 0.1)
            elif cr.selected:
                # print cr.id, "selected"
                gl.glColor3f(0.5, 0.5, 0.0)
            elif cr.is_neighbor:
                # print cr.id, "neighbor"
                gl.glColor3f(0.2, 0.2, 0.5)
            else:
                gl.glColor3f(color[0], color[1], color[2])

            if single_object_mode:
                gl.glPushMatrix()
                gl.glTranslate(cr.pos[0], cr.pos[1], cr.pos[2])
                if cr.dead:
                    glut.glutSolidSphere(1, 20, 20)  # glutSolidCube( size )
                else:
                    glut.glutSolidSphere(1, 20, 20)  # glutSolidCube( size )

                gl.glPopMatrix()
            else:
                gl.glVertex3f(cr.pos[0], cr.pos[1], cr.pos[2])

        if not single_object_mode:
            # print "glend"
            gl.glEnd()
            gl.glEnable(gl.GL_LIGHTING)

        if show_index:
            i = 0
            for cr in colony.polyp_list:
                i += 1
                if cr.dead: continue
                gl.glDisable(gl.GL_LIGHTING)
                gl.glColor3f(.5, .5, 1.0)
                gl.glRasterPos3f(cr.pos[0], cr.pos[1] + size * 2, cr.pos[2])
                for letter in list(str(i)):
                    glut.glutBitmapCharacter(glut.GLUT_BITMAP_HELVETICA_18, ord(letter))
                gl.glEnable(gl.GL_LIGHTING)
        gl.glPopMatrix()