def load(self, file):
        """Load a scene from file or string"""
        # keep root node instance and copy children instead so root variable in console stays valid
        del self._root[:]
        self._root += iv.read(file)[:]
        if self._root is not None:
            if file[0] is not '#':
                self._filePath = file
            else:
                self._filePath = ""

            self.parent().setWindowTitle(self.applicationTitle())
            del self.previewWidget.sceneManager.scene[:]
            resetCamera = False

            if (len(iv.search(self._root, type="DirectionalLight")) == 0):
                self.previewWidget.sceneManager.scene += iv.DirectionalLight()
            if (len(iv.search(self._root, type="Camera")) == 0):
                self.previewWidget.sceneManager.scene += [ iv.OrthographicCamera(), self._root ]
                resetCamera = True

            self.previewWidget.sceneManager.scene += self._root

            if resetCamera:
                self.previewWidget.sceneManager.view_all()

            self.inspectorWidget.attach(self._root)
Esempio n. 2
0
    def load(self, file):
        """Load a scene from file or string"""
        # keep root node instance and copy children instead so root variable in console stays valid
        del self._root[:]
        self._root += iv.read(file)[:]
        if self._root is not None:
            if file[0] is not '#':
                self._filePath = file
            else:
                self._filePath = ""

            self.parent().setWindowTitle(self.applicationTitle())
            del self.previewWidget.sceneManager.scene[:]
            resetCamera = False

            if (iv.search(self._root, type="DirectionalLight") is None):
                self.previewWidget.sceneManager.scene += iv.DirectionalLight()
            if (iv.search(self._root, type="Camera") is None):
                self.previewWidget.sceneManager.scene += [
                    iv.OrthographicCamera(), self._root
                ]
                resetCamera = True

            self.previewWidget.sceneManager.scene += self._root

            if resetCamera:
                self.previewWidget.sceneManager.view_all()

            self.inspectorWidget.attach(self._root)
Esempio n. 3
0
 def loadScene(self, file):
     root = iv.read(file)
     if root:
         self.glWidget.sceneManager.scene = root
         if (len(iv.search(self.glWidget.sceneManager.scene, type="Camera")) == 0):
             self.glWidget.sceneManager.scene.insert(0, iv.OrthographicCamera())
         if (len(iv.search(self.glWidget.sceneManager.scene, type="DirectionalLight")) == 0):
             self.glWidget.sceneManager.scene.insert(0, iv.DirectionalLight())
         self.glWidget.sceneManager.view_all()
Esempio n. 4
0
 def loadScene(self, file):
     root = iv.read(file)
     if root:
         self.glWidget.sceneManager.scene = root
         if (len(iv.search(self.glWidget.sceneManager.scene,
                           type="Camera")) == 0):
             self.glWidget.sceneManager.scene.insert(
                 0, iv.OrthographicCamera())
         if (len(
                 iv.search(self.glWidget.sceneManager.scene,
                           type="DirectionalLight")) == 0):
             self.glWidget.sceneManager.scene.insert(
                 0, iv.DirectionalLight())
         self.glWidget.sceneManager.view_all()
Esempio n. 5
0
    def test_selection(self):
        selectionNode = inventor.search(self.view.scene,
                                        type="Selection",
                                        first=True)[-1]
        selectionSensor = inventor.Sensor(selectionNode, "selection",
                                          self.selection_callback)
        deselectionSensor = inventor.Sensor(selectionNode, "deselection",
                                            self.deselection_callback)
        startSensor = inventor.Sensor(selectionNode, "start",
                                      self.start_callback)
        finishSensor = inventor.Sensor(selectionNode, "finish",
                                       self.finish_callback)

        # click on cone to select
        self.callback_info = ["", "", "", ""]
        self.view.mouse_button(0, 0, 128, 128)
        self.view.mouse_button(0, 1, 128, 128)
        self.assertEqual(self.callback_info,
                         ['Cone', '', 'Selection', 'Selection'])

        # click outside to deselect
        self.callback_info = ["", "", "", ""]
        self.view.mouse_button(0, 0, 1, 1)
        self.view.mouse_button(0, 1, 1, 1)
        self.assertEqual(self.callback_info,
                         ['', 'Cone', 'Selection', 'Selection'])
Esempio n. 6
0
 def createScene(self):
     self.ivWidget.sceneManager.scene = iv.read(__file__.replace(".py", ".iv"))
     self.manip = iv.TransformBoxManip()
     
     # find selection node and attach callbacks
     selectionNode = iv.search(self.ivWidget.sceneManager.scene, type="Selection")[-1]
     self.selectionSensor = iv.Sensor(selectionNode, "selection", self.selectionCB)
     self.deselectionSensor = iv.Sensor(selectionNode, "deselection", self.deselectionCB)
Esempio n. 7
0
    def createScene(self):
        self.ivWidget.sceneManager.scene = iv.read(
            __file__.replace(".py", ".iv"))
        self.manip = iv.TransformBoxManip()

        # find selection node and attach callbacks
        selectionNode = iv.search(self.ivWidget.sceneManager.scene,
                                  type="Selection")[-1]
        self.selectionSensor = iv.Sensor(selectionNode, "selection",
                                         self.selectionCB)
        self.deselectionSensor = iv.Sensor(selectionNode, "deselection",
                                           self.deselectionCB)
Esempio n. 8
0
    def test_selection(self):
        selectionNode = inventor.search(self.view.scene, type="Selection", first = True)[-1]
        selectionSensor = inventor.Sensor(selectionNode, "selection", self.selection_callback)
        deselectionSensor = inventor.Sensor(selectionNode, "deselection", self.deselection_callback)
        startSensor = inventor.Sensor(selectionNode, "start", self.start_callback)
        finishSensor = inventor.Sensor(selectionNode, "finish", self.finish_callback)

        # click on cone to select
        self.callback_info = ["", "", "", ""]
        self.view.mouse_button(0, 0, 128, 128)
        self.view.mouse_button(0, 1, 128, 128)
        self.assertEqual(self.callback_info, ['Cone', '', 'Selection', 'Selection'])

        # click outside to deselect
        self.callback_info = ["", "", "", ""]
        self.view.mouse_button(0, 0, 1, 1)
        self.view.mouse_button(0, 1, 1, 1)
        self.assertEqual(self.callback_info, ['', 'Cone', 'Selection', 'Selection'])
Esempio n. 9
0
 def deselectionCB(self, path):
     # remove manipulator
     self.manip.replace_manip(iv.search(self.ivWidget.sceneManager.scene, node=self.manip))
Esempio n. 10
0
 def deselectionCB(self, path):
     # remove manipulator
     self.manip.replace_manip(
         iv.search(self.ivWidget.sceneManager.scene, node=self.manip))