def grabMyScreen(x, y, width, height,filename = None, productionRender=False):
            if width <= 0 or height <= 0:
                raise RuntimeError("width or height is 0")

            log.debug('grabScreen: %d %d %d %d', x, y, width, height)
    # Draw before grabbing, to make sure we grab a rendering and not a picking buffer
            glmodule.draw(productionRender)
            sx0 = x
            sy0 = G.windowHeight - y - height
            sx1 = sx0 + width
            sy1 = sy0 + height
            sx0 = max(sx0, 0)
            sx1 = min(sx1, G.windowWidth)
            sy0 = max(sy0, 0)
            sy1 = min(sy1, G.windowHeight)
            rwidth = sx1 - sx0
            rwidth -= rwidth % 4
            sx1 = sx0 + rwidth
            rheight = sy1 - sy0
            surface = np.empty((rheight, rwidth, 3), dtype = np.uint8)
            log.debug('glReadPixels: %d %d %d %d', sx0, sy0, rwidth, rheight)
            glmodule.glReadPixels(sx0, sy0, rwidth, rheight, GL_RGB, GL_UNSIGNED_BYTE, surface)
            if width != rwidth or height != rheight:
                surf = np.zeros((height, width, 3), dtype = np.uint8) + 127
                surf[...] = surface[:1,:1,:]
                dx0 = (width - rwidth) / 2
                dy0 = (height - rheight) / 2
                dx1 = dx0 + rwidth
                dy1 = dy0 + rheight
                surf[dy0:dy1,dx0:dx1] = surface
                surface = surf

            surface = np.ascontiguousarray(surface[::-1,:,:])
    #surface = Image(data = surface)
            return surface  
Пример #2
0
        def grabMyScreen(x, y, width, height, filename=None, productionRender=False):
            if width <= 0 or height <= 0:
                raise RuntimeError("width or height is 0")

            log.debug('grabScreen: %d %d %d %d', x, y, width, height)
            # Draw before grabbing, to make sure we grab a rendering and not a picking buffer
            glmodule.draw(productionRender)
            sx0 = x
            sy0 = G.windowHeight - y - height
            sx1 = sx0 + width
            sy1 = sy0 + height
            sx0 = max(sx0, 0)
            sx1 = min(sx1, G.windowWidth)
            sy0 = max(sy0, 0)
            sy1 = min(sy1, G.windowHeight)
            rwidth = sx1 - sx0
            rwidth -= rwidth % 4
            sx1 = sx0 + rwidth
            rheight = sy1 - sy0
            surface = np.empty((rheight, rwidth, 3), dtype=np.uint8)
            log.debug('glReadPixels: %d %d %d %d', sx0, sy0, rwidth, rheight)
            glmodule.glReadPixels(sx0, sy0, rwidth, rheight, GL_RGB, GL_UNSIGNED_BYTE, surface)
            if width != rwidth or height != rheight:
                surf = np.zeros((height, width, 3), dtype=np.uint8) + 127
                surf[...] = surface[:1, :1, :]
                dx0 = (width - rwidth) / 2
                dy0 = (height - rheight) / 2
                dx1 = dx0 + rwidth
                dy1 = dy0 + rheight
                surf[dy0:dy1, dx0:dx1] = surface
                surface = surf

            surface = np.ascontiguousarray(surface[::-1, :, :])
            # surface = Image(data = surface)
            return surface
Пример #3
0
    def renderFacsPicture(self,
                          dir_images=None,
                          pic_file=None,
                          pic_file_reverse=None):
        #self.facs_human.applyAllTargets()
        #self.refreshAuSmoothSetting()
        self.renderingWidth = '500'
        self.renderingHeight = '500'

        self.grabPath = mh.getPath('grab')
        #log.message('self.grabPath = %s', self.grabPath)
        grabName = datetime.datetime.now().strftime(
            'grab_%Y-%m-%d_%H.%M.%S.png')
        pic_file = os.path.join(self.grabPath, 'test', grabName)

        img_width, img_height = int(self.renderingWidth), int(
            self.renderingHeight)
        glmodule.draw(False)
        img = glmodule.renderToBuffer(img_width, img_height)
        #log.message('img type = %s'. type(img))
        alphaImg = glmodule.renderAlphaMask(int(img_width), int(img_height))
        img = imgop.addAlpha(img, imgop.getChannel(alphaImg, 0))
        img = img.toQImage()
        img.save(pic_file)
        log.message("Image saved to %s", pic_file)
        del alphaImg
        del img
    def renderSurveyImg(self,
                        i4,
                        i7,
                        i9,
                        i10,
                        dir_images=None,
                        pic_file=None,
                        pic_file_reverse=None):
        self.facs_human.applyAllTargets()
        self.refreshAuSmoothSetting()

        grabPath = mh.getPath('grab')
        if not os.path.exists(grabPath):
            os.makedirs(grabPath)

        if pic_file is not None:
            dir_pic_file = os.path.join(grabPath, dir_images)
            pic_file = pic_file + '.png'
            pic_file = os.path.join(dir_pic_file, pic_file)
            if pic_file_reverse is not None:
                pic_file_reverse = pic_file_reverse + '.png'
                pic_file_reverse = os.path.join(dir_pic_file, pic_file_reverse)
        else:
            grabName = str(i4) + str(i7) + str(i9) + str(i10) + '.png'
            pic_file = os.path.join(grabPath, grabName)

        if self.renderingWidth == '' or self.renderingHeight == '':
            G.app.prompt('Warning', 'Nothing to render check the image size.',
                         'Ok')
        else:
            img_width, img_height = 2000, 2000  #int(self.renderingWidth), int(self.renderingHeight)
            glmodule.draw(False)
            img = glmodule.renderToBuffer(img_width, img_height)
            alphaImg = glmodule.renderAlphaMask(img_width, img_height)
            img = imgop.addAlpha(img, imgop.getChannel(alphaImg, 0))
            img = img.toQImage()
            if pic_file is not None:
                img.save(pic_file)
                log.message("Image saved to %s", pic_file)
            if pic_file_reverse is not None:
                img.save(pic_file_reverse)
                log.message("Image saved to %s", pic_file_reverse)
            del alphaImg
            del img

            gui3d.app.statusPersist("Image saved to %s", pic_file)
Пример #5
0
 def paintGL(self):
     self.app.logger_redraw.debug('paintGL')
     gl.draw()
Пример #6
0
 def paintGL(self):
     gl.draw()
Пример #7
0
 def setWeight(self,weight):
     log.message("SCRIPT: setWeight(" + str(weight) + ")")
     self.human.setWeight(weight)
     humanmodifier.MacroModifier('macrodetails', 'universal', 'Weight', 0.0, 1.0).setValue(gui3d.app.selectedHuman, weight)
     self.human.applyAllTargets()
     glmodule.draw()
Пример #8
0
 def setAge(self,age):
     log.message("SCRIPT: setAge(" + str(age) + ")")
     self.human.setAge(age)
     humanmodifier.MacroModifier('macrodetails', None, 'Age', 0.0, 1.0).setValue(gui3d.app.selectedHuman, age)
     self.human.applyAllTargets()
     glmodule.draw()
Пример #9
0
 def applyTarget(self,targetName,power):
     log.message("SCRIPT: applyTarget(" + targetName + ", " + str(power) + ")")
     self.human.setDetail("data/targets/" + targetName + ".target",power)
     self.human.applyAllTargets()
     glmodule.draw()
Пример #10
0
 def paintGL(self):
     self.app.logger_redraw.debug('paintGL')
     gl.draw()
Пример #11
0
 def paintGL(self):
     gl.draw()