Пример #1
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'vsScript')

        box = self.addLeftWidget(gui.GroupBox('vsScript'))
        self.category = category
        # We add a button to the current task
        # A button just fires an event when it is clicked, if a selected texture is specified,
        # it is used while the mouse is down on the button
        self.vsWeight_gui = 1.0
        self.modelName_gui = "T1_large_s_mkh"
        self.userDocPath_gui = r"C:\Users\Bekki\Documents"
        self.mkhPath_gui = r"c:\Program Files\makehuman-community"

        self.aTextEdit = box.addWidget(gui.TextEdit(text='add model name'))
        self.aButton = box.addWidget(gui.Button('Load MKH Model'))
        self.bButton = box.addWidget(gui.Button('Export STL Model'))

        self.pushed = 0
        self.aButtonLabel = box.addWidget(gui.TextView('Pushed 0 times'))
        #self.loadRunScript()

        @self.aButton.mhEvent
        def onClicked(event):
            #loadProxy(gui3d.app, 0.88,"T3_s_mkh",r"C:\Users\Bekki\Documents",  r"c:\Program Files\makehuman-community")
            loadProxy(gui3d.app, self.vsWeight_gui, self.modelName_gui,
                      self.userDocPath_gui, self.mkhPath_gui)

        @self.bButton.mhEvent
        def onClicked(event):
            exportProxy(gui3d.app, self.modelName_gui)

        # We want the slider to start from the middle
        self.aSlider = box.addWidget(
            gui.Slider(value=0.5, label=['Change Weight', ' %.2f']))

        self.aSliderLabel = box.addWidget(gui.TextView('Value is 0.5'))

        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('Weight value is %f', value)
            self.aProgressBar.setProgress(value)

        # we also create a progressbar, which is updated as the slider moves

        self.aProgressBar = box.addWidget(gui.ProgressBar())
        self.aProgressBar.setProgress(0.5)
    def __init__(self, category):
        """
        Creates the widget with two text inputs to specify the
        number of instances to generate and the output directory
        :param category: where to display the widget
        """
        gui3d.TaskView.__init__(self, category, 'Generator')

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

        # number of instances to generate
        self.numberInstances = box.addWidget(gui.TextEdit(text="10"))

        # where to store the generated models
        self.outputTextEdit = box.addWidget(
            gui.TextEdit(text=os.path.expanduser("~")))

        # progress bars
        self.genProgressBar = box.addWidget(gui.ProgressBar())
        self.genProgressBar.setProgress(0)

        # button to trigger the generation
        self.genButton = box.addWidget(gui.Button('Generate'))

        # used to avoid any duplicate in the current run
        self.duplicate_tracker = {}

        @self.genButton.mhEvent
        def onClicked(event):
            output_dir = self.outputTextEdit.text

            os.makedirs(output_dir, exist_ok=True)
            N = int(self.numberInstances.text)

            self.duplicate_tracker = {}

            for i in range(N):
                name = f"model_{i}"
                path = os.path.join(output_dir, name)
                os.makedirs(path, exist_ok=True)
                self.generateHuman(path)
                self.genProgressBar.setProgress((i + 1) / N)
Пример #3
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Example')

        box = self.addLeftWidget(gui.GroupBox('Example'))
        
        # We add a button to the current task
        # A button just fires an event when it is clicked, if a selected texture is specified,
        # it is used while the mouse is down on the button

        self.aButton = box.addWidget(gui.Button('Button'))
        
        self.pushed = 0
        self.aButtonLabel = box.addWidget(gui.TextView('Pushed 0 times'))

        @self.aButton.mhEvent
        def onClicked(event):
            self.pushed += 1
            self.aButtonLabel.setTextFormat('Pushed %d times', self.pushed)

        # We add a toggle button to the current task
        # A toggle button fires an event when it is clicked but retains its selected state after the mouse is up,
        # if a selected texture is specified, it is used to show whether the button is toggled

        self.aToggleButton = box.addWidget(gui.CheckBox('ToggleButton'))

        self.aToggleButtonLabel = box.addWidget(gui.TextView('Not selected'))

        @self.aToggleButton.mhEvent
        def onClicked(event):
            if self.aToggleButton.selected:
                self.aToggleButtonLabel.setText('Selected')
            else:
                self.aToggleButtonLabel.setText('Not selected')

        # Next we will add some radio buttons. For this we need a group, since only one in the group can be selected
        # A radio button fires an event when it is clicked but retains its selected state after the mouse is up, and deselects all other buttons in the group
        # If a selected texture is specified, it is used to show whether the button is selected

        self.aRadioButtonGroup = []

         # We make the first one selected
        self.aRadioButton1 = box.addWidget(gui.RadioButton(self.aRadioButtonGroup, 'RadioButton1', selected=True))
        self.aRadioButton2 = box.addWidget(gui.RadioButton(self.aRadioButtonGroup, 'RadioButton2'))

        self.aRadioButtonLabel = box.addWidget(gui.TextView('Button 1 is selected'))

        @self.aRadioButton1.mhEvent
        def onClicked(event):
            self.aRadioButtonLabel.setText('Button 1 is selected')

        @self.aRadioButton2.mhEvent
        def onClicked(event):
            self.aRadioButtonLabel.setText('Button 2 is selected')

        # When the slider is dragged and released, an onChange event is fired
        # By default a slider goes from 0.0 to 1.0, and the initial position will be 0.0 unless specified

        # We want the slider to start from the middle
        self.aSlider = box.addWidget(gui.Slider(value=0.5, label=['Slider',' %.2f']))

        self.aSliderLabel = box.addWidget(gui.TextView('Value is 0.5'))

        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setTextFormat('Value is %f', value)
            self.aProgressBar.setProgress(value)

        # we also create a progressbar, which is updated as the slider moves

        self.aProgressBar = box.addWidget(gui.ProgressBar())
        self.aProgressBar.setProgress(0.5)
        
        # A text edit

        self.aTextEdit = box.addWidget(gui.TextEdit(text='Some text'))
        
        self.meshSlider = box.addWidget(gui.Slider(value=0.5, label=['Mesh distort',' %0.2f']))
        
        self.isMeshStored = False
        @self.meshSlider.mhEvent
        def onChanging(value):
            human = gui3d.app.selectedHuman
            if self.isMeshStored:
                self.restoreMesh(human)
            else:
                self.storeMesh(human)
                self.isMeshStored = True
            human.mesh.coord += human.mesh.vnorm * value
            human.mesh.markCoords(coor=True)
            human.mesh.update()
    
        @self.meshSlider.mhEvent
        def onChange(value):
            human = gui3d.app.selectedHuman
            human.applyAllTargets()
            self.isMeshStored = False
            human.mesh.coord += human.mesh.vnorm * value
            human.mesh.markCoords(coor=True)
            human.mesh.update()