Ejemplo n.º 1
0
    def __init__(self, path=None):
        self.lights = []
        self.environment = Environment(self)

        self.file = managed_file.File()

        self.load(path)
Ejemplo n.º 2
0
    def __init__(self):
        if G.app is not None:
            raise RuntimeError('MHApplication is a singleton')
        G.app = self
        gui3d.Application.__init__(self)
        mh.Application.__init__(self)

        self.shortcuts = {
            # Actions
            'undo': (mh.Modifiers.CTRL, mh.Keys.z),
            'redo': (mh.Modifiers.CTRL, mh.Keys.y),
            'modelling': (mh.Modifiers.CTRL, mh.Keys.m),
            'save': (mh.Modifiers.CTRL, mh.Keys.s),
            'load': (mh.Modifiers.CTRL, mh.Keys.l),
            'export': (mh.Modifiers.CTRL, mh.Keys.e),
            'rendering': (mh.Modifiers.CTRL, mh.Keys.r),
            'help': (mh.Modifiers.CTRL, mh.Keys.h),
            'exit': (mh.Modifiers.CTRL, mh.Keys.q),
            'stereo': (mh.Modifiers.CTRL, mh.Keys.w),
            'wireframe': (mh.Modifiers.CTRL, mh.Keys.f),
            'savetgt': (mh.Modifiers.ALT, mh.Keys.t),
            'qexport': (mh.Modifiers.ALT, mh.Keys.e),
            'smooth': (mh.Modifiers.ALT, mh.Keys.s),
            'grab': (mh.Modifiers.ALT, mh.Keys.g),
            'profiling': (mh.Modifiers.ALT, mh.Keys.p),
            # Camera navigation
            'rotateD': (0, mh.Keys.N2),
            'rotateL': (0, mh.Keys.N4),
            'rotateR': (0, mh.Keys.N6),
            'rotateU': (0, mh.Keys.N8),
            'panU': (0, mh.Keys.UP),
            'panD': (0, mh.Keys.DOWN),
            'panR': (0, mh.Keys.RIGHT),
            'panL': (0, mh.Keys.LEFT),
            'zoomIn': (0, mh.Keys.PLUS),
            'zoomOut': (0, mh.Keys.MINUS),
            'front': (0, mh.Keys.N1),
            'right': (0, mh.Keys.N3),
            'top': (0, mh.Keys.N7),
            'back': (mh.Modifiers.CTRL, mh.Keys.N1),
            'left': (mh.Modifiers.CTRL, mh.Keys.N3),
            'bottom': (mh.Modifiers.CTRL, mh.Keys.N7),
            'resetCam': (0, mh.Keys.PERIOD),
            # Version check
            '_versionSentinel': (0, 0x87654321)
        }

        self.mouseActions = {
            (0, mh.Buttons.LEFT_MASK): self.mouseRotate,
            (0, mh.Buttons.RIGHT_MASK): self.mouseZoom,
            (0, mh.Buttons.MIDDLE_MASK): self.mouseTranslate,
            (mh.Modifiers.CTRL, mh.Buttons.RIGHT_MASK): self.mouseFocus
        }

        if mh.isRelease():
            self.settings = {
                'realtimeUpdates':
                True,
                'realtimeFitting':
                True,
                'sliderImages':
                True,
                'excludePlugins': [
                    "7_data",
                    "7_example",
                    "7_material_editor",
                    "7_profile",
                    "7_scene_editor",
                    "7_scripting",
                    "7_shell",
                    "7_targets",
                ],
                'rtl':
                False,
                'invertMouseWheel':
                False,
                'lowspeed':
                1,
                'preloadTargets':
                True,
                'cameraAutoZoom':
                False,
                'language':
                'english',
                'highspeed':
                5,
                'realtimeNormalUpdates':
                True,
                'units':
                'metric',
                'guiTheme':
                'makehuman',
                'restoreWindowSize':
                True
            }
        else:
            self.settings = {
                'realtimeUpdates': True,
                'realtimeFitting': True,
                'realtimeNormalUpdates': True,
                'cameraAutoZoom': False,
                'lowspeed': 1,
                'highspeed': 5,
                'units': 'metric',
                'invertMouseWheel': False,
                'language': 'english',
                'excludePlugins': [],
                'rtl': False,
                'sliderImages': True,
                'guiTheme': 'makehuman',
                'preloadTargets': False,
                'restoreWindowSize': False
            }

        self.loadHandlers = {}
        self.saveHandlers = []

        self.dialog = None
        self.helpIds = set()

        self.tool = None
        self.selectedGroup = None

        self.undoStack = []
        self.redoStack = []

        self.actions = Expando()

        self.clearColor = [0.5, 0.5, 0.5]
        self.gridColor = [1.0, 1.0, 1.0]
        self.gridSubColor = [0.7, 0.7, 0.7]

        self.modules = {}

        self.selectedHuman = None
        self.currentFile = managed_file.File()
        self._scene = None
        self.backplaneGrid = None
        self.groundplaneGrid = None

        self.theme = None

        @self.currentFile.mhEvent
        # def onModified(event):
        #    self.updateFilenameCaption()

        #self.modelCamera = mh.Camera()
        #self.modelCamera.switchToOrtho()
        #self.modelCamera = mh.OrbitalCamera()
        #self.modelCamera.debug = True

        #@self.modelCamera.mhEvent
        def onChanged(event):
            for category in self.categories.itervalues():
                for task in category.tasks:
                    task.callEvent('onCameraChanged', event)