Exemplo n.º 1
0
def onFileSaveData():

    obj = om.getActiveObject()
    if not obj:
        app.showErrorMessage('Please select an object', title='No object selected')
        return
    if isinstance(obj, otdfmodel.OtdfModelItem):
        mainWindow = app.getMainWindow()
        filename = QtGui.QFileDialog.getSaveFileName(mainWindow, "Save Data...", getDefaultDirectory(), 'OTDF (*.otdf)', 'OTDF (*.otdf)')

        if not os.path.splitext(filename)[1]:
            filename += '.otdf'

        storeDefaultDirectory(filename)
        otdfString = obj.parser.getUpdatedOtdf()
        otdfFile = open(filename, 'w')
        otdfFile.write(otdfString)
        otdfFile.close()
    elif hasattr(obj, 'polyData'):
        mainWindow = app.getMainWindow()
        fileFilters = "PLY (*.ply);;STL (*.stl);;VTP (*.vtp)";
        filename = QtGui.QFileDialog.getSaveFileName(mainWindow, "Save Data...", getDefaultDirectory(), fileFilters, 'VTP (*.vtp)')

        if not filename:
            return

        if not os.path.splitext(filename)[1]:
            filename += '.vtp'

        polyData = io.writePolyData(obj.polyData, filename)
    else:
        app.showErrorMessage('Please select an object that contains geometry data or an OTDF object', title='Invalid object selected')
        return

    storeDefaultDirectory(filename)
Exemplo n.º 2
0
 def getPointCloud(self):
     obj = om.getActiveObject()
     if obj and obj.getProperty('Name') == 'Multisense':
         return SnapshotMultisensePointcloud().getPointCloud()
     elif obj and obj.getProperty('Name') == 'stereo point cloud':
         return SnapshotStereoPointcloud().getPointCloud()
     elif obj and hasattr(obj, 'polyData'):
         return obj.polyData
     else:
         self.fail('no pointcloud is selected')
Exemplo n.º 3
0
 def getPointCloud(self):
     obj = om.getActiveObject()
     if obj and obj.getProperty('Name') == 'Multisense':
         return SnapshotMultisensePointcloud().getPointCloud()
     elif obj and obj.getProperty('Name') == 'stereo point cloud':
         return SnapshotStereoPointcloud().getPointCloud()
     elif obj and hasattr(obj, 'polyData'):
         return obj.polyData
     else:
         self.fail('no pointcloud is selected')
Exemplo n.º 4
0
def onFileSaveData():

    obj = om.getActiveObject()
    if not obj:
        app.showErrorMessage("Please select an object",
                             title="No object selected")
        return
    if isinstance(obj, otdfmodel.OtdfModelItem):
        mainWindow = app.getMainWindow()
        filename = QtGui.QFileDialog.getSaveFileName(
            mainWindow,
            "Save Data...",
            getDefaultDirectory(),
            "OTDF (*.otdf)",
            "OTDF (*.otdf)",
        )

        if not os.path.splitext(filename)[1]:
            filename += ".otdf"

        storeDefaultDirectory(filename)
        otdfString = obj.parser.getUpdatedOtdf()
        otdfFile = open(filename, "w")
        otdfFile.write(otdfString)
        otdfFile.close()
    elif hasattr(obj, "polyData"):
        mainWindow = app.getMainWindow()
        fileFilters = "PLY (*.ply);;STL (*.stl);;VTP (*.vtp);;VTK (*.vtk)"
        defaultFilter = "VTP (*.vtp)"
        filename = QtGui.QFileDialog.getSaveFileName(
            mainWindow,
            "Save Data...",
            getDefaultDirectory(),
            fileFilters,
            defaultFilter,
        )

        if not filename:
            return

        if not os.path.splitext(filename)[1]:
            filename += ".vtp"

        polyData = io.writePolyData(obj.polyData, filename)
    else:
        app.showErrorMessage(
            "Please select an object that contains geometry data or an OTDF object",
            title="Invalid object selected",
        )
        return

    storeDefaultDirectory(filename)
Exemplo n.º 5
0
def onFileExportUrdf():
    obj = om.getActiveObject()
    if not obj or not isinstance(obj, otdfmodel.OtdfModelItem):
        app.showErrorMessage('Please select an OTDF object', title='OTDF object not selected')
        return

    mainWindow = app.getMainWindow()
    filename = QtGui.QFileDialog.getSaveFileName(mainWindow, "Save Data...", getDefaultDirectory(), 'URDF (*.urdf)', 'URDF (*.urdf)')

    if not os.path.splitext(filename)[1]:
        filename += '.urdf'

    storeDefaultDirectory(filename)
    urdfString = obj.parser.getUrdfFromOtdf()
    urdfFile = open(filename, 'w')
    urdfFile.write(urdfString)
    urdfFile.close()
Exemplo n.º 6
0
    def run(self):

        candidates = self.getCandidates()
        if not candidates:
            self.fail('no affordance candidates found')

        om.clearSelection()

        self.statusMessage = 'Please select affordance candidate: %s' % self.properties.getProperty('Candidate name prefix')

        while True:
            obj = om.getActiveObject()
            if obj and obj in candidates:
                break
            else:
                yield

        self.selectCandidate(obj, candidates)
Exemplo n.º 7
0
    def run(self):

        candidates = self.getCandidates()
        if not candidates:
            self.fail('no affordance candidates found')

        om.clearSelection()

        self.statusMessage = 'Please select affordance candidate: %s' % self.properties.getProperty('Candidate name prefix')

        while True:
            obj = om.getActiveObject()
            if obj and obj in candidates:
                break
            else:
                yield

        self.selectCandidate(obj, candidates)
Exemplo n.º 8
0
    def getSelectedAffordance(self):

        affordanceName = self.properties.getProperty('Affordance name')
        if affordanceName:
            obj = om.findObjectByName(affordanceName)
            if not obj:
                self.fail('could not find affordance: %s' % affordanceName)

        else:
            obj = om.getActiveObject()
            if obj is None:
                self.fail('no affordance is selected')

        try:
            frame = obj.getChildFrame()
        except AttributeError:
            frame = None

        if frame is None:
            self.fail('affordance does not have a frame')
        return obj
Exemplo n.º 9
0
    def getSelectedAffordance(self):

        affordanceName = self.properties.getProperty('Affordance name')
        if affordanceName:
            obj = om.findObjectByName(affordanceName)
            if not obj:
                self.fail('could not find affordance: %s' % affordanceName)

        else:
            obj = om.getActiveObject()
            if obj is None:
                self.fail('no affordance is selected')

        try:
            frame = obj.getChildFrame()
        except AttributeError:
            frame = None

        if frame is None:
            self.fail('affordance does not have a frame')
        return obj
Exemplo n.º 10
0
def fitSelectedGeometryObject():
    obj = om.getActiveObject()
    t = obj.actor.GetUserTransform()
    polyData = filterUtils.transformPolyData(obj.polyData, t)
    obj = fitObjectFromPolyData(polyData)
Exemplo n.º 11
0
 def getSelectedTarget(self):
     obj = om.getActiveObject()
     return obj if obj and hasattr(obj, 'actor') else None
Exemplo n.º 12
0
 def getSelectedTarget(self):
     obj = om.getActiveObject()
     return obj if obj and hasattr(obj, 'actor') else None