Пример #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)
Пример #2
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Expression mixer')

        self.human = gui3d.app.selectedHuman

        self.base_bvh = None
        self.base_anim = None

        self.sliders = []
        self.modifiers = {}

        savebox = self.addRightWidget(gui.GroupBox("Save"))
        loadbox = self.addRightWidget(gui.GroupBox('Load'))
        resetbox = self.addRightWidget(gui.GroupBox('Reset'))

        self.nameField = savebox.addWidget(TextEdit("Name"))
        self.descrField = savebox.addWidget(TextEdit("Description"))
        self.tagsField = savebox.addWidget(TextEdit("Tags (separate with ;)"))
        self.authorField = savebox.addWidget(TextEdit("Author"))
        self.copyrightField = savebox.addWidget(TextEdit("Copyright"))
        self.licenseField = savebox.addWidget(TextEdit("License"))
        self.websiteField = savebox.addWidget(TextEdit("Website"))

        lic = mh.getAssetLicense()
        self.authorField.setValue(lic.author)
        self.copyrightField.setValue(lic.copyright)
        self.licenseField.setValue(lic.license)
        self.websiteField.setValue(lic.homepage)
        self.descrField.setValue("No description set")
        self.tagsField.setValue("")

        self.saveBtn = savebox.addWidget(
            gui.BrowseButton(mode='save', label="Save pose"))
        self.saveBtn.setFilter("MakeHuman blend pose file (*.mhpose)")
        savepath = getpath.getDataPath('expressions')
        if not os.path.exists(savepath):
            os.makedirs(savepath)
        self.saveBtn.setDirectory(getpath.getDataPath('expressions'))

        self.loadBtn = loadbox.addWidget(
            gui.BrowseButton(mode='open', label='Load pose'))
        self.loadBtn.setFilter('MakeHuman Poses (*.mhpose)')

        self.resetBtn = resetbox.addWidget(gui.Button('Reset'))

        @self.saveBtn.mhEvent
        def onClicked(path):
            if path:
                if not os.path.splitext(path)[1]:
                    path = path + ".mhpose"
                self.saveCurrentPose(path)

        @self.loadBtn.mhEvent
        def onClicked(path):
            if os.path.isfile(path):
                self.loadPose(path)

        @self.resetBtn.mhEvent
        def onClicked(event):
            self.resetExpression()
Пример #3
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Standardize Models')


        buttonsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        buttonsBox.addWidget(gui.TextView("Options"))
        self.geoBox = buttonsBox.addWidget(gui.CheckBox("Geometries"))
        self.shapeBox = buttonsBox.addWidget(gui.CheckBox("Shapes"))
        # self.AAbox.selected
        
        self.path_out = ""
        self.path_button_out = buttonsBox.addWidget(gui.BrowseButton('dir', "Select an output directory"))
        self.out_path_box = buttonsBox.addWidget(gui.TextEdit(self.path_out))
        
        self.path_in = ""
        self.path_button_in = buttonsBox.addWidget(gui.BrowseButton('dir', "Select an input directory"))
        self.in_path_box = buttonsBox.addWidget(gui.TextEdit(self.path_in))
        
        self.path_exemplar = ""
        self.path_button_exemplar = buttonsBox.addWidget(gui.BrowseButton('open', "Select the standard model"))
        self.exemplar_path_box = buttonsBox.addWidget(gui.TextEdit(self.path_exemplar))
        
        @self.path_button_out.mhEvent
        def onClicked(path):
            self.path_out = path
            self.out_path_box.setText(self.path_out)
        
        @self.path_button_in.mhEvent
        def onClicked(path):
            self.path_in = path
            self.in_path_box.setText(self.path_in)
            
        @self.path_button_exemplar.mhEvent
        def onClicked(path):
            self.path_exemplar = path
            self.exemplar_path_box.setText(self.path_exemplar)
        buttonsBox.addWidget(gui.TextView("Features to standardize (comma+space separated regular expressions)"))
        self.standardShapeFeatures = buttonsBox.addWidget(gui.TextEdit("^head, neck, ear, proportions"))
        
        self.goButton = buttonsBox.addWidget(gui.Button('Go'))
        
        @self.goButton.mhEvent
        def onClicked(event):
            settings = {}
            settings['geometries'] = self.geoBox.selected
            settings['shapes'] = self.shapeBox.selected
            settings['standard_shapes'] = self.standardShapeFeatures.getText().split(", ")
            standard = Standardizer(settings['standard_shapes'])
            specific_model = self.exemplar_path_box.getText()
            if specific_model == "":
                specific_model = None
            standard.load_models(self.in_path_box.getText(), specific_model)
            if settings['geometries'] and settings['standard_shapes']:
                standard.standardize_all(self.out_path_box.getText())
            elif settings['geometries']:
                standard.standardize_geometries(self.out_path_box.getText())  
            elif settings['standard_shapes']:
                standard.standardize_shape(self.out_path_box.getText())  
Пример #4
0
    def __init__(self, parent, value, defaultPath = None):
        super(TextureValue, self).__init__()
        self.parent = parent

        self.layout = gui.QtWidgets.QGridLayout(self)
        self.imageView = gui.ImageView()
        self.browseBtn = gui.BrowseButton()
        self.browseBtn.setFilter("Image Files (*.png *.jpg *.bmp)")

        self.layout.addWidget(self.imageView)
        self.layout.addWidget(self.browseBtn)

        self.value = value

        self.setValue(value)
        if value and isinstance(value, str):
            self.browseBtn._path = pathToUnicode(value)
        elif defaultPath:
            self.browseBtn._path = pathToUnicode(defaultPath)

        @self.browseBtn.mhEvent
        def onClicked(path):
            if not path:
                return
            self._path = pathToUnicode(path)
            self.imageView.setImage(self.value)
            self.parent.callEvent('onActivate', self.value)
Пример #5
0
    def __init__(self, category):
        super(ProfilingTaskView, self).__init__(category, 'Profile')
        self.profile = None

        self.sortKey = 'prim'
        self.sortDir = 0

        self.table = self.addTopWidget(gui.TableView())

        self.sortKeyBox = self.addLeftWidget(gui.GroupBox('Sort'))
        group = []
        for name, key in Stat._fields:
            radio = self.sortKeyBox.addWidget(KeyRadioButton(group, name, key))

        self.sortDirBox = self.addLeftWidget(gui.GroupBox('Sort'))
        group = []
        for name, dir in [('Descending', 0), ('Ascending', 1)]:
            radio = self.sortDirBox.addWidget(DirRadioButton(group, name, dir))

        self.saveBox = self.addLeftWidget(gui.GroupBox('Save'))
        self.save = gui.BrowseButton('save')
        self.saveBox.addWidget(self.save)
        self.save.setEnabled(False)

        self.table.setColumnCount(len(self._columns))
        self.table.setHorizontalHeaderLabels(self._columns)
        self.table.setColumnWidth(len(self._columns) - 1, 300)

        @self.save.mhEvent
        def onClicked(path):
            if path:
                self.saveStats(path)
Пример #6
0
    def __init__(self, category):
        guirender.RenderTaskView.__init__(self, category, 'Mitsuba')

        # Buttons
        pathBox = self.addLeftWidget(gui.GroupBox('Mitsuba  bin  path'))
        mitsuba_bin = gui3d.app.settings.get('mitsuba_bin', '')
        self.path= pathBox.addWidget(gui.TextEdit(str(mitsuba_bin)), 0, 0, 1, 2)
        self.browse = pathBox.addWidget(gui.BrowseButton('dir'), 1, 0, 1, 1)
        self.browse.setPath(mitsuba_bin)
        if sys.platform == 'win32':
            self.browse.setFilter('Executable programs (*.exe);;All files (*.*)')
        #
        @self.path.mhEvent
        def onChange(value):
            gui3d.app.settings['mitsuba_bin'] = 'Enter your path' if not value else str(value)

        @self.browse.mhEvent
        def onClicked(path):
            if os.path.isfile(path):
                gui3d.app.settings['mitsuba_bin'] = path
                self.path.setText(path)

        # Type of lighting method
        lightingBox = self.addLeftWidget(gui.GroupBox('Integrators'))
        lighting = []
        self.dlButton = lightingBox.addWidget(gui.RadioButton(lighting, 'DirectLighting', selected = True))
        self.ptButton = lightingBox.addWidget(gui.RadioButton(lighting, 'Path Tracing'))
        self.pmButton = lightingBox.addWidget(gui.RadioButton(lighting, 'Photon Mapping'))

        #
        samplerBox = self.addLeftWidget(gui.GroupBox('Sampler Options'))
        sampler = []
        self.lowdButton = samplerBox.addWidget(gui.RadioButton(sampler, 'Low Discrepancy', selected = True))
        self.indepButton = samplerBox.addWidget(gui.RadioButton(sampler, 'Independent'))
        #
        renderBox = self.addLeftWidget(gui.GroupBox('Render Options'))
        source=[]
        self.consoleButton = renderBox.addWidget(gui.RadioButton(source, 'Render console'))
        self.guiButton = renderBox.addWidget(gui.RadioButton(source, 'Render GUI', selected = True))
        self.xmlButton = renderBox.addWidget(gui.RadioButton(source, 'Write XML'))
        self.renderButton = renderBox.addWidget(gui.Button('Render'))


        @self.renderButton.mhEvent
        def onClicked(event):

            reload(mh2mitsuba)  # Avoid having to close and reopen MH for every coding change (can be removed once testing is complete)
            mh2mitsuba.MitsubaExport(gui3d.app.selectedHuman.mesh, gui3d.app,
                {'source':'console' if self.consoleButton.selected else 'gui' if self.guiButton.selected else 'xml',
                 'lighting':'dl' if self.dlButton.selected else 'pt' if self.ptButton.selected else 'pm',
                 'sampler':'low' if self.lowdButton.selected else 'ind'})
Пример #7
0
    def __init__(self, category):

        super(SaveTargetsTaskView, self).__init__(category, 'Save Targets')

        self.fileName = 'full_target.target'
        self.dirName = gp.getDataPath('custom')

        self.saveBox = gui.GroupBox('Save Model as Target')
        self.addLeftWidget(self.saveBox)

        label = self.saveBox.addWidget(gui.TextView('Filename:'))

        self.nameEdit = gui.TextEdit(self.fileName)
        self.nameEdit.textChanged.connect(self.onChange)
        self.saveBox.addWidget(self.nameEdit)

        space = self.saveBox.addWidget(gui.TextView(''))

        self.saveButton = gui.Button('Save')
        self.saveBox.addWidget(self.saveButton)

        self.saveAsButton = gui.BrowseButton(label='Save As ...', mode='save')
        self.saveAsButton.path = os.path.join(self.dirName, self.fileName)
        self.saveAsButton.setFilter('MakeHuman Target ( *.target )')
        self.saveBox.addWidget(self.saveAsButton)

        self.createShortCut()

        @self.saveButton.mhEvent
        def onClicked(event):
            self.quickSave()

        @self.saveAsButton.mhEvent
        def onClicked(path):
            if path:
                if not path.lower().endswith('.target'):
                    error_msg = 'Cannot save target to file: {0:s}\n Expected a path to a .target file'.format(
                        path)
                    dialog = gui.Dialog()
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    return
                else:
                    self.saveTargets(path)
                    self.nameEdit.setText(self.fileName)
                    self.saveAsButton.path = path
                    G.app.statusPersist('Saving Directory: ' + self.dirName)
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Import Measurements')
        self.human = G.app.selectedHuman
        toolbox = self.addLeftWidget(gui.SliderBox('Import JSON'))
        self.loadButton = toolbox.addWidget(gui.BrowseButton(mode='open'), 0,
                                            0)
        self.loadButton.setLabel('Load ...')
        self.loadButton.directory = mh.getPath()
        self.saveAsButton = toolbox.addWidget(gui.Button('Save As...'), 2, 0)

        @self.loadButton.mhEvent
        def onClicked(filename):
            if not filename:
                return
            if (os.path.exists(filename)):
                # read in json information
                contents = open(filename, 'rU', encoding="utf-8").read()
                log.debug('File contents read')
                newMeasurements = json.loads(contents)
                # validate/process the new measurements
                #oldValues = dict( [(m.fullName, m.getValue()) for m in self.human.modifiers] )
                newValues, oldValues = processMeaurements(
                    self.human, newMeasurements)
                log.debug("File imported for measurements")
                # apply new measurements
                gui3d.app.do(ImportAction(self.human, oldValues, newValues))
                log.debug("Imported measurements have been applied")
                self.filename = filename
                self.directory = os.path.split(filename)[0]
                log.debug(oldValues)
                for key, value in newValues.iteritems():
                    if key in measures:
                        DebugDump().appendMessage('{0}: {1}'.format(
                            key, str(getMeasure(self.human, key, 'metric'))))

            else:
                log.debug(
                    "Imported measurements have been not been applied, file does not exist"
                )

        @self.saveAsButton.mhEvent
        def onClicked(event):
            filename = mh.getSaveFileName(
                mh.getPath(), 'JSON File (*.json);;All files (*.*)')
            if filename:
                doSave(filename)
Пример #9
0
    def __init__(self, name, value, defaultPath = None):
        super(FileValue, self).__init__(name)
        self.name = name

        self.fileText = self.addWidget(gui.TextView(''), 0, 0)
        self.browseBtn = self.addWidget(gui.BrowseButton(), 1, 0)

        if value:
            self.browseBtn._path = pathToUnicode(value)
        elif defaultPath:
            self.browseBtn._path = pathToUnicode(defaultPath)

        @self.browseBtn.mhEvent
        def onClicked(path):
            if not path:
                return
            self.setValue(path)
            self.callEvent('onActivate', self.getValue())

        self.setValue(value)
Пример #10
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))
Пример #11
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Average Model')

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        self.path = ""
        self.path_button = settingsBox.addWidget(
            gui.BrowseButton('dir', "Select an input 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.goButton = settingsBox.addWidget(gui.Button('Start'))

        self.save_button = settingsBox.addWidget(
            gui.Button("Save Average JSON"))
        self.load_button = settingsBox.addWidget(
            gui.BrowseButton('dir', 'Load Average JSONs from Folder'))
        self.generate_button = settingsBox.addWidget(
            gui.Button('Generate Randomly From Average'))

        self.avg_params = None
        self.params_max = None
        self.params_min = None

        @self.goButton.mhEvent
        def onClicked(event):
            self.avg_params, self.sd_params, self.params_min, self.params_max = makehuman_average.make_average(
                self.pathBox.getText())

        @self.load_button.mhEvent
        def onClicked(path):
            jsons = glob(os.path.join(path, "*.json"))
            self.pathBox.setText(self.path)
            for file in jsons:
                with open(file, 'r') as f:
                    if "avg" in file:
                        self.avg_params = json.load(f)
                    elif "sd" in file:
                        self.sd_params = json.load(f)
                    elif "min" in file:
                        self.params_min = json.load(f)
                    elif "max" in file:
                        self.params_max = json.load(f)
            models = glob(os.path.join(path, "*.mhm"))
            # subdirectories
            models += glob(os.path.join(path, "*/*.mhm"))
            gui3d.app.loadHumanMHM(models[0])
            makehuman_average.updateModelingParameters(self.avg_params)

        @self.save_button.mhEvent
        def onClicked(event):
            path = self.pathBox.getText()
            avg_file = os.path.join(path, "avg.json")
            min_file = os.path.join(path, "min.json")
            max_file = os.path.join(path, "max.json")
            sd_file = os.path.join(path, "sd.json")

            with open(avg_file, 'w') as f:
                json.dump(self.avg_params, f)
            with open(sd_file, 'w') as f:
                json.dump(self.sd_params, f)
            with open(min_file, 'w') as f:
                json.dump(self.params_min, f)
            with open(max_file, 'w') as f:
                json.dump(self.params_max, f)

        @self.generate_button.mhEvent
        def onClicked(event):
            params = {}
            for param in self.avg_params:
                params[param] = self.random_between(self.avg_params[param],
                                                    self.params_min[param],
                                                    self.params_max[param],
                                                    self.sd_params[param])
            makehuman_average.updateModelingParameters(params)
            human = gui3d.app.selectedHuman
            mhmain.SymmetryAction(human, 1).do()
Пример #12
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))
Пример #13
0
    def __init__(self, category):

        super(SaveTargetsTaskView, self).__init__(category, 'Save Targets')

        mainPanel = QtWidgets.QWidget()
        layout = QtWidgets.QVBoxLayout()
        mainPanel.setLayout(layout)

        metaFileID = str(uuid4()) + '.target'
        self.metaFilePath = os.path.join(os.path.dirname(__file__),
                                         '__cache__')
        self.metaFile = os.path.join(self.metaFilePath, metaFileID)

        self.fileName = 'full_target.target'
        self.dirName = gp.getDataPath('custom')

        self.diffFileName = 'diff_target.target'
        self.diffDirName = gp.getDataPath('custom')

        self.saveBox = gui.GroupBox('Save Model as Target')
        layout.addWidget(self.saveBox)

        layout.addSpacing(15)

        label = self.saveBox.addWidget(gui.TextView('Filename:'))

        self.nameEdit = gui.TextEdit(self.fileName)
        self.nameEdit.textChanged.connect(self.onChange)
        self.saveBox.addWidget(self.nameEdit)

        self.stripBaseTargets = gui.CheckBox('Strip Base Targets', True)
        self.saveBox.addWidget(self.stripBaseTargets)

        self.saveButton = gui.Button('Save')
        self.saveBox.addWidget(self.saveButton)

        self.saveAsButton = gui.BrowseButton(label='Save As ...', mode='save')
        self.saveAsButton.path = os.path.join(self.dirName, self.fileName)
        self.saveAsButton.setFilter('MakeHuman Target ( *.target )')
        self.saveBox.addWidget(self.saveAsButton)

        self.saveDiffBox = gui.GroupBox('Save Diff Target')
        layout.addWidget(self.saveDiffBox)

        layout.addSpacing(15)

        self.diffNameEdit = gui.TextEdit(self.diffFileName)
        self.diffNameEdit.textChanged.connect(self.onDiffChange)
        self.saveDiffBox.addWidget(self.diffNameEdit)

        self.setBaseButton = gui.Button('Set Base')
        self.saveDiffBox.addWidget(self.setBaseButton)

        self.saveDiffButton = gui.Button('Save')
        self.saveDiffBox.addWidget(self.saveDiffButton)

        self.saveDiffAsButton = gui.BrowseButton(label='Save As ...',
                                                 mode='save')
        self.saveDiffAsButton.path = os.path.join(self.diffDirName,
                                                  self.diffFileName)
        self.saveDiffAsButton.setFilter('MakeHuman Target ( *.target )')
        self.saveDiffBox.addWidget(self.saveDiffAsButton)

        self.clearButton = gui.Button(label='Clear Cache')
        self.saveDiffBox.addWidget((self.clearButton))

        infoBox = gui.GroupBox('Info')
        layout.addWidget(infoBox)
        infoText = gui.TextView(info_message)
        infoText.setWordWrap(True)
        infoBox.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)
        infoBox.addWidget(infoText)

        layout.addStretch()
        self.addLeftWidget(mainPanel)

        self.createShortCut()

        @self.saveAsButton.mhEvent
        def beforeBrowse(event):
            self.saveAsButton.path = os.path.join(self.dirName, self.fileName)

        @self.saveDiffAsButton.mhEvent
        def beforeBrowse(event):
            self.saveDiffAsButton.path = os.path.join(self.dirName,
                                                      self.fileName)

        @self.saveButton.mhEvent
        def onClicked(event):
            self.quickSave()

        @self.saveAsButton.mhEvent
        def onClicked(path):
            if os.path.exists(path):
                if not path.lower().endswith('.target'):
                    error_msg = 'Cannot save target to file: {0:s}\nExpected a path to a .target file'.format(
                        path)
                    dialog = gui.Dialog()
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    log.error('Cannot save targets to %s. Not a .target file.',
                              path)
                    return
                else:
                    self.saveTargets(path, self.stripBaseTargets.selected)
                    self.fileName = os.path.basename(path)
                    self.dirName = os.path.dirname(path)
                    self.nameEdit.setText(self.fileName)
                    self.saveAsButton.path = path
                    G.app.statusPersist('Saving Target Directory: ' +
                                        self.dirName +
                                        '   Saving Diff Targets Directory: ' +
                                        self.diffDirName)

        @self.setBaseButton.mhEvent
        def onClicked(event):
            if not os.path.isdir(self.metaFilePath):
                os.mkdir(self.metaFilePath)
            self.saveTargets(self.metaFile, False)

        @self.saveDiffButton.mhEvent
        def onClicked(event):
            if not os.path.isfile(self.metaFile):
                error_msg = 'No Base Model defined.\nPress "Set Base"'
                dialog = gui.Dialog()
                dialog.prompt(title='Error', text=error_msg, button1Label='OK')
                log.warning(error_msg)
            else:
                path = os.path.join(self.diffDirName, self.diffFileName)
                overwrite = True
                dialog = gui.Dialog()

                if not path.lower().endswith('.target'):
                    error_msg = 'Cannot save target to file: {0:s}\nExpected a path to a .target file'.format(
                        path)
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    log.error('Cannot save targets to %s. Not a .target file.',
                              path)
                    return
                else:
                    if os.path.exists(path):
                        msg = 'File {0:s} already exists. Overwrite?'.format(
                            path)
                        overwrite = dialog.prompt(title='Warning',
                                                  text=msg,
                                                  button1Label='YES',
                                                  button2Label='NO')
                        if overwrite:
                            log.message('Overwriting %s ...', path)
                    if overwrite:
                        human = G.app.selectedHuman
                        target = algos3d.getTarget(human.meshData,
                                                   self.metaFile)
                        target.apply(human.meshData, -1)
                        self.saveTargets(path, False)
                        target.apply(human.meshData, 1)

        @self.saveDiffAsButton.mhEvent
        def onClicked(path):
            if path:
                if not os.path.isfile(self.metaFile):
                    error_msg = 'No Base Model defined.\nPress "Set Base"'
                    dialog = gui.Dialog()
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    log.warning(error_msg)
                else:
                    if not path.lower().endswith('.target'):
                        error_msg = 'Cannot save diff target to file: {0:s}\nExpected a path to a .target file'.format(
                            path)
                        dialog = gui.Dialog()
                        dialog.prompt(title='Error',
                                      text=error_msg,
                                      button1Label='OK')
                        return
                    else:
                        human = G.app.selectedHuman
                        target = algos3d.getTarget(human.meshData,
                                                   self.metaFile)
                        target.apply(human.meshData, -1)
                        self.saveTargets(path, False)
                        target.apply(human.meshData, 1)
                        self.diffFileName = os.path.basename(path)
                        self.diffDirName = os.path.dirname(path)
                        self.diffNameEdit.setText(self.diffFileName)
                        self.saveDiffAsButton.path = path
                        G.app.statusPersist(
                            'Saving Target Directory: ' + self.dirName +
                            '   Saving Diff Targets Directory: ' +
                            self.diffDirName)

        @self.clearButton.mhEvent
        def onClicked(sevent):
            for file in os.listdir(path=self.metaFilePath):
                if file:
                    try:
                        os.remove(os.path.join(self.metaFilePath, file))
                    except os.error as e:
                        pass
Пример #14
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Povray')

        # for path to PovRay binaries file
        binary = ''

        bintype = []
        pathBox = self.addLeftWidget(gui.GroupBox('Povray  bin  path'))
        # this part load old settings values for next session; str(povray_bin)
        povray_bin = gui3d.app.settings.get('povray_bin', '')
        self.path = pathBox.addWidget(gui.TextEdit(str(povray_bin)), 0, 0, 1,
                                      2)
        self.browse = pathBox.addWidget(gui.BrowseButton('dir'), 1, 0, 1, 1)
        self.browse.setPath(povray_bin)
        if sys.platform == 'win32':
            self.browse.setFilter(
                'Executable programs (*.exe);;All files (*.*)')

        #
        if os.name == 'nt':
            #
            if os.environ['PROCESSOR_ARCHITECTURE'] == 'x86':
                self.win32sse2Button = pathBox.addWidget(
                    gui.CheckBox('Use SSE2 bin', True))
        #
        @self.path.mhEvent
        def onChange(value):
            gui3d.app.settings[
                'povray_bin'] = 'Enter your path' if not value else str(value)

        @self.browse.mhEvent
        def onClicked(path):
            if os.path.isdir(path):
                gui3d.app.settings['povray_bin'] = path
                self.path.setText(path)

        #------------------------------------------------------------------------------------
        filter = []
        # Options box
        optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.doSubdivide = optionsBox.addWidget(
            gui.CheckBox('Subdivide mesh', True))
        self.useSSS = optionsBox.addWidget(
            gui.CheckBox('Use S.S. Scattering', True))
        self.SSSA = optionsBox.addWidget(
            gui.Slider(value=0.3, label="SSS Amount"))
        self.AA = optionsBox.addWidget(
            gui.Slider(value=0.4, label="AntiAliasing"))

        materialsBox = self.addRightWidget(gui.GroupBox('Materials'))
        self.skinoil = materialsBox.addWidget(
            gui.Slider(value=0.4, label="Skin oil"))
        self.rough = materialsBox.addWidget(
            gui.Slider(value=0.5, label="Skin roughness"))
        self.wrinkles = materialsBox.addWidget(
            gui.Slider(value=0.2, label="Skin wrinkles"))
        self.hairSpec = materialsBox.addWidget(
            gui.CheckBox('Hair shine', False))
        self.hspecA = materialsBox.addWidget(
            gui.Slider(value=0.5, label="Shine strength"))
        self.hairThick = materialsBox.addWidget(
            gui.Slider(value=0.67, label="Hair thickness"))

        # box
        #optionsBox = self.addLeftWidget(gui.GroupBox('Options'))

        #Buttons
        # Simplified the gui a bit for the average user. Uncomment to clutter it up with developer - useful stuff.
        #source=[]
        #self.iniButton = optionsBox.addWidget(gui.RadioButton(source, 'Use ini settings'))
        #self.guiButton = optionsBox.addWidget(gui.RadioButton(source, 'Use gui settings', selected = True))
        #format=[]
        #self.arrayButton = optionsBox.addWidget(gui.RadioButton(format, 'Array  format'))
        #self.mesh2Button = optionsBox.addWidget(gui.RadioButton(format, 'Mesh2 format', selected = True))
        #action=[]
        #self.exportButton = optionsBox.addWidget(gui.RadioButton(action , 'Export only', selected = True))
        #self.exportandrenderButton = optionsBox.addWidget(gui.RadioButton(action , 'Export and render'))
        self.renderButton = optionsBox.addWidget(gui.Button('Render'))

        #
        @self.renderButton.mhEvent
        def onClicked(event):

            reload(
                mh2povray
            )  # Avoid having to close and reopen MH for every coding change (can be removed once testing is complete)
            # it is necessary to put this code here, so that it is executed with the 'renderButton.event'
            if os.name == 'nt':
                #
                if os.environ['PROCESSOR_ARCHITECTURE'] == "x86":
                    binary = 'win32'
                    #
                    if self.win32sse2Button.selected:
                        binary = 'win32sse2'
                #
                else:
                    binary = 'win64'
            # for Ubuntu.. atm
            if sys.platform == 'linux2':
                binary = 'linux'
            #
            mh2povray.povrayExport(
                gui3d.app.selectedHuman.mesh,
                gui3d.app,
                {
                    'source':
                    'gui',  # 'ini' if self.iniButton.selected else 'gui',
                    'format':
                    'mesh2',  # 'array' if self.arrayButton.selected else 'mesh2',
                    'action':
                    'render',  # 'export' if self.exportButton.selected else 'render',
                    'subdivide': True if self.doSubdivide.selected else False,
                    'AA': 0.5 - 0.49 * self.AA.getValue(),
                    'bintype': binary,
                    'SSS': True if self.useSSS.selected else False,
                    'SSSA': 6 * self.SSSA.getValue(),  # power of 2
                    'skinoil': 0.001 *
                    (10**(4 * self.skinoil.getValue())),  # exponential slider
                    'rough': 0.001 *
                    (10**(2 * self.rough.getValue())),  # exponential slider
                    'wrinkles': 0.5 * self.wrinkles.getValue(),
                    'hairSpec': True if self.hairSpec.selected else False,
                    'hspecA': 0.1 *
                    (10**(2 * self.hspecA.getValue())),  # exponential slider
                    'hairThin': 5**(2 * (1 - self.hairThick.getValue()))
                })  # exponential slider
Пример #15
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, 'Face Reconstruction')
        toolbox = self.addLeftWidget(gui.SliderBox('Face Reconstruction'))

        self.Dir = toolbox.addWidget(gui.BrowseButton(mode='dir'), 0, 0)
        self.Dir.setLabel('Face Reference Directory')
        self.Dir.directory = '.' #mh.getPath('scripts')

        self.fast = toolbox.addWidget(gui.CheckBox("Fast Method", False))
        self.semifast = toolbox.addWidget(gui.CheckBox("Normal Method", False))
        self.slow = toolbox.addWidget(gui.CheckBox("Slow Method", False))
        self.rslow = toolbox.addWidget(gui.CheckBox("Really Slow Method", False))
        self.brute = toolbox.addWidget(gui.CheckBox("Bruteforce Method", False))
        self.random = toolbox.addWidget(gui.CheckBox("Random Method (best)", True))
        self.epoch = toolbox.addWidget(gui.Slider(5, 4, 20,
                                                 ["Epoch rounds (only for random method)", ": %d"]))
        self.iter = toolbox.addWidget(gui.Slider(3, 1, 50,
                                                    ["Iterations Per Modifier (only for random method)", ": %d"]))
        self.faceBtn = toolbox.addWidget(gui.Button("Do Face Reconstruction"))
        self.cam = G.app.modelCamera
        self.human = gui3d.app.selectedHuman
        self.fcount = 0
        cv2.namedWindow("Face Preview")


        @self.faceBtn.mhEvent
        def onClicked(event):
            if self.Dir.directory == '.':
                log.error("Not a valid reference folder. Aborting...")
                return
            avg = self.createavg()
            if avg is None:
                log.error("Not a valid reference folder. Aborting...")
                return
            log.notice(self.createavg())
            modifierGroups = ['eyebrows', 'eyes', 'chin',
                              'forehead', 'head', 'mouth', 'nose', 'neck', 'ears',
                              'cheek']
            modifiers = []

            for mGroup in modifierGroups:
                modifiers = modifiers + self.human.getModifiersByGroup(mGroup)

            # Make sure not all modifiers are always set in the same order
            # (makes it easy to vary dependent modifiers like ethnics)
            random.shuffle(modifiers)
            with open("Output.txt", "w", buffering=1) as text_file:
                if self.fast.selected:
                    self.checkFace([0.2,  0.2], text_file, avg, modifiers)
                    self.checkFace([-0.4, 0.4], text_file, avg, modifiers)

                if self.semifast.selected:
                    self.checkFace([-0.4, -0.2, 0.2, 0.4], text_file, avg, modifiers)
                    self.checkFace([-0.8, -0.6, 0.6, 0.8], text_file, avg, modifiers)

                if self.slow.selected:
                    self.checkFace([-0.2, -0.1, 0.1, 0.2], text_file, avg, modifiers)
                    self.checkFace([-0.4, -0.3, 0.3, 0.4], text_file, avg, modifiers)
                    self.checkFace([-0.6, -0.5, 0.5, 0.6], text_file, avg, modifiers)
                    self.checkFace([-0.8, -0.7, 0.7, 0.8], text_file, avg, modifiers)

                if self.rslow.selected:
                    self.checkFace([-0.2, -0.1, 0.1, 0.2], text_file, avg, modifiers)
                    self.checkFace([-0.4, -0.3, -0.2, -0.1, 0.1, 0.2, 0.3, 0.4], text_file, avg, modifiers)
                    self.checkFace([-0.6, -0.5,-0.4, -0.3, -0.2, -0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], text_file, avg, modifiers)
                    self.checkFace([-0.8, -0.7,-0.6, -0.5,-0.4, -0.3, -0.2, -0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8], text_file, avg, modifiers)
                if self.brute.selected:
                    self.checkFace([-0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],text_file, avg, modifiers)

                if self.random.selected:
                    ip = 0.2
                    for j in range(int(self.epoch.getValue())):
                        self.checkFace(None,text_file, avg, modifiers,imin=-ip,imax=ip,c=int(self.iter.getValue()),irandom=True)
                        ip = min(ip + 0.2, 1.0)



            mh.redraw()
Пример #17
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Povray')

        # for path to PovRay binaries file
        binary = ''

        bintype = []
        pathBox = self.addLeftWidget(gui.GroupBox('Povray  bin  path'))
        # this part load old settings values for next session; str(povray_bin)
        povray_bin = gui3d.app.settings.get('povray_bin', '')
        self.path = pathBox.addWidget(gui.TextEdit(str(povray_bin)), 0, 0, 1,
                                      2)
        self.browse = pathBox.addWidget(gui.BrowseButton('dir'), 1, 0, 1, 1)
        self.browse.setPath(povray_bin)
        if sys.platform == 'win32':
            self.browse.setFilter(
                'Executable programs (*.exe);;All files (*.*)')

        #
        if os.name == 'nt':
            #
            if os.environ['PROCESSOR_ARCHITECTURE'] == 'x86':
                self.win32sse2Button = pathBox.addWidget(
                    gui.CheckBox('Use SSE2 bin', True))
        #
        @self.path.mhEvent
        def onChange(value):
            gui3d.app.settings[
                'povray_bin'] = 'Enter your path' if not value else str(value)

        @self.browse.mhEvent
        def onClicked(path):
            if os.path.isdir(path):
                gui3d.app.settings['povray_bin'] = path
                self.path.setText(path)

        #------------------------------------------------------------------------------------
        filter = []
        # Options box
        optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.doSubdivide = optionsBox.addWidget(
            gui.CheckBox('Subdivide mesh', True))
        self.usebump = optionsBox.addWidget(gui.CheckBox(
            'Use bump maps', True))
        self.useSSS = optionsBox.addWidget(
            gui.CheckBox('Use S.S. Scattering', True))
        self.SSSA = optionsBox.addWidget(
            gui.Slider(value=0.5, label="SSS Amount"))

        settingsBox = self.addLeftWidget(gui.GroupBox('Settings'))
        settingsBox.addWidget(gui.TextView("Resolution"))
        self.resBox = settingsBox.addWidget(
            gui.TextEdit("x".join([str(self.resWidth),
                                   str(self.resHeight)])))
        self.AA = settingsBox.addWidget(
            gui.Slider(value=0.5, label="AntiAliasing"))

        materialsBox = self.addRightWidget(gui.GroupBox('Materials'))
        self.skinoil = materialsBox.addWidget(
            gui.Slider(value=0.5, label="Skin oil"))
        self.moist = materialsBox.addWidget(
            gui.Slider(value=0.7, label="Moisturization"))
        self.tension = materialsBox.addWidget(
            gui.Slider(value=0.7, label="Skin tension"))
        self.grain = materialsBox.addWidget(
            gui.Slider(value=0.5, label="Skin graininess"))
        self.hairShine = materialsBox.addWidget(
            gui.CheckBox('Hair shine', False))
        self.hairSpec = materialsBox.addWidget(
            gui.Slider(value=0.45, label="Shine strength"))
        self.hairRough = materialsBox.addWidget(
            gui.Slider(value=0.4, label="Shine coverage"))
        self.hairHard = materialsBox.addWidget(
            gui.Slider(value=0.5, label="Hair hardness"))

        # box
        #optionsBox = self.addLeftWidget(gui.GroupBox('Options'))

        #Buttons
        # Simplified the gui a bit for the average user. Uncomment to clutter it up with developer - useful stuff.
        #source=[]
        #self.iniButton = optionsBox.addWidget(gui.RadioButton(source, 'Use ini settings'))
        #self.guiButton = optionsBox.addWidget(gui.RadioButton(source, 'Use gui settings', selected = True))
        #format=[]
        #self.arrayButton = optionsBox.addWidget(gui.RadioButton(format, 'Array  format'))
        #self.mesh2Button = optionsBox.addWidget(gui.RadioButton(format, 'Mesh2 format', selected = True))
        #action=[]
        #self.exportButton = optionsBox.addWidget(gui.RadioButton(action , 'Export only', selected = True))
        #self.exportandrenderButton = optionsBox.addWidget(gui.RadioButton(action , 'Export and render'))
        self.renderButton = optionsBox.addWidget(gui.Button('Render'))

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

        #
        @self.renderButton.mhEvent
        def onClicked(event):
            reload(
                mh2povray
            )  # Avoid having to close and reopen MH for every coding change (can be removed once testing is complete)
            # it is necessary to put this code here, so that it is executed with the 'renderButton.event'
            if os.name == 'nt':
                #
                if os.environ['PROCESSOR_ARCHITECTURE'] == "x86":
                    binary = 'win32'
                    if self.win32sse2Button.selected:
                        binary = 'win32sse2'
                else:
                    binary = 'win64'
            # for Ubuntu.. atm
            if sys.platform == 'linux2':
                binary = 'linux'
            #
            mh2povray.povrayExport({
                'source':
                'gui',  # 'ini' if self.iniButton.selected else 'gui',
                'format':
                'mesh2',  # 'array' if self.arrayButton.selected else 'mesh2',
                'action':
                'render',  # 'export' if self.exportButton.selected else 'render',
                'scene':
                gui3d.app.getCategory('Rendering').getTaskByName(
                    'Scene').scene,
                'subdivide':
                True if self.doSubdivide.selected else False,
                'AA':
                0.5 - 0.49 * self.AA.getValue(),
                'bintype':
                binary,
                'SSS':
                True if self.useSSS.selected else False,
                'SSSA':
                self.SSSA.getValue() + 0.01,  # blur strength. Prevent zero
                'skinoil':
                0.001 *
                (10**(4 * self.skinoil.getValue())),  # exponential slider
                'moist':
                self.moist.getValue(),  # percentage
                'rough':
                0.001 *
                (10**(2 *
                      (1 - self.tension.getValue()))),  # exponential slider
                'wrinkles':
                0.5 * self.grain.getValue(),
                'usebump':
                True if self.usebump.selected else False,
                'hairShine':
                True if self.hairShine.selected else False,
                'hairSpec':
                self.hairSpec.getValue(),
                'hairRough': (0.7 * self.hairRough.getValue())**2,
                'hairHard':
                0.01 * 10**(4 * self.hairHard.getValue())
            })  # exponential slider
Пример #18
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'BVH')

        self.BVH = bvh.BVH()

        #self.systemAnims = os.path.join('data', 'animations')
        #self.userAnims = os.path.join(mh.getPath(''), 'data', 'animations')
        #self.animPaths = [self.userAnims, self.systemAnims]
        #if not os.path.exists(self.userAnims):
        #    os.makedirs(self.userAnims)
        #self.extension = "mhanim"

        self.skelObj = None  # indicates skeleton object attached
        self.lastSkeleton = None

        self.human = gui3d.app.selectedHuman
        self.oldHumanTransp = self.human.meshData.transparentPrimitives

        displayBox = self.addLeftWidget(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.showSkeletonTggl = displayBox.addWidget(
            gui.ToggleButton("Show skeleton"))

        @self.showSkeletonTggl.mhEvent
        def onClicked(event):
            if not self.skelObj:
                return
            if self.showSkeletonTggl.selected:
                self.skelObj.show()
                self.setHumanTransparency(True)
            else:
                self.skelObj.hide()
                self.setHumanTransparency(False)

        self.showSkeletonTggl.setSelected(True)

        self.skinProxiesTggl = displayBox.addWidget(
            gui.ToggleButton("Skin clothes and hair"))

        @self.skinProxiesTggl.mhEvent
        def onClicked(event):
            self.setupProxySkinning()

        self.skinProxiesTggl.setSelected(False)

        pathBox = self.addLeftWidget(gui.GroupBox('BVH  path'))
        self.path = pathBox.addWidget(gui.TextEdit('/'), 0, 0, 1, 2)
        self.file = pathBox.addWidget(gui.BrowseButton('open'), 1, 0, 1, 1)
        self.file.setLabel("Select BVH")

        @self.path.mhEvent
        def onChange(value):
            print '[BVHAnimLibrary: onChange] Path value changed:' + value

        @self.file.mhEvent
        def onClicked(file):
            #if os.path.isdir(path):
            print '[BVHAnimLibrary: onClicked] File value changed:' + file
            self.path.setText(file)
            if os.path.isfile(file):
                self.BVH = bvh.load(file)
                #self.BVH.fromFile(file)
                print '[BVHAnimLibrary: onClicked] Loaded BVH file'
Пример #19
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))
Пример #20
0
    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)
    def __init__(self, category, appFacs):
        gui3d.TaskView.__init__(self, category, 'Pain Face Generator')
        self.facs_human = appFacs.selectedHuman
        camera = G.app.modelCamera
        self.app = appFacs

        # self.targets_path_emotions_blender = getpath.getPath('data/FACSHuman/00 Emotions')
        self.targets_path_upper_face = getpath.getPath(
            'data/FACSHuman/01 Upper Face AUs')
        self.targets_path_lower_face = getpath.getPath(
            'data/FACSHuman/02 Lower Face AUs')
        self.targets_path_lip_jaw = getpath.getPath(
            'data/FACSHuman/03 Lip Parting and Jaw Opening')
        # self.targets_path_eye = getpath.getPath('data/FACSHuman/04 Eye Positions')
        # self.targets_path_head = getpath.getPath('data/FACSHuman/05 Head Positions')
        # self.targets_path_misc = getpath.getPath('data/FACSHuman/06 Miscellaneous AUs')

        self.last_directory_rendering = ''
        self.images_to_convert = ''
        self.video_destination = ''
        #self.video_background = 'black.jpg'
        self.renderingWidth = '500'
        self.renderingHeight = '500'
        self.images_set_dir_destination = ''

        # box_emotions_blender = self.addLeftWidget(gui.GroupBox('Emotions blender'))
        box_upper = self.addLeftWidget(gui.GroupBox('Upper Face AUs'))
        box_lower = self.addLeftWidget(gui.GroupBox('Lower Face AUs'))
        # box_head = self.addLeftWidget(gui.GroupBox('Head Positions'))
        # box_eye = self.addLeftWidget(gui.GroupBox('Eye Positions'))
        box_lip = self.addLeftWidget(
            gui.GroupBox('Lip Parting and Jaw Opening'))
        # box_misc = self.addLeftWidget(gui.GroupBox('Miscellaneous AUs'))
        box_weight = self.addRightWidget(gui.GroupBox('AU Matrix Weights'))
        box_gen = self.addRightWidget(gui.GroupBox('View and Generate Images'))
        box_tools = self.addRightWidget(gui.GroupBox('Tools'))
        # box_aus_code = self.addRightWidget(gui.GroupBox('Action Units coding'))

        # self.general_intensity = box_aus_code.addWidget(gui.Slider(value=100, min=0, max=100, label=['General Intensity : ','%d%%']), columnSpan = 2)
        # #self.general_intensity_progress_bar = box_tools.addWidget(gui.ProgressBar())
        # #self.general_intensity_progress_bar.setProgress(1)
        # self.txt_file_loaded = box_aus_code.addWidget(gui.TextView('- New facial code -'), columnSpan = 2)
        # self.load_facs_button = box_aus_code.addWidget(gui.BrowseButton('open', "Load FACS Code"), 3, 0)
        # self.save_facs_button = box_aus_code.addWidget(gui.BrowseButton('save', "Save FACS Code"), 3, 1)
        # # self.save_target_button = box_aus_code.addWidget(gui.BrowseButton('save', "Save target"))
        # self.generate_au_coding_button = box_aus_code.addWidget(gui.Button('Get AU\'s Code'), columnSpan = 2)
        # self.txt_coding = box_aus_code.addWidget(gui.TextView('AU\'s code generated :'), columnSpan = 2)
        # self.au_coding = box_aus_code.addWidget(gui.DocumentEdit(text='Neutral'), columnSpan = 2)
        # self.one_shot_button = box_tools.addWidget(gui.Button('Take one shot'), 1, 0)

        self.survey_img_button = box_weight.addWidget(
            gui.Button('Generate Survey Images'), columnSpan=2)
        self.au4_lab = box_weight.addWidget(gui.TextView('AU4 Weight'))
        self.au4_val = box_weight.addWidget(gui.TextEdit(text='0.8865'))
        self.au7_lab = box_weight.addWidget(gui.TextView('AU7 Weight'))
        self.au7_val = box_weight.addWidget(gui.TextEdit(text='0.7758'))
        self.au9_lab = box_weight.addWidget(gui.TextView('AU9 Weight'))
        self.au9_val = box_weight.addWidget(gui.TextEdit(text='2.6129'))
        self.au10_lab = box_weight.addWidget(gui.TextView('AU10 Weight'))
        self.au10_val = box_weight.addWidget(gui.TextEdit(text='3.6517'))

        self.reset_camera_button = box_gen.addWidget(
            gui.Button('Full face camera view'), columnSpan=2)
        self.master_slider = box_gen.addWidget(gui.Slider(
            value=0, min=0, max=100, label=['General Intensity : ', '%d%%']),
                                               columnSpan=2)
        self.one_shot_button = box_gen.addWidget(gui.Button('Take one shot'),
                                                 columnSpan=2)
        self.generate_set_button = box_gen.addWidget(
            gui.Button('generate pain image set'), columnSpan=2)

        self.one_shot_stereo_button = box_tools.addWidget(
            gui.Button('Stereoscopic shot'), columnSpan=2)
        self.au_set_gen_button = box_tools.addWidget(
            gui.BrowseButton('open', "Dir to img"), 2, 0)
        self.material_gen_button = box_tools.addWidget(
            gui.BrowseButton('open', "Images set"), 2, 1)
        self.material_gen_dir_button = box_tools.addWidget(gui.FileEntryView(
            'Browse', mode='dir'),
                                                           columnSpan=2)
        self.camera_slider_x = box_tools.addWidget(gui.Slider(
            value=0, min=-1, max=1, label=['camera x: ', '%2f']),
                                                   columnSpan=2)
        self.camera_slider_y = box_tools.addWidget(gui.Slider(
            value=0, min=-1, max=1, label=['camera y: ', '%2f']),
                                                   columnSpan=2)
        self.camera_slider_zoom = box_tools.addWidget(gui.Slider(
            value=0, min=4, max=9, label=['Zoom: ', '%2f']),
                                                      columnSpan=2)
        self.rotation_slider_z = box_tools.addWidget(gui.Slider(
            value=0, min=-90, max=90, label=['rotation z: ', '%2f']),
                                                     columnSpan=2)
        self.reset_button = box_tools.addWidget(
            gui.Button('Reset Facial Code'), columnSpan=2)
        self.full_set_button = box_tools.addWidget(
            gui.Button('Full set generation'), columnSpan=2)
        self.facsvatar_set_button = box_tools.addWidget(gui.BrowseButton(
            'open', 'FACAvatar rendering'),
                                                        columnSpan=2)

        self.facs_code_names_path = getpath.getDataPath('FACSHuman')
        self.facs_code_names_file = self.facs_code_names_path + '/au.json'
        self.facs_code_names = json.loads(
            open(self.facs_code_names_file).read())

        self.slidersValues = {
        }  #Keep a trace of values in the General intensity sliders function
        self.sliders = {}
        self.sliders_order = []
        self.labelSlider = {}
        #self.modifiers = {}
        self.au_timeline_values = {}  # For the animation functionality
        self.au_facs_loaded_file_values = {}  # For the animation functionality

        self.facs_code_names_path = getpath.getDataPath('FACSHuman')
        self.facs_code_names_file = self.facs_code_names_path + '/au.json'
        self.facs_code_names = json.loads(
            open(self.facs_code_names_file).read())

        # self.searchTargets(self.targets_path_emotions_blender, box_emotions_blender, 'Emotions Blender')
        self.searchTargets(self.targets_path_upper_face, box_upper,
                           'Upper Face AUs')
        self.searchTargets(self.targets_path_lower_face, box_lower,
                           'Lower Face AUs')
        self.searchTargets(self.targets_path_lip_jaw, box_lip,
                           'Lip Parting and Jaw Opening')
        # self.searchTargets(self.targets_path_eye, box_eye, 'Eye Positions')
        # self.searchTargets(self.targets_path_head, box_head, 'Head Positions')
        # self.searchTargets(self.targets_path_misc, box_misc, 'Miscellaneous AUs')

        @self.camera_slider_x.mhEvent
        def onChanging(value):
            pos = self.facs_human.getPosition()
            pos[0] = value
            self.facs_human.setPosition(pos)
            mh.redraw()

        @self.camera_slider_y.mhEvent
        def onChanging(value):
            pos = self.facs_human.getPosition()
            pos[1] = value
            self.facs_human.setPosition(pos)
            mh.redraw()

        @self.camera_slider_zoom.mhEvent
        def onChanging(value):
            camera.setZoomFactor(value)

        @self.rotation_slider_z.mhEvent
        def onChanging(value):
            pos = self.facs_human.getRotation()
            pos[1] = value
            self.facs_human.setRotation(pos)
            mh.redraw()

##########################################################################
# Generate all AUs images
##########################################################################

        @self.facsvatar_set_button.mhEvent
        def onClicked(path):
            self.generateFacsvatarDirSet(path)

##########################################################################
# Generate all AUs images
##########################################################################

        @self.au_set_gen_button.mhEvent
        def onClicked(path):
            self.generateDirSet(path)

##########################################################################
# Generate material images
##########################################################################

        @self.material_gen_button.mhEvent
        def onClicked(path):
            self.generateCompleteImagesSetFromDir(path)
##########################################################################
# Generate material images
##########################################################################

        @self.material_gen_dir_button.mhEvent
        def onFileSelected(event):
            # self.images_set_dir_destination = os.path.dirname(path)
            self.images_set_dir_destination = event.path
            # self.images_set_dir_destination = os.path.dirname(path)
            gui3d.app.statusPersist('Images destination : ' +
                                    str(self.images_set_dir_destination))

##########################################################################
# Reset button for camera's orientation to have full face view
# in order to have constant point of view for experiments
##########################################################################

        @self.reset_camera_button.mhEvent
        def onClicked(event):
            gui3d.app.setTargetCamera(131, 9, False)
            gui3d.app.axisView([0.0, 0.0, 0.0])
            pos = [0, 0.2, 0]
            self.facs_human.setPosition(pos)
            self.camera_slider_x.setValue(0)
            self.camera_slider_y.setValue(0.2)
            self.camera_slider_zoom.setValue(9)
            self.rotation_slider_z.setValue(0)
            self.rotation_slider_z.onChanging(0)
            self.rotation_slider_z.update()
            mh.redraw()
            gui3d.app.statusPersist('Camera updated')

        @self.one_shot_button.mhEvent
        def onClicked(event):
            self.renderFacsPicture()

##########################################################################
# Reset facial code and AUs button
##########################################################################

        @self.reset_button.mhEvent
        def onClicked(event):
            G.app.prompt('Confirmation',
                         'Do you really want to reset your Facial code ?',
                         'Yes', 'Cancel', self.resetFacialCodes)

##########################################################################
# Generate 81 images for the survey website
##########################################################################

        @self.survey_img_button.mhEvent
        def onClicked(event):
            weight = [0, 0.5, 1]
            for i4 in range(3):
                for i7 in range(3):
                    for i9 in range(3):
                        for i10 in range(3):
                            self.survey_img_gen(weight[i4], weight[i7],
                                                weight[i9], weight[i10])
                            time.sleep(0.5)
                            self.renderSurveyImg(i4, i7, i9, i10)

##########################################################################
# Generate and save 101 images for overall intensity = 0% to 100%
##########################################################################

        @self.generate_set_button.mhEvent
        def onClicked(event):
            for val in range(0, 101):
                self.generate_face_set(val)
                time.sleep(0.5)
                self.renderFacsPicture()


##########################################################################
# View pain expression change at various general intensities
##########################################################################

        @self.master_slider.mhEvent
        def onChange(value):
            self.masterslider_render(value, True)