Ejemplo n.º 1
0
 def remove_item(self):
     for item in self.selectedItems():
         if item == item.root() or item.object in item.root().object.items:
             self.removeItemWidget(item, 0)
             self.signal_item_removed.emit(item)
             del item
         else:
             log.warn("can not remove item")
Ejemplo n.º 2
0
 def remove_item(self):
     for item in self.selectedItems():
         if item == item.root() or item.object in item.root().object.items:
             self.removeItemWidget(item, 0)
             self.signal_item_removed.emit(item)
             del item
         else:
             log.warn("can not remove item")
Ejemplo n.º 3
0
 def load(self, func_name="load"):
     """
     Defers actually loading the scene until necessary.
     """
     if not self.loaded and not self.bad:
         log.debug("[%s] reading %s" % (func_name, self.filepath))
         try:
             super(SceneWrapper, self).__init__(self.filepath)
             self.loaded = True
         except Exception, e:
             log.warn("BAD ARCHIVE: %s\n%s" % (self.filepath, str(e)))
             self.bad = True
Ejemplo n.º 4
0
 def load(self, func_name="load"):
     """
     Defers actually loading the scene until necessary.
     """
     if not self.loaded and not self.bad:
         log.debug("[%s] reading %s" % (func_name, self.filepath))
         try:
             super(SceneWrapper, self).__init__(self.filepath)
             self.loaded = True
         except Exception, e:
             log.warn("BAD ARCHIVE: %s\n%s" % (self.filepath, str(e)))
             self.bad = True
Ejemplo n.º 5
0
    def set_camera(self, camera="interactive"):
        """
        Sets the scene camera from a given camera name string

        :param camera: Name of camera or GLCamera object
        """
        if type(camera) in [str, unicode]:
            if "/" in camera:
                camera = os.path.split("/")[-1]
            if camera not in [cam.name for cam in self.state.cameras]:
                log.warn("camera not found: %s" % camera)
                return
            self.camera = self.state.get_camera_by_name(camera)
        else:
            self.camera = camera
        self.resizeGL(self.width(), self.height())
        self.signal_set_camera.emit(self.camera)
Ejemplo n.º 6
0
    def set_camera(self, camera="interactive"):
        """
        Sets the scene camera from a given camera name string

        :param camera: Name of camera or GLCamera object
        """
        if type(camera) in [str, unicode]:
            if "/" in camera:
                camera = os.path.split("/")[-1]
            if camera not in [cam.name for cam in self.state.cameras]:
                log.warn("camera not found: %s" % camera)
                return
            self.camera = self.state.get_camera_by_name(camera)
        else:
            self.camera = camera
        self.resizeGL(self.width(), self.height())
        self.signal_set_camera.emit(self.camera)
Ejemplo n.º 7
0
        def _draw(obj):
            md = obj.getMetaData()
            if alembic.AbcGeom.IPolyMesh.matches(
                    md) or alembic.AbcGeom.ISubD.matches(md):
                meshObj = alembic.AbcGeom.IPolyMesh(obj.getParent(),
                                                    obj.getName())
                mesh = meshObj.getSchema()

                xf = get_final_matrix(meshObj)
                iss = alembic.Abc.ISampleSelector(0)

                facesProp = mesh.getFaceIndicesProperty()
                if not facesProp.valid():
                    return
                pointsProp = mesh.getPositionsProperty()
                if not pointsProp.valid():
                    return
                normalsProp = mesh.getNormalsParam().getValueProperty()
                if not normalsProp.valid():
                    return
                boundsProp = mesh.getSelfBoundsProperty()
                if not boundsProp.valid():
                    return

                faces = facesProp.getValue(iss)
                points = pointsProp.getValue(iss)
                normals = normalsProp.getValue(iss)
                bounds = boundsProp.getValue(iss)

                for i, fi in enumerate(faces):
                    p = points[fi] * xf
                    n = normals[i]
                    v = p + n
                    glBegin(GL_LINES)
                    glColor3f(0, 1, 0)
                    glVertex3f(p[0], p[1], p[2])
                    glVertex3f(v[0], v[1], v[2])
                    glEnd()

            for child in obj.children:
                try:
                    _draw(child)
                except Exception, e:
                    log.warn("unhandled exception: %s" % e)
Ejemplo n.º 8
0
        def _draw(obj):
            md = obj.getMetaData()
            if alembic.AbcGeom.IPolyMesh.matches(md) or alembic.AbcGeom.ISubD.matches(md):
                meshObj = alembic.AbcGeom.IPolyMesh(obj.getParent(), obj.getName())
                mesh = meshObj.getSchema()
                
                xf = get_final_matrix(meshObj)
                iss = alembic.Abc.ISampleSelector(0)

                facesProp = mesh.getFaceIndicesProperty()
                if not facesProp.valid():
                    return
                pointsProp = mesh.getPositionsProperty()
                if not pointsProp.valid():
                    return
                normalsProp = mesh.getNormalsParam().getValueProperty()
                if not normalsProp.valid():
                    return
                boundsProp = mesh.getSelfBoundsProperty()
                if not boundsProp.valid():
                    return
                
                faces = facesProp.getValue(iss)
                points = pointsProp.getValue(iss)
                normals = normalsProp.getValue(iss)
                bounds = boundsProp.getValue(iss)

                for i, fi in enumerate(faces):
                    p = points[fi] * xf
                    n = normals[i]
                    v = p + n
                    glBegin(GL_LINES)
                    glColor3f(0, 1, 0)
                    glVertex3f(p[0], p[1], p[2])
                    glVertex3f(v[0], v[1], v[2])
                    glEnd()
        
            for child in obj.children:
                try:
                    _draw(child)
                except Exception, e:
                    log.warn("unhandled exception: %s" % e)
Ejemplo n.º 9
0
def create_viewer_app(filepath=None):
    """
    Creates a standalone viewer app. ::

        >>> from abcview.widget.viewer_widget import create_viewer_app
        >>> create_viewer_app("file.abc")

    """
    app = QtGui.QApplication(sys.argv)

    # create the viewer widget
    viewer = GLWidget()
    viewer_group = QtGui.QGroupBox()
    viewer_group.setLayout(QtGui.QVBoxLayout())
    viewer_group.layout().setSpacing(0)
    viewer_group.layout().setMargin(0)
    viewer_group.layout().addWidget(viewer)
    viewer_group.setWindowTitle("GLWidget")

    # set default size
    viewer_group.setMinimumSize(QtCore.QSize(100, 100))
    viewer_group.resize(500, 300)

    # display the viewer app
    viewer_group.show()
    viewer_group.raise_()

    # override key press event handler
    viewer_group.keyPressEvent = viewer.keyPressEvent

    # open a file
    if filepath:
        if os.path.exists(filepath):
            viewer.add_file(filepath)
        else:
            log.warn("file not found: %s" % filepath)

    return app.exec_()
Ejemplo n.º 10
0
def create_viewer_app(filepath=None):
    """
    Creates a standalone viewer app. ::

        >>> from abcview.widget.viewer_widget import create_viewer_app
        >>> create_viewer_app("file.abc")

    """
    app = QtGui.QApplication(sys.argv)

    # create the viewer widget
    viewer = GLWidget()
    viewer_group = QtGui.QGroupBox()
    viewer_group.setLayout(QtGui.QVBoxLayout())
    viewer_group.layout().setSpacing(0)
    viewer_group.layout().setMargin(0)
    viewer_group.layout().addWidget(viewer)
    viewer_group.setWindowTitle("GLWidget")

    # set default size
    viewer_group.setMinimumSize(QtCore.QSize(100, 100))
    viewer_group.resize(500, 300)

    # display the viewer app
    viewer_group.show()
    viewer_group.raise_()

    # override key press event handler
    viewer_group.keyPressEvent = viewer.keyPressEvent

    # open a file
    if filepath:
        if os.path.exists(filepath):
            viewer.add_file(filepath)
        else:
            log.warn("file not found: %s" % filepath)

    return app.exec_()
Ejemplo n.º 11
0
 def _set_parent(self, parent):
     if type(parent) in (Scene, Session) or parent == None:
         self._parent = parent
     else:
         log.warn("cannot parent to: %s" % parent)
Ejemplo n.º 12
0
 def _set_parent(self, parent):
     if type(parent) in (Scene, Session) or parent == None:
         self._parent = parent
     else:
         log.warn("cannot parent to: %s" % parent)