Beispiel #1
0
    def __init__ (self, parent):
        super(_RoadmapTab, self).__init__ (parent)
        self.plugin = parent
        box = QtGui.QGridLayout(self)

        box.addWidget(QtGui.QLabel("Number of nodes:"), 0, 0)
        self.nbNode = QtGui.QLabel()
        box.addWidget(self.nbNode, 0, 1)

        box.addWidget(QtGui.QLabel("Number of edges:"), 1, 0)
        self.nbEdge = QtGui.QLabel()
        box.addWidget(self.nbEdge, 1, 1)

        box.addWidget(QtGui.QLabel("Number of connected components :"), 2, 0)
        self.nbComponent = QtGui.QLabel()
        box.addWidget(self.nbComponent, 2, 1)

        self.updateCB = QtGui.QCheckBox("Continuous update")
        box.addWidget(self.updateCB, 3, 2, 1, 2)
        self.updateCB.setTristate(False)

        self.timer = Qt.QTimer(self)
        self.timer.setInterval(500)
        self.timer.setSingleShot(False)

        self.timer.connect("timeout()", self.updateCount)
        self.updateCB.connect("stateChanged(int)", self.startStopTimer)
    def __init__(self, plugin):
        super(QCPWidget, self).__init__(plugin)
        self.plugin = plugin

        layout = QtGui.QVBoxLayout(self)

        from PythonQt.QCustomPlot import QCustomPlot, QCP
        self.qcpWidget = QCustomPlot()
        self.qcpWidget.autoAddPlottableToLegend = True
        self.qcpWidget.setInteraction(QCP.iRangeDrag, True)  # iRangeDrap
        self.qcpWidget.setInteraction(QCP.iRangeZoom, True)  # iRangeZoom
        self.qcpWidget.setInteraction(QCP.iSelectAxes, True)  # iSelectAxes
        self.qcpWidget.legend().visible = True
        layout.addWidget(self.qcpWidget, 1)
        self.qcpWidget.connect(Qt.SIGNAL("mouseDoubleClick(QMouseEvent*)"),
                               self._mouseDoubleClick)
        self.qcpWidget.xAxis().connect(
            Qt.SIGNAL("selectionChanged(QCPAxis::SelectableParts)"),
            self._axesSelectionChanged)
        self.qcpWidget.yAxis().connect(
            Qt.SIGNAL("selectionChanged(QCPAxis::SelectableParts)"),
            self._axesSelectionChanged)

        buttonbar = QtGui.QWidget()
        bbLayout = QtGui.QHBoxLayout(buttonbar)
        button = QtGui.QPushButton("Replot", buttonbar)
        button.connect(QtCore.SIGNAL("clicked()"), self.refreshPlot)
        bbLayout.addWidget(button)
        button = QtGui.QPushButton("Remove", buttonbar)
        button.connect(QtCore.SIGNAL("clicked()"), self.removePlot)
        bbLayout.addWidget(button)
        button = QtGui.QPushButton("Legend", buttonbar)
        button.checkable = True
        button.checked = True
        button.connect(QtCore.SIGNAL("toggled(bool)"), self.toggleLegend)
        bbLayout.addWidget(button)
        button = QtGui.QPushButton(QtGui.QIcon.fromTheme("zoom-fit-best"), "",
                                   buttonbar)
        button.setToolTip("Zoom fit best")
        button.connect(QtCore.SIGNAL("clicked()"), self.qcpWidget.rescaleAxes)
        bbLayout.addWidget(button)

        self.xselect = QtGui.QComboBox(self)
        bbLayout.addWidget(self.xselect, 1)
        layout.addWidget(buttonbar)

        self.data = DataQCP(plugin, self.qcpWidget)
Beispiel #3
0
 def loadSetting(self, key, default):
     settings = Qt.QSettings()
     settings.beginGroup(self.SETTING_GROUP_NAME)
     val = settings.value(key)
     settings.endGroup()
     if (val == None) or (str(val) == ""):
         val = default
         self.saveSetting(key, val)
     return str(val)
 def applyGuiConfig(self):
     width = int(self.widgetWidthEdit.text)
     height = int(self.widgetHeightEdit.text)
     left = int(self.widgetLeftEdit.text)
     top = int(self.widgetTopEdit.text)
     self.resize(width,height)
     if (left != 0) and (top != 0):
         self.pos = Qt.QPoint(left,top)
     return
    def __init__(self, parent):
        super(CollisionPairs, self).__init__(parent)
        self.plugin = parent
        # parent.widgetToRefresh.append(self)
        self.orderedPairs = list()
        self.pairToRow = dict()
        box = QtGui.QVBoxLayout(self)

        button = QtGui.QPushButton(
            "Toggle between collision and visual robot bodies", self)
        button.checkable = True
        button.connect("clicked(bool)", self.toggleVisual)
        box.addWidget(button)

        button = QtGui.QPushButton(QtGui.QIcon.fromTheme("view-refresh"),
                                   "Refresh list", self)
        button.connect("clicked()", self.refresh)
        box.addWidget(button)

        # Create table
        self.table = TableWidget(0, 6)
        self.table.setHorizontalHeaderLabels([
            "Active", "Link 1", "Link 2", "Reason", "Current configuration",
            "% of collision"
        ])
        if Qt.qVersion().startswith('4'):
            self.table.horizontalHeader().setResizeMode(
                QtGui.QHeaderView.Interactive)
        else:
            self.table.horizontalHeader().setSectionResizeMode(
                QtGui.QHeaderView.Interactive)
        self.table.selectionBehavior = QtGui.QAbstractItemView.SelectRows
        self.table.connect(
            "currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)",
            self.currentItemChanged)
        box.addWidget(self.table)

        # "Number of random configuration (log scale)"
        self.sliderRandomCfg = QtGui.QSlider(Qt.Qt.Horizontal, self)
        self.sliderRandomCfg.setRange(20, 60)
        self.sliderRandomCfg.setValue(30)
        box.addWidget(self.sliderRandomCfg)
        button = QtGui.QPushButton("Compute percentage of collision", self)
        button.connect("clicked()", self.computePercentageOfCollision)
        box.addWidget(button)

        button = QtGui.QPushButton("Save to file...", self)
        button.connect("clicked()", self.writeToFile)
        box.addWidget(button)

        obj = self.plugin.main.getFromSlot("getHppIIOPurl")
        if obj is not None:
            obj.connect("configurationValidationStatus(QStringList)",
                        self.currentBodyInCollisions)
        else:
            print("Could not find obj")
 def saveConfig(self):
     settings = Qt.QSettings()
     settings.beginGroup(self.pluginConf)
     for (widget,key,default) in self.settings:
         if type(default)==type("a"):
             val_str = str(widget.text)
         elif type(default)==type(True):
             val_str = str(int(widget.isChecked()))
         settings.setValue(key,val_str)
     settings.endGroup()
     return
    def __init__(self, plugin):
        self.plugin = plugin
        self.graph = QGVScene("graph")
        self.view = QtGui.QGraphicsView(self.graph)
        self.layoutShouldBeFreed = False
        self.graph.connect(Qt.SIGNAL("nodeMouseRelease(QGVNode*)"),
                           self.updateLayout)
        self.graph.connect(Qt.SIGNAL("nodeContextMenu(QGVNode*)"),
                           self._nodeContextMenu)
        self.graph.connect(Qt.SIGNAL("edgeContextMenu(QGVEdge*)"),
                           self._signalContextMenu)

        ### An object returned by re.compile
        self.entityFilter = None
        self.typeCallbacks = {
            "Task": (self._nodeEntityTask, self._edgeEntityTask),
            "SOT": (self._nodeEntitySOT, self._edgeEntitySOT)
        }

        self.initCmd()
        self.createAllGraph()
 def loadConfig(self):
     settings = Qt.QSettings()
     settings.beginGroup(self.pluginConf)
     for (widget,key,default) in self.settings:
         val = settings.value(key)
         if (val == None) or (str(val)==""):
             val_str = default
         else:
             val_str = str(val)
         if type(default)==type("a"):
             widget.text = val_str
         elif type(default)==type(True):
             widget.setChecked(bool(int(val_str)))
     settings.endGroup()
     return
 def __init__(self, mainWindow):
     super(Plugin, self).__init__("Gepetto Viewer plugin", mainWindow)
     self.setObjectName("Gepetto Viewer plugin")
     self.client = Client()
     # Initialize the widget
     self.tabWidget = QtGui.QTabWidget(self)
     # This avoids having a widget bigger than what it needs. It avoids having
     # a big dock widget and a small osg widget when creating the main osg widget.
     p = Qt.QSizePolicy.Maximum
     self.tabWidget.setSizePolicy(Qt.QSizePolicy(p, p))
     self.setWidget(self.tabWidget)
     self.nodeCreator = _NodeCreator(self, self)
     self.tabWidget.addTab(self.nodeCreator, "Node Creator")
     self.main = mainWindow
     mainWindow.connect("refresh()", self.refresh)
     mainWindow.bodyTree().connect("bodySelected(SelectionEvent*)",
                                   self.selected)
    def __init__ (self, mainWindow, flags = None):
        if flags is None:
            super(Plugin, self).__init__ ("Matplotlib example plugin", mainWindow)
        else:
            super(Plugin, self).__init__ ("Matplotlib example plugin", mainWindow, flags)
        self.setObjectName("Matplotlib example plugin")
        self.client = Client()

        # This avoids having a widget bigger than what it needs. It avoids having
        # a big dock widget and a small osg widget when creating the main osg widget.
        p = Qt.QSizePolicy.Ignored
        self.testWidget = MatplotlibWidget(self, True)
        self.testWidget.setSizePolicy(Qt.QSizePolicy(p,p))
        self.setWidget (self.testWidget)

        # Plot something
        x = np.linspace (0, 10, num=100)
        y = np.sin(x)
        self.testWidget.figure.gca().plot (x, y)
Beispiel #11
0
    def __init__(self, mainWindow, flags=None):
        if flags is None:
            super(Plugin, self).__init__("Path graph plugin", mainWindow)
        else:
            super(Plugin, self).__init__("Path graph plugin", mainWindow,
                                         flags)
        self.setObjectName("Path graph plugin")

        self.main = mainWindow
        self.hppPlugin = self.main.getFromSlot("getHppIIOPurl")
        self.pathPlayer = self.main.getFromSlot("getCurrentPath")
        self.jointgroupcreator = self.main.getFromSlot(
            "requestCreateJointGroup")
        self.comgroupcreator = self.main.getFromSlot("requestCreateComGroup")
        self.velocities = Velocities(self)
        self.jointActions = dict()
        self.jointNames = None

        self.qcpWidgets = list()

        # This avoids having a widget bigger than what it needs. It avoids having
        # a big dock widget and a small osg widget when creating the main osg widget.
        p = Qt.QSizePolicy.Ignored
        self.topWidget = QtGui.QSplitter(Qt.Qt.Horizontal, self)
        self.topWidget.setSizePolicy(Qt.QSizePolicy(p, p))
        self.setWidget(self.topWidget)

        self.leftPane = QtGui.QWidget(self)
        l = QtGui.QVBoxLayout()
        self.makeLeftPane(l)
        self.leftPane.setLayout(l)

        self.topWidget.addWidget(self.leftPane)

        self.rightPane = QtGui.QWidget(self)
        self.rightPaneLayout = QtGui.QVBoxLayout()
        self.rightPane.setLayout(self.rightPaneLayout)
        self.addPlotBelow()
        self.topWidget.addWidget(self.rightPane)
        self.topWidget.setStretchFactor(1, 1)
Beispiel #12
0
    def __init__(self, mainWindow):
        super(Plugin, self).__init__("Coordinates viewer plugin", mainWindow)
        self.setObjectName("Coordinates viewer plugin")
        self.client = Client()

        self.le_name = QtGui.QLineEdit()
        self.le_name.setReadOnly(True)
        self.transform = QtGui.QLineEdit()
        self.transform.setReadOnly(True)

        self.local = QtGui.QCheckBox()
        self.local.setChecked(True)
        self.point = QtGui.QLineEdit()
        self.point.setReadOnly(True)
        self.normal = QtGui.QLineEdit()
        self.normal.setReadOnly(True)

        layout = QtGui.QFormLayout()
        layout.addRow('Name', self.le_name)
        layout.addRow('Transform', self.transform)
        layout.addRow('Local frame', self.local)
        layout.addRow('Point', self.point)
        layout.addRow('Normal', self.normal)

        # Initialize the widget
        widget = QtGui.QWidget(self)
        widget.setLayout(layout)
        # This avoids having a widget bigger than what it needs. It avoids having
        # a big dock widget and a small osg widget when creating the main osg widget.
        p = Qt.QSizePolicy.Maximum
        widget.setSizePolicy(
            Qt.QSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Maximum))
        self.setWidget(widget)

        mainWindow.bodyTree().connect('bodySelected(SelectionEvent*)',
                                      self.selected)
    def writeToFile(self):
        _ = _bodyNameToUrdfLinkName
        filename = QtGui.QFileDialog.getSaveFileName(self, "SRDF file", "",
                                                     "SRDF files (*.srdf)")
        file = Qt.QFileInfo(filename)
        if file.exists():
            tree = ET.parse(filename)
        else:
            tree = ET.ElementTree(ET.Element("robot", {"name": "name"}))
            tree.getroot().append(
                ET.Comment("Generated by hpp-gui Python plugin"))

        robot = tree.getroot()
        pairsInFile = dict()
        for dc in robot.findall("disable_collisions"):
            p = _Pair(dc.attrib["link1"], dc.attrib["link2"])
            pairsInFile[p] = dc

        for p, row in self.pairToRow.items():
            if row[self.ACTIVE].checked:
                continue
            reason = str(row[self.REASON].text())
            pp = _Pair(_(p.l1), _(p.l2))
            if pp in pairsInFile:
                dc.attrib["reason"] = reason
            else:
                attrib = dict()
                attrib["link1"] = pp.l1
                attrib["link2"] = pp.l2
                attrib["reason"] = reason
                el = ET.Element("disable_collisions", attrib=attrib)
                if len(robot.getchildren()) > 0:
                    robot.getchildren()[-1].tail = "\n  "
                robot.append(el)

        tree.write(filename)
Beispiel #14
0
 def saveSetting(self, key, val):
     settings = Qt.QSettings()
     settings.beginGroup(self.SETTING_GROUP_NAME)
     settings.setValue(key, str(val))
     settings.endGroup()
     return