Esempio n. 1
0
 def clear_namespace(self, interpreter, project):
     if project is None:
         return
     sys.path = self.old_syspath
     for k in project.ns.keys() + ['world', 'data', 'project']:
         if k in interpreter.user_ns:
             del interpreter.user_ns[k]
     from openalea.oalab.world import World
     world = World()
     world.clear()
Esempio n. 2
0
 def update_namespace(self, interpreter):
     """
     Definition: Update namespace
     """
     if self._cproject:
         if self._cproject.path.exists():
             os.chdir(self._cproject.path)
             sys.path.insert(0, str(self._cproject.path / 'lib'))
         else:
             os.chdir(self.tmpdir)
             sys.path.insert(0, str(self.tmpdir / 'lib'))
         interpreter.user_ns.update(self._cproject.ns)
         interpreter.user_ns['project'] = self._cproject
         interpreter.user_ns['data'] = self._cproject.path / 'data'
         from openalea.oalab.world import World
         world = World()
         world.update_namespace(interpreter)
Esempio n. 3
0
 def setUp(self):
     ev.events
     self.world = World()
     self.world.register_listener(ev)
Esempio n. 4
0
    def __init__(self, parent=None):
        #         super(Viewer, self).__init__()
        AbstractListener.__init__(self)
        view3D.__init__(self, parent=parent)

        self.setAccessibleName("3DViewer")
        self.setMinimumSize(100, 100)

        self.autofocus = True
        self._fps = False
        self.axis = False
        self.grid = True

        actionResetZoom = QtGui.QAction(
            QtGui.QIcon(":/images/resources/resetzoom.png"), "Home", self)
        self.actionAutoFocus = QtGui.QAction(
            QtGui.QIcon(":/images/resources/resetzoom.png"), "Auto Focus",
            self)
        self.actionAutoFocus.setCheckable(True)
        self.actionAutoFocus.setChecked(self.autofocus)
        self.actionAutoFocus.changed.connect(self._on_autofocus_changed)
        actionZoomOut = QtGui.QAction(
            QtGui.QIcon(":/images/resources/zoomout.png"), "Zoom Out", self)
        actionZoomIn = QtGui.QAction(
            QtGui.QIcon(":/images/resources/zoomin.png"), "Zoom In", self)
        actionShowAxis = QtGui.QAction(
            QtGui.QIcon(":/images/resources/axis.png"), "Show Axis", self)
        actionShowGrid = QtGui.QAction(
            QtGui.QIcon(":/images/resources/grid.png"), "Show Grid", self)
        actionRadius = QtGui.QAction(
            QtGui.QIcon(":/images/resources/growth2.png"), "Focus", self)
        actionShowFps = QtGui.QAction(
            QtGui.QIcon(":/images/resources/fps.png"), "Show FPS", self)

        actionBlack = QtGui.QAction(QtGui.QIcon(""), "Bg Black", self)
        actionWhite = QtGui.QAction(QtGui.QIcon(""), "Bg White", self)

        actionShowAxis.setShortcut(
            QtGui.QApplication.translate("MainWindow", "Ctrl+A", None,
                                         QtGui.QApplication.UnicodeUTF8))
        actionShowGrid.setShortcut(
            QtGui.QApplication.translate("MainWindow", "Ctrl+I", None,
                                         QtGui.QApplication.UnicodeUTF8))
        actionRadius.setShortcut(
            QtGui.QApplication.translate("MainWindow", "Ctrl+M", None,
                                         QtGui.QApplication.UnicodeUTF8))
        actionResetZoom.setShortcut(
            QtGui.QApplication.translate("MainWindow", "Ctrl+0", None,
                                         QtGui.QApplication.UnicodeUTF8))
        actionZoomOut.setShortcut(
            QtGui.QApplication.translate("MainWindow", "Ctrl+-", None,
                                         QtGui.QApplication.UnicodeUTF8))
        actionZoomIn.setShortcut(
            QtGui.QApplication.translate("MainWindow", "Ctrl++", None,
                                         QtGui.QApplication.UnicodeUTF8))

        QtCore.QObject.connect(actionResetZoom,
                               QtCore.SIGNAL('triggered(bool)'),
                               self.resetzoom)
        QtCore.QObject.connect(actionZoomOut, QtCore.SIGNAL('triggered(bool)'),
                               self.zoomout)
        QtCore.QObject.connect(actionZoomIn, QtCore.SIGNAL('triggered(bool)'),
                               self.zoomin)

        QtCore.QObject.connect(actionShowAxis,
                               QtCore.SIGNAL('triggered(bool)'),
                               self.show_hide_axis)
        QtCore.QObject.connect(actionShowGrid,
                               QtCore.SIGNAL('triggered(bool)'),
                               self.show_hide_grid)
        QtCore.QObject.connect(actionRadius, QtCore.SIGNAL('triggered(bool)'),
                               self.update_radius)

        QtCore.QObject.connect(actionShowFps, QtCore.SIGNAL('triggered(bool)'),
                               self.show_fps)

        QtCore.QObject.connect(actionBlack, QtCore.SIGNAL('triggered(bool)'),
                               self.set_bg_black)
        QtCore.QObject.connect(actionWhite, QtCore.SIGNAL('triggered(bool)'),
                               self.set_bg_white)

        world = World()
        world.register_listener(self)

        self._actions = [
            ["Viewer", "Zoom", actionResetZoom, 0],
            ["Viewer", "Zoom", actionZoomOut, 0],
            ["Viewer", "Zoom", actionZoomIn, 0],
            ["Viewer", "Zoom", self.actionAutoFocus, 0],
            ["Viewer", "Camera", actionShowAxis, 0],
            ["Viewer", "Camera", actionShowGrid, 0],
            ["Viewer", "Camera", actionRadius, 0],
            ["Viewer", "Camera", actionBlack, 0],
            ["Viewer", "Camera", actionWhite, 0],
            #["Viewer", "Informations", actionShowFps, 1]
        ]