예제 #1
0
 def appendQt(self):
     import qtui
     self.open()
     self.write("QT.VERSION: %s", qtui.getQtVersionString())
     self.write("QT.JPG_SUPPORT: %s",
                "supported" if qtui.supportsJPG() else "not supported")
     self.write("QT.SVG_SUPPORT: %s",
                "supported" if qtui.supportsSVG() else "not supported")
     py_plugin_path = os.path.pathsep.join([
         getpath.pathToUnicode(p)
         for p in qtui.QtCore.QCoreApplication.libraryPaths()
     ])
     self.write("QT.PLUGIN_PATH: %s" % py_plugin_path)
     qt_plugin_path_env = os.environ[
         'QT_PLUGIN_PATH'] if 'QT_PLUGIN_PATH' in os.environ else ""
     self.write("QT.PLUGIN_PATH_ENV: %s" %
                getpath.pathToUnicode(qt_plugin_path_env))
     qt_conf_present = os.path.isfile(getpath.getSysPath('qt.conf'))
     if qt_conf_present:
         import io
         f = io.open(getpath.getSysPath('qt.conf'),
                     "r",
                     encoding="utf-8",
                     errors="replace")
         qt_conf_content = f.read()
         qt_conf_content = qt_conf_content.replace(
             '\n', '\n' + (' ' * len('QT.CONF: '))).strip()
         f.close()
         self.write("QT.CONF: %s" % qt_conf_content)
     else:
         self.write("QT.CONF: NOT PRESENT")
     self.close()
예제 #2
0
    def __init__(self, parent, value, defaultPath = None):
        super(TextureValue, self).__init__()
        self.parent = parent
        self._path = pathToUnicode(value)

        self.layout = gui.QtGui.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

        if value and isinstance(value, basestring):
            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)
예제 #3
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)
예제 #4
0
 def setValue(self, value):
     self._path = pathToUnicode(value)
     if value:
         self.imageView.setImage(value)
         if isinstance(value, basestring):
             self.browseBtn._path = pathToUnicode(value)
     else:
         self.imageView.setImage(mh.getSysDataPath('notfound.thumb'))
예제 #5
0
 def setValue(self, value):
     self._path = pathToUnicode(value)
     if value:
         self.imageView.setImage(value)
         if isinstance(value, basestring):
             self.browseBtn._path = pathToUnicode(value)
     else:
         self.imageView.setImage(mh.getSysDataPath('notfound.thumb'))
예제 #6
0
    def reset(self):
        self.open()

        mhv = MHVersion()

        self.write("VERSION: %s", os.environ['MH_VERSION'])
        self.write("SHORT VERSION: %s", os.environ['MH_SHORT_VERSION'])
        self.write("LONG VERSION: %s", mhv.getFullVersionStr())
        self.write("BASEMESH VERSION: %s", os.environ['MH_MESH_VERSION'])
        self.write("IS BUILT (FROZEN): %s", os.environ['MH_FROZEN'])
        self.write("IS RELEASE VERSION: %s", os.environ['MH_RELEASE'])
        self.write("DEFAULT ENCODING: %s", sys.getdefaultencoding())
        self.write("FILESYSTEM ENCODING: %s", sys.getfilesystemencoding())
        self.write("STDOUT ENCODING: %s", sys.stdout.encoding)
        self.write("LOCALE PREFERRED ENCODING: %s",
                   locale.getpreferredencoding(False))
        self.write("WORKING DIRECTORY: %s", getpath.pathToUnicode(os.getcwd()))
        self.write("HOME LOCATION: %s",
                   getpath.pathToUnicode(getpath.getHomePath()))
        syspath = os.path.pathsep.join(
            [getpath.pathToUnicode(p) for p in sys.path])
        self.write("PYTHON PATH: %s", syspath)
        self.write("DLL PATH: %s", getpath.pathToUnicode(os.environ['PATH']))
        version = re.sub(r"[\r\n]", " ", sys.version)
        self.write("SYS.VERSION: %s", version)
        self.write("SYS.PLATFORM: %s", sys.platform)
        self.write("SYS.EXECUTABLE: %s", sys.executable)
        self.write("PLATFORM.MACHINE: %s", platform.machine())
        self.write("PLATFORM.PROCESSOR: %s", platform.processor())
        self.write("PLATFORM.UNAME.RELEASE: %s", platform.uname()[2])

        if sys.platform.startswith('linux'):
            try:
                self.write("PLATFORM.LINUX_DISTRIBUTION: %s",
                           ' '.join(platform.linux_distribution()))
            except AttributeError:
                try:
                    import distro
                    self.write("PLATFORM.LINUX_DISTRIBUTION: %s",
                               ' '.join(distro.linux_distribution()))
                except ImportError:
                    self.write("PLATFORM.LINUX_DISTRIBUTION: %s", 'Unknown')

        if sys.platform.startswith('darwin'):
            self.write("PLATFORM.MAC_VER: %s", platform.mac_ver()[0])

        if sys.platform.startswith('win'):
            self.write("PLATFORM.WIN32_VER: %s",
                       " ".join(platform.win32_ver()))

        import numpy
        self.write("NUMPY.VERSION: %s", numpy.__version__)
        numpyVer = numpy.__version__.split('.')
        if int(numpyVer[0]) <= 1 and int(numpyVer[1]) < 6:
            raise DependencyError(
                'MakeHuman requires at least numpy version 1.6')

        self.close()
예제 #7
0
    def _associate(self, path, reason, extrareason=None, data=None):
        """Internal method that associates the File object with a path."""
        if isinstance(path, basestring):
            path = os.path.normpath(path)

        event = FileModifiedEvent(self, False, self._modified, reason, data)
        self._modified = False
        event.addReason(extrareason)
        if pathToUnicode(path) != self.path:
            event.addReason("newpath")
            self._path = pathToUnicode(path)
        self.callEvent('onModified', event)
예제 #8
0
    def _associate(self, path, reason, extrareason=None, data=None):
        """Internal method that associates the File object with a path."""
        if isinstance(path, str):
            path = os.path.normpath(path)

        event = FileModifiedEvent(self, False, self._modified, reason, data)
        self._modified = False
        event.addReason(extrareason)
        if pathToUnicode(path) != self.path:
            event.addReason("newpath")
            self._path = pathToUnicode(path)
        self.callEvent('onModified', event)
예제 #9
0
    def reset(self):
        self.open()

        self.write("VERSION: %s", os.environ['MH_VERSION'])
        if 'HGREVISION' in os.environ and 'HGREVISION_SOURCE' in os.environ:
            self.write("HG REVISION: r%s (%s) [%s]", os.environ['HGREVISION'],
                       os.environ['HGNODEID'], os.environ['HGREVISION_SOURCE'])
        else:
            self.write("HG REVISION: UNKNOWN")
        if 'HGBRANCH' in os.environ:
            self.write("HG BRANCH: %s", os.environ['HGBRANCH'])
        self.write("SHORT VERSION: %s", os.environ['MH_SHORT_VERSION'])
        self.write("BASEMESH VERSION: %s", os.environ['MH_MESH_VERSION'])
        self.write("IS BUILT (FROZEN): %s", os.environ['MH_FROZEN'])
        self.write("IS RELEASE VERSION: %s", os.environ['MH_RELEASE'])
        self.write("DEFAULT ENCODING: %s", sys.getdefaultencoding())
        self.write("FILESYSTEM ENCODING: %s", sys.getfilesystemencoding())
        self.write("STDOUT ENCODING: %s", sys.stdout.encoding)
        self.write("WORKING DIRECTORY: %s", getpath.pathToUnicode(os.getcwd()))
        self.write("HOME LOCATION: %s",
                   getpath.pathToUnicode(getpath.getHomePath()))
        syspath = os.path.pathsep.join(
            [getpath.pathToUnicode(p) for p in sys.path])
        self.write("PYTHON PATH: %s", syspath)
        self.write("DLL PATH: %s", getpath.pathToUnicode(os.environ['PATH']))
        version = re.sub(r"[\r\n]", " ", sys.version)
        self.write("SYS.VERSION: %s", version)
        self.write("SYS.PLATFORM: %s", sys.platform)
        self.write("SYS.EXECUTABLE: %s", sys.executable)
        self.write("PLATFORM.MACHINE: %s", platform.machine())
        self.write("PLATFORM.PROCESSOR: %s", platform.processor())
        self.write("PLATFORM.UNAME.RELEASE: %s", platform.uname()[2])

        if sys.platform.startswith('linux'):
            self.write("PLATFORM.LINUX_DISTRIBUTION: %s",
                       ' '.join(platform.linux_distribution()))

        if sys.platform.startswith('darwin'):
            self.write("PLATFORM.MAC_VER: %s", platform.mac_ver()[0])

        if sys.platform.startswith('win'):
            self.write("PLATFORM.WIN32_VER: %s",
                       " ".join(platform.win32_ver()))

        import numpy
        self.write("NUMPY.VERSION: %s", numpy.__version__)
        numpyVer = numpy.__version__.split('.')
        if int(numpyVer[0]) <= 1 and int(numpyVer[1]) < 6:
            raise DependencyError(
                'MakeHuman requires at least numpy version 1.6')

        self.close()
    def reset(self):
        self.open()

        self.write("VERSION: %s", os.environ["MH_VERSION"])
        if "HGREVISION" in os.environ and "HGREVISION_SOURCE" in os.environ:
            self.write(
                "HG REVISION: r%s (%s) [%s]",
                os.environ["HGREVISION"],
                os.environ["HGNODEID"],
                os.environ["HGREVISION_SOURCE"],
            )
        else:
            self.write("HG REVISION: UNKNOWN")
        if "HGBRANCH" in os.environ:
            self.write("HG BRANCH: %s", os.environ["HGBRANCH"])
        self.write("SHORT VERSION: %s", os.environ["MH_SHORT_VERSION"])
        self.write("BASEMESH VERSION: %s", os.environ["MH_MESH_VERSION"])
        self.write("IS BUILT (FROZEN): %s", os.environ["MH_FROZEN"])
        self.write("IS RELEASE VERSION: %s", os.environ["MH_RELEASE"])
        self.write("WORKING DIRECTORY: %s", getpath.pathToUnicode(os.getcwd()))
        self.write("HOME LOCATION: %s", getpath.pathToUnicode(self.home))
        syspath = os.path.pathsep.join([getpath.pathToUnicode(p) for p in sys.path])
        self.write("PYTHON PATH: %s", syspath)
        self.write("DLL PATH: %s", os.environ["PATH"])
        version = re.sub(r"[\r\n]", " ", sys.version)
        self.write("SYS.VERSION: %s", version)
        self.write("SYS.PLATFORM: %s", sys.platform)
        self.write("SYS.EXECUTABLE: %s", sys.executable)
        self.write("PLATFORM.MACHINE: %s", platform.machine())
        self.write("PLATFORM.PROCESSOR: %s", platform.processor())
        self.write("PLATFORM.UNAME.RELEASE: %s", platform.uname()[2])

        if sys.platform == "linux2":
            self.write("PLATFORM.LINUX_DISTRIBUTION: %s", string.join(platform.linux_distribution(), " "))

        if sys.platform.startswith("darwin"):
            self.write("PLATFORM.MAC_VER: %s", platform.mac_ver()[0])

        if sys.platform == "win32":
            self.write("PLATFORM.WIN32_VER: %s", string.join(platform.win32_ver(), " "))

        import numpy

        self.write("NUMPY.VERSION: %s", numpy.__version__)
        numpyVer = numpy.__version__.split(".")
        if int(numpyVer[0]) <= 1 and int(numpyVer[1]) < 6:
            raise DependencyError("MakeHuman requires at least numpy version 1.6")

        self.close()
예제 #11
0
    def reloadMaterial(self):
        obj = self.getSelectedObject()

        if shader.Shader.supported():
            self.listShaders(obj.material)
            self.listUniforms(obj.material)
        self.updateShaderConfig(obj.material)
        self.listMaterialSettings(obj)

        if obj.material.filepath:
            self.saveMaterialBtn._path = pathToUnicode(obj.material.filepath)
            self.loadMaterialBtn._path = pathToUnicode(obj.material.filepath)
        else:
            self.saveMaterialBtn._path = mh.getPath('data')
            self.loadMaterialBtn._path = mh.getSysDataPath()
예제 #12
0
    def reloadMaterial(self):
        obj = self.getSelectedObject()

        if shader.Shader.supported():
            self.listShaders(obj.material)
            self.listUniforms(obj.material)
        self.updateShaderConfig(obj.material)
        self.listMaterialSettings(obj)

        if obj.material.filepath:
            self.saveMaterialBtn._path = pathToUnicode(obj.material.filepath)
            self.loadMaterialBtn._path = pathToUnicode(obj.material.filepath)
        else:
            self.saveMaterialBtn._path = mh.getPath('data')
            self.loadMaterialBtn._path = mh.getSysDataPath()
    def appendQt(self):
        import qtui

        self.open()
        self.write("PYQT.VERSION: %s", qtui.getQtVersionString())
        self.write("PYQT.JPG_SUPPORT: %s", "supported" if qtui.supportsJPG() else "not supported")
        self.write("PYQT.SVG_SUPPORT: %s", "supported" if qtui.supportsSVG() else "not supported")
        py_plugin_path = os.path.pathsep.join(
            [getpath.pathToUnicode(str(p)) for p in qtui.QtCore.QCoreApplication.libraryPaths()]
        )
        self.write("QT.PLUGIN_PATH: %s" % py_plugin_path)
        qt_plugin_path_env = os.environ["QT_PLUGIN_PATH"] if "QT_PLUGIN_PATH" in os.environ else ""
        self.write("QT.PLUGIN_PATH_ENV: %s" % qt_plugin_path_env)
        qt_conf_present = os.path.isfile(getpath.getSysPath("qt.conf"))
        if qt_conf_present:
            from codecs import open

            f = open(getpath.getSysPath("qt.conf"), "r", encoding="utf-8", errors="replace")
            qt_conf_content = f.read()
            qt_conf_content = qt_conf_content.replace("\n", "\n" + (" " * len("QT.CONF: "))).strip()
            f.close()
            self.write("QT.CONF: %s" % qt_conf_content)
        else:
            self.write("QT.CONF: NOT PRESENT")
        self.close()
예제 #14
0
 def onClicked(event):
     filename = getpath.pathToUnicode(
         gui.QtWidgets.QFileDialog.getOpenFileName(
             gui3d.app.mainwin,
             directory=self.home,
             filter='Python files ( *.py );; All files ( *.* )'))
     if os.path.isfile(filename) and os.path.splitext(
             filename)[1] == '.py':
         try:
             shutil.copy2(filename, getpath.getPath('plugins'))
         except OSError as e:
             gui3d.app.prompt(
                 'Error', 'Failed to copy {0:s} to user plugins folder',
                 'OK')
         for child in self.userPluginBox.children:
             self.userPluginBox.removeWidget(child)
         updatePlugins = self.getUserPlugins()
         for i, plugin in enumerate(updatePlugins):
             self.userPluginBox.addWidget(
                 UserPluginCheckBox(plugin),
                 row=i,
                 alignment=gui.QtCore.Qt.AlignTop)
         gui3d.app.prompt(
             'Info',
             'The plugin copied successfully. To activate check '
             'the plugin in the list and restart MakeHuman.',
             'OK',
             helpId='installPluginHelp')
     self.home = os.path.dirname(filename)
예제 #15
0
파일: qtui.py 프로젝트: dimichgh/makehuman
 def dragEnterEvent(self, event):
     """Decide whether to accept files dragged into the MakeHuman window."""
     if event.mimeData().hasUrls():
         url = event.mimeData().urls()[0]
         path = getpath.pathToUnicode(url.toLocalFile())
         if os.path.splitext(path)[1].lower() == '.mhm':
             event.acceptProposedAction()
예제 #16
0
 def refresh(self, files):
     for file in files:
         label = getpath.pathToUnicode( os.path.basename(file) )
         if len(self.fileChooser.extensions) > 0:
             label = os.path.splitext(label)[0].replace('_', ' ').capitalize()
         label = label[0].capitalize() + label[1:]
         self.fileChooser.addItem(file, label, self.getPreview(file))
예제 #17
0
 def refresh(self, files):
     for file in files:
         label = getpath.pathToUnicode( os.path.basename(file) )
         if len(self.fileChooser.extensions) > 0:
             label = os.path.splitext(label)[0].replace('_', ' ').capitalize()
         label = label[0].capitalize() + label[1:]
         self.fileChooser.addItem(file, label, self.getPreview(file))
예제 #18
0
 def updateFilenameCaption(self):
     """Calculate and set the window title according to the
     name of the current open file and the version of MH."""
     filename = self.currentFile.name
     if filename is None:
         filename = "Untitled"
     if mh.isRelease():
         from getpath import pathToUnicode
         self.setCaption("MakeHuman %s - [%s][*]" %
                         (mh.getVersionStr(), pathToUnicode(filename)))
     else:
         from getpath import pathToUnicode
         self.setCaption("MakeHuman r%s (%s) - [%s][*]" %
                         (os.environ['HGREVISION'], os.environ['HGNODEID'],
                          pathToUnicode(filename)))
     self.mainwin.setWindowModified(self.currentFile.modified)
예제 #19
0
def saveMHM(path):
    """Save the .mhm and the thumbnail to the selected save path."""
    path = pathToUnicode(os.path.normpath(path))

    savedir = os.path.dirname(path)
    if not os.path.exists(savedir):
        os.makedirs(savedir)

    name = os.path.splitext(os.path.basename(path))[0]

    # Save square sized thumbnail
    size = min(G.windowWidth, G.windowHeight)
    img = mh.grabScreen((G.windowWidth - size) // 2,
                        (G.windowHeight - size) // 2, size, size)

    # Resize thumbnail to max 128x128
    if size > 128:
        img.resize(128, 128)
    img.save(os.path.join(savedir, name + '.thumb'))

    # Save the model
    G.app.selectedHuman.save(path)
    #G.app.clearUndoRedo()

    # Remember last save folder
    gui3d.app.setSetting('savedir', formatPath(os.path.dirname(path)))

    G.app.status('Your model has been saved to %s.', path)
예제 #20
0
        def onClicked(event):

            filename = getpath.pathToUnicode(
                gui.QtWidgets.QFileDialog.getOpenFileName(
                    gui3d.app.mainwin,
                    directory=self.home,
                    filter='Zip files ( *.zip );; All files ( *.* )')[0])

            dest_path = getpath.getPath('plugins')
            if os.path.isfile(filename):
                result = decompress(filename, dest_path)
                if result == 0:
                    self.updatePluginList()
                    gui3d.app.prompt(
                        'Info',
                        'The plugin copied successfully. To activate, check '
                        'the plugin in the list and press the "Activate"-Button or restart MakeHuman.',
                        'OK',
                        helpId='installPluginHelp')
                elif result == 3:
                    gui3d.app.prompt(
                        'Warning',
                        'Potentially dangerous zip file, containing files with unsuitable path. '
                        'Inspect/fix the zip file before usage!', 'OK')
                elif result == 4:
                    gui3d.app.prompt(
                        'Error',
                        'Zip file {0:s} contains exiting files.'.format(
                            filename), 'OK')
                elif result == 1:
                    gui3d.app.prompt('Error',
                                     'Not a zip file {0:s}'.format(filename),
                                     'OK')
            self.home = os.path.dirname(filename)
def saveMHM(path):
    """Save the .mhm and the thumbnail to the selected save path."""
    path = pathToUnicode(os.path.normpath(path))

    savedir = os.path.dirname(path)
    if not os.path.exists(savedir):
        os.makedirs(savedir)

    name = os.path.splitext(os.path.basename(path))[0]

    # Save square sized thumbnail
    size = min(G.windowWidth, G.windowHeight)
    img = mh.grabScreen(
        (G.windowWidth - size) / 2, (G.windowHeight - size) / 2, size, size)

    # Resize thumbnail to max 128x128
    if size > 128:
        img.resize(128, 128)
    img.save(os.path.join(savedir, name + '.thumb'))

    # Save the model
    G.app.selectedHuman.save(path, name)
    #G.app.clearUndoRedo()

    # Remember last save folder
    gui3d.app.setSetting('savedir', os.path.dirname(path))

    G.app.status('Your model has been saved to %s.', path)
 def dragEnterEvent(self, event):
     """Decide whether to accept files dragged into the MakeHuman window."""
     if event.mimeData().hasUrls():
         url = event.mimeData().urls()[0]
         path = getpath.pathToUnicode(url.toLocalFile())
         if os.path.splitext(path)[1].lower() == '.mhm':
             event.acceptProposedAction()
예제 #23
0
def save(path, data):
    """
    Save Image (data) to file.
    """
    import getpath
    path = getpath.pathToUnicode(path)

    im = toQImage(data)
    format = "PNG" if path.lower().endswith('.thumb') else None
    if not im.save(path, format):
        raise RuntimeError('error saving image %s' % path)
예제 #24
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)
예제 #25
0
 def refresh(self, files):
     """
     Load tags from mhclo file.
     """
     import exportutils.config
     for file in files:
         label = getpath.pathToUnicode( os.path.basename(file) )
         if len(self.fileChooser.extensions) > 0:
             label = os.path.splitext(label)[0]
         tags = self.library.getTags(filename = file)
         self.fileChooser.addItem(file, label, self.getPreview(file), tags)
예제 #26
0
def save(path, data):
    """
    Save Image (data) to file.
    """
    import getpath
    path = getpath.pathToUnicode(path)

    im = toQImage(data)
    format = "PNG" if path.lower().endswith('.thumb') else None
    if not im.save(path, format):
        raise RuntimeError('error saving image %s' % path)
예제 #27
0
 def refresh(self, files):
     """
     Load tags from mhclo file.
     """
     import exportutils.config
     for file in files:
         label = getpath.pathToUnicode(os.path.basename(file))
         if len(self.fileChooser.extensions) > 0:
             label = os.path.splitext(label)[0]
         tags = self.library.getTags(filename=file)
         self.fileChooser.addItem(file, label, self.getPreview(file), tags)
예제 #28
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)
예제 #29
0
 def refresh(self, files):
     """
     Load tags from mhclo file.
     """
     for file in files:
         label = getpath.pathToUnicode( os.path.basename(file) )
         if len(self.fileChooser.extensions) > 0:
             label = os.path.splitext(label)[0].replace('_', ' ')
         label = label[0].capitalize() + label[1:]
         tags = self.library.getTags(filename = file)
         self.fileChooser.addItem(file, label, self.getPreview(file), tags)
예제 #30
0
    def reset(self):
        self.open()

        self.write("VERSION: %s", os.environ['MH_VERSION'])
        if 'HGREVISION' in os.environ and 'HGREVISION_SOURCE' in os.environ:
            self.write("HG REVISION: r%s (%s) [%s]", os.environ['HGREVISION'], os.environ['HGNODEID'], os.environ['HGREVISION_SOURCE'])
        else:
            self.write("HG REVISION: UNKNOWN")
        if 'HGBRANCH' in os.environ:
            self.write("HG BRANCH: %s", os.environ['HGBRANCH'])
        self.write("SHORT VERSION: %s", os.environ['MH_SHORT_VERSION'])
        self.write("BASEMESH VERSION: %s", os.environ['MH_MESH_VERSION'])
        self.write("IS BUILT (FROZEN): %s", os.environ['MH_FROZEN'])
        self.write("IS RELEASE VERSION: %s", os.environ['MH_RELEASE'])
        self.write("WORKING DIRECTORY: %s", getpath.pathToUnicode(os.getcwd()))
        self.write("HOME LOCATION: %s", getpath.pathToUnicode(self.home))
        syspath = ':'.join( [getpath.pathToUnicode(p) for p in sys.path] )
        self.write("PYTHON PATH: %s", syspath)
        version = re.sub(r"[\r\n]"," ", sys.version)
        self.write("SYS.VERSION: %s", version)
        self.write("SYS.PLATFORM: %s", sys.platform)
        self.write("PLATFORM.MACHINE: %s", platform.machine())
        self.write("PLATFORM.PROCESSOR: %s", platform.processor())
        self.write("PLATFORM.UNAME.RELEASE: %s", platform.uname()[2])

        if sys.platform == 'linux2':
            self.write("PLATFORM.LINUX_DISTRIBUTION: %s", string.join(platform.linux_distribution()," "))
            
        if sys.platform.startswith("darwin"):
            self.write("PLATFORM.MAC_VER: %s", platform.mac_ver()[0])
            
        if sys.platform == 'win32':
            self.write("PLATFORM.WIN32_VER: %s", string.join(platform.win32_ver()," "))

        import numpy
        self.write("NUMPY.VERSION: %s", numpy.__version__)
        numpyVer = numpy.__version__.split('.')
        if int(numpyVer[0]) <= 1 and int(numpyVer[1]) < 6:
            raise DependencyError('MakeHuman requires at least numpy version 1.6')

        self.close()
예제 #31
0
 def addItem(self, file, label, preview, tags=[], pos = None):
     item = super(IconListFileChooser, self).addItem(file, label, preview, tags, pos)
     preview = getpath.pathToUnicode(preview)
     if preview not in self._iconCache:
         pixmap = QtGui.QPixmap(preview)
         size = pixmap.size()
         if size.width() > 128 or size.height() > 128:
             pixmap = pixmap.scaled(128, 128, QtCore.Qt.KeepAspectRatio)
         icon = QtGui.QIcon(pixmap)
         icon.addPixmap(pixmap, QtGui.QIcon.Selected)    # make sure that the icon does not change color when item is highlighted
         self._iconCache[preview] = icon
     icon = self._iconCache[preview]
     item.setIcon(icon)
     return item
예제 #32
0
 def addItem(self, file, label, preview, tags=[], pos = None):
     item = super(IconListFileChooser, self).addItem(file, label, preview, tags, pos)
     preview = getpath.pathToUnicode(preview)
     mtime = os.path.getmtime(preview) if os.path.isfile(preview) else 0
     if preview not in self._iconCache or mtime > self._iconCache[preview][1]:
         pixmap = QtGui.QPixmap(preview)
         size = pixmap.size()
         if size.width() > 128 or size.height() > 128:
             pixmap = pixmap.scaled(128, 128, QtCore.Qt.KeepAspectRatio)
         icon = QtGui.QIcon(pixmap)
         icon.addPixmap(pixmap, QtGui.QIcon.Selected)    # make sure that the icon does not change color when item is highlighted
         self._iconCache[preview] = (icon, mtime)
     icon = self._iconCache[preview][0]
     item.setIcon(icon)
     return item
예제 #33
0
    def saveMHM(self, path):
        """Save the .mhm and the thumbnail to the selected save path."""
        path = pathToUnicode(os.path.normpath(path))

        savedir = os.path.dirname(path)
        if not os.path.exists(savedir):
            os.makedirs(savedir)

        name = os.path.splitext(os.path.basename(path))[0]

        # Save the model
        from core import G
        G.app.selectedHuman.save(path, name)
        #G.app.clearUndoRedo()

        G.app.status('Your model has been saved to %s.', path)
    def dropEvent(self, event):
        """Support drag and dropping .MHM files in the MakeHuman window to load
        them"""
        mime_data = event.mimeData()
        if not mime_data.hasUrls():
            return

        url = mime_data.urls()[0]
        path = getpath.pathToUnicode(url.toLocalFile())
        if os.path.splitext(path)[1].lower() != '.mhm':
            return

        if self.app.currentFile.modified:
            self.app.prompt("Load", "You have unsaved changes. Are you sure you want to close the current file?",
                             "Yes", "No", lambda: self.app.loadHumanMHM(path))
        else:
            self.app.loadHumanMHM(path)
예제 #35
0
    def dropEvent(self, event):
        """Support drag and dropping .MHM files in the MakeHuman window to load
        them"""
        mime_data = event.mimeData()
        if not mime_data.hasUrls():
            return

        url = mime_data.urls()[0]
        path = getpath.pathToUnicode(url.toLocalFile())
        if os.path.splitext(path)[1].lower() != '.mhm':
            return

        if self.app.currentFile.modified:
            self.app.prompt("Load", "You have unsaved changes. Are you sure you want to close the current file?",
                             "Yes", "No", lambda: self.app.loadHumanMHM(path))
        else:
            self.app.loadHumanMHM(path)
예제 #36
0
 def refresh(self, files):
     """
     Load tags from mhclo file.
     """
     oldSelection = self.fileChooser.getSelectedTags().copy()
     self.fileChooser.removeTags()
     for file in files:
         label = ''
         tags = self.library.getTags(filename=file)
         if self.useNameTags:
             name = self.library.getName(filename=file)
             label = name
         if not label:
             label = getpath.pathToUnicode(os.path.basename(file))
             if len(self.fileChooser.extensions) > 0:
                 label = os.path.splitext(label)[0].replace('_', ' ')
             label = label[0].capitalize() + label[1:]
         self.fileChooser.addItem(file, label, self.getPreview(file), tags)
     self.fileChooser.showTags(oldSelection)
예제 #37
0
        def onClicked(event):

            filename = getpath.pathToUnicode(
                gui.QtWidgets.QFileDialog.getOpenFileName(
                    gui3d.app.mainwin,
                    directory=self.home,
                    filter='Zip files ( *.zip );; All files ( *.* )'))

            dest_path = getpath.getPath('plugins')
            if os.path.isfile(filename):
                result = self.decompress(filename, dest_path)
                if result == 1:
                    gui3d.app.prompt('Error',
                                     'Not a zip file {0:s}'.format(filename),
                                     'OK')
                elif result == 3:
                    gui3d.app.prompt(
                        'Warning',
                        'Potentially dangerous zip file, containing files with unsuitable path. '
                        'Inspect/fix the zip file before usage!', 'OK')
                elif result == -1:
                    gui3d.app.prompt(
                        'Error',
                        'Zip file {0:s} contains exiting files.'.format(
                            filename), 'OK')
                elif result == 0:
                    gui3d.app.prompt(
                        'Info',
                        'The plugin copied successfully. To activate check '
                        'the plugin in the list and restart MakeHuman.',
                        'OK',
                        helpId='installPluginHelp')
                    for child in self.userPluginBox.children:
                        self.userPluginBox.removeWidget(child)
                    updatePlugins = self.getUserPlugins()
                    for i, plugin in enumerate(updatePlugins):
                        self.userPluginBox.addWidget(
                            UserPluginCheckBox(plugin),
                            row=i,
                            alignment=gui.QtCore.Qt.AlignTop)
            self.home = os.path.dirname(filename)
예제 #38
0
파일: image_qt.py 프로젝트: nouei/makehuman
def load(path):
    """
    Load an Image (data) from specified image file path.
    Or convert QImage to Image (data).
    """
    if isinstance(path, QtGui.QImage):
        im = path
    else:
        import getpath
        path = getpath.pathToUnicode(path)
        im = QtGui.QImage(path)
    if im.isNull():
        raise RuntimeError("unable to load image '%s'" % path)
    w, h = im.width(), im.height()
    alpha = im.hasAlphaChannel()
    im = im.convertToFormat(QtGui.QImage.Format_ARGB32)

    if G.hasPySide:
        pixels = bytes(im.bits())
    else:
        pixels = im.bits().asstring(h * w * 4)

    pixels = np.fromstring(pixels, dtype=np.uint32).reshape((h, w))
    del im

    a = (pixels >> 24).astype(np.uint8)
    r = (pixels >> 16).astype(np.uint8)
    g = (pixels >> 8).astype(np.uint8)
    b = (pixels >> 0).astype(np.uint8)
    del pixels

    if alpha:
        data = np.dstack((r, g, b, a))
    else:
        data = np.dstack((r, g, b))

    del a, r, g, b

    data = np.ascontiguousarray(data)

    return data
예제 #39
0
    def __init__(self, owner, file, label, imagePath):
        super(FileChooserRectangle, self).__init__()
        gui.Widget.__init__(self)
        self.owner = owner
        self.file = file

        self.layout = QtGui.QGridLayout(self)
        self.layout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)

        image = self._imageCache[imagePath]
        self.preview = QtGui.QLabel()
        self.preview.setPixmap(getpath.pathToUnicode(image))
        self.layout.addWidget(self.preview, 0, 0)
        self.layout.setRowStretch(0, 1)
        self.layout.setColumnMinimumWidth(0, self._size[0])
        self.layout.setRowMinimumHeight(0, self._size[1])

        self.label = QtGui.QLabel()
        self.label.setText(label)
        self.label.setMinimumWidth(1)
        self.layout.addWidget(self.label, 1, 0)
        self.layout.setRowStretch(1, 0)
예제 #40
0
    def __init__(self, owner, file, label, imagePath):
        super(FileChooserRectangle, self).__init__()
        gui.Widget.__init__(self)
        self.owner = owner
        self.file = file

        self.layout = QtWidgets.QGridLayout(self)
        self.layout.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize)

        image = self._imageCache[imagePath]
        self.preview = QtWidgets.QLabel()
        self.preview.setPixmap(getpath.pathToUnicode(image))
        self.layout.addWidget(self.preview, 0, 0)
        self.layout.setRowStretch(0, 1)
        self.layout.setColumnMinimumWidth(0, self._size[0])
        self.layout.setRowMinimumHeight(0, self._size[1])

        self.label = QtWidgets.QLabel()
        self.label.setText(label)
        self.label.setMinimumWidth(1)
        self.layout.addWidget(self.label, 1, 0)
        self.layout.setRowStretch(1, 0)
예제 #41
0
 def onClicked(event):
     filename = getpath.pathToUnicode(
         gui.QtWidgets.QFileDialog.getOpenFileName(
             gui3d.app.mainwin,
             directory=self.home,
             filter='Python files ( *.py );; All files ( *.* )')[0])
     if os.path.isfile(filename) and os.path.splitext(
             filename)[1] == '.py':
         try:
             shutil.copy2(filename, getpath.getPath('plugins'))
         except OSError as e:
             gui3d.app.prompt(
                 'Error',
                 'Failed to copy {0:s} to user plugins folder'.format(
                     filename), 'OK')
         self.updatePluginList()
         gui3d.app.prompt(
             'Info',
             'The plugin copied successfully. To activate, check '
             'the plugin in the list and press the "Activate"-Button or restart MakeHuman.',
             'OK',
             helpId='installPluginHelp')
     self.home = os.path.dirname(filename)
예제 #42
0
    def __init__(self, name, defaultLevel = 2, mirrorToMHLog = False):

        self.name = name

        if name in os.environ and os.environ.get(name,"").isdigit():
            defaultLevel = int(os.environ.get(name,"2"))

        if "mirrorToMHLog" in os.environ and os.environ.get("mirrorToMHLog","") != "":
            mirrorToMHLog = True

        self.level = defaultLevel
        self.mirror = mirrorToMHLog
        self.api = gui3d.app.mhapi

        self.root = self.api.locations.getUserHomePath("plugin_logs")

        if not os.path.exists(self.root):
            os.makedirs(self.root)

        self.fileName = os.path.join(self.root,name + ".txt")

        fnDecoded = getpath.pathToUnicode(self.fileName)
        with open(self.fileName,"wt", encoding='utf-8') as f:
            f.write("--- " + fnDecoded + " ---\n\n")
예제 #43
0
def load(path):
    """
    Load an Image (data) from specified image file path.
    Or convert QImage to Image (data).
    """
    if isinstance(path, QtGui.QImage):
        im = path
    else:
        import getpath
        path = getpath.pathToUnicode(path)
        im = QtGui.QImage(path)
    if im.isNull():
        raise RuntimeError("unable to load image '%s'" % path)
    w, h = im.width(), im.height()
    alpha = im.hasAlphaChannel()
    im = im.convertToFormat(QtGui.QImage.Format_ARGB32)
    pixels = im.bits().asstring(h * w * 4)
    pixels = np.fromstring(pixels, dtype=np.uint32).reshape((h, w))
    del im

    a = (pixels >> 24).astype(np.uint8)
    r = (pixels >> 16).astype(np.uint8)
    g = (pixels >>  8).astype(np.uint8)
    b = (pixels >>  0).astype(np.uint8)
    del pixels

    if alpha:
        data = np.dstack((r,g,b,a))
    else:
        data = np.dstack((r,g,b))

    del a,r,g,b

    data = np.ascontiguousarray(data)

    return data
예제 #44
0
 def onClicked(path):
     if not path:
         return
     self._path = pathToUnicode(path)
     self.imageView.setImage(self.value)
     self.parent.callEvent('onActivate', self.value)
예제 #45
0
 def refresh(self, files):
     for file in files:
         label = getpath.pathToUnicode(os.path.basename(file))
         if isinstance(self.fileChooser.extensions, str):
             label = os.path.splitext(label)[0]
         self.fileChooser.addItem(file, label, self.getPreview(file))
예제 #46
0
 def refresh(self, files):
     for file in files:
         label = getpath.pathToUnicode( os.path.basename(file) )
         if isinstance(self.fileChooser.extensions, str):
             label = os.path.splitext(label)[0]
         self.fileChooser.addItem(file, label, self.getPreview(file))
예제 #47
0
 def onClicked(path):
     if not path:
         return
     self._path = pathToUnicode(path)
     self.imageView.setImage(self.value)
     self.parent.callEvent('onActivate', self.value)