コード例 #1
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)
コード例 #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 (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)
コード例 #3
0
ファイル: Manipulators.py プロジェクト: TheHubbit/PyInventor
 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)
コード例 #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()
コード例 #5
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        baseSceneStr = "#Inventor V2.1 ascii\n \
             Separator { \
               DirectionalLight {}\n \
               OrthographicCamera { orientation 1 0 0 3.1415926 position 0 0 -5 }\n \
               Material { diffuseColor 1 1 1 }\n \
             }"

        volNode = iv.SoVolumeData("fileName 3dhead.vol")

        # transfer function: simple ramp
        cmap = np.ones((4, 256))
        cmap[:4] = np.linspace(0, 1, 256)

        mainLayout = QtGui.QHBoxLayout()
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.setSpacing(2)

        widget = QtInventor.QIVWidget()
        widget.sceneManager.background = (0.5, 0.3, 0.3)
        widget.sceneManager.scene = iv.read(baseSceneStr)
        widget.sceneManager.scene += volNode
        widget.sceneManager.scene += iv.SoTransferFunction(
            "colorMapType RGBA predefColorMap NONE")
        widget.sceneManager.scene[-1].colorMap = cmap.T
        widget.sceneManager.scene += iv.SoOrthoSlice("axis Z sliceNumber 52")
        mainLayout.addWidget(widget)

        widget = QtInventor.QIVWidget(None, widget)
        widget.sceneManager.background = (0.3, 0.5, 0.3)
        widget.sceneManager.scene = iv.read(baseSceneStr)
        widget.sceneManager.scene += iv.TrackballManip()
        widget.sceneManager.scene += volNode
        widget.sceneManager.scene += iv.SoTransferFunction(
            "colorMapType RGBA predefColorMap NONE remapLow 0x30 remapHigh 0xff"
        )
        widget.sceneManager.scene[-1].colorMap = cmap.T
        widget.sceneManager.scene += iv.SoVolumeRender()
        mainLayout.addWidget(widget)

        self.setLayout(mainLayout)
        self.setWindowTitle(self.tr("Volume Rendering"))
コード例 #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)
コード例 #7
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        
        baseSceneStr = "#Inventor V2.1 ascii\n \
             Separator { \
               DirectionalLight {}\n \
               OrthographicCamera { orientation 1 0 0 3.1415926 position 0 0 -5 }\n \
               Material { diffuseColor 1 1 1 }\n \
             }"
        volNode = iv.SoVolumeData("fileName 3dhead.vol")

        # transfer function: simple ramp
        cmap = np.ones((4,256))
        cmap[:4] = np.linspace(0, 1, 256)
        
        mainLayout = QtGui.QHBoxLayout()
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.setSpacing(2)
        
        widget = QtInventor.QIVWidget()
        widget.sceneManager.background = (0.5, 0.3, 0.3)
        widget.sceneManager.scene = iv.read(baseSceneStr)
        widget.sceneManager.scene += volNode
        widget.sceneManager.scene += iv.SoTransferFunction("colorMapType RGBA predefColorMap NONE")
        widget.sceneManager.scene[-1].colorMap = cmap.T
        widget.sceneManager.scene += iv.SoOrthoSlice("axis Z sliceNumber 52")
        mainLayout.addWidget(widget)
        
        widget = QtInventor.QIVWidget(None, widget)
        widget.sceneManager.background = (0.3, 0.5, 0.3)
        widget.sceneManager.scene = iv.read(baseSceneStr)
        widget.sceneManager.scene += iv.TrackballManip()
        widget.sceneManager.scene += volNode
        widget.sceneManager.scene += iv.SoTransferFunction("colorMapType RGBA predefColorMap NONE remapLow 0x30 remapHigh 0xff")
        widget.sceneManager.scene[-1].colorMap = cmap.T
        widget.sceneManager.scene += iv.SoVolumeRender()
        mainLayout.addWidget(widget)

        self.setLayout(mainLayout)
        self.setWindowTitle(self.tr("Volume Rendering"))
コード例 #8
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()