Esempio n. 1
0
    def createEditor(self, parent, option, index):
        """
        Create for the display and interaction with the user an editor.

        @param QtGui.QWidget parent: The parent object (probably QTableView)
        @param QtGui.QStyleOptionViewItemV4 option: This is a setting option which you can use for
                                                    style configuration.
        @param QtCore.QModelIndex index: That index will be passed by the model object of the
                                         QTableView to the delegated object. This index contains
                                         information about the selected current cell.

        An editor can be in principle any QWidget, which you want to use to display the current
        (model-)data. Therefore the editor is also a container, which handles the passed entries
        from the user interface and should save the data in the model object of the QTableWidget.

        Do not save the created editor as a class variable! This consumes a lot of unneeded memory.
        It is way better to create an editor if it is needed. The inherent function closeEditor()
        of QStyledItemDelegate takes care of closing and destroying the editor for you, if it is not
        needed any longer.
        """
        widget = QtGui.QComboBox(parent)
        widget.addItems(self._item_list)
        widget.setGeometry(option.rect)
        widget.currentIndexChanged.connect(self.commitAndCloseEditor)
        return widget
Esempio n. 2
0
 def paint(self, painter, option, index):
     painter.save()
     r = option.rect
     painter.translate(r.topLeft())
     widget = QtGui.QComboBox()
     widget.addItem(index.data(self._access_role))
     widget.setGeometry(r)
     widget.render(painter)
     painter.restore()
Esempio n. 3
0
    def __init__(self, data, win_parent=None):
        """
        +--------+
        | BC Map |
        +--------+---------------+
        |  Origin                |
        |     X       Y      Z   |
        |                        |
        |  Normal                |
        |    NX      NY     NZ   |
        |                        |
        |  Apply Normal          |
        |    NX      NY     NZ   |
        |                        |
        |    Apply   OK  Cancel  |
        +--------+---------------+
        """
        QtGui.QDialog.__init__(self, win_parent)

        self._default_name = 'Plane'
        self.out_data = data
        self._axis = '?'
        self._plane = '?'

        ox_value, oy_value, oz_value = self.out_data['origin']
        nx_value, ny_value, nz_value = self.out_data['normal']
        ax_value, ay_value, az_value = self.out_data['a']
        bx_value, by_value, bz_value = self.out_data['b']

        self._origin_x_default = ox_value
        self._origin_y_default = oy_value
        self._origin_z_default = oz_value

        self._normal_x_default = nx_value
        self._normal_y_default = ny_value
        self._normal_z_default = nz_value

        self._ax_default = ax_value
        self._ay_default = ay_value
        self._az_default = az_value

        self._bx_default = bx_value
        self._by_default = by_value
        self._bz_default = bz_value

        self._default_is_apply = True

        self.name = QtGui.QLabel("Title:")
        self.name_edit = QtGui.QLineEdit(str(self._default_name))
        self.name_button = QtGui.QPushButton("Default")

        self.axis = QtGui.QLabel("Point on ? Axis:")
        self.combo_axis = QtGui.QComboBox(self)
        self.combo_axis.addItem("X")
        self.combo_axis.addItem("Y")
        self.combo_axis.addItem("Z")

        self.plane = QtGui.QLabel("Point on %s? Plane:" % self._axis)
        self.combo_plane = QtGui.QComboBox(self)
        self.combo_plane.addItem("X")
        self.combo_plane.addItem("Y")
        self.combo_plane.addItem("Z")

        self.origin = QtGui.QLabel("Origin:")
        self.origin_x_edit = QtGui.QLineEdit(str(self._origin_x_default))
        self.origin_y_edit = QtGui.QLineEdit(str(self._origin_y_default))
        self.origin_z_edit = QtGui.QLineEdit(str(self._origin_z_default))
        self.origin_default_button = QtGui.QPushButton("Default")
        #self.name_button = QtGui.QPushButton("Default")

        self.normal = QtGui.QLabel("Normal:")
        self.normal_x_edit = QtGui.QLineEdit(str(self._normal_x_default))
        self.normal_y_edit = QtGui.QLineEdit(str(self._normal_y_default))
        self.normal_z_edit = QtGui.QLineEdit(str(self._normal_z_default))
        self.normal_default_button = QtGui.QPushButton("Default")

        self.snap = QtGui.QLabel("Snap Normal:")
        self.snap_normal_xy_button = QtGui.QPushButton("XY Plane")
        self.snap_normal_yz_button = QtGui.QPushButton("YZ Plane")
        self.snap_normal_xz_button = QtGui.QPushButton("XZ Plane")

        self.point_a = QtGui.QLabel("Point on %s Axis:" % self._axis)
        self.ax_edit = QtGui.QLineEdit(str(self._ax_default))
        self.ay_edit = QtGui.QLineEdit(str(self._ay_default))
        self.az_edit = QtGui.QLineEdit(str(self._az_default))

        self.point_b = QtGui.QLabel("Point on %s%s Plane:" %
                                    (self._axis, self._plane))
        self.bx_edit = QtGui.QLineEdit(str(self._bx_default))
        self.by_edit = QtGui.QLineEdit(str(self._by_default))
        self.bz_edit = QtGui.QLineEdit(str(self._bz_default))

        self.check_apply = QtGui.QCheckBox("Automatically apply results")
        self.check_apply.setChecked(self._default_is_apply)

        # closing
        self.apply_button = QtGui.QPushButton("Apply")
        if self._default_is_apply:
            self.apply_button.setDisabled(True)

        self.ok_button = QtGui.QPushButton("OK")
        self.cancel_button = QtGui.QPushButton("Cancel")
        self.create_layout()
        self.set_connections()
Esempio n. 4
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(1115, 652)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.centralwidget)
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.tabMain = QtGui.QTabWidget(self.centralwidget)
        self.tabMain.setObjectName(_fromUtf8("tabMain"))
        self.tab = QtGui.QWidget()
        self.tab.setObjectName(_fromUtf8("tab"))
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.tab)
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.gridLayout_4 = QtGui.QGridLayout()
        self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
        self.label_6 = QtGui.QLabel(self.tab)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.gridLayout_4.addWidget(self.label_6, 0, 0, 1, 1)
        self.txtLambda0 = QtGui.QLineEdit(self.tab)
        self.txtLambda0.setAlignment(QtCore.Qt.AlignRight
                                     | QtCore.Qt.AlignTrailing
                                     | QtCore.Qt.AlignVCenter)
        self.txtLambda0.setObjectName(_fromUtf8("txtLambda0"))
        self.gridLayout_4.addWidget(self.txtLambda0, 0, 1, 1, 1)
        self.label = QtGui.QLabel(self.tab)
        self.label.setObjectName(_fromUtf8("label"))
        self.gridLayout_4.addWidget(self.label, 1, 0, 1, 1)
        self.cbSuperstrate = QtGui.QComboBox(self.tab)
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.cbSuperstrate.setFont(font)
        self.cbSuperstrate.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.cbSuperstrate.setStyleSheet(_fromUtf8("text-align: right;"))
        self.cbSuperstrate.setEditable(True)
        self.cbSuperstrate.setObjectName(_fromUtf8("cbSuperstrate"))
        self.gridLayout_4.addWidget(self.cbSuperstrate, 1, 1, 1, 1)
        self.verticalLayout_3.addLayout(self.gridLayout_4)
        self.tblStack = QtGui.QTableWidget(self.tab)
        self.tblStack.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.tblStack.setAlternatingRowColors(True)
        self.tblStack.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.tblStack.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.tblStack.setObjectName(_fromUtf8("tblStack"))
        self.tblStack.setColumnCount(2)
        self.tblStack.setRowCount(1)
        item = QtGui.QTableWidgetItem()
        self.tblStack.setVerticalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.tblStack.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.tblStack.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.tblStack.setItem(0, 0, item)
        item = QtGui.QTableWidgetItem()
        self.tblStack.setItem(0, 1, item)
        self.tblStack.horizontalHeader().setSortIndicatorShown(False)
        self.tblStack.horizontalHeader().setStretchLastSection(True)
        self.tblStack.verticalHeader().setVisible(False)
        self.verticalLayout_3.addWidget(self.tblStack)
        self.horizontalLayout_7 = QtGui.QHBoxLayout()
        self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7"))
        self.btnAddLayer = QtGui.QPushButton(self.tab)
        self.btnAddLayer.setText(_fromUtf8(""))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("gui/icons/list-add.svg")),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btnAddLayer.setIcon(icon)
        self.btnAddLayer.setObjectName(_fromUtf8("btnAddLayer"))
        self.horizontalLayout_7.addWidget(self.btnAddLayer)
        self.btnRemoveLayer = QtGui.QPushButton(self.tab)
        self.btnRemoveLayer.setText(_fromUtf8(""))
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(_fromUtf8("gui/icons/list-remove.svg")),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btnRemoveLayer.setIcon(icon1)
        self.btnRemoveLayer.setObjectName(_fromUtf8("btnRemoveLayer"))
        self.horizontalLayout_7.addWidget(self.btnRemoveLayer)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_7.addItem(spacerItem)
        self.verticalLayout_3.addLayout(self.horizontalLayout_7)
        self.horizontalLayout_4 = QtGui.QHBoxLayout()
        self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
        self.label_2 = QtGui.QLabel(self.tab)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.horizontalLayout_4.addWidget(self.label_2)
        self.cbSubstrate = QtGui.QComboBox(self.tab)
        self.cbSubstrate.setEditable(True)
        self.cbSubstrate.setObjectName(_fromUtf8("cbSubstrate"))
        self.horizontalLayout_4.addWidget(self.cbSubstrate)
        self.verticalLayout_3.addLayout(self.horizontalLayout_4)
        self.tabMain.addTab(self.tab, _fromUtf8(""))
        self.tab_3 = QtGui.QWidget()
        self.tab_3.setObjectName(_fromUtf8("tab_3"))
        self.tabMain.addTab(self.tab_3, _fromUtf8(""))
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName(_fromUtf8("tab_2"))
        self.verticalLayout_4 = QtGui.QVBoxLayout(self.tab_2)
        self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
        self.horizontalLayout_11 = QtGui.QHBoxLayout()
        self.horizontalLayout_11.setObjectName(
            _fromUtf8("horizontalLayout_11"))
        self.label_5 = QtGui.QLabel(self.tab_2)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.horizontalLayout_11.addWidget(self.label_5)
        self.cbPlotType = QtGui.QComboBox(self.tab_2)
        self.cbPlotType.setObjectName(_fromUtf8("cbPlotType"))
        self.horizontalLayout_11.addWidget(self.cbPlotType)
        self.horizontalLayout_11.setStretch(1, 1)
        self.verticalLayout_4.addLayout(self.horizontalLayout_11)
        self.groupBox = QtGui.QGroupBox(self.tab_2)
        self.groupBox.setMinimumSize(QtCore.QSize(0, 0))
        self.groupBox.setMaximumSize(QtCore.QSize(16777215, 220))
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.horizontalLayout_8 = QtGui.QHBoxLayout(self.groupBox)
        self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8"))
        self.horizontalLayout_9 = QtGui.QHBoxLayout()
        self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9"))
        self.groupBox_2 = QtGui.QGroupBox(self.groupBox)
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.gridLayout = QtGui.QGridLayout(self.groupBox_2)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.lineEdit_2 = QtGui.QLineEdit(self.groupBox_2)
        self.lineEdit_2.setEnabled(False)
        self.lineEdit_2.setMaximumSize(QtCore.QSize(50, 16777215))
        self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
        self.gridLayout.addWidget(self.lineEdit_2, 2, 2, 1, 1)
        self.radioButton = QtGui.QRadioButton(self.groupBox_2)
        self.radioButton.setChecked(True)
        self.radioButton.setObjectName(_fromUtf8("radioButton"))
        self.gridLayout.addWidget(self.radioButton, 0, 0, 1, 3)
        self.lineEdit = QtGui.QLineEdit(self.groupBox_2)
        self.lineEdit.setEnabled(False)
        self.lineEdit.setMaximumSize(QtCore.QSize(50, 16777215))
        self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
        self.gridLayout.addWidget(self.lineEdit, 2, 0, 1, 1)
        self.label_3 = QtGui.QLabel(self.groupBox_2)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.gridLayout.addWidget(self.label_3, 2, 1, 1, 1)
        self.radioButton_2 = QtGui.QRadioButton(self.groupBox_2)
        self.radioButton_2.setObjectName(_fromUtf8("radioButton_2"))
        self.gridLayout.addWidget(self.radioButton_2, 1, 0, 1, 3)
        self.horizontalLayout_9.addWidget(self.groupBox_2)
        self.groupBox_3 = QtGui.QGroupBox(self.groupBox)
        self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_3)
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
        self.radioButton_3 = QtGui.QRadioButton(self.groupBox_3)
        self.radioButton_3.setChecked(True)
        self.radioButton_3.setObjectName(_fromUtf8("radioButton_3"))
        self.verticalLayout_2.addWidget(self.radioButton_3)
        self.radioButton_4 = QtGui.QRadioButton(self.groupBox_3)
        self.radioButton_4.setObjectName(_fromUtf8("radioButton_4"))
        self.verticalLayout_2.addWidget(self.radioButton_4)
        self.horizontalLayout_9.addWidget(self.groupBox_3)
        self.horizontalLayout_8.addLayout(self.horizontalLayout_9)
        self.verticalLayout_4.addWidget(self.groupBox)
        self.groupBox_4 = QtGui.QGroupBox(self.tab_2)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.groupBox_4.sizePolicy().hasHeightForWidth())
        self.groupBox_4.setSizePolicy(sizePolicy)
        self.groupBox_4.setMinimumSize(QtCore.QSize(0, 0))
        self.groupBox_4.setMaximumSize(QtCore.QSize(16777215, 220))
        self.groupBox_4.setObjectName(_fromUtf8("groupBox_4"))
        self.horizontalLayout_6 = QtGui.QHBoxLayout(self.groupBox_4)
        self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6"))
        self.horizontalLayout_10 = QtGui.QHBoxLayout()
        self.horizontalLayout_10.setObjectName(
            _fromUtf8("horizontalLayout_10"))
        self.groupBox_5 = QtGui.QGroupBox(self.groupBox_4)
        self.groupBox_5.setObjectName(_fromUtf8("groupBox_5"))
        self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_5)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.radioButton_7 = QtGui.QRadioButton(self.groupBox_5)
        self.radioButton_7.setChecked(True)
        self.radioButton_7.setObjectName(_fromUtf8("radioButton_7"))
        self.gridLayout_2.addWidget(self.radioButton_7, 0, 0, 1, 3)
        self.radioButton_8 = QtGui.QRadioButton(self.groupBox_5)
        self.radioButton_8.setObjectName(_fromUtf8("radioButton_8"))
        self.gridLayout_2.addWidget(self.radioButton_8, 1, 0, 1, 3)
        self.lineEdit_3 = QtGui.QLineEdit(self.groupBox_5)
        self.lineEdit_3.setEnabled(False)
        self.lineEdit_3.setMaximumSize(QtCore.QSize(50, 16777215))
        self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))
        self.gridLayout_2.addWidget(self.lineEdit_3, 2, 0, 1, 1)
        self.label_4 = QtGui.QLabel(self.groupBox_5)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.gridLayout_2.addWidget(self.label_4, 2, 1, 1, 1)
        self.lineEdit_4 = QtGui.QLineEdit(self.groupBox_5)
        self.lineEdit_4.setEnabled(False)
        self.lineEdit_4.setMaximumSize(QtCore.QSize(50, 16777215))
        self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4"))
        self.gridLayout_2.addWidget(self.lineEdit_4, 2, 2, 1, 1)
        self.horizontalLayout_10.addWidget(self.groupBox_5)
        self.groupBox_6 = QtGui.QGroupBox(self.groupBox_4)
        self.groupBox_6.setObjectName(_fromUtf8("groupBox_6"))
        self.verticalLayout_5 = QtGui.QVBoxLayout(self.groupBox_6)
        self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5"))
        self.radioButton_5 = QtGui.QRadioButton(self.groupBox_6)
        self.radioButton_5.setChecked(True)
        self.radioButton_5.setObjectName(_fromUtf8("radioButton_5"))
        self.verticalLayout_5.addWidget(self.radioButton_5)
        self.radioButton_6 = QtGui.QRadioButton(self.groupBox_6)
        self.radioButton_6.setObjectName(_fromUtf8("radioButton_6"))
        self.verticalLayout_5.addWidget(self.radioButton_6)
        self.horizontalLayout_10.addWidget(self.groupBox_6)
        self.horizontalLayout_6.addLayout(self.horizontalLayout_10)
        self.verticalLayout_4.addWidget(self.groupBox_4)
        self.groupBox_7 = QtGui.QGroupBox(self.tab_2)
        self.groupBox_7.setObjectName(_fromUtf8("groupBox_7"))
        self.gridLayout_3 = QtGui.QGridLayout(self.groupBox_7)
        self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
        self.listWidget = QtGui.QListWidget(self.groupBox_7)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.listWidget.sizePolicy().hasHeightForWidth())
        self.listWidget.setSizePolicy(sizePolicy)
        self.listWidget.setMaximumSize(QtCore.QSize(130, 16777215))
        self.listWidget.setObjectName(_fromUtf8("listWidget"))
        self.gridLayout_3.addWidget(self.listWidget, 0, 0, 5, 1)
        self.pushButton = QtGui.QPushButton(self.groupBox_7)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setObjectName(_fromUtf8("pushButton"))
        self.gridLayout_3.addWidget(self.pushButton, 0, 1, 1, 1)
        self.pushButton_5 = QtGui.QPushButton(self.groupBox_7)
        self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
        self.gridLayout_3.addWidget(self.pushButton_5, 1, 1, 1, 1)
        self.pushButton_4 = QtGui.QPushButton(self.groupBox_7)
        self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
        self.gridLayout_3.addWidget(self.pushButton_4, 2, 1, 1, 1)
        self.pushButton_2 = QtGui.QPushButton(self.groupBox_7)
        self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
        self.gridLayout_3.addWidget(self.pushButton_2, 3, 1, 1, 1)
        self.pushButton_3 = QtGui.QPushButton(self.groupBox_7)
        self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
        self.gridLayout_3.addWidget(self.pushButton_3, 4, 1, 1, 1)
        self.gridLayout_3.setColumnMinimumWidth(0, 1)
        self.verticalLayout_4.addWidget(self.groupBox_7)
        spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                        QtGui.QSizePolicy.Expanding)
        self.verticalLayout_4.addItem(spacerItem1)
        self.tabMain.addTab(self.tab_2, _fromUtf8(""))
        self.horizontalLayout_2.addWidget(self.tabMain)
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.pltMain = MatplotlibWidget(self.centralwidget)
        self.pltMain.setObjectName(_fromUtf8("pltMain"))
        self.verticalLayout.addWidget(self.pltMain)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem2)
        self.btnUpdate = QtGui.QPushButton(self.centralwidget)
        self.btnUpdate.setObjectName(_fromUtf8("btnUpdate"))
        self.horizontalLayout.addWidget(self.btnUpdate)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2.addLayout(self.verticalLayout)
        self.horizontalLayout_2.setStretch(1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1115, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFile = QtGui.QMenu(self.menubar)
        self.menuFile.setObjectName(_fromUtf8("menuFile"))
        self.menuPlot = QtGui.QMenu(self.menubar)
        self.menuPlot.setObjectName(_fromUtf8("menuPlot"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.actionQuit = QtGui.QAction(MainWindow)
        self.actionQuit.setObjectName(_fromUtf8("actionQuit"))
        self.actionNew = QtGui.QAction(MainWindow)
        self.actionNew.setObjectName(_fromUtf8("actionNew"))
        self.actionSave = QtGui.QAction(MainWindow)
        self.actionSave.setObjectName(_fromUtf8("actionSave"))
        self.actionOpen = QtGui.QAction(MainWindow)
        self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
        self.actionExport = QtGui.QAction(MainWindow)
        self.actionExport.setObjectName(_fromUtf8("actionExport"))
        self.menuFile.addAction(self.actionNew)
        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSave)
        self.menuFile.addSeparator()
        self.menuFile.addAction(self.actionQuit)
        self.menuPlot.addAction(self.actionExport)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuPlot.menuAction())

        self.retranslateUi(MainWindow)
        self.tabMain.setCurrentIndex(0)
        QtCore.QObject.connect(self.actionQuit,
                               QtCore.SIGNAL(_fromUtf8("triggered()")),
                               MainWindow.close)
        QtCore.QObject.connect(self.radioButton_2,
                               QtCore.SIGNAL(_fromUtf8("toggled(bool)")),
                               self.lineEdit.setEnabled)
        QtCore.QObject.connect(self.radioButton_2,
                               QtCore.SIGNAL(_fromUtf8("toggled(bool)")),
                               self.lineEdit_2.setEnabled)
        QtCore.QObject.connect(self.radioButton_8,
                               QtCore.SIGNAL(_fromUtf8("toggled(bool)")),
                               self.lineEdit_3.setEnabled)
        QtCore.QObject.connect(self.radioButton_8,
                               QtCore.SIGNAL(_fromUtf8("toggled(bool)")),
                               self.lineEdit_4.setEnabled)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Esempio n. 5
0
    def __init__(self,
                 topics=None,
                 terms=None,
                 addr=None,
                 uiTemplate=None,
                 parent=None,
                 **kwargs):
        super().__init__(parent)
        self.node = kwargs.get('node', None)
        self.units = kwargs.get('units', {})

        self.fetcher = None
        if addr:
            self.fetcher = AsyncFetcher(topics, terms, addr, parent=self)
            self.fetcher.start()

        self.plot_view = self.addPlot()
        if self.node:
            # node is passed in on subprocess
            self.viewbox_proxy = pg.SignalProxy(
                self.plot_view.vb.sigRangeChangedManually,
                delay=0.5,
                slot=lambda args: self.node.sigStateChanged.emit(self.node))
            self.plot_view.autoBtn.clicked.connect(
                lambda args: self.node.sigStateChanged.emit(self.node))

        self.plot_view.showGrid(True, True)

        ax = self.plot_view.getAxis('bottom')
        ax.enableAutoSIPrefix(enable=bool(self.units))
        ax.setZValue(100)

        ay = self.plot_view.getAxis('left')
        ay.enableAutoSIPrefix(enable=bool(self.units))
        ay.setZValue(100)

        self.plot_view.setMenuEnabled(False)

        self.configure_btn = pg.ButtonItem(pg.pixmaps.getPixmap('ctrl'),
                                           14,
                                           parentItem=self.plot_view)
        self.configure_btn.clicked.connect(self.configure_plot)
        self.configure_btn.show()

        self.plot = {}  # { name : PlotDataItem }
        self.trace_ids = {}  # { trace_idx : name }
        self.trace_attrs = {}
        self.legend_editors = {}
        self.annotation_editors = {}
        self.annotation_traces = {}

        self.terms = terms

        self.last_updated = pg.LabelItem(parent=self.plot_view)
        self.pixel_value = pg.LabelItem(parent=self.plot_view)
        self.hover_proxy = pg.SignalProxy(self.sceneObj.sigMouseMoved,
                                          rateLimit=30,
                                          slot=self.cursor_hover_evt)

        if uiTemplate is None:
            uiTemplate = [
                ('Title', 'text'),
                ('Show Grid', 'check', {
                    'checked': True
                }),
                # ('Auto Range', 'check', {'checked': True}),
                # x axis
                ('Label', 'text', {
                    'group': 'X Axis'
                }),
                ('Log Scale', 'check', {
                    'group': 'X Axis',
                    'checked': False
                }),
                # y axis
                ('Label', 'text', {
                    'group': 'Y Axis'
                }),
                ('Log Scale', 'check', {
                    'group': 'Y Axis',
                    'checked': False
                })
            ]

        self.uiTemplate = uiTemplate
        self.ui, self.stateGroup, self.ctrls, self.plot_attrs = generateUi(
            self.uiTemplate)

        if self.stateGroup:
            self.stateGroup.sigChanged.connect(self.state_changed)

        ctrl_layout = self.ui.layout()

        self.legend = None
        if kwargs.get('legend', True):
            self.legend = self.plot_view.addLegend()
            self.legend_layout = QtGui.QFormLayout()

            self.legend_groupbox = QtWidgets.QGroupBox()
            self.legend_groupbox.setTitle("Legend")
            self.legend_groupbox.setLayout(self.legend_layout)
            ctrl_layout.addWidget(self.legend_groupbox)
            self.ctrls["Legend"] = self.legend_groupbox

        self.annotation_layout = QtGui.QFormLayout()
        self.annotation_groupbox = QtWidgets.QGroupBox()
        self.annotation_groupbox.setTitle("Annotations")
        self.annotation_groupbox.setLayout(self.annotation_layout)
        ctrl_layout.addWidget(self.annotation_groupbox)
        self.ctrls["Annotations"] = self.annotation_groupbox

        self.annotation_type = QtGui.QComboBox(parent=self.annotation_groupbox)
        self.annotation_type.addItem("Line", LineEditor)
        self.annotation_type.addItem("Circle", CircleEditor)
        self.annotation_type.addItem("Rect", RectEditor)
        self.annotation_layout.addWidget(self.annotation_type)

        self.add_annotation_btn = QtWidgets.QPushButton(
            "Add", self.annotation_groupbox)
        self.add_annotation_btn.clicked.connect(self.add_annotation)
        self.annotation_layout.addWidget(self.add_annotation_btn)

        self.apply_btn = QtWidgets.QPushButton("Apply", self.ui)
        self.apply_btn.clicked.connect(self.apply_clicked)
        ctrl_layout.addWidget(self.apply_btn)

        self.win = QtGui.QMainWindow()
        scrollArea = QtWidgets.QScrollArea(parent=self.win)
        scrollArea.setWidgetResizable(True)
        scrollArea.setWidget(self.ui)
        self.win.setCentralWidget(scrollArea)
        if self.node:
            self.win.setWindowTitle(self.node.name() + ' configuration')
Esempio n. 6
0
    def __init__(self, parent=None, parameters_dict=None):
        super().__init__(parent)
        if parameters_dict is None:
            self._parameters = OrderedDict()
        else:
            self._parameters = parameters_dict

        self._width_hint = 90 * len(self._parameters)
        self._ach_widgets = OrderedDict()

        main_layout = QtGui.QHBoxLayout()
        for param in self._parameters:
            label = QtGui.QLabel(param)
            label.setAlignment(QtCore.Qt.AlignCenter)
            if self._parameters[param]['type'] == float:
                widget = ScienDSpinBox()
                widget.setMinimum(self._parameters[param]['min'])
                widget.setMaximum(self._parameters[param]['max'])
                widget.setDecimals(6, False)
                widget.setValue(self._parameters[param]['init'])
                widget.setSuffix(self._parameters[param]['unit'])
                # Set size constraints
                widget.setFixedWidth(90)
                # Forward editingFinished signal of child widget
                widget.editingFinished.connect(self.editingFinished)
            elif self._parameters[param]['type'] == int:
                widget = ScienSpinBox()
                widget.setValue(self._parameters[param]['init'])
                widget.setMinimum(self._parameters[param]['min'])
                widget.setMaximum(self._parameters[param]['max'])
                widget.setSuffix(self._parameters[param]['unit'])
                # Set size constraints
                widget.setFixedWidth(90)
                # Forward editingFinished signal of child widget
                widget.editingFinished.connect(self.editingFinished)
            elif self._parameters[param]['type'] == str:
                widget = QtGui.QLineEdit()
                widget.setText(self._parameters[param]['init'])
                # Set size constraints
                widget.setFixedWidth(90)
                # Forward editingFinished signal of child widget
                widget.editingFinished.connect(self.editingFinished)
            elif self._parameters[param]['type'] == bool:
                widget = QtGui.QCheckBox()
                widget.setChecked(self._parameters[param]['init'])
                # Set size constraints
                widget.setFixedWidth(90)
                # Forward editingFinished signal of child widget
                widget.stateChanged.connect(self.editingFinished)
            elif issubclass(self._parameters[param]['type'], Enum):
                widget = QtGui.QComboBox()
                for option in self._parameters[param]['type']:
                    widget.addItem(option.name, option)
                widget.setCurrentText(self._parameters[param]['init'].name)
                # Set size constraints
                widget.setFixedWidth(90)
                # Forward editingFinished signal of child widget
                widget.currentIndexChanged.connect(self.editingFinished)

            self._ach_widgets[param] = {'label': label, 'widget': widget}

            v_layout = QtGui.QVBoxLayout()
            v_layout.addWidget(label)
            v_layout.addWidget(widget)
            v_layout.setAlignment(label, QtCore.Qt.AlignHCenter)
            v_layout.setAlignment(widget, QtCore.Qt.AlignHCenter)
            main_layout.addLayout(v_layout)

        main_layout.addStretch(1)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)
Esempio n. 7
0
    def populate_gui(self):
        _contain_parsed = self.contain_parsed
        for _row, _entry in enumerate(_contain_parsed):

            if _entry == ['']:
                continue

            self.parent.ui.table.insertRow(_row)

            #select
            _layout = QtGui.QHBoxLayout()
            _widget = QtGui.QCheckBox()
            _widget.setEnabled(True)
            _layout.addWidget(_widget)
            _layout.addStretch()
            _new_widget = QtGui.QWidget()
            _new_widget.setLayout(_layout)

            #if _entry[0] == "True":
            #   _widget.setChecked(True)
            _widget.stateChanged.connect(
                lambda state=0, row=_row: self.parent.
                table_select_state_changed(state, row))
            self.parent.ui.table.setCellWidget(_row, 0, _new_widget)

            #name
            _item = QtGui.QTableWidgetItem(_entry[1])
            self.parent.ui.table.setItem(_row, 1, _item)

            #runs
            _item = QtGui.QTableWidgetItem(_entry[2])
            self.parent.ui.table.setItem(_row, 2, _item)

            #Sample formula
            if _entry[3]:
                _item = QtGui.QTableWidgetItem(_entry[3])
            else:
                _item = QtGui.QTableWidgetItem("")
            self.parent.ui.table.setItem(_row, 3, _item)

            #mass density
            if _entry[4]:
                _item = QtGui.QTableWidgetItem(_entry[4])
            else:
                _item = QtGui.QTableWidgetItem("")
            self.parent.ui.table.setItem(_row, 4, _item)

            #radius
            if _entry[5]:
                _item = QtGui.QTableWidgetItem(_entry[5])
            else:
                _item = QtGui.QTableWidgetItem("")
            self.parent.ui.table.setItem(_row, 5, _item)

            #packing fraction
            if _entry[6]:
                _item = QtGui.QTableWidgetItem(_entry[6])
            else:
                _item = QtGui.QTableWidgetItem("")
            self.parent.ui.table.setItem(_row, 6, _item)

            #sample shape
            _widget = QtGui.QComboBox()
            _widget.addItem("Cylinder")
            _widget.addItem("Sphere")
            if _entry[7] == "Sphere":
                _widget.setCurrentIndex(1)
            self.parent.ui.table.setCellWidget(_row, 7, _widget)

            #do abs corr
            _layout = QtGui.QHBoxLayout()
            _widget = QtGui.QCheckBox()
            if _entry[8] == "True":
                _widget.setCheckState(QtCore.Qt.Checked)
            _widget.setStyleSheet("border:  2px; solid-black")
            _widget.setEnabled(True)
            _layout.addStretch()
            _layout.addWidget(_widget)
            _layout.addStretch()
            _new_widget = QtGui.QWidget()
            _new_widget.setLayout(_layout)
            self.parent.ui.table.setCellWidget(_row, 8, _new_widget)

        for _row, _entry in enumerate(_contain_parsed):

            if _entry == ['']:
                continue

            #select
            _widget = self.parent.ui.table.cellWidget(_row, 0).children()[1]
            if _entry[0] == "True":
                _widget.setChecked(True)