Beispiel #1
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Material Editor')

        self.human = gui3d.app.selectedHuman

        self.humanObjSelector = self.addLeftWidget(HumanObjectSelector(self.human))
        @self.humanObjSelector.mhEvent
        def onActivate(value):
            self.reloadMaterial()

        shaderBox = self.addLeftWidget(gui.GroupBox('Shader'))
        self.shaderList = shaderBox.addWidget(gui.ListView())
        self.shaderList.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)

        self.shaderConfBox = self.addLeftWidget(gui.GroupBox('Shader config'))
        shaderConfig = self.human.material.shaderConfig
        for name in shaderConfig:
            chkBox = gui.CheckBox(name, shaderConfig[name])
            self.shaderConfBox.addWidget(chkBox)
            @chkBox.mhEvent
            def onClicked(event):
                shaderConfig = dict()
                for child in self.shaderConfBox.children:
                    shaderConfig[str(child.text())] = child.isChecked()
                self.getSelectedObject().material.configureShading(**shaderConfig)

        self.shaderDefBox = self.addLeftWidget(gui.GroupBox('Custom shader defines'))

        self.paramBox = self.addRightWidget(gui.GroupBox('Shader parameters'))

        self.materialBox = self.addRightWidget(gui.GroupBox('Material settings'))

        if not shader.Shader.supported():
            log.notice('Shaders not supported')
            self.shaderList.setEnabled(False)
            self.shaderList.hide()
            self.paramBox.hide()

        @self.shaderList.mhEvent
        def onClicked(item):
            self.setShader(unicode(item.getUserData()))

        self.loadSaveBox = self.addRightWidget(gui.GroupBox("Material file"))
        self.loadMaterialBtn = self.loadSaveBox.addWidget(gui.BrowseButton(), 0, 0)
        self.loadMaterialBtn.setFilter("MakeHuman Material (*.mhmat)")
        self.loadMaterialBtn.setText('Load')
        @self.loadMaterialBtn.mhEvent
        def onClicked(path):
            if path:
                self.loadMaterial(path)
        self.saveMaterialBtn = self.loadSaveBox.addWidget(gui.BrowseButton('save'), 0, 1)
        self.saveMaterialBtn.setFilter("MakeHuman Material (*.mhmat)")
        self.saveMaterialBtn.setText('Save')

        @self.saveMaterialBtn.mhEvent
        def onClicked(path):
            if path:
                if not os.path.splitext(path)[1]:
                    path = path + ".mhmat"
                self.saveMaterial(path)
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Shaders')

        shaderBox = self.addLeftWidget(gui.GroupBox('Shader'))
        self.shaderList = shaderBox.addWidget(gui.ListView())
        self.shaderList.setSizePolicy(gui.SizePolicy.Ignored,
                                      gui.SizePolicy.Preferred)

        if not shader.Shader.supported():
            log.notice('Shaders not supported')
            self.shaderList.setEnabled(False)

        self.paramBox = self.addRightWidget(gui.GroupBox('Parameters'))

        @self.shaderList.mhEvent
        def onActivate(item):
            self.setShader(item.getUserData())
Beispiel #3
0
    def __init__(self, category):
        RenderTaskView.__init__(self, category, 'Classification Images Render')

        # Declare settings
        G.app.addSetting('GL_RENDERER_SSS', False)
        G.app.addSetting('GL_RENDERER_AA', True)

        # Don't change shader for this RenderTaskView.
        self.taskViewShader = G.app.selectedHuman.material.shader

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        settingsBox.addWidget(gui.TextView("Resolution"))
        self.resBox = settingsBox.addWidget(
            gui.TextEdit("x".join(
                [str(self.renderingWidth),
                 str(self.renderingHeight)])))
        self.AAbox = settingsBox.addWidget(gui.CheckBox("Anti-aliasing"))
        self.AAbox.setSelected(G.app.getSetting('GL_RENDERER_AA'))

        self.path = ""
        self.path_button = settingsBox.addWidget(
            gui.BrowseButton('dir', "Select an output directory"))
        self.pathBox = settingsBox.addWidget(gui.TextEdit(self.path))

        @self.path_button.mhEvent
        def onClicked(path):
            self.path = path
            self.pathBox.setText(self.path)

        self.renderButton = settingsBox.addWidget(gui.Button('Render'))

        self.lightmapSSS = gui.CheckBox("Lightmap SSS")
        self.lightmapSSS.setSelected(G.app.getSetting('GL_RENDERER_SSS'))

        self.optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.optionsWidgets = []

        renderMethodBox = self.addRightWidget(
            gui.GroupBox('Rendering methods'))
        self.renderMethodList = renderMethodBox.addWidget(gui.ListView())
        self.renderMethodList.setSizePolicy(gui.SizePolicy.Ignored,
                                            gui.SizePolicy.Preferred)

        # Rendering methods
        self.renderMethodList.addItem('Quick Render')
        self.renderMethodList.addItem('Advanced Render',
                                      data=[self.lightmapSSS])

        if not mh.hasRenderToRenderbuffer():
            self.firstTimeWarn = True
            # Can only use screen grabbing as fallback,
            # resolution option disabled
            self.resBox.setEnabled(False)
            self.AAbox.setEnabled(False)

        self.listOptions(None)

        classificationImagesSettingsBox = self.addRightWidget(
            gui.GroupBox('Classification Image Settings'))

        classificationImagesSettingsBox.addWidget(
            gui.TextView("The number of trials"))
        self.trialsBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit("10"))

        classificationImagesSettingsBox.addWidget(
            gui.TextView("Orbit Camera Y (left-right)"))
        self.camY = classificationImagesSettingsBox.addWidget(
            gui.TextEdit("0.0"))
        classificationImagesSettingsBox.addWidget(
            gui.TextView("Oribt Camera X (up-down)"))
        self.camX = classificationImagesSettingsBox.addWidget(
            gui.TextEdit("0.0"))

        classificationImagesSettingsBox.addWidget(
            gui.TextView("Fraction of Feature Range SD"))
        self.SDBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit("0.05"))

        classificationImagesSettingsBox.addWidget(
            gui.TextView("Material File"))
        self.materialBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit("young_caucasian_avg"))

        classificationImagesSettingsBox.addWidget(gui.TextView("Model File"))
        self.modelBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit(""))
        self.model_button = classificationImagesSettingsBox.addWidget(
            gui.BrowseButton('open', "Select a model file"))

        @self.model_button.mhEvent
        def onClicked(path):
            self.modelBox.setText(path)

        self.modelFeatureList = classificationImagesSettingsBox.addWidget(
            gui.ListView())
        classificationImagesSettingsBox.addWidget(gui.TextView("Features"))
        self.modelFeatureBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit(".*"))
        # recommended groups
        self.modelGroups = [
            "all", "nose", "head", "forehead", "eyebrow", "eyes", "mouth",
            "ear", "chin", "cheek"
        ]
        self.modelGroupBox = mhapi.ui.createComboBox(self.modelGroups,
                                                     self._onModelGroupChange)
        classificationImagesSettingsBox.addWidget(self.modelGroupBox)
        self.modelAddButton = classificationImagesSettingsBox.addWidget(
            gui.Button("Add"))
        self.modelRemoveButton = classificationImagesSettingsBox.addWidget(
            gui.Button("Remove"))

        self.expressionBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit(""))
        self.expression_button = classificationImagesSettingsBox.addWidget(
            gui.BrowseButton('open', "Select an expression file"))

        @self.expression_button.mhEvent
        def onClicked(path):
            self.expressionBox.setText(path)

        self.expressionFeatureList = classificationImagesSettingsBox.addWidget(
            gui.ListView())
        classificationImagesSettingsBox.addWidget(gui.TextView("Features"))
        self.expressionFeatureBox = classificationImagesSettingsBox.addWidget(
            gui.TextEdit(".*"))
        # recommended groups
        self.expressionGroups = [
            "all", "Nose", "Eyebrow", "Eye", "Mouth", "Chin", "Cheek",
            "Left Eyebrow", "Left Chin", "Left Eye", "Left Mouth",
            "Right Eyebrow", "Right Chin", "Right Eye", "Right Mouth"
        ]
        self.expressionGroupBox = mhapi.ui.createComboBox(
            self.expressionGroups, self._onExpressionGroupChange)
        classificationImagesSettingsBox.addWidget(self.expressionGroupBox)

        self.expressionAddButton = classificationImagesSettingsBox.addWidget(
            gui.Button("Add"))
        self.expressionRemoveButton = classificationImagesSettingsBox.addWidget(
            gui.Button("Remove"))

        @self.modelAddButton.mhEvent
        def onClicked(event):
            features = self.modelFeatureBox.getText()
            self.modelFeatureList.addItem('{0}'.format(features),
                                          data=dict(features=features))

        @self.modelRemoveButton.mhEvent
        def onClicked(event):
            selected_frame = self.modelFeatureList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [
                item for item in self.modelFeatureList.getItems()
                if item is not selected_frame
            ]
            self.reassign(self.modelFeatureList, new_items)

        @self.expressionAddButton.mhEvent
        def onClicked(event):
            features = self.expressionFeatureBox.getText()
            self.expressionFeatureList.addItem('{0}'.format(features),
                                               data=dict(features=features))

        @self.expressionRemoveButton.mhEvent
        def onClicked(event):
            selected_frame = self.expressionFeatureList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [
                item for item in self.expressionFeatureList.getItems()
                if item is not selected_frame
            ]
            self.reassign(self.expressionFeatureList, new_items)

        @self.resBox.mhEvent
        def onChange(value):
            try:
                value = value.replace(" ", "")
                res = [int(x) for x in value.split("x")]
                self.renderingWidth = res[0]
                self.renderingHeight = res[1]
            except:  # The user hasn't typed the value correctly yet.
                pass

        @self.AAbox.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_AA', self.AAbox.selected)

        @self.lightmapSSS.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_SSS', self.lightmapSSS.selected)

        @self.renderMethodList.mhEvent
        def onClicked(item):
            self.listOptions(item.getUserData())

        @self.renderButton.mhEvent
        def onClicked(event):
            settings = dict()
            settings['scene'] = G.app.scene
            settings['AA'] = self.AAbox.selected
            settings['dimensions'] = (self.renderingWidth,
                                      self.renderingHeight)
            settings[
                'lightmapSSS'] = self.lightmapSSS.selected and self.lightmapSSS in self.optionsWidgets
            # change the timing of the render
            # add path output
            # base_model, trials, shape_parameters, pose_parameters, SD=.3, rot_X=0, rot_Y=0, material_file="young_caucasian_avg"
            _, shape_parameters = self.get_data_labels(
                self.modelFeatureList.getItems())
            #log.message("Shape parameters "+shape_parameters)
            _, pose_parameters = self.get_data_labels(
                self.expressionFeatureList.getItems())
            CI_settings = dict(base_model=self.modelBox.getText(),
                               base_expression=self.expressionBox.getText(),
                               trials=int(self.trialsBox.getText()),
                               shape_parameters=shape_parameters,
                               pose_parameters=pose_parameters,
                               material_file=self.materialBox.getText(),
                               rot_X=float(self.camX.getText()),
                               rot_Y=float(self.camY.getText()),
                               SD=float(self.SDBox.getText()))
            classification_images.do_op(
                classification_image_settings=CI_settings,
                save_path=self.pathBox.getText(),
                render_function=(mh2opengl.Render, settings))
Beispiel #4
0
    def __init__(self, category):
        RenderTaskView.__init__(self, category, 'Interpolation Render')

        # Declare settings
        G.app.addSetting('GL_RENDERER_SSS', False)
        G.app.addSetting('GL_RENDERER_AA', True)

        # Don't change shader for this RenderTaskView.
        self.taskViewShader = G.app.selectedHuman.material.shader

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        settingsBox.addWidget(gui.TextView("Resolution"))
        self.resBox = settingsBox.addWidget(
            gui.TextEdit("x".join(
                [str(self.renderingWidth),
                 str(self.renderingHeight)])))
        self.AAbox = settingsBox.addWidget(gui.CheckBox("Anti-aliasing"))
        self.AAbox.setSelected(G.app.getSetting('GL_RENDERER_AA'))

        self.path = ""
        self.path_button = settingsBox.addWidget(
            gui.BrowseButton('dir', "Select an output directory"))
        self.pathBox = settingsBox.addWidget(gui.TextEdit(self.path))

        @self.path_button.mhEvent
        def onClicked(path):
            self.path = path
            self.pathBox.setText(self.path)

        self.renderButton = settingsBox.addWidget(gui.Button('Render'))

        self.lightmapSSS = gui.CheckBox("Lightmap SSS")
        self.lightmapSSS.setSelected(G.app.getSetting('GL_RENDERER_SSS'))

        self.optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.optionsWidgets = []

        renderMethodBox = self.addRightWidget(
            gui.GroupBox('Rendering methods'))
        self.renderMethodList = renderMethodBox.addWidget(gui.ListView())
        self.renderMethodList.setSizePolicy(gui.SizePolicy.Ignored,
                                            gui.SizePolicy.Preferred)

        # Rendering methods
        self.renderMethodList.addItem('Quick Render')
        self.renderMethodList.addItem('Advanced Render',
                                      data=[self.lightmapSSS])

        if not mh.hasRenderToRenderbuffer():
            self.firstTimeWarn = True
            # Can only use screen grabbing as fallback,
            # resolution option disabled
            self.resBox.setEnabled(False)
            self.AAbox.setEnabled(False)

        self.listOptions(None)

        # add interpolation settings to the right pane
        interpolateFrameBox = self.addRightWidget(gui.GroupBox('Total Frames'))
        interpolateFrameBox.addWidget(gui.TextView("Frames"))
        self.framesBox = interpolateFrameBox.addWidget(gui.TextEdit("120"))

        interpolatedFramesBox = self.addRightWidget(
            gui.GroupBox('Interpolated Frames'))
        self.interpolatedFramesList = interpolatedFramesBox.addWidget(
            gui.ListView())
        self.interpolatedFramesList.setSizePolicy(gui.SizePolicy.Ignored,
                                                  gui.SizePolicy.Preferred)
        self.interpolatedFramesList.setVerticalScrollingEnabled(True)
        self.addFrame = interpolatedFramesBox.addWidget(
            gui.Button('Add Frame'))
        self.removeFrame = interpolatedFramesBox.addWidget(
            gui.Button('Remove Frame'))
        self.save_button = interpolatedFramesBox.addWidget(
            gui.BrowseButton('save', "Save As.."))
        self.load_button = interpolatedFramesBox.addWidget(
            gui.BrowseButton('open', 'Load JSON'))

        self.key_frames = None

        @self.load_button.mhEvent
        def onClicked(path):
            with open(path, 'r') as f:
                self.key_frames = json.load(f)
                self.GUItize_key_frames()
                self.resort_frames()

        @self.save_button.mhEvent
        def onClicked(path):
            self.generate_key_frames()

            with open(path, 'w') as f:
                json.dump(self.key_frames, f)

        interpolateSettingsBox = self.addRightWidget(
            gui.GroupBox('Interpolation Settings'))
        interpolateSettingsBox.addWidget(
            gui.TextView(
                "Current Frame (integer frame # or float proportion)"))
        self.currentFramesBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("0.0"))
        interpolateSettingsBox.addWidget(
            gui.TextView("Orbit Camera Y (left-right)"))
        self.camY = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        interpolateSettingsBox.addWidget(
            gui.TextView("Oribt Camera X (up-down)"))
        self.camX = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        interpolateSettingsBox.addWidget(gui.TextView("Model File"))

        self.modelBox = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        self.model_button = interpolateSettingsBox.addWidget(
            gui.BrowseButton('open', "Select a model file"))

        @self.model_button.mhEvent
        def onClicked(path):
            self.modelBox.setText(path)

        interpolateSettingsBox.addWidget(
            gui.TextView("Model Extrapolation Percentage"))
        self.modelPercentageBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("100"))

        interpolateSettingsBox.addWidget(
            gui.TextView("Expression file (or specify 'None')"))
        self.expressionBox = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        self.expression_button = interpolateSettingsBox.addWidget(
            gui.BrowseButton('open', "Select an expression file"))
        interpolateSettingsBox.addWidget(
            gui.TextView("Expression Extrapolation Percentage"))
        self.expressionPercentageBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("100"))

        @self.expression_button.mhEvent
        def onClicked(path):
            self.expressionBox.setText(path)

        self.updateFrame = interpolateSettingsBox.addWidget(
            gui.Button('Update Frame'))

        self.keybox = {
            "frame": self.currentFramesBox,
            "rot_Y": self.camY,
            "rot_X": self.camX,
            "model": self.modelBox,
            "expression": self.expressionBox
        }

        @self.framesBox.mhEvent
        def onChange(value):
            try:
                tmp = 1 / int(value)
                self.resort_frames()
            except:
                pass

        # save the values back to the selected frame
        @self.updateFrame.mhEvent
        def onClicked(event):
            selected_frame = self.interpolatedFramesList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            selected_frame.setText('Frame {0}'.format(
                self.currentFramesBox.getText()))
            selected_frame.setUserData(
                data={
                    "frame":
                    self.num(self.currentFramesBox.getText()),
                    "rot_Y":
                    self.num(self.camY.getText()),
                    "rot_X":
                    self.num(self.camX.getText()),
                    "model":
                    self.modelBox.getText() + "|" +
                    self.modelPercentageBox.getText(),
                    "expression":
                    self.expressionBox.getText() + "|" +
                    self.expressionPercentageBox.getText()
                })
            self.resort_frames()

        @self.addFrame.mhEvent
        def onClicked(event):
            self.interpolatedFramesList.addItem(
                'Frame {0}'.format(self.currentFramesBox.getText()),
                data={
                    "frame":
                    self.num(self.currentFramesBox.getText()),
                    "rot_Y":
                    self.num(self.camY.getText()),
                    "rot_X":
                    self.num(self.camX.getText()),
                    "model":
                    self.modelBox.getText() + "|" +
                    self.modelPercentageBox.getText(),
                    "expression":
                    self.expressionBox.getText() + "|" +
                    self.expressionPercentageBox.getText()
                })
            self.resort_frames()

        @self.removeFrame.mhEvent
        def onClicked(event):
            selected_frame = self.interpolatedFramesList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [
                item for item in self.interpolatedFramesList.getItems()
                if item is not selected_frame
            ]
            self.reassign(new_items)

        @self.interpolatedFramesList.mhEvent
        def onClicked(item):
            self.listInterpolationFrameOptions(item.getUserData())

        @self.resBox.mhEvent
        def onChange(value):
            try:
                value = value.replace(" ", "")
                res = [int(x) for x in value.split("x")]
                self.renderingWidth = res[0]
                self.renderingHeight = res[1]
            except:  # The user hasn't typed the value correctly yet.
                pass

        @self.AAbox.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_AA', self.AAbox.selected)

        @self.lightmapSSS.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_SSS', self.lightmapSSS.selected)

        @self.renderMethodList.mhEvent
        def onClicked(item):
            self.listOptions(item.getUserData())

        @self.renderButton.mhEvent
        def onClicked(event):
            settings = dict()
            settings['scene'] = G.app.scene
            settings['AA'] = self.AAbox.selected
            settings['dimensions'] = (self.renderingWidth,
                                      self.renderingHeight)
            settings[
                'lightmapSSS'] = self.lightmapSSS.selected and self.lightmapSSS in self.optionsWidgets
            # change the timing of the render
            # add path output
            self.generate_key_frames()
            interpolate.do_op(self.key_frames,
                              "Front",
                              save_path=self.pathBox.getText(),
                              render_function=(mh2opengl.Render, settings))
Beispiel #5
0
    def __init__(self, category):
        RenderTaskView.__init__(self, category, 'Classification Images Motion Render')

        # Declare settings
        G.app.addSetting('GL_RENDERER_SSS', False)
        G.app.addSetting('GL_RENDERER_AA', True)

        # Don't change shader for this RenderTaskView.
        self.taskViewShader = G.app.selectedHuman.material.shader

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        settingsBox.addWidget(gui.TextView("Resolution"))
        self.resBox = settingsBox.addWidget(gui.TextEdit(
            "x".join([str(self.renderingWidth), str(self.renderingHeight)])))
        self.AAbox = settingsBox.addWidget(gui.CheckBox("Anti-aliasing"))
        self.AAbox.setSelected(G.app.getSetting('GL_RENDERER_AA'))
        
        self.path = ""
        self.path_button = settingsBox.addWidget(gui.BrowseButton('dir', "Select an output directory"))
        self.pathBox = settingsBox.addWidget(gui.TextEdit(self.path))

        @self.path_button.mhEvent
        def onClicked(path):
            self.path = path
            self.pathBox.setText(self.path)
        
        
        self.renderButton = settingsBox.addWidget(gui.Button('Render'))

        self.lightmapSSS = gui.CheckBox("Lightmap SSS")
        self.lightmapSSS.setSelected(G.app.getSetting('GL_RENDERER_SSS'))

        self.optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.optionsWidgets = []

        renderMethodBox = self.addRightWidget(gui.GroupBox('Rendering methods'))
        self.renderMethodList = renderMethodBox.addWidget(gui.ListView())
        self.renderMethodList.setSizePolicy(
            gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)

        # Rendering methods
        self.renderMethodList.addItem('Quick Render')
        self.renderMethodList.addItem('Advanced Render',
            data=[self.lightmapSSS])

        if not mh.hasRenderToRenderbuffer():
            self.firstTimeWarn = True
            # Can only use screen grabbing as fallback,
            # resolution option disabled
            self.resBox.setEnabled(False)
            self.AAbox.setEnabled(False)

        self.listOptions(None)
        
        
        
        
        classificationImagesSettingsBox = self.addRightWidget(gui.GroupBox('Classification Image Settings'))

        classificationImagesSettingsBox.addWidget(gui.TextView("The number of trials"))
        self.trialsBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("1"))

        classificationImagesSettingsBox.addWidget(gui.TextView("The number of frames per trial"))
        self.framesBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("30"))

        classificationImagesSettingsBox.addWidget(gui.TextView("Orbit Camera Y (left-right)"))
        self.camY = classificationImagesSettingsBox.addWidget(gui.TextEdit("0.0"))
        classificationImagesSettingsBox.addWidget(gui.TextView("Oribt Camera X (up-down)"))
        self.camX = classificationImagesSettingsBox.addWidget(gui.TextEdit("0.0"))

        classificationImagesSettingsBox.addWidget(gui.TextView("Oribt Camera Z (out-int)"))
        self.camZ = classificationImagesSettingsBox.addWidget(gui.TextEdit("8.7"))

        classificationImagesSettingsBox.addWidget(gui.TextView("Frame Rate"))
        self.frameRateBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("30"))

        classificationImagesSettingsBox.addWidget(gui.TextView("Material File"))
        self.materialBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("young_caucasian_avg"))

        classificationImagesSettingsBox.addWidget(gui.TextView("Start Model File"))
        self.modelBox = classificationImagesSettingsBox.addWidget(gui.TextEdit(""))
        self.model_button = classificationImagesSettingsBox.addWidget(gui.BrowseButton('open', "Select a model file"))
        @self.model_button.mhEvent
        def onClicked(path):
            self.modelBox.setText(path)

        classificationImagesSettingsBox.addWidget(gui.TextView("End Model File"))
        self.modelBox2 = classificationImagesSettingsBox.addWidget(gui.TextEdit("None"))
        self.model_button2 = classificationImagesSettingsBox.addWidget(gui.BrowseButton('open', "Select a model file"))
        
        @self.model_button2.mhEvent
        def onClicked(path):
            self.modelBox2.setText(path)



        self.modelFeatureList = classificationImagesSettingsBox.addWidget(gui.ListView())
        classificationImagesSettingsBox.addWidget(gui.TextView("Features"))
        self.modelFeatureBox = classificationImagesSettingsBox.addWidget(gui.TextEdit(".*"))
        # recommended groups
        self.modelGroups = ["all", "nose", "head", "forehead", "eyebrow", "eyes", "mouth", "ear", "chin", "cheek"]
        self.modelGroupBox = mhapi.ui.createComboBox(self.modelGroups, self._onModelGroupChange)
        classificationImagesSettingsBox.addWidget(self.modelGroupBox)
        classificationImagesSettingsBox.addWidget(gui.TextView("Mode and SD"))
        self.modelAlphaBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("0.5"))
        self.modelAlphaSDBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("0.1667"))
        classificationImagesSettingsBox.addWidget(gui.TextView("Concentration and SD"))
        self.modelBetaBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("25.0"))
        self.modelBetaSDBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("7.6667"))
        self.modelAddButton = classificationImagesSettingsBox.addWidget(gui.Button("Add"))
        self.modelRemoveButton = classificationImagesSettingsBox.addWidget(gui.Button("Remove"))
        
        classificationImagesSettingsBox.addWidget(gui.TextView("Start Expression File"))
        self.expressionBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("None"))
        self.expression_button = classificationImagesSettingsBox.addWidget(gui.BrowseButton('open', "Select an expression"))
        @self.expression_button.mhEvent
        def onClicked(path):
            self.expressionBox.setText(path)

        classificationImagesSettingsBox.addWidget(gui.TextView("End Expression File"))
        self.expressionBox2 = classificationImagesSettingsBox.addWidget(gui.TextEdit(""))
        self.expression_button2 = classificationImagesSettingsBox.addWidget(gui.BrowseButton('open', "Select an expression"))
        @self.expression_button2.mhEvent
        def onClicked(path):
            self.expressionBox2.setText(path)


        self.expressionFeatureList = classificationImagesSettingsBox.addWidget(gui.ListView())

        # add the default CCNLab NSF groups
        alpha = 0.5
        alpha_sd = .5/3
        beta = 25.0
        beta_sd = 7 + 1/3.
        
        # between the brows
        features = "NoseWrinkler"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))
        
        # the nose
        features = "Nose,Naso"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))
        
        # left brow
        features = "Left.*Brow"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        # left eyelid
        features = "Left.*Eye,Left.*Lid"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        # right brow
        features = "Right.*Brow"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        # right eyelid
        features = "Right.*Eye,Right.*Lid"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))
        
        # chin and jaw
        features = "Chin,Jaw"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        # left mouth and cheek
        features = "Mouth.*Left,TongueLeft,Left.*Cheek"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        # right mouth and cheek
        features = "Mouth.*Right,TongueRight,Right.*Cheek"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        # center mouth
        features = "Tongue,Lip"
        self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        classificationImagesSettingsBox.addWidget(gui.TextView("Features"))
        self.expressionFeatureBox = classificationImagesSettingsBox.addWidget(gui.TextEdit(".*"))
        # recommended groups
        self.expressionGroups = ["all", "Nose", "Eyebrow", "Eye", "Mouth", "Chin", "Cheek", "Left Eyebrow", "Left Chin", "Left Eye", "Left Mouth", "Right Eyebrow", "Right Chin", "Right Eye", "Right Mouth"]
        self.expressionGroupBox = mhapi.ui.createComboBox(self.expressionGroups, self._onExpressionGroupChange)
        classificationImagesSettingsBox.addWidget(self.expressionGroupBox)
        
        classificationImagesSettingsBox.addWidget(gui.TextView("Mode and SD"))
        self.expressionAlphaBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("0.5"))
        self.expressionAlphaSDBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("0.1667"))
        classificationImagesSettingsBox.addWidget(gui.TextView("Concentration and SD"))
        self.expressionBetaBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("25.0"))
        self.expressionBetaSDBox = classificationImagesSettingsBox.addWidget(gui.TextEdit("7.6667"))

        self.expressionAddButton = classificationImagesSettingsBox.addWidget(gui.Button("Add"))
        self.expressionRemoveButton = classificationImagesSettingsBox.addWidget(gui.Button("Remove"))

        @self.modelAddButton.mhEvent
        def onClicked(event):
            features = self.modelFeatureBox.getText()
            alpha = float(self.modelAlphaBox.getText())
            alpha_sd = float(self.modelAlphaSDBox.getText())
            beta = float(self.modelBetaBox.getText())
            beta_sd = float(self.modelBetaSDBox.getText())
            self.modelFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        @self.modelRemoveButton.mhEvent
        def onClicked(event):
            selected_frame = self.modelFeatureList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [item for item in self.modelFeatureList.getItems() if item is not selected_frame]
            self.reassign(self.modelFeatureList, new_items)

        @self.expressionAddButton.mhEvent
        def onClicked(event):
            features = self.expressionFeatureBox.getText()
            alpha = float(self.expressionAlphaBox.getText())
            alpha_sd = float(self.expressionAlphaSDBox.getText())
            beta = float(self.expressionBetaBox.getText())
            beta_sd = float(self.expressionBetaSDBox.getText())
            self.expressionFeatureList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta), data=dict(features=features, alpha=alpha, alpha_sd=alpha_sd, beta=beta, beta_sd=beta_sd))

        @self.expressionRemoveButton.mhEvent
        def onClicked(event):
            selected_frame = self.expressionFeatureList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [item for item in self.expressionFeatureList.getItems() if item is not selected_frame]
            self.reassign(self.expressionFeatureList, new_items)


            
            
        @self.resBox.mhEvent
        def onChange(value):
            try:
                value = value.replace(" ", "")
                res = [int(x) for x in value.split("x")]
                self.renderingWidth = res[0]
                self.renderingHeight = res[1]
            except:  # The user hasn't typed the value correctly yet.
                pass

        @self.AAbox.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_AA', self.AAbox.selected)

        @self.lightmapSSS.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_SSS', self.lightmapSSS.selected)
            
        @self.renderMethodList.mhEvent
        def onClicked(item):
            self.listOptions(item.getUserData())

        @self.renderButton.mhEvent
        def onClicked(event):
            settings = dict()
            settings['scene'] = G.app.scene
            settings['AA'] = self.AAbox.selected
            settings['dimensions'] = (self.renderingWidth, self.renderingHeight)
            settings['lightmapSSS'] = self.lightmapSSS.selected and self.lightmapSSS in self.optionsWidgets
            # change the timing of the render
            # add path output
            # base_model, trials, shape_parameters, pose_parameters, SD=.3, rot_X=0, rot_Y=0, material_file="young_caucasian_avg"
            shape_data,shape_parameters = self.get_data_labels(self.modelFeatureList.getItems())
            #log.message("Shape parameters "+shape_parameters)
            pose_data,pose_parameters = self.get_data_labels(self.expressionFeatureList.getItems())
            frame_rate = float(self.frameRateBox.getText())
            CI_settings = dict(base_model = self.modelBox.getText(),
                                end_model = self.modelBox2.getText(),
                                base_expression = self.expressionBox.getText(),
                                end_expression = self.expressionBox2.getText(),
                                trials = int(self.trialsBox.getText()),
                                frames = int(self.framesBox.getText()),
                                shape_parameters = shape_parameters,
                                pose_parameters=pose_parameters,
                                shape_data=shape_data,
                                pose_data=pose_data,
                                material_file = self.materialBox.getText(),
                                rot_X = float(self.camX.getText()),
                                rot_Y = float(self.camY.getText()),
                                cam_Z = float(self.camZ.getText()))
            classification_images_motion.do_op(classification_image_settings=CI_settings, 
            save_path = self.pathBox.getText(), 
            frame_rate = frame_rate, render_function = (mh2opengl.Render, settings))
Beispiel #6
0
                width='61',
                text=u'Nombre:',
            )
            gui.TextBox(name='nombre_cliente',
                        left='367',
                        top='23',
                        width='240',
                        value=u'',
                        onchange=on_busqueda)

        nTop = str(int(nTop) + 80)
        with gui.ListView(
                name='listado',
                height='353',
                left='7',
                top=nTop,
                width='775',
                item_count=0,
                sort_column=-1,
        ):
            gui.ListColumn(name=u'tipo_doc', text='Tipo Doc', width=50)
            gui.ListColumn(name=u'nro_doc',
                           text='Nro Doc',
                           width=100,
                           represent="%s",
                           align="right")
            gui.ListColumn(name=u'nombre_cliente', text='Cliente', width=150)

        gui.Button(label=u'Salir',
                   name='close',
                   sizer_border=4,
Beispiel #7
0
 def createList(self, data=None):
     l = gui.ListView()
     if data:
         l.setData(data)
     return l
Beispiel #8
0
    def __init__(self, category):
        guirender.RenderTaskView.__init__(self, category, 'Scene Editor')

        # Declare settings
        G.app.addSetting('Scene_Editor_FileDlgPath', mh.getDataPath('scenes'))

        sceneBox = self.addLeftWidget(gui.GroupBox('Scene'))
        self.fnlbl = sceneBox.addWidget(gui.TextView('<New scene>'))
        self.saveButton = sceneBox.addWidget(gui.Button('Save'), 1, 0)
        self.loadButton = sceneBox.addWidget(gui.Button('Load ...'), 1, 1)
        self.saveAsButton = sceneBox.addWidget(gui.Button('Save As...'), 2, 0)
        self.closeButton = sceneBox.addWidget(gui.Button('Close'), 2, 1)

        itemBox = self.addLeftWidget(gui.GroupBox('Items'))
        self.itemList = itemBox.addWidget(gui.ListView())
        self.itemList.setSizePolicy(
            gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)

        self.propsBox = gui.StackedBox()
        self.addRightWidget(self.propsBox)

        self.addButton = itemBox.addWidget(gui.Button('Add...'))
        self.adder = SceneItemAdder(self)
        self.propsBox.addWidget(self.adder.widget)
        self.activeItem = None

        self._scene = None

        def doLoad():
            filename = mh.getOpenFileName(
                G.app.getSetting('Scene_Editor_FileDlgPath'),
                'MakeHuman scene (*.mhscene);;All files (*.*)')
            if filename:
                G.app.setSetting('Scene_Editor_FileDlgPath', filename)
                self.scene.load(filename)

        def doSave(filename):
            ok = self.scene.save(filename)
            if ok and self._scene.file.path is not None \
                and self._scene.file.path == self.scene.file.path:
                # Refresh MH's current scene if it was modified.
                self._scene.load(self._scene.file.path)

        @self.loadButton.mhEvent
        def onClicked(event):
            if self.scene.file.modified:
                G.app.prompt('Confirmation',
                    'Your scene is unsaved. Are you sure you want to close it?',
                    'Close', 'Cancel', doLoad)
            else:
                doLoad()

        @self.saveButton.mhEvent
        def onClicked(event):
            if self.scene.file.path is None:
                self.saveAsButton.callEvent('onClicked', event)
            else:
                doSave(self.scene.file.path)

        @self.closeButton.mhEvent
        def onClicked(event):
            if self.scene.file.modified:
                G.app.prompt('Confirmation',
                    'Your scene is unsaved. Are you sure you want to close it?',
                    'Close', 'Cancel', self.scene.reset)
            else:
                self.scene.reset()

        @self.saveAsButton.mhEvent
        def onClicked(event):
            filename = mh.getSaveFileName(
                G.app.getSetting('Scene_Editor_FileDlgPath'),
                'MakeHuman scene (*.mhscene);;All files (*.*)')
            if filename:
                G.app.setSetting('Scene_Editor_FileDlgPath', filename)
                doSave(filename)

        @self.itemList.mhEvent
        def onClicked(item):
            item.getUserData().showProps()

        @self.addButton.mhEvent
        def onClicked(event):
            self.adder.showProps()
Beispiel #9
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Scripting')

        self.directory = os.getcwd()
        self.filename = None

        box = self.addLeftWidget(gui.GroupBox('Script'))

        self.scriptText = self.addTopWidget(gui.DocumentEdit())
        self.scriptText.setText('')

        self.scriptText.setLineWrapMode(gui.DocumentEdit.NoWrap)

        self.loadButton = box.addWidget(gui.Button('Load ...'), 0, 0)
        self.saveButton = box.addWidget(gui.Button('Save ...'), 0, 1)

        @self.loadButton.mhEvent
        def onClicked(event):
            filename = mh.getOpenFileName(
                self.directory, 'Python scripts (*.py);;All files (*.*)')
            if (os.path.exists(filename)):
                contents = open(filename, 'r').read()
                self.scriptText.setText(contents)
                dlg = gui.Dialog()
                dlg.prompt("Load script",
                           "File was loaded in an acceptable manner", "OK")
                self.filename = filename
                self.directory = os.path.split(filename)[0]
            else:
                dlg = gui.Dialog()
                dlg.prompt("Load script",
                           "File " + filename + " does not seem to exist",
                           "OK")

        @self.saveButton.mhEvent
        def onClicked(event):
            filename = mh.getSaveFileName(
                self.filename or self.directory,
                'Python scripts (*.py);;All files (*.*)')
            with open(filename, "w") as f:
                f.write(self.scriptText.getText())
            dlg = gui.Dialog()
            dlg.prompt("Save script",
                       "File was written in an acceptable manner", "OK")
            self.filename = filename
            self.directory = os.path.split(filename)[0]

        box2 = self.addLeftWidget(gui.GroupBox('Examples'))

        self.insertLabel = box2.addWidget(
            gui.TextView('Append example to script'))
        self.listView = box2.addWidget(gui.ListView())
        self.listView.setSizePolicy(gui.SizePolicy.Ignored,
                                    gui.SizePolicy.Preferred)

        testlist = [
            'applyTarget()', 'incrementingFilename()', 'getPositionX()',
            'getPositionY()', 'getPositionZ()', 'getRotationX()',
            'getRotationY()', 'getRotationZ()', 'getZoom()', 'loadModel()',
            'modifyPositionX()', 'modifyPositionY()', 'modifyPositionZ()',
            'modifyRotationX()', 'modifyRotationY()', 'modifyRotationZ()',
            'modifyZoom()', 'printCameraInfo()', 'printDetailStack()',
            'printPositionInfo()', 'printRotationInfo()', 'saveModel()',
            'screenShot()', 'setAge()', 'setPositionX()', 'setPositionY()',
            'setPositionZ()', 'setRotationX()', 'setRotationY()',
            'setRotationZ()', 'setZoom()', 'setWeight()'
        ]

        self.listView.setData(testlist)

        self.insertButton = box2.addWidget(gui.Button('Append'))

        @self.insertButton.mhEvent
        def onClicked(event):
            item = self.listView.getSelectedItem()

            if (item == 'applyTarget()'):
                text = "# applyTarget(<target file name>, <power (from 0.0 to 1.0)>)\n"
                text = text + "#\n"
                text = text + "# This will apply the target on the model. If the target was already applied, the power will be updated\n"
                text = text + "# Note that targets are relative to the data/targets directory, and should not include the .target\n"
                text = text + "# extension, so a valid target name would be, for example, \"breast/breast-dist-max\"\n\n"
                text = text + "MHScript.applyTarget('aTargetName',1.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'loadModel()'):
                text = "# loadModel(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will load a human model from an MHM file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .MHM extension. The [path] part defaults to the user's makehuman/models directory.\n\n"
                text = text + "MHScript.loadModel('myTestModel')\n\n"
                self.scriptText.addText(text)

            if (item == 'incrementingFilename()'):
                text = "# incrementingFilename(<file name base>, [file extension], [pad length])\n"
                text = text + "#\n"
                text = text + "# This will return a file name containing a numerical component which increases by one for each call.\n"
                text = text + "# The default file extension is \".png\". The default pad length is 4. For example, the following lines:\n"
                text = text + "#\n"
                text = text + "# print incrementingFilename(\"test\",\".target\",3) + \"\\n\"\n"
                text = text + "# print incrementingFilename(\"test\",\".target\",3) + \"\\n\"\n"
                text = text + "#\n"
                text = text + "# Will print:\n"
                text = text + "#\n"
                text = text + "# test001.target\n"
                text = text + "# test002.target\n"
                text = text + "#\n"
                text = text + "# The counter is reset each time the script is executed\n\n"
                text = text + "filename = MHScript.incrementingFilename('test')\n\n"
                self.scriptText.addText(text)

            if (item == 'printCameraInfo()'):
                text = "# printCameraInfo()\n"
                text = text + "#\n"
                text = text + "# This will print info about how the camera is targeted and focused .\n\n"
                text = text + "MHScript.printCameraInfo()\n\n"
                self.scriptText.addText(text)

            if (item == 'printDetailStack()'):
                text = "# printDetailStack()\n"
                text = text + "#\n"
                text = text + "# This will print a list of all applied targets (and their weights) to standard output.\n\n"
                text = text + "MHScript.printDetailStack()\n\n"
                self.scriptText.addText(text)

            if (item == 'printPositionInfo()'):
                text = "# printPositionInfo()\n"
                text = text + "#\n"
                text = text + "# This will print info about where the human object is currently located.\n\n"
                text = text + "MHScript.printPositionInfo()\n\n"
                self.scriptText.addText(text)

            if (item == 'printRotationInfo()'):
                text = "# printRotationInfo()\n"
                text = text + "#\n"
                text = text + "# This will print info about how the human object is currently rotated.\n\n"
                text = text + "MHScript.printRotationInfo()\n\n"
                self.scriptText.addText(text)

            if (item == 'saveModel()'):
                text = "# saveModel(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will save the human model to an MHM file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .MHM extension. The [path] part defaults to the user's makehuman/models directory.\n"
                text = text + "# Note that this will not save any thumbnail.\n\n"
                text = text + "MHScript.saveModel('myTestModel')\n\n"
                self.scriptText.addText(text)

            if (item == 'screenShot()'):
                text = "# screenShot(<png file name>)\n"
                text = text + "#\n"
                text = text + "# This will save a png file of how the model currently looks.\n\n"
                text = text + "MHScript.screenShot('screenshot.png')\n\n"
                self.scriptText.addText(text)

            if (item == 'setAge()'):
                text = "# setAge(age)\n"
                text = text + "#\n"
                text = text + "# Sets the age of the model. The age parameter is a float between 0 and 1, where 0 is 12 years old and 1 is 70.\n\n"
                text = text + "MHScript.setAge(0.5)\n\n"
                self.scriptText.addText(text)

            if (item == 'setWeight()'):
                text = "# setWeight(weight)\n"
                text = text + "#\n"
                text = text + "# Sets the weight of the model. The weight parameter is a float between 0 and 1, where 0 is starved and\n"
                text = text + "# 1 is severely overweight\n\n"
                text = text + "MHScript.setWeight(0.5)\n\n"
                self.scriptText.addText(text)

            if (item == 'setPositionX()'):
                text = "# setPositionX(xpos)\n"
                text = text + "#\n"
                text = text + "# Sets the X position of the model of the model in 3d space, where 0.0 is centered.\n\n"
                text = text + "MHScript.setPositionX(2.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getPositionX()'):
                text = "# getPositionX()\n"
                text = text + "#\n"
                text = text + "# Returns the current X position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.getPositionX()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyPositionX()'):
                text = "# modifyPositionX(xmod)\n"
                text = text + "#\n"
                text = text + "# Modifies X position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.modifyPositionX(-0.1)\n\n"
                self.scriptText.addText(text)

            if (item == 'setPositionZ()'):
                text = "# setPositionZ(zpos)\n"
                text = text + "#\n"
                text = text + "# Sets the Z position of the model of the model in 3d space, where 0.0 is centered.\n\n"
                text = text + "MHScript.setPositionZ(2.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getPositionZ()'):
                text = "# getPositionZ()\n"
                text = text + "#\n"
                text = text + "# Returns the current Z position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.getPositionZ()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyPositionZ()'):
                text = "# modifyPositionZ(zmod)\n"
                text = text + "#\n"
                text = text + "# Modifies Z position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.modifyPositionZ(-0.1)\n\n"
                self.scriptText.addText(text)

            if (item == 'setPositionY()'):
                text = "# setPositionY(ypos)\n"
                text = text + "#\n"
                text = text + "# Sets the Y position of the model of the model in 3d space, where 0.0 is centered.\n"
                text = text + "# Note that the depth of the scene is clipped, so if you move the model too far back\n"
                text = text + "# it will disappear. You will most likely want to use zoom instead of Y position.\n\n"
                text = text + "MHScript.setPositionY(2.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getPositionY()'):
                text = "# getPositionY()\n"
                text = text + "#\n"
                text = text + "# Returns the current Y position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.getPositionY()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyPositionY()'):
                text = "# modifyPositionY(ymod)\n"
                text = text + "#\n"
                text = text + "# Modifies Y position of the model of the model in 3d space.\n"
                text = text + "# Note that the depth of the scene is clipped, so if you move the model too far back\n"
                text = text + "# it will disappear. You will most likely want to use zoom instead of Y position.\n\n"
                text = text + "MHScript.modifyPositionY(-0.1)\n\n"
                self.scriptText.addText(text)

            if (item == 'setRotationX()'):
                text = "# setRotationX(xrot)\n"
                text = text + "#\n"
                text = text + "# Sets the rotation around the X axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.setRotationX(90.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getRotationX()'):
                text = "# getRotationX()\n"
                text = text + "#\n"
                text = text + "# Returns the current rotatation around the X axis of the model.\n\n"
                text = text + "MHScript.getRotationX()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyRotationX()'):
                text = "# modifyRotationX(xmod)\n"
                text = text + "#\n"
                text = text + "# Modifies the rotation around the X axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.modifyRotationX(-5.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'setRotationZ()'):
                text = "# setRotationZ(zrot)\n"
                text = text + "#\n"
                text = text + "# Sets the rotation around the Z axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.setRotationZ(90.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getRotationZ()'):
                text = "# getRotationZ()\n"
                text = text + "#\n"
                text = text + "# Returns the current rotatation around the Z axis of the model.\n\n"
                text = text + "MHScript.getRotationZ()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyRotationZ()'):
                text = "# modifyRotationZ(zmod)\n"
                text = text + "#\n"
                text = text + "# Modifies the rotation around the Z axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.modifyRotationZ(-5.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'setRotationY()'):
                text = "# setRotationY(yrot)\n"
                text = text + "#\n"
                text = text + "# Sets the rotation around the Y axis for the model, where 0.0 is upright projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.setRotationY(90.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getRotationY()'):
                text = "# getRotationY()\n"
                text = text + "#\n"
                text = text + "# Returns the current rotatation around the Y axis of the model.\n\n"
                text = text + "MHScript.getRotationY()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyRotationY()'):
                text = "# modifyRotationY(ymod)\n"
                text = text + "#\n"
                text = text + "# Modifies the rotation around the Y axis for the model, where 0.0 is upright projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.modifyRotationY(-5.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'setZoom()'):
                text = "# setZoom(zoom)\n"
                text = text + "#\n"
                text = text + "# Sets current camera zoom. In practise this moves the camera closer or further from the.\n"
                text = text + "# the model. The zoom factor is reversed ans goes from 100.0 which is far away from the\n"
                text = text + "# the model as possible (if you move further away, the model will be clipped and disappear)\n"
                text = text + "# and 0.0 is inside the model. A zoom factor of 10.0 is what is used for the face\n"
                text = text + "# projection, and is in most cases as zoomed in as is functional.\n\n"
                text = text + "MHScript.setZoom(70.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyZoom()'):
                text = "# modifyZoom(zmod)\n"
                text = text + "#\n"
                text = text + "# Modifies current camera zoom. In practise this moves the camera closer or further from the.\n"
                text = text + "# the model. The zoom factor is reversed ans goes from 100.0 which is far away from the\n"
                text = text + "# the model as possible (if you move further away, the model will be clipped and disappear)\n"
                text = text + "# and 0.0 is inside the model. A zoom factor of 10.0 is what is used for the face\n"
                text = text + "# projection, and is in most cases as zoomed in as is functional.\n\n"
                text = text + "MHScript.modifyZoom(1.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getZoom()'):
                text = "# getZoom()\n"
                text = text + "#\n"
                text = text + "# Returns the current camera zoom factor.\n\n"
                text = text + "MHScript.getZoom()\n\n"
                self.scriptText.addText(text)
Beispiel #10
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Scripting')

        self.directory = os.getcwd()
        self.filename =  None

        box = self.addLeftWidget(gui.GroupBox('Script'))

        self.scriptText = self.addTopWidget(gui.DocumentEdit())
        self.scriptText.setText('');

        self.scriptText.setLineWrapMode(gui.DocumentEdit.NoWrap)

        self.loadButton = box.addWidget(gui.Button('Load ...'), 0, 0)
        self.saveButton = box.addWidget(gui.Button('Save ...'), 0, 1)

        @self.loadButton.mhEvent
        def onClicked(event):
            filename = mh.getOpenFileName(self.directory, 'Python scripts (*.py);;All files (*.*)')
            if(os.path.exists(filename)):
                contents = open(filename, 'r').read()
                self.scriptText.setText(contents)
                dlg = gui.Dialog()
                dlg.prompt("Load script","File was loaded in an acceptable manner","OK")
                self.filename = filename
                self.directory = os.path.split(filename)[0]
            else:
                dlg = gui.Dialog()
                dlg.prompt("Load script","File " + filename + " does not seem to exist","OK")

        @self.saveButton.mhEvent
        def onClicked(event):
            filename = mh.getSaveFileName(self.filename or self.directory, 'Python scripts (*.py);;All files (*.*)')
            with open(filename, "w") as f:
                f.write(self.scriptText.getText())
            dlg = gui.Dialog()
            dlg.prompt("Save script","File was written in an acceptable manner","OK")
            self.filename = filename
            self.directory = os.path.split(filename)[0]

        box2 = self.addLeftWidget(gui.GroupBox('Examples'))

        self.insertLabel = box2.addWidget(gui.TextView('Append example to script'))
        self.listView = box2.addWidget(gui.ListView())
        self.listView.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)

        testlist = [ 
            'applyTarget()', 
            'incrementingFilename()',
            'loadModel()',
            'saveModel()',
            'screenShot()',
            'setAge()',
            'printDetailStack()',
            'setWeight()'
        ]

        self.listView.setData(testlist)

        self.insertButton = box2.addWidget(gui.Button('Append'))

        @self.insertButton.mhEvent
        def onClicked(event):
            item = self.listView.getSelectedItem()

            if(item == 'applyTarget()'):
                text = "# applyTarget(<target file name>, <power (from 0.0 to 1.0)>)\n"
                text = text + "#\n"
                text = text + "# This will apply the target on the model. If the target was already applied, the power will be updated\n"
                text = text + "# Note that targets are relative to the data/targets directory, and should not include the .target\n"
                text = text + "# extension, so a valid target name would be, for example, \"breast/breast-dist-max\"\n\n"
                text = text + "MHScript.applyTarget('aTargetName',1.0)\n\n"
                self.scriptText.addText(text)

            if(item == 'loadModel()'):
                text = "# loadModel(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will load a human model from an MHM file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .MHM extension. The [path] part defaults to the user's makehuman/models directory.\n\n"
                text = text + "MHScript.loadModel('myTestModel')\n\n"
                self.scriptText.addText(text)

            if(item == 'incrementingFilename()'):
                text = "# incrementingFilename(<file name base>, [file extension], [pad length])\n"
                text = text + "#\n"
                text = text + "# This will return a file name containing a numerical component which increases by one for each call.\n"
                text = text + "# The default file extension is \".png\". The default pad length is 4. For example, the following lines:\n";
                text = text + "#\n"
                text = text + "# print incrementingFilename(\"test\",\".target\",3) + \"\\n\"\n"
                text = text + "# print incrementingFilename(\"test\",\".target\",3) + \"\\n\"\n"
                text = text + "#\n"
                text = text + "# Will print:\n"
                text = text + "#\n"
                text = text + "# test001.target\n"
                text = text + "# test002.target\n"
                text = text + "#\n"
                text = text + "# The counter is reset each time the script is executed\n\n"
                text = text + "filename = MHScript.incrementingFilename('test')\n\n"
                self.scriptText.addText(text)

            if(item == 'printDetailStack()'):
                text = "# printDetailStack()\n"
                text = text + "#\n"
                text = text + "# This will print a list of all applied targets (and their weights) to standard output.\n\n"
                text = text + "MHScript.printDetailStack()\n\n"
                self.scriptText.addText(text)

            if(item == 'saveModel()'):
                text = "# saveModel(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will save the human model to an MHM file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .MHM extension. The [path] part defaults to the user's makehuman/models directory.\n"
                text = text + "# Note that this will not save any thumbnail.\n\n"
                text = text + "MHScript.saveModel('myTestModel')\n\n"
                self.scriptText.addText(text)

            if(item == 'screenShot()'):
                text = "# screenShot(<png file name>)\n"
                text = text + "#\n"
                text = text + "# This will save a png file of how the model currently looks.\n\n"
                text = text + "MHScript.screenShot('screenshot.png')\n\n"
                self.scriptText.addText(text)

            if(item == 'setAge()'):
                text = "# setAge(age)\n"
                text = text + "#\n"
                text = text + "# Sets the age of the model. The age parameter is a float between 0 and 1, where 0 is 12 years old and 1 is 70.\n\n"
                text = text + "MHScript.setAge(0.5)\n\n"
                self.scriptText.addText(text)

            if(item == 'setWeight()'):
                text = "# setWeight(weight)\n"
                text = text + "#\n"
                text = text + "# Sets the weight of the model. The weight parameter is a float between 0 and 1, where 0 is starved and\n"
                text = text + "# 1 is severely overweight\n\n"
                text = text + "MHScript.setWeight(0.5)\n\n"
                self.scriptText.addText(text)
Beispiel #11
0
    def main(self):
        verticalContainer = gui.Widget(640, 680, False, 10)

        horizontalContainer = gui.Widget(620, 620, True, 10)

        subContainerLeft = gui.Widget(340, 530, False, 10)
        self.img = gui.Image(100, 100, './res/logo.png')

        self.table = gui.Table(300, 200)
        row = gui.TableRow()
        item = gui.TableTitle()
        item.append(str(id(item)), 'ID')
        row.append(str(id(item)), item)
        item = gui.TableTitle()
        item.append(str(id(item)), 'First Name')
        row.append(str(id(item)), item)
        item = gui.TableTitle()
        item.append(str(id(item)), 'Last Name')
        row.append(str(id(item)), item)
        self.table.append(str(id(row)), row)
        self.add_table_row(self.table, '101', 'Danny', 'Young')
        self.add_table_row(self.table, '102', 'Christine', 'Holand')
        self.add_table_row(self.table, '103', 'Lars', 'Gordon')
        self.add_table_row(self.table, '104', 'Roberto', 'Robitaille')
        self.add_table_row(self.table, '105', 'Maria', 'Papadopoulos')

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget(240, 560, False, 10)

        self.lbl = gui.Label(200, 30, 'This is a LABEL!')

        self.bt = gui.Button(200, 30, 'Press me!')
        # setting the listener for the onclick event of the button
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        self.txt = gui.TextInput(200, 30)
        self.txt.set_text('This is a TEXTAREA')
        self.txt.set_on_change_listener(self, 'on_text_area_change')

        self.spin = gui.SpinBox(200, 30)
        self.spin.set_on_change_listener(self, 'on_spin_change')

        self.btInputDiag = gui.Button(200, 30, 'Open InputDialog')
        self.btInputDiag.set_on_click_listener(self, 'open_input_dialog')

        self.btFileDiag = gui.Button(200, 30, 'File Selection Dialog')
        self.btFileDiag.set_on_click_listener(self,
                                              'open_fileselection_dialog')

        self.btUploadFile = gui.FileUploader(200, 30, './')
        self.btUploadFile.set_on_success_listener(self,
                                                  'fileupload_on_success')
        self.btUploadFile.set_on_failed_listener(self, 'fileupload_on_failed')

        self.listView = gui.ListView(300, 120)
        self.listView.set_on_selection_listener(self, "list_view_on_selected")
        li0 = gui.ListItem(279, 20, 'Danny Young')
        li1 = gui.ListItem(279, 20, 'Christine Holand')
        li2 = gui.ListItem(279, 20, 'Lars Gordon')
        li3 = gui.ListItem(279, 20, 'Roberto Robitaille')
        self.listView.append('0', li0)
        self.listView.append('1', li1)
        self.listView.append('2', li2)
        self.listView.append('3', li3)

        self.dropDown = gui.DropDown(200, 20)
        c0 = gui.DropDownItem(200, 20, 'DropDownItem 0')
        c1 = gui.DropDownItem(200, 20, 'DropDownItem 1')
        self.dropDown.append('0', c0)
        self.dropDown.append('1', c1)
        self.dropDown.set_on_change_listener(self, 'drop_down_changed')

        self.slider = gui.Slider(200, 20, 10, 0, 100, 5)
        self.slider.set_on_change_listener(self, 'slider_changed')

        self.colorPicker = gui.ColorPicker(200, 20, '#ffbb00')
        self.colorPicker.set_on_change_listener(self, 'color_picker_changed')

        self.date = gui.Date(200, 20, '2015-04-13')
        self.date.set_on_change_listener(self, 'date_changed')

        # appending a widget to another, the first argument is a string key
        subContainerRight.append('1', self.lbl)
        subContainerRight.append('2', self.bt)
        subContainerRight.append('3', self.txt)
        subContainerRight.append('4', self.spin)
        subContainerRight.append('5', self.btInputDiag)
        subContainerRight.append('5_', self.btFileDiag)
        subContainerRight.append(
            '5__',
            gui.FileDownloader(200, 30, 'download test', './res/logo.png'))
        subContainerRight.append('5___', self.btUploadFile)
        subContainerRight.append('6', self.dropDown)
        subContainerRight.append('7', self.slider)
        subContainerRight.append('8', self.colorPicker)
        subContainerRight.append('9', self.date)
        self.subContainerRight = subContainerRight

        subContainerLeft.append('0', self.img)
        subContainerLeft.append('1', self.table)
        subContainerLeft.append('2', self.listView)

        horizontalContainer.append('0', subContainerLeft)
        horizontalContainer.append('1', subContainerRight)

        menu = gui.Menu(620, 40)
        m1 = gui.MenuItem(100, 40, 'File')
        m2 = gui.MenuItem(100, 40, 'View')
        m2.set_on_click_listener(self, 'menu_view_clicked')
        m11 = gui.MenuItem(100, 40, 'Save')
        m12 = gui.MenuItem(100, 40, 'Open')
        m12.set_on_click_listener(self, 'menu_open_clicked')
        m111 = gui.MenuItem(100, 40, 'Save')
        m111.set_on_click_listener(self, 'menu_save_clicked')
        m112 = gui.MenuItem(100, 40, 'Save as')
        m112.set_on_click_listener(self, 'menu_saveas_clicked')

        menu.append('1', m1)
        menu.append('2', m2)
        m1.append('11', m11)
        m1.append('12', m12)
        m11.append('111', m111)
        m11.append('112', m112)

        verticalContainer.append('0', menu)
        verticalContainer.append('1', horizontalContainer)

        # returning the root widget
        return verticalContainer
Beispiel #12
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Scene Editor')
        sceneBox = self.addLeftWidget(gui.GroupBox('Scene'))
        self.fnlbl = sceneBox.addWidget(gui.TextView('<New scene>'))
        self.saveButton = sceneBox.addWidget(gui.Button('Save'), 1, 0)
        self.loadButton = sceneBox.addWidget(gui.Button('Load ...'), 1, 1)
        self.saveAsButton = sceneBox.addWidget(gui.Button('Save As...'), 2, 0)
        self.closeButton = sceneBox.addWidget(gui.Button('Close'), 2, 1)

        itemBox = self.addLeftWidget(gui.GroupBox('Items'))
        self.itemList = itemBox.addWidget(gui.ListView())
        self.itemList.setSizePolicy(gui.SizePolicy.Ignored,
                                    gui.SizePolicy.Preferred)

        self.propsBox = gui.StackedBox()
        self.addRightWidget(self.propsBox)

        self.addButton = itemBox.addWidget(gui.Button('Add...'))
        self.adder = SceneItemAdder(self)
        self.propsBox.addWidget(self.adder.widget)

        self.items = {}
        self.activeItem = None
        self.scene = scene.Scene()
        self.readScene()

        def doLoad():
            filename = mh.getOpenFileName(
                mh.getPath("scenes"),
                'MakeHuman scene (*.mhscene);;All files (*.*)')
            if filename:
                self.scene.load(filename)
                self.readScene()

        @self.scene.mhEvent
        def onChanged(scene):
            self.updateFileTitle()

        @self.loadButton.mhEvent
        def onClicked(event):
            if self.scene.unsaved:
                gui3d.app.prompt(
                    'Confirmation',
                    'Your scene is unsaved. Are you sure you want to close it?',
                    'Close', 'Cancel', doLoad())
            else:
                doLoad()

        @self.saveButton.mhEvent
        def onClicked(event):
            if self.scene.path is None:
                self.saveAsButton.callEvent('onClicked', None)
            else:
                self.scene.save()
            self.updateFileTitle()

        @self.closeButton.mhEvent
        def onClicked(event):
            if self.scene.unsaved:
                gui3d.app.prompt(
                    'Confirmation',
                    'Your scene is unsaved. Are you sure you want to close it?',
                    'Close', 'Cancel', self.scene.close())
            else:
                self.scene.close()
            self.readScene()

        @self.saveAsButton.mhEvent
        def onClicked(event):
            filename = mh.getSaveFileName(
                mh.getPath("scenes"),
                'MakeHuman scene (*.mhscene);;All files (*.*)')
            if filename:
                self.scene.save(filename)
            self.updateFileTitle()

        @self.itemList.mhEvent
        def onClicked(event):
            self.items[self.itemList.getSelectedItem()].showProps()

        @self.addButton.mhEvent
        def onClicked(event):
            self.adder.showProps()
    def __init__(self, category):        
        
        gui3d.TaskView.__init__(self, category, 'Download assets')

        self.notfound = mhapi.locations.getSystemDataPath("notfound.thumb")

        self.human = gui3d.app.selectedHuman

        self.selectBox = self.addLeftWidget(gui.GroupBox('Select asset'))

        self.selectBox.addWidget(gui.TextView("\nType"))
        #self.typeList = self.selectBox.addWidget(gui.ListView())
        #self.typeList.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)


        types = [
            "Target",
            "Clothes",
            "Hair",
            "Teeth",
            "Eyebrows",
            "Eyelashes",
            "Skin",
            "Proxy",
            "Pose",
            "Material",
            "Model",
            "Rig"
        ]

        self.typeList = mhapi.ui.createComboBox(types,self.onTypeChange)
        self.selectBox.addWidget(self.typeList)

        #self.typeList.setData(types)
        #self.typeList.setCurrentRow(0)
        #self.typeList.selectionModel().selectionChanged.connect(self.onTypeChange)

        categories = [
            "All"
        ]

        self.selectBox.addWidget(gui.TextView("\nCategory"))
        self.categoryList = mhapi.ui.createComboBox(categories,self.onCategoryChange)
        self.selectBox.addWidget(self.categoryList)
        self.categoryList.setCurrentRow(0)

        self.selectBox.addWidget(gui.TextView("\nAsset"))
        self.assetList = self.selectBox.addWidget(gui.ListView())
        self.assetList.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)

        assets = [
        ]

        self.assetList.setData(assets)
        self.assetList.selectionModel().selectionChanged.connect(self.onAssetChange)

        self.selectBox.addWidget(gui.TextView(" "))

        self.downloadButton = self.selectBox.addWidget(gui.Button('Download'))
        self.downloadButton.setDisabled(True)

        self.downloadLabel = self.selectBox.addWidget(gui.TextView(" "))
        self.downloadLabel.setWordWrap(True)
        
        @self.downloadButton.mhEvent
        def onClicked(event):
            self.downloadButtonClick()

        self.refreshBox = self.addRightWidget(gui.GroupBox('Synchronize'))
        refreshString = "Synchronizing data with the server can take some time, so it is not done automatically. Synchronizing will also download thumbnails and screenshots, if available. Click here to start the synchronization."
        self.refreshLabel = self.refreshBox.addWidget(gui.TextView(refreshString))
        self.refreshLabel.setWordWrap(True)
        self.refreshButton = self.refreshBox.addWidget(gui.Button('Synchronize'))

        @self.refreshButton.mhEvent
        def onClicked(event):
            self.refreshButtonClick()

        self.mainPanel = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()

        self.assetInfoBox = gui.GroupBox("Asset info")
        self.assetInfoText = self.assetInfoBox.addWidget(gui.TextView("No asset selected"))
        self.assetDescription = self.assetInfoBox.addWidget(gui.TextView("-"))
        self.assetDescription.setWordWrap(True)

        layout.addWidget(self.assetInfoBox)

        self.assetThumbBox = gui.GroupBox("Asset thumbnail (if any)")
        self.thumbnail = self.assetThumbBox.addWidget(gui.TextView())
        self.thumbnail.setPixmap(QtGui.QPixmap(os.path.abspath(self.notfound)))
        self.thumbnail.setGeometry(0,0,128,128)

        layout.addWidget(self.assetThumbBox)

        self.assetScreenieBox = gui.GroupBox("Asset screenshot (if any)")
        self.screenshot = self.assetScreenieBox.addWidget(gui.TextView(""))
        self.screenshot.setPixmap(QtGui.QPixmap(os.path.abspath(self.notfound)))

        layout.addWidget(self.assetScreenieBox)

        layout.addStretch(1)

        self.mainPanel.setLayout(layout)

        self.addTopWidget(self.mainPanel)

        self.setupAssetDir()
    def __init__(self, category):
        # Setup GUI elements
        gui3d.TaskView.__init__(self, category, 'Actions')

        box = self.addLeftWidget(gui.GroupBox('Export'))
        self.rigButton = box.addWidget(FileSelectView('Load BVH'))
        self.rigButton.setDirectory(DATA_PATH)
        self.rigButton.setFilter('Biovision Motion Hierarchy (*.bvh)')
        self.exportButton = box.addWidget(gui.Button('Export animation'))
        self.exportAllButton = box.addWidget(gui.Button('Export all'))

        self.window = None
        @self.rigButton.mhEvent
        def onFilesSelected(filenames):
            if not self.skel:
                self.loadRig()
            loadFirst = (self.animationList.rowCount() == 0)
            for filename in filenames:
                if filename not in self.selectedBVHs:
                    item = self.animationList.addItem(os.path.splitext(os.path.basename(filename))[0])
                    item.filename = filename
                    self.selectedBVHs.add(filename)
            if loadFirst:
                self.loadAnimation(filenames[0])

        @self.exportButton.mhEvent
        def onClicked(event):
            self.export()

        @self.exportAllButton.mhEvent
        def onClicked(event):
            self.exportAll()

        self.human = gui3d.app.selectedHuman
        self.humanChanged = False
        self.humanTransparent = False

        self.selectedBVHs = set()

        self.skel = None
        self.animated = None

        self.bvhAnimated = None

        self.skelMesh = None
        self.skelObj = None

        self.bvhMesh = None
        self.bvhObj = None

        self.timer = None
        self.currFrame = 0
        self.anim = None

        self.bvhAnim = None

        self.oldHumanTransp = self.human.meshData.transparentPrimitives

        optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.kinectCamTggle = optionsBox.addWidget(gui.ToggleButton("Kinect camera"))
        self.kinectCamTggle.setSelected(True)

        self.useMHCamTggl = optionsBox.addWidget(gui.ToggleButton("Use camera pos"))
        self.useMHCamTggl.setSelected(False)

        mesh = BackPlane(20, 20, centered=True)
        self.bgPlane = self.addObject(gui3d.Object([0, 0, 0], mesh))
        mesh.setColor([255, 255, 255, 255])
        mesh.setShadeless(True)
        mesh.priority = -90

        mesh = GroundPlane(20, 20, centered=True)
        self.groundPlane = self.addObject(gui3d.Object([0, 0, 0], mesh))
        mesh.setColor([0, 0, 0, 255])
        mesh.setShadeless(True)
        mesh.priority = -90

        yOffset = self.getFeetOnGroundOffset()
        self.groundposSlider = optionsBox.addWidget(gui.Slider(value=int(yOffset), min=-125,max=125, label = "Ground Pos: %d"))
        self.groundposVal = int(yOffset)
        self.groundPlane.mesh.move(0,yOffset,0)

        @self.groundposSlider.mhEvent
        def onChanging(value):
            val = value - self.groundposVal
            self.groundPlane.mesh.move(0,val,0)
            self.groundposVal = self.groundposVal + val
        @self.groundposSlider.mhEvent
        def onChange(value):
            val = value - self.groundposVal
            self.groundPlane.mesh.move(0,val,0)
            self.groundposVal = self.groundposVal + val

        self.backposSlider = optionsBox.addWidget(gui.Slider(value=-9, min=-125,max=125, label = "Back Pos: %d"))
        self.backposVal = -9

        @self.backposSlider.mhEvent
        def onChanging(value):
            val = value - self.backposVal
            self.bgPlane.mesh.move(0,0,val)
            self.backposVal = self.backposVal + val
        @self.backposSlider.mhEvent
        def onChange(value):
            val = value - self.backposVal
            self.bgPlane.mesh.move(0,0,val)
            self.backposVal = self.backposVal + val

        self.bgPlane.mesh.move(0,0,self.backposVal)
        
        displayBox = self.addRightWidget(gui.GroupBox('Display'))
        self.showHumanTggl = displayBox.addWidget(gui.ToggleButton("Show human"))
        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()
        self.showHumanTggl.setSelected(True)

        self.showMHXRigTggl = displayBox.addWidget(gui.ToggleButton("Show human Rig"))
        @self.showMHXRigTggl.mhEvent
        def onClicked(event):
            self.setShowRig(self.showMHXRigTggl.selected)
        self.showMHXRigTggl.setSelected(True)
 
        self.showBVHRigTggl = displayBox.addWidget(gui.ToggleButton("Show BVH Rig"))
        @self.showBVHRigTggl.mhEvent
        def onClicked(event):
            self.setShowBVHRig(self.showBVHRigTggl.selected)
        self.showBVHRigTggl.setSelected(False)

        self.imageExported = False

        self.playbackBox = None
        self.playPause = None

        self.createPlaybackControl()
        animationListBox = self.addRightWidget(gui.GroupBox('BVHs'))
        self.animationList = animationListBox.addWidget(gui.ListView())
        self.animationList.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.MinimumExpanding)
        self.animationList.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        @self.animationList.mhEvent
        def onClicked(item):
            self.loadAnimation(item.filename)
        self.removeAnimBtn = animationListBox.addWidget(gui.Button('Remove selected'))
        @self.removeAnimBtn.mhEvent
        def onClicked(item):
            print "remove clicked"
            if len(self.animationList.selectedItems()) > 0:
                print "taking action"
                item = self.animationList.selectedItems()[0]
                self.removeAnimation(item.filename)
Beispiel #15
0
gui.Label(name='label_image', left='10', top='306', parent='mywin.notebook.tab_message', text='Image')
gui.Button(label='File', name='choose_image', left='80', top='300', width='85', default=True, parent='mywin.notebook.tab_message', onclick=ui.choose_image)
gui.TextBox(name='filename', left='166', top='301', parent='mywin.notebook.tab_message', value='')

# buttons
gui.Button(label='Send', name='send', left='80', top='326', width='85', default=True, parent='mywin.notebook.tab_message')
gui.StatusBar(name='statusbar', parent='mywin')

#### list ####
gui.Label(name='label_page', left='10', top='5', parent='mywin.notebook.tab_list', text='Page : 0/0')
gui.Button(label='Prev', name='prev', left='100', top='5', width='85', default=True, parent='mywin.notebook.tab_list', onclick=ui.refresh_prev)
gui.Button(label='Next', name='next', left='190', top='5', width='85', default=True, parent='mywin.notebook.tab_list', onclick=ui.refresh_next)
gui.Button(label='Refresh', name='refresh', left='290', top='5', width='85', default=True, parent='mywin.notebook.tab_list', onclick=ui.refresh_status)
gui.ListView(name='listview', height='320', left='0', top='30', width='590', 
             item_count=27, parent='mywin.notebook.tab_list', sort_column=0, 
             onitemselected="print ('sel %s' % event.target.get_selected_items())", )
gui.ListColumn(name='col_accepted_time', text='Date', parent='listview', )
gui.ListColumn(name='col_callno', text='Phone Number', parent='listview', )
gui.ListColumn(name='col_status', text='Status', width=20, parent='listview', )
gui.ListColumn(name='col_resultcode', text='Result Code', width=26, parent='listview', )
gui.ListColumn(name='col_resultmessage', text='Result Message', parent='listview', )
gui.ListColumn(name='col_sent_time', text='Sent time', parent='listview', )
gui.ListColumn(name='col_text', text='Text', parent='listview', )

mywin = gui.get("mywin")

mywin.onload = ui.load
mywin['notebook']['tab_message']['send'].onclick = ui.send_message
mywin['menubar']['menu']['menu_quit'].onclick = ui.close_window
Beispiel #16
0
    def __init__(self, category):
        RenderTaskView.__init__(self, category, 'Render')

        # Declare settings
        G.app.addSetting('GL_RENDERER_SSS', False)
        G.app.addSetting('GL_RENDERER_AA', True)

        # Don't change shader for this RenderTaskView.
        self.taskViewShader = G.app.selectedHuman.material.shader

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        settingsBox.addWidget(gui.TextView("Resolution"))
        self.resBox = settingsBox.addWidget(gui.TextEdit(
            "x".join([str(self.renderingWidth), str(self.renderingHeight)])))
        self.AAbox = settingsBox.addWidget(gui.CheckBox("Anti-aliasing"))
        self.AAbox.setSelected(G.app.getSetting('GL_RENDERER_AA'))
        self.renderButton = settingsBox.addWidget(gui.Button('Render'))

        self.lightmapSSS = gui.CheckBox("Lightmap SSS")
        self.lightmapSSS.setSelected(G.app.getSetting('GL_RENDERER_SSS'))

        self.optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.optionsWidgets = []

        renderMethodBox = self.addRightWidget(gui.GroupBox('Rendering methods'))
        self.renderMethodList = renderMethodBox.addWidget(gui.ListView())
        self.renderMethodList.setSizePolicy(
            gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)

        # Rendering methods
        self.renderMethodList.addItem('Quick Render')
        self.renderMethodList.addItem('Advanced Render',
            data=[self.lightmapSSS])

        if not mh.hasRenderToRenderbuffer():
            self.firstTimeWarn = True
            # Can only use screen grabbing as fallback,
            # resolution option disabled
            self.resBox.setEnabled(False)
            self.AAbox.setEnabled(False)

        self.listOptions(None)

        @self.resBox.mhEvent
        def onChange(value):
            try:
                value = value.replace(" ", "")
                res = [int(x) for x in value.split("x")]
                self.renderingWidth = res[0]
                self.renderingHeight = res[1]
            except:  # The user hasn't typed the value correctly yet.
                pass

        @self.AAbox.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_AA', self.AAbox.selected)

        @self.lightmapSSS.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_SSS', self.lightmapSSS.selected)

        @self.renderMethodList.mhEvent
        def onClicked(item):
            self.listOptions(item.getUserData())

        @self.renderButton.mhEvent
        def onClicked(event):
            settings = dict()
            settings['scene'] = G.app.scene
            settings['AA'] = self.AAbox.selected
            settings['dimensions'] = (self.renderingWidth, self.renderingHeight)
            settings['lightmapSSS'] = self.lightmapSSS.selected and self.lightmapSSS in self.optionsWidgets

            mh2opengl.Render(settings)
Beispiel #17
0
    def __init__(self, category):
        RenderTaskView.__init__(self, category, 'Interpolation Render')

        # Declare settings
        G.app.addSetting('GL_RENDERER_SSS', False)
        G.app.addSetting('GL_RENDERER_AA', True)

        # Don't change shader for this RenderTaskView.
        self.taskViewShader = G.app.selectedHuman.material.shader

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        settingsBox.addWidget(gui.TextView("Resolution"))
        self.resBox = settingsBox.addWidget(
            gui.TextEdit("x".join(
                [str(self.renderingWidth),
                 str(self.renderingHeight)])))
        self.AAbox = settingsBox.addWidget(gui.CheckBox("Anti-aliasing"))
        self.AAbox.setSelected(G.app.getSetting('GL_RENDERER_AA'))

        self.path = ""
        self.path_button = settingsBox.addWidget(
            gui.BrowseButton('dir', "Select an output directory"))
        self.pathBox = settingsBox.addWidget(gui.TextEdit(self.path))

        self.save_models = gui.CheckBox("Save a Model per Frame")
        settingsBox.addWidget(self.save_models)

        @self.path_button.mhEvent
        def onClicked(path):
            self.path = path
            self.pathBox.setText(self.path)

        self.renderButton = settingsBox.addWidget(gui.Button('Render'))

        self.lightmapSSS = gui.CheckBox("Lightmap SSS")
        self.lightmapSSS.setSelected(G.app.getSetting('GL_RENDERER_SSS'))

        self.optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.optionsWidgets = []

        renderMethodBox = self.addRightWidget(
            gui.GroupBox('Rendering methods'))
        self.renderMethodList = renderMethodBox.addWidget(gui.ListView())
        self.renderMethodList.setSizePolicy(gui.SizePolicy.Ignored,
                                            gui.SizePolicy.Preferred)

        # Rendering methods
        self.renderMethodList.addItem('Quick Render')
        self.renderMethodList.addItem('Advanced Render',
                                      data=[self.lightmapSSS])

        if not mh.hasRenderToRenderbuffer():
            self.firstTimeWarn = True
            # Can only use screen grabbing as fallback,
            # resolution option disabled
            self.resBox.setEnabled(False)
            self.AAbox.setEnabled(False)

        self.listOptions(None)

        # add interpolation settings to the right pane
        interpolateFrameBox = self.addRightWidget(gui.GroupBox('Total Frames'))
        interpolateFrameBox.addWidget(gui.TextView("Frames"))
        self.framesBox = interpolateFrameBox.addWidget(gui.TextEdit("120"))

        interpolatedFramesBox = self.addRightWidget(
            gui.GroupBox('Interpolated Frames'))
        self.interpolatedFramesList = interpolatedFramesBox.addWidget(
            gui.ListView())
        self.interpolatedFramesList.setSizePolicy(gui.SizePolicy.Ignored,
                                                  gui.SizePolicy.Preferred)
        self.interpolatedFramesList.setVerticalScrollingEnabled(True)
        self.addFrame = interpolatedFramesBox.addWidget(
            gui.Button('Add Frame'))
        self.removeFrame = interpolatedFramesBox.addWidget(
            gui.Button('Remove Frame'))
        self.save_button = interpolatedFramesBox.addWidget(
            gui.BrowseButton('save', "Save As.."))
        self.load_button = interpolatedFramesBox.addWidget(
            gui.BrowseButton('open', 'Load JSON'))

        self.key_frames = None

        @self.load_button.mhEvent
        def onClicked(path):
            with open(path, 'r') as f:
                self.key_frames = json.load(f)
                self.GUItize_key_frames()
                self.resort_frames()

        @self.save_button.mhEvent
        def onClicked(path):
            self.generate_key_frames()

            with open(path, 'w') as f:
                json.dump(self.key_frames, f)

        interpolateSettingsBox = self.addRightWidget(
            gui.GroupBox('Interpolation Settings'))
        interpolateSettingsBox.addWidget(
            gui.TextView(
                "Current Frame (integer frame # or float proportion)"))
        self.currentFramesBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("0.0"))
        interpolateSettingsBox.addWidget(
            gui.TextView("Orbit Camera Y (left-right)"))
        self.camY = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        interpolateSettingsBox.addWidget(
            gui.TextView("Oribt Camera X (up-down)"))
        self.camX = interpolateSettingsBox.addWidget(gui.TextEdit(""))

        interpolateSettingsBox.addWidget(
            gui.TextView("Zoom Factor (8.7 for default face cam)"))
        self.camZ = interpolateSettingsBox.addWidget(gui.TextEdit(""))

        interpolateSettingsBox.addWidget(gui.TextView("Model File"))
        self.modelBox = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        self.model_button = interpolateSettingsBox.addWidget(
            gui.BrowseButton('open', "Select a model file"))

        @self.model_button.mhEvent
        def onClicked(path):
            self.modelBox.setText(path)

        interpolateSettingsBox.addWidget(
            gui.TextView("Model Extrapolation Percentage"))
        self.modelPercentageBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("100"))
        # allow alpha beta parameters
        self.modelAlphaBetaList = interpolateSettingsBox.addWidget(
            gui.ListView())
        interpolateSettingsBox.addWidget(gui.TextView("Features"))
        self.modelFeatureBox = interpolateSettingsBox.addWidget(
            gui.TextEdit(".*"))
        # recommended groups
        self.modelGroups = [
            "all", "nose", "head", "forehead", "eyebrow", "eyes", "mouth",
            "ear", "chin", "cheek"
        ]
        self.modelGroupBox = mhapi.ui.createComboBox(self.modelGroups,
                                                     self._onModelGroupChange)
        interpolateSettingsBox.addWidget(self.modelGroupBox)

        interpolateSettingsBox.addWidget(gui.TextView("Alpha"))
        self.modelAlphaBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("1.0"))
        interpolateSettingsBox.addWidget(gui.TextView("Beta"))
        self.modelBetaBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("1.0"))
        self.modelAddButton = interpolateSettingsBox.addWidget(
            gui.Button("Add"))
        self.modelRemoveButton = interpolateSettingsBox.addWidget(
            gui.Button("Remove"))

        interpolateSettingsBox.addWidget(
            gui.TextView("Expression file (or specify 'None')"))
        self.expressionBox = interpolateSettingsBox.addWidget(gui.TextEdit(""))
        self.expression_button = interpolateSettingsBox.addWidget(
            gui.BrowseButton('open', "Select an expression file"))
        interpolateSettingsBox.addWidget(
            gui.TextView("Expression Extrapolation Percentage"))
        self.expressionPercentageBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("100"))
        # alphas and betas for expressions
        self.expressionAlphaBetaList = interpolateSettingsBox.addWidget(
            gui.ListView())
        interpolateSettingsBox.addWidget(gui.TextView("Features"))
        self.expressionFeatureBox = interpolateSettingsBox.addWidget(
            gui.TextEdit(".*"))
        # recommended groups
        self.expressionGroups = [
            "all", "Nose", "Eyebrow", "Eye", "Mouth", "Chin", "Cheek",
            "Left Eyebrow", "Left Chin", "Left Eye", "Left Mouth",
            "Right Eyebrow", "Right Chin", "Right Eye", "Right Mouth"
        ]
        self.expressionGroupBox = mhapi.ui.createComboBox(
            self.expressionGroups, self._onExpressionGroupChange)
        interpolateSettingsBox.addWidget(self.expressionGroupBox)

        interpolateSettingsBox.addWidget(gui.TextView("Alpha"))
        self.expressionAlphaBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("1.0"))
        interpolateSettingsBox.addWidget(gui.TextView("Beta"))
        self.expressionBetaBox = interpolateSettingsBox.addWidget(
            gui.TextEdit("1.0"))
        self.expressionAddButton = interpolateSettingsBox.addWidget(
            gui.Button("Add"))
        self.expressionRemoveButton = interpolateSettingsBox.addWidget(
            gui.Button("Remove"))

        @self.modelAddButton.mhEvent
        def onClicked(event):
            features = self.modelFeatureBox.getText()
            alpha = float(self.modelAlphaBox.getText())
            beta = float(self.modelBetaBox.getText())
            self.modelAlphaBetaList.addItem('{0}: ({1:0.2f}, {2:0.2f})'.format(
                features, alpha, beta),
                                            data=dict(features=features,
                                                      alpha=alpha,
                                                      beta=beta))

        @self.modelRemoveButton.mhEvent
        def onClicked(event):
            selected_frame = self.modelAlphaBetaList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [
                item for item in self.modelAlphaBetaList.getItems()
                if item is not selected_frame
            ]
            self.reassign(self.modelAlphaBetaList, new_items)

        @self.expressionAddButton.mhEvent
        def onClicked(event):
            features = self.expressionFeatureBox.getText()
            alpha = float(self.expressionAlphaBox.getText())
            beta = float(self.expressionBetaBox.getText())
            self.expressionAlphaBetaList.addItem(
                '{0}: ({1:0.2f}, {2:0.2f})'.format(features, alpha, beta),
                data=dict(features=features, alpha=alpha, beta=beta))

        @self.expressionRemoveButton.mhEvent
        def onClicked(event):
            selected_frame = self.expressionAlphaBetaList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [
                item for item in self.expressionAlphaBetaList.getItems()
                if item is not selected_frame
            ]
            self.reassign(self.expressionAlphaBetaList, new_items)

        @self.expression_button.mhEvent
        def onClicked(path):
            self.expressionBox.setText(path)

        self.updateFrame = interpolateSettingsBox.addWidget(
            gui.Button('Update Frame'))

        self.keybox = {
            "frame": self.currentFramesBox,
            "rot_Y": self.camY,
            "rot_X": self.camX,
            "cam_Z": self.camZ,
            "model": self.modelBox,
            "expression": self.expressionBox
        }

        @self.framesBox.mhEvent
        def onChange(value):
            try:
                tmp = 1 / int(value)
                self.resort_frames()
            except:
                pass

        # save the values back to the selected frame
        @self.updateFrame.mhEvent
        def onClicked(event):
            selected_frame = self.interpolatedFramesList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            selected_frame.setText('Frame {0}'.format(
                self.currentFramesBox.getText()))

            # each item has a Regular expression and the alpha beta values
            model_extra = {}
            for item in self.modelAlphaBetaList.getItems():
                d = item.getUserData()
                model_extra[d['features']] = (d['alpha'], d['beta'])

            expression_extra = {}
            for item in self.expressionAlphaBetaList.getItems():
                d = item.getUserData()
                expression_extra[d['features']] = (d['alpha'], d['beta'])

            selected_frame.setUserData(
                data={
                    "frame":
                    self.num(self.currentFramesBox.getText()),
                    "rot_Y":
                    self.num(self.camY.getText()),
                    "rot_X":
                    self.num(self.camX.getText()),
                    "cam_Z":
                    self.num(self.camZ.getText()),
                    "model": (self.modelBox.getText(),
                              self.num(self.modelPercentageBox.getText()),
                              model_extra),
                    "expression": (
                        self.expressionBox.getText(),
                        self.num(self.expressionPercentageBox.getText()),
                        expression_extra)
                })
            self.resort_frames()
            self.generate_key_frames()

        @self.addFrame.mhEvent
        def onClicked(event):
            # each item has a Regular expression and the alpha beta values
            model_extra = {}
            for item in self.modelAlphaBetaList.getItems():
                d = item.getUserData()
                model_extra[d['features']] = (d['alpha'], d['beta'])

            expression_extra = {}
            for item in self.expressionAlphaBetaList.getItems():
                d = item.getUserData()
                expression_extra[d['features']] = (d['alpha'], d['beta'])

            self.interpolatedFramesList.addItem(
                'Frame {0}'.format(self.currentFramesBox.getText()),
                data={
                    "frame":
                    self.num(self.currentFramesBox.getText()),
                    "rot_Y":
                    self.num(self.camY.getText()),
                    "rot_X":
                    self.num(self.camX.getText()),
                    "cam_Z":
                    self.num(self.camZ.getText()),
                    "model":
                    (self.modelBox.getText(),
                     self.num(self.modelPercentageBox.getText()), model_extra),
                    "expression":
                    (self.expressionBox.getText(),
                     self.num(self.expressionPercentageBox.getText()),
                     expression_extra)
                })
            self.resort_frames()

        @self.removeFrame.mhEvent
        def onClicked(event):
            selected_frame = self.interpolatedFramesList.selectedItems()
            if len(selected_frame) == 0:
                return
            selected_frame = selected_frame[0]
            new_items = [
                item for item in self.interpolatedFramesList.getItems()
                if item is not selected_frame
            ]
            self.reassign(self.interpolatedFramesList, new_items)

        @self.interpolatedFramesList.mhEvent
        def onClicked(item):
            self.listInterpolationFrameOptions(item.getUserData())

        @self.resBox.mhEvent
        def onChange(value):
            try:
                value = value.replace(" ", "")
                res = [int(x) for x in value.split("x")]
                self.renderingWidth = res[0]
                self.renderingHeight = res[1]
            except:  # The user hasn't typed the value correctly yet.
                pass

        @self.AAbox.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_AA', self.AAbox.selected)

        @self.lightmapSSS.mhEvent
        def onClicked(value):
            G.app.setSetting('GL_RENDERER_SSS', self.lightmapSSS.selected)

        @self.renderMethodList.mhEvent
        def onClicked(item):
            self.listOptions(item.getUserData())

        @self.renderButton.mhEvent
        def onClicked(event):
            settings = dict()
            settings['scene'] = G.app.scene
            settings['AA'] = self.AAbox.selected
            settings['dimensions'] = (self.renderingWidth,
                                      self.renderingHeight)
            settings[
                'lightmapSSS'] = self.lightmapSSS.selected and self.lightmapSSS in self.optionsWidgets
            settings['saveModels'] = self.save_models.selected
            # change the timing of the render
            # add path output
            self.generate_key_frames()
            interpolate.do_op(self.key_frames,
                              "Front",
                              save_path=self.pathBox.getText(),
                              render_function=(mh2opengl.Render, settings))
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Scripting')

        self.directory = os.getcwd()
        self.filename = None

        scriptingHome = mh.getPath('scripts')
        if not os.path.exists(scriptingHome):
            try:
                os.mkdir(scriptingHome)
            except OSError:
                scriptingHome = mh.getPath()

        box = self.addLeftWidget(gui.GroupBox('Script'))

        self.scriptText = self.addTopWidget(gui.DocumentEdit())
        self.scriptText.setText('')

        self.scriptText.setLineWrapMode(gui.DocumentEdit.NoWrap)

        self.loadButton = box.addWidget(gui.BrowseButton(mode='open'), 0, 0)
        self.loadButton.setLabel('Load ...')
        self.loadButton.directory = scriptingHome
        self.saveButton = box.addWidget(gui.BrowseButton(mode='save'), 0, 1)
        self.saveButton.setLabel('Save ...')
        self.saveButton.directory = scriptingHome

        @self.loadButton.mhEvent
        def onClicked(filename):
            if not filename:
                return

            if (os.path.exists(filename)):
                contents = io.open(filename, 'r', encoding="utf-8").read()
                self.scriptText.setText(contents)
                dlg = gui.Dialog()
                dlg.prompt("Load script",
                           "File was loaded in an acceptable manner", "OK")
                self.filename = filename
                self.directory = os.path.split(filename)[0]
            else:
                dlg = gui.Dialog()
                dlg.prompt("Load script",
                           "File %s does not exist",
                           "OK",
                           fmtArgs=filename)

        @self.saveButton.mhEvent
        def onClicked(filename):
            if not filename:
                return

            with io.open(filename, "w", encoding="utf-8") as f:
                f.write(self.scriptText.getText())
            dlg = gui.Dialog()
            dlg.prompt("Save script",
                       "File was written in an acceptable manner", "OK")
            self.filename = filename
            self.directory = os.path.split(filename)[0]

        box2 = self.addLeftWidget(gui.GroupBox('Examples'))

        self.insertLabel = box2.addWidget(
            gui.TextView('Append example to script'))
        self.listView = box2.addWidget(gui.ListView())
        self.listView.setSizePolicy(gui.SizePolicy.Ignored,
                                    gui.SizePolicy.Preferred)

        testlist = [
            'applyTarget()', 'incrementingFilename()', 'getHeightCm()',
            'getPositionX()', 'getPositionY()', 'getPositionZ()',
            'getRotationX()', 'getRotationY()', 'getRotationZ()', 'getZoom()',
            'loadModel()', 'modifyPositionX()', 'modifyPositionY()',
            'modifyPositionZ()', 'modifyRotationX()', 'modifyRotationY()',
            'modifyRotationZ()', 'modifyZoom()', 'printCameraInfo()',
            'printDetailStack()', 'printPositionInfo()', 'printRotationInfo()',
            'saveModel()', 'screenShot()', 'setAge()', 'setPositionX()',
            'setPositionY()', 'setPositionZ()', 'setRotationX()',
            'setRotationY()', 'setRotationZ()', 'setZoom()', 'setWeight()',
            'setMaterial()', 'setHeadSquareness()', 'getModelingParameters()',
            'updateModelingParameter()', 'updateModelingParameters()',
            'saveObj()'
        ]

        self.listView.setData(testlist)

        self.insertButton = box2.addWidget(gui.Button('Append'))

        @self.insertButton.mhEvent
        def onClicked(event):
            item = self.listView.getSelectedItem()

            if (item == 'applyTarget()'):
                text = "# applyTarget(<target file name>, <power (from 0.0 to 1.0)>)\n"
                text = text + "#\n"
                text = text + "# This will apply the target on the model. If the target was already applied, the power will be updated\n"
                text = text + "# Note that targets are relative to the data/targets directory, and should not include the .target\n"
                text = text + "# extension, so a valid target name would be, for example, \"breast/breast-dist-max\"\n\n"
                text = text + "MHScript.applyTarget('aTargetName',1.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'loadModel()'):
                text = "# loadModel(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will load a human model from an MHM file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .MHM extension. The [path] part defaults to the user's makehuman/models directory.\n\n"
                text = text + "MHScript.loadModel('myTestModel')\n\n"
                self.scriptText.addText(text)

            if (item == 'incrementingFilename()'):
                text = "# incrementingFilename(<file name base>, [file extension], [pad length])\n"
                text = text + "#\n"
                text = text + "# This will return a file name containing a numerical component which increases by one for each call.\n"
                text = text + "# The default file extension is \".png\". The default pad length is 4. For example, the following lines:\n"
                text = text + "#\n"
                text = text + "# print incrementingFilename(\"test\",\".target\",3) + \"\\n\"\n"
                text = text + "# print incrementingFilename(\"test\",\".target\",3) + \"\\n\"\n"
                text = text + "#\n"
                text = text + "# Will print:\n"
                text = text + "#\n"
                text = text + "# test001.target\n"
                text = text + "# test002.target\n"
                text = text + "#\n"
                text = text + "# The counter is reset each time the script is executed\n\n"
                text = text + "filename = MHScript.incrementingFilename('test')\n\n"
                self.scriptText.addText(text)

            if (item == 'printCameraInfo()'):
                text = "# printCameraInfo()\n"
                text = text + "#\n"
                text = text + "# This will print info about how the camera is targeted and focused .\n\n"
                text = text + "MHScript.printCameraInfo()\n\n"
                self.scriptText.addText(text)

            if (item == 'printDetailStack()'):
                text = "# printDetailStack()\n"
                text = text + "#\n"
                text = text + "# This will print a list of all applied targets (and their weights) to standard output.\n\n"
                text = text + "MHScript.printDetailStack()\n\n"
                self.scriptText.addText(text)

            if (item == 'printPositionInfo()'):
                text = "# printPositionInfo()\n"
                text = text + "#\n"
                text = text + "# This will print info about where the human object is currently located.\n\n"
                text = text + "MHScript.printPositionInfo()\n\n"
                self.scriptText.addText(text)

            if (item == 'printRotationInfo()'):
                text = "# printRotationInfo()\n"
                text = text + "#\n"
                text = text + "# This will print info about how the human object is currently rotated.\n\n"
                text = text + "MHScript.printRotationInfo()\n\n"
                self.scriptText.addText(text)

            if (item == 'saveModel()'):
                text = "# saveModel(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will save the human model to an MHM file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .MHM extension. The [path] part defaults to the user's makehuman/models directory.\n"
                text = text + "# Note that this will not save any thumbnail.\n\n"
                text = text + "MHScript.saveModel('myTestModel')\n\n"
                self.scriptText.addText(text)

            if (item == 'saveObj()'):
                text = "# saveObj(<model name>,[path])\n"
                text = text + "#\n"
                text = text + "# This will save the human model to a wavefront .OBJ file. The <model name> part should be a string without spaces\n"
                text = text + "# and without the .obj extension. The [path] part defaults to the user's makehuman/exports directory.\n"
                text = text + "MHScript.saveObj('myOBJExport')\n\n"
                self.scriptText.addText(text)

            if (item == 'screenShot()'):
                text = "# screenShot(<png file name>)\n"
                text = text + "#\n"
                text = text + "# This will save a png file of how the model currently looks.\n\n"
                text = text + "MHScript.screenShot('screenshot.png')\n\n"
                self.scriptText.addText(text)

            if (item == 'setAge()'):
                text = "# setAge(age)\n"
                text = text + "#\n"
                text = text + "# Sets the age of the model. The age parameter is a float between 0 and 1, where 0 is 1 year old, 0.18 is 10 years old, 0.5 is 25 years and 1 equals 90 years old.\n\n"
                text = text + "MHScript.setAge(0.5)\n\n"
                self.scriptText.addText(text)

            if (item == 'setWeight()'):
                text = "# setWeight(weight)\n"
                text = text + "#\n"
                text = text + "# Sets the weight of the model. The weight parameter is a float between 0 and 1, where 0 is starved and\n"
                text = text + "# 1 is severely overweight\n\n"
                text = text + "MHScript.setWeight(0.5)\n\n"
                self.scriptText.addText(text)

            if (item == 'setHeadSquareness()'):
                text = "# setHeadSquareness(squareness)\n"
                text = text + "#\n"
                text = text + "# Sets the squaredness of the model's head. The squareness parameter is a float between 0 and 1, where 0 is not square and\n"
                text = text + "# 1 is very square shaped\n\n"
                text = text + "MHScript.setHeadSquareness(0.5)\n\n"
                self.scriptText.addText(text)

            if (item == 'setMaterial()'):
                text = "# setMaterial(mhmat_filename)\n"
                text = text + "#\n"
                text = text + "# Sets the skin material of the 3D model\n"
                text = text + "# The filename must be realtive to the App Resources directory\n\n"
                text = text + "MHScript.setMaterial('data/skins/young_caucasian_female/young_caucasian_female.mhmat')\n\n"
                self.scriptText.addText(text)

            if (item == 'getHeightCm()'):
                text = "# getHeightCm()\n"
                text = text + "#\n"
                text = text + "# Gets the current height of the model, in cm.\n\n"
                text = text + "height = MHScript.getHeightCm()\n"
                text = text + "print('height='+str(height))\n\n"
                self.scriptText.addText(text)

            if (item == 'getModelingParameters()'):
                text = "# getModelingParameters()\n"
                text = text + "#\n"
                text = text + "# Prints the names of all modeling aspects that can be modified on the human model.\n"
                text = text + "MHScript.getModelingParameters()\n\n"
                self.scriptText.addText(text)

            if (item == 'updateModelingParameter()'):
                text = "# updateModelingParameter(parameterName, value)\n"
                text = text + "#\n"
                text = text + "# Sets the modeling parameter with specified name of the model to the specified value.\n"
                text = text + "# The value is a float between 0 and 1, where 0 means nothing at all or minimal, and 1 is the maximum value.\n\n"
                text = text + "MHScript.updateModelingParameter('macrodetails/Age', 0.7)\n\n"
                self.scriptText.addText(text)

            if (item == 'updateModelingParameters()'):
                text = "# updateModelingParameters(dictOfParameterNameAndValue)\n"
                text = text + "#\n"
                text = text + "# Sets more modeling parameters with specified names of the model to the specified values.\n"
                text = text + "# Faster than setting parameters one by one because the 3D mesh is updated only once.\n"
                text = text + "# The values are a float between 0 and 1, where 0 means nothing at all or minimal, and 1 is the maximum value.\n\n"
                text = text + "MHScript.updateModelingParameters({'macrodetails/Caucasian': 1.000,'macrodetails/Gender': 1.000,'macrodetails/Age': 0.250})\n\n"
                self.scriptText.addText(text)

            if (item == 'setPositionX()'):
                text = "# setPositionX(xpos)\n"
                text = text + "#\n"
                text = text + "# Sets the X position of the model of the model in 3d space, where 0.0 is centered.\n\n"
                text = text + "MHScript.setPositionX(2.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getPositionX()'):
                text = "# getPositionX()\n"
                text = text + "#\n"
                text = text + "# Returns the current X position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.getPositionX()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyPositionX()'):
                text = "# modifyPositionX(xmod)\n"
                text = text + "#\n"
                text = text + "# Modifies X position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.modifyPositionX(-0.1)\n\n"
                self.scriptText.addText(text)

            if (item == 'setPositionZ()'):
                text = "# setPositionZ(zpos)\n"
                text = text + "#\n"
                text = text + "# Sets the Z position of the model of the model in 3d space, where 0.0 is centered.\n\n"
                text = text + "MHScript.setPositionZ(2.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getPositionZ()'):
                text = "# getPositionZ()\n"
                text = text + "#\n"
                text = text + "# Returns the current Z position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.getPositionZ()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyPositionZ()'):
                text = "# modifyPositionZ(zmod)\n"
                text = text + "#\n"
                text = text + "# Modifies Z position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.modifyPositionZ(-0.1)\n\n"
                self.scriptText.addText(text)

            if (item == 'setPositionY()'):
                text = "# setPositionY(ypos)\n"
                text = text + "#\n"
                text = text + "# Sets the Y position of the model of the model in 3d space, where 0.0 is centered.\n"
                text = text + "# Note that the depth of the scene is clipped, so if you move the model too far back\n"
                text = text + "# it will disappear. You will most likely want to use zoom instead of Y position.\n\n"
                text = text + "MHScript.setPositionY(2.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getPositionY()'):
                text = "# getPositionY()\n"
                text = text + "#\n"
                text = text + "# Returns the current Y position of the model of the model in 3d space.\n\n"
                text = text + "MHScript.getPositionY()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyPositionY()'):
                text = "# modifyPositionY(ymod)\n"
                text = text + "#\n"
                text = text + "# Modifies Y position of the model of the model in 3d space.\n"
                text = text + "# Note that the depth of the scene is clipped, so if you move the model too far back\n"
                text = text + "# it will disappear. You will most likely want to use zoom instead of Y position.\n\n"
                text = text + "MHScript.modifyPositionY(-0.1)\n\n"
                self.scriptText.addText(text)

            if (item == 'setRotationX()'):
                text = "# setRotationX(xrot)\n"
                text = text + "#\n"
                text = text + "# Sets the rotation around the X axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.setRotationX(90.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getRotationX()'):
                text = "# getRotationX()\n"
                text = text + "#\n"
                text = text + "# Returns the current rotatation around the X axis of the model.\n\n"
                text = text + "MHScript.getRotationX()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyRotationX()'):
                text = "# modifyRotationX(xmod)\n"
                text = text + "#\n"
                text = text + "# Modifies the rotation around the X axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.modifyRotationX(-5.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'setRotationZ()'):
                text = "# setRotationZ(zrot)\n"
                text = text + "#\n"
                text = text + "# Sets the rotation around the Z axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.setRotationZ(90.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getRotationZ()'):
                text = "# getRotationZ()\n"
                text = text + "#\n"
                text = text + "# Returns the current rotatation around the Z axis of the model.\n\n"
                text = text + "MHScript.getRotationZ()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyRotationZ()'):
                text = "# modifyRotationZ(zmod)\n"
                text = text + "#\n"
                text = text + "# Modifies the rotation around the Z axis for the model, where 0.0 is frontal projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.modifyRotationZ(-5.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'setRotationY()'):
                text = "# setRotationY(yrot)\n"
                text = text + "#\n"
                text = text + "# Sets the rotation around the Y axis for the model, where 0.0 is upright projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.setRotationY(90.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getRotationY()'):
                text = "# getRotationY()\n"
                text = text + "#\n"
                text = text + "# Returns the current rotatation around the Y axis of the model.\n\n"
                text = text + "MHScript.getRotationY()\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyRotationY()'):
                text = "# modifyRotationY(ymod)\n"
                text = text + "#\n"
                text = text + "# Modifies the rotation around the Y axis for the model, where 0.0 is upright projection.\n"
                text = text + "# Rotation is set in degrees from -180.0 to +180.0 (these two extremes are equal)\n\n"
                text = text + "MHScript.modifyRotationY(-5.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'setZoom()'):
                text = "# setZoom(zoom)\n"
                text = text + "#\n"
                text = text + "# Sets current camera zoom. In practise this moves the camera closer or further from the.\n"
                text = text + "# the model. The zoom factor is reversed ans goes from 100.0 which is far away from the\n"
                text = text + "# the model as possible (if you move further away, the model will be clipped and disappear)\n"
                text = text + "# and 0.0 is inside the model. A zoom factor of 10.0 is what is used for the face\n"
                text = text + "# projection, and is in most cases as zoomed in as is functional.\n\n"
                text = text + "MHScript.setZoom(70.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'modifyZoom()'):
                text = "# modifyZoom(zmod)\n"
                text = text + "#\n"
                text = text + "# Modifies current camera zoom. In practise this moves the camera closer or further from the.\n"
                text = text + "# the model. The zoom factor is reversed ans goes from 100.0 which is far away from the\n"
                text = text + "# the model as possible (if you move further away, the model will be clipped and disappear)\n"
                text = text + "# and 0.0 is inside the model. A zoom factor of 10.0 is what is used for the face\n"
                text = text + "# projection, and is in most cases as zoomed in as is functional.\n\n"
                text = text + "MHScript.modifyZoom(1.0)\n\n"
                self.scriptText.addText(text)

            if (item == 'getZoom()'):
                text = "# getZoom()\n"
                text = text + "#\n"
                text = text + "# Returns the current camera zoom factor.\n\n"
                text = text + "MHScript.getZoom()\n\n"
                self.scriptText.addText(text)
Beispiel #19
0
    def __init__(self, category):
        guirender.RenderTaskView.__init__(self, category, 'Scene Editor')
        sceneBox = self.addLeftWidget(gui.GroupBox('Scene'))
        self.fnlbl = sceneBox.addWidget(gui.TextView('<New scene>'))
        self.saveButton = sceneBox.addWidget(gui.Button('Save'), 1, 0)
        self.loadButton = sceneBox.addWidget(gui.Button('Load ...'), 1, 1)
        self.saveAsButton = sceneBox.addWidget(gui.Button('Save As...'), 2, 0)
        self.closeButton = sceneBox.addWidget(gui.Button('Close'), 2, 1)

        itemBox = self.addLeftWidget(gui.GroupBox('Items'))
        self.itemList = itemBox.addWidget(gui.ListView())
        self.itemList.setSizePolicy(gui.SizePolicy.Ignored,
                                    gui.SizePolicy.Preferred)

        self.propsBox = gui.StackedBox()
        self.addRightWidget(self.propsBox)

        self.addButton = itemBox.addWidget(gui.Button('Add...'))
        self.adder = SceneItemAdder(self)
        self.propsBox.addWidget(self.adder.widget)

        self.items = {}
        self.activeItem = None
        self.scene = scene.Scene()
        self.readScene()

        def doLoad():
            filename = mh.getOpenFileName(
                G.app.settings.get('Scene_Editor_FileDlgPath',
                                   mh.getPath('data/scenes')),
                'MakeHuman scene (*.mhscene);;All files (*.*)')
            if filename:
                G.app.settings['Scene_Editor_FileDlgPath'] = filename
                self.scene.load(filename)
                self.readScene()

        def doSave(filename=None):
            ok = self.scene.save(filename)
            if ok and not G.app.currentScene.path is None \
                and os.path.normpath(G.app.currentScene.path) \
                == os.path.normpath(self.scene.path):
                # Refresh MH's current scene if it was modified.
                G.app.currentScene.reload()

        @self.scene.mhEvent
        def onChanged(scn):
            self.updateScene()

        @self.loadButton.mhEvent
        def onClicked(event):
            if self.scene.unsaved:
                G.app.prompt(
                    'Confirmation',
                    'Your scene is unsaved. Are you sure you want to close it?',
                    'Close', 'Cancel', doLoad)
            else:
                doLoad()

        @self.saveButton.mhEvent
        def onClicked(event):
            if self.scene.path is None:
                self.saveAsButton.callEvent('onClicked', None)
            else:
                doSave()
            self.updateFileTitle()

        @self.closeButton.mhEvent
        def onClicked(event):
            if self.scene.unsaved:
                G.app.prompt(
                    'Confirmation',
                    'Your scene is unsaved. Are you sure you want to close it?',
                    'Close', 'Cancel', self.scene.close)
            else:
                self.scene.close()
            self.readScene()

        @self.saveAsButton.mhEvent
        def onClicked(event):
            filename = mh.getSaveFileName(
                G.app.settings.get('Scene_Editor_FileDlgPath',
                                   mh.getPath('data/scenes')),
                'MakeHuman scene (*.mhscene);;All files (*.*)')
            if filename:
                G.app.settings['Scene_Editor_FileDlgPath'] = filename
                doSave(filename)
            self.updateFileTitle()

        @self.itemList.mhEvent
        def onClicked(event):
            self.items[self.itemList.getSelectedItem()].showProps()

        @self.addButton.mhEvent
        def onClicked(event):
            self.adder.showProps()