예제 #1
0
    def findBranch(self, base_class, parent=QtCore.QModelIndex()):
        parent_item = self.getItem(parent)

        child_item = parent_item.findBranch(base_class)
        if child_item:
            return self.index(child_item.childNumber(), 0, parent)
        else:
            return QtCore.QModelIndex()
예제 #2
0
    def parent(self, index=QtCore.QModelIndex()):
        if not index.isValid():
            return QtCore.QModelIndex()

        child_item = self.getItem(index)
        parent_item = child_item.parentItem()

        if parent_item == self._root_item:
            return QtCore.QModelIndex()

        return self.createIndex(parent_item.childNumber(), 0, parent_item)
예제 #3
0
    def findChild(self, description, parent=QtCore.QModelIndex()):
        parent_item = self.getItem(parent)
        if parent_item == self._root_item:
            parent = self.findBranch(description.base_class.data, parent)

        if not parent.isValid():
            return QtCore.QModelIndex()

        child_item = parent_item.findChild(description)
        if child_item:
            return self.index(child_item.childNumber(), 0, parent)
        else:
            return QtCore.QModelIndex()
예제 #4
0
    def __init__(self, context):
        super(CalibrationUI, self).__init__(context)

        self.setObjectName('Instructor Calibration UI')

        # Create QWidget
        self._widget = QWidget()

        # Get path to UI file which is a sibling of this file
        rospack = rospkg.RosPack()
        ui_path = rospack.get_path('instructor_core') + '/ui/calibration.ui'

        # Load the ui attributes into the main widget
        loadUi(ui_path, self._widget)
        self._widget.setObjectName('InstructorCalibrationUI')
        self._widget.setWindowTitle('Instructor Calibration UI')

        # Show _widget.windowTitle on left-top of each plugin (when
        # it's set in _widget). This is useful when you open multiple
        # plugins at once. Also if you open multiple instances of your
        # plugin at once, these lines add number to make it easy to
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))

        # Add widget to the user interface
        context.add_widget(self._widget)
        palette = QPalette()
        palette.setColor(QPalette.Background, Qt.white)
        self._widget.setPalette(palette)

        # Initialize empty set of available markers for each camera
        for c in range(self.n_cameras):
            self.camera_marker_frame_names[c] = {}
            self.cameras_calibrated += [False]

        # Add listener to detect AR markers
        self.tf_listen = tf.TransformListener()
        self.tf_broadcast = tf.TransformBroadcaster()

        # Add timer
        self.timer = QtCore.QTimer()
        self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.update)
        self.timer.start(100)
        self._widget.done_btn.clicked.connect(self.done_event)
        self._widget.recalibrate_btn.clicked.connect(self.recalibrate_event)

        ### Change Indicator Sample Code --------------------------------------#
        self._widget.done_btn.setStyleSheet('color:#999999')
예제 #5
0
    def index(self, row, column, parent=QtCore.QModelIndex()):
        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

        if parent.isValid() and parent.column() != 0:
            return QtCore.QModelIndex()

        parent_item = self.getItem(parent)

        child_item = parent_item.child(row)
        if child_item:
            return self.createIndex(row, column, child_item)
        else:
            return QtCore.QModelIndex()
예제 #6
0
    def loadFile(self, fileName):
        file = QtCore.QFile(fileName)
        if not file.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
            QtGui.QMessageBox.warning(
                self, "${APP_NAME}", "Cannot read file %s:\n%s." % (
                    fileName, file.errorString()))
            return

        inf = QtCore.QTextStream(file)
        QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        self.textEdit.setPlainText(inf.readAll())
        QtGui.QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)
        self.statusBar().showMessage("File loaded", 2000)
예제 #7
0
    def saveFile(self, fileName):
        file = QtCore.QFile(fileName)
        if not file.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text):
            QtGui.QMessageBox.warning(
                self, "${APP_NAME}", "Cannot write file %s:\n%s." % (
                    fileName, file.errorString()))
            return False

        outf = QtCore.QTextStream(file)
        QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        outf << self.textEdit.toPlainText()
        QtGui.QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)
        self.statusBar().showMessage("File saved", 2000)
        return True
예제 #8
0
    def insertRows(self, row, count, parent=QtCore.QModelIndex()):
        parent_item = self.getItem(parent)

        self.beginInsertRows(parent, row, row + count - 1)
        success = parent_item.insertChildren(row, count)
        self.endInsertRows()

        return success
예제 #9
0
    def removeRows(self, row, count, parent=QtCore.QModelIndex()):
        parent_item = self.getItem(parent)

        self.beginRemoveRows(parent, row, row + count - 1)
        success = parent_item.removeChildren(row, count)
        self.endRemoveRows()

        # remove empty branch
        if success and parent_item.parentItem() and not parent_item.childCount():
            return self.removeRows(parent_item.childNumber(), 1)

        return success
예제 #10
0
    def addBranch(self, base_class):
        # check if branch already does exist
        branch = self.findBranch(base_class)
        if branch.isValid():
            return branch

        state = PluginState()
        state.description.base_class.data = base_class

        # add new branch
        temp_list = [child.getPluginState().description.base_class.data for child in self._root_item.childs()]
        position = bisect.bisect(temp_list, base_class)

        if self.insertRows(position, 1):
            branch_item = self._root_item.child(position)
            branch_item.setData(state)
            return self.index(position, 0)

        return QtCore.QModelIndex()
예제 #11
0
    def addItem(self, state):
        # search for branch with type_class
        branch = self.addBranch(state.description.base_class.data)
        branch_item = self.getItem(branch)

        # check if child already does exist
        child = self.findChild(state.description, branch)
        if child.isValid():
            return child

        # add new item to branch
        entry = (state.description.type_class.data, state.description.name.data)
        temp_list = [(child.getPluginState().description.type_class.data, child.getPluginState().description.name.data) for child in branch_item.childs()]
        position = bisect.bisect(temp_list, entry)

        if self.insertRows(position, 1, branch):
            child_item = branch_item.child(position)
            child_item.setData(state)
            return self.index(position, 0, branch)

        return QtCore.QModelIndex()
예제 #12
0
 def writeSettings(self):
     settings = QtCore.QSettings("Trolltech", "${APP_NAME}")
     settings.setValue("pos", self.pos())
     settings.setValue("size", self.size())
예제 #13
0
 def readSettings(self):
     settings = QtCore.QSettings("Trolltech", "${APP_NAME}")
     pos = settings.value("pos", QtCore.QPoint(200, 200))
     size = settings.value("size", QtCore.QSize(400, 400))
     self.resize(size)
     self.move(pos)
    def __init__(self, context):
        super(WorkspaceUI, self).__init__(context)

        self.setObjectName('Instructor Workspace UI')

        # Create QWidget
        self._widget = QWidget()

        # Get path to UI file which is a sibling of this file
        rospack = rospkg.RosPack()
        ui_path = rospack.get_path('instructor_core') + '/ui/workspace.ui'

        # Load the ui attributes into the main widget
        loadUi(ui_path, self._widget)
        self._widget.setObjectName('InstructorWorkspaceUI')
        self._widget.setWindowTitle('Instructor Workspace UI')

        # Show _widget.windowTitle on left-top of each plugin (when
        # it's set in _widget). This is useful when you open multiple
        # plugins at once. Also if you open multiple instances of your
        # plugin at once, these lines add number to make it easy to
        # tell from pane to pane.
        if context.serial_number() > 1:
            title = self._widget.windowTitle() + (' (%d)' %
                                                  context.serial_number())
            self._widget.setWindowTitle(title)

        # Add widget to the user interface
        context.add_widget(self._widget)
        palette = QPalette()
        palette.setColor(QPalette.Background, Qt.white)
        self._widget.setPalette(palette)

        # Hide things to start with
        self._widget.fiducial_found_widget.hide()
        self._widget.add_fiducial_widget.hide()

        # Connect things
        self._widget.add_ok_btn.clicked.connect(self.add_ok_event)
        self._widget.add_cancel_btn.clicked.connect(self.add_cancel_event)
        self._widget.fiducial_name_edit.textChanged.connect(
            self.name_entered_event)

        # Add listener to detect AR markers
        self.tf_listen = tf.TransformListener()

        # Add predicator publisher
        self.pub_predicates = rospy.Publisher('predicator/input',
                                              PredicateList)

        # Clean params for landmarks
        rospy.loginfo('Cleaning up previous workspace landmark params')
        params = rospy.get_param_names()
        landmarks = [p for p in params if "instructor_landmark" in p]
        rospy.loginfo(landmarks)
        for marker in landmarks:
            rospy.loginfo('Removed ' + str(marker))
            rospy.delete_param(marker)

        # Add timer
        self.timer = QtCore.QTimer()
        self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.update)
        self.timer.start(100)
예제 #15
0
def qInitResources():
    QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
예제 #16
0
 def getItem(self, index=QtCore.QModelIndex()):
     if index.isValid():
         return index.internalPointer()
     else:
         return self._root_item
예제 #17
0
 def flags(self, index=QtCore.QModelIndex()):
     if index.isValid():
         return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | super(PluginTreeModel, self).flags(index) #QtCore.Qt.ItemIsEditable
     else:
         return QtCore.Qt.NoItemFlags
예제 #18
0
 def strippedName(self, fullFileName):
     return QtCore.QFileInfo(fullFileName).fileName()
예제 #19
0
 def rowCount(self, parent=QtCore.QModelIndex()):
     if parent.isValid():
         return parent.internalPointer().childCount()
     else:
         return self._root_item.childCount()
예제 #20
0
def qCleanupResources():
    QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
예제 #21
0
import sys

${PyQT_API_CHECK}from ${QT_LIBRARY} import QtCore

if __name__ == '__main__':

    app = QtCore.QCoreApplication(sys.argv)
    print "Initializing the main events loop"
    sys.exit(app.exec_())