Exemplo n.º 1
0
    def draw(self):
        x, y, w, h = self.getSize()

        glPushMatrix()
        glTranslatef(x, y, 0)

        if self.hasFocus():
            glColor4ub(255, 255, 255, 255)
        else:
            glColor4ub(255, 255, 255, 192)
        glBegin(GL_QUADS)
        glTexCoord2f(1, 0)
        glVertex2f(w, 0)
        glTexCoord2f(0, 0)
        glVertex2f(0, 0)
        glTexCoord2f(0, 1)
        glVertex2f(0, h - 1)
        glTexCoord2f(1, 1)
        glVertex2f(w, h - 1)
        glEnd()

        glTranslate(5, h - 5, 0)
        glColor4ub(0, 0, 0, 255)
        openglHelpers.glDrawStringLeft(self._value)
        if self.hasFocus():
            glTranslate(
                openglHelpers.glGetStringSize(
                    self._value[0:self._selectPos])[0] - 2, -1, 0)
            openglHelpers.glDrawStringLeft('|')
        glPopMatrix()
Exemplo n.º 2
0
	def draw(self):
		x, y, w, h = self.getSize()

		glPushMatrix()
		glTranslatef(x, y, 0)

		if self.hasFocus():
			glColor4ub(255,255,255,255)
		else:
			glColor4ub(255,255,255,192)
		glBegin(GL_QUADS)
		glTexCoord2f(1, 0)
		glVertex2f( w, 0)
		glTexCoord2f(0, 0)
		glVertex2f( 0, 0)
		glTexCoord2f(0, 1)
		glVertex2f( 0, h-1)
		glTexCoord2f(1, 1)
		glVertex2f( w, h-1)
		glEnd()

		glTranslate(5, h - 5, 0)
		glColor4ub(0,0,0,255)
		openglHelpers.glDrawStringLeft(self._value)
		if self.hasFocus():
			glTranslate(openglHelpers.glGetStringSize(self._value[0:self._selectPos])[0] - 2, -1, 0)
			openglHelpers.glDrawStringLeft('|')
		glPopMatrix()
Exemplo n.º 3
0
    def _OnGuiPaint(self, e):
        self._idleCalled = False
        h = self.GetSize().GetHeight()
        w = self.GetSize().GetWidth()
        oldButtonSize = self._buttonSize
        if h / 3 < w / 4:
            w = h * 4 / 3
        if w < 64 * 8:
            self._buttonSize = 32
        elif w < 64 * 10:
            self._buttonSize = 48
        elif w < 64 * 15:
            self._buttonSize = 64
        elif w < 64 * 20:
            self._buttonSize = 80
        else:
            self._buttonSize = 96
        if self._buttonSize != oldButtonSize:
            self._container.updateLayout()

        dc = wx.PaintDC(self)
        try:
            self.SetCurrent(self._context)
            for obj in self.glReleaseList:
                obj.release()
            del self.glReleaseList[:]
            renderStartTime = time.time()
            self.OnPaint(e)
            self._drawGui()
            glFlush()
            if version.isDevVersion():
                renderTime = time.time() - renderStartTime
                if renderTime == 0:
                    renderTime = 0.001
                glLoadIdentity()
                glTranslate(10, self.GetSize().GetHeight() - 30, -1)
                glColor4f(0.2, 0.2, 0.2, 0.5)
                openglHelpers.glDrawStringLeft("fps:%d" % (1 / renderTime))
            self.SwapBuffers()
        except:
            # When an exception happens, catch it and show a message box. If the exception is not caught the draw function bugs out.
            # Only show this exception once so we do not overload the user with popups.
            errStr = _("An error has occurred during the 3D view drawing.")
            tb = traceback.extract_tb(sys.exc_info()[2])
            errStr += "\n%s: '%s'" % (str(
                sys.exc_info()[0].__name__), str(sys.exc_info()[1]))
            for n in xrange(len(tb) - 1, -1, -1):
                locationInfo = tb[n]
                errStr += "\n @ %s:%s:%d" % (os.path.basename(
                    locationInfo[0]), locationInfo[2], locationInfo[1])
            if not self._shownError:
                traceback.print_exc()
                wx.CallAfter(wx.MessageBox, errStr, _("3D window error"),
                             wx.OK | wx.ICON_EXCLAMATION)
                self._shownError = True
Exemplo n.º 4
0
	def _OnGuiPaint(self, e):
		self._idleCalled = False
		h = self.GetSize().GetHeight()
		w = self.GetSize().GetWidth()
		oldButtonSize = self._buttonSize
		if h / 3 < w / 4:
			w = h * 4 / 3
		if w < 64 * 8:
			self._buttonSize = 32
		elif w < 64 * 10:
			self._buttonSize = 48
		elif w < 64 * 15:
			self._buttonSize = 64
		elif w < 64 * 20:
			self._buttonSize = 80
		else:
			self._buttonSize = 96
		if self._buttonSize != oldButtonSize:
			self._container.updateLayout()

		dc = wx.PaintDC(self)
		try:
			self.SetCurrent(self._context)
			for obj in self.glReleaseList:
				obj.release()
			del self.glReleaseList[:]
			renderStartTime = time.time()
			self.OnPaint(e)
			self._drawGui()
			glFlush()
			if version.isDevVersion():
				renderTime = time.time() - renderStartTime
				if renderTime == 0:
					renderTime = 0.001
				glLoadIdentity()
				glTranslate(10, self.GetSize().GetHeight() - 30, -1)
				glColor4f(0.2,0.2,0.2,0.5)
				openglHelpers.glDrawStringLeft("fps:%d" % (1 / renderTime))
			self.SwapBuffers()
		except:
			# When an exception happens, catch it and show a message box. If the exception is not caught the draw function bugs out.
			# Only show this exception once so we do not overload the user with popups.
			errStr = _("An error has occurred during the 3D view drawing.")
			tb = traceback.extract_tb(sys.exc_info()[2])
			errStr += "\n%s: '%s'" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]))
			for n in xrange(len(tb)-1, -1, -1):
				locationInfo = tb[n]
				errStr += "\n @ %s:%s:%d" % (os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])
			if not self._shownError:
				traceback.print_exc()
				wx.CallAfter(wx.MessageBox, errStr, _("3D window error"), wx.OK | wx.ICON_EXCLAMATION)
				self._shownError = True
Exemplo n.º 5
0
    def draw(self):
        if self._hidden:
            return

        w, h = self.getMinSize()
        pos = self._getPixelPos()

        glPushMatrix()
        glTranslatef(pos[0], pos[1], 0)
        glDisable(GL_TEXTURE_2D)
        if self.hasFocus():
            glColor4ub(60, 60, 60, 255)
        else:
            glColor4ub(60, 60, 60, 192)
        glBegin(GL_QUADS)
        glVertex2f(w / 2, -h / 2)
        glVertex2f(-w / 2, -h / 2)
        glVertex2f(-w / 2, h / 2)
        glVertex2f(w / 2, h / 2)
        glEnd()
        scrollLength = h - w
        if self._maxValue - self._minValue != 0:
            valueNormalized = ((self.getValue() - self._minValue) /
                               (self._maxValue - self._minValue))
        else:
            valueNormalized = 0
        glTranslate(0.0, scrollLength / 2, 0)
        if True:  # self._focus:
            glColor4ub(0, 0, 0, 255)
            glPushMatrix()
            glTranslate(
                -w / 2,
                openglHelpers.glGetStringSize(str(self._minValue))[1] / 2, 0)
            openglHelpers.glDrawStringRight(str(self._minValue))
            glTranslate(0, -scrollLength, 0)
            openglHelpers.glDrawStringRight(str(self._maxValue))
            glTranslate(w, scrollLength - scrollLength * valueNormalized, 0)
            openglHelpers.glDrawStringLeft(str(self.getValue()))
            glPopMatrix()
        glColor4ub(255, 255, 255, 240)
        glTranslate(0.0, -scrollLength * valueNormalized, 0)
        glBegin(GL_QUADS)
        glVertex2f(w / 2, -w / 2)
        glVertex2f(-w / 2, -w / 2)
        glVertex2f(-w / 2, w / 2)
        glVertex2f(w / 2, w / 2)
        glEnd()
        glPopMatrix()
Exemplo n.º 6
0
	def draw(self):
		if self._hidden:
			return

		w, h = self.getMinSize()
		pos = self._getPixelPos()

		glPushMatrix()
		glTranslatef(pos[0], pos[1]*1.05, 0)
		glDisable(GL_TEXTURE_2D)
		if self.hasFocus():
			glColor4ub(177,205,54,255)
		else:
			glColor4ub(177,205,54,192)
		glBegin(GL_QUADS)
		glVertex2f( w/2,-h/2)
		glVertex2f(-w/2,-h/2)
		glVertex2f(-w/2, h/2)
		glVertex2f( w/2, h/2)
		glEnd()
		scrollLength = h - w
		if self._maxValue-self._minValue != 0:
			valueNormalized = ((self.getValue()-self._minValue)/(self._maxValue-self._minValue))
		else:
			valueNormalized = 0
		glTranslate(0.0,scrollLength/2,0)
		if True:  # self._focus:
			glColor4ub(90,104,27,255)
			glPushMatrix()
			glTranslate(-w/2,openglHelpers.glGetStringSize(str(self._minValue))[1]/2,0)
			openglHelpers.glDrawStringRight(str(self._minValue))
			glTranslate(0,-scrollLength,0)
			openglHelpers.glDrawStringRight(str(self._maxValue))
			glTranslate(w,scrollLength-scrollLength*valueNormalized,0)
			openglHelpers.glDrawStringLeft(str(self.getValue()))
			glPopMatrix()
		glColor4ub(90,104,27,255)
		glTranslate(0.0,-scrollLength*valueNormalized,0)
		glBegin(GL_QUADS)
		glVertex2f( w/2,-w/2)
		glVertex2f(-w/2,-w/2)
		glVertex2f(-w/2, w/2)
		glVertex2f( w/2, w/2)
		glEnd()
		glPopMatrix()
Exemplo n.º 7
0
    def draw(self):
        x, y, w, h = self.getSize()

        glPushMatrix()
        glTranslatef(x, y, 0)

        #		glColor4ub(255,255,255,128)
        #		glBegin(GL_QUADS)
        #		glTexCoord2f(1, 0)
        #		glVertex2f( w, 0)
        #		glTexCoord2f(0, 0)
        #		glVertex2f( 0, 0)
        #		glTexCoord2f(0, 1)
        #		glVertex2f( 0, h)
        #		glTexCoord2f(1, 1)
        #		glVertex2f( w, h)
        #		glEnd()

        glTranslate(5, h - 5, 0)
        glColor4ub(0, 0, 0, 255)
        openglHelpers.glDrawStringLeft(self._label)
        glPopMatrix()
Exemplo n.º 8
0
	def draw(self):
		x, y, w, h = self.getSize()

		glPushMatrix()
		glTranslatef(x, y, 0)

#		glColor4ub(255,255,255,128)
#		glBegin(GL_QUADS)
#		glTexCoord2f(1, 0)
#		glVertex2f( w, 0)
#		glTexCoord2f(0, 0)
#		glVertex2f( 0, 0)
#		glTexCoord2f(0, 1)
#		glVertex2f( 0, h)
#		glTexCoord2f(1, 1)
#		glVertex2f( w, h)
#		glEnd()

		glTranslate(5, h - 5, 0)
		glColor4ub(255,255,255,255)
		openglHelpers.glDrawStringLeft(self._label)
		glPopMatrix()