Exemple #1
0
 def _setup_table(self, prechecked_elements, state_list, state_list_enables,
                  partly_disabled, disable_fancy, auto_depresso):
     self.signalMapper = QtCore.QSignalMapper(self)
     self.signalMapper.mapped[QWidget].connect(self.previewToggler)
     self.signalMapper2 = QtCore.QSignalMapper(self)
     self.signalMapper2.mapped[QWidget].connect(self.elementToggler)
     self.signalMapper3 = QtCore.QSignalMapper(self)
     self.signalMapper3.mapped[QWidget].connect(self.emit_right_clicked)
     self.signalMapper4 = QtCore.QSignalMapper(self)
     self.signalMapper4.mapped[QWidget].connect(self.focus_on_toggler)
     self.signalMapper5 = QtCore.QSignalMapper(self)
     self.signalMapper5.mapped[QWidget].connect(self.focus_off_toggler)
     self.signalMapper6 = QtCore.QSignalMapper(self)
     self.signalMapper6.mapped[QWidget].connect(self.emit_triggered)
     is_checkable = not auto_depresso
     for i in pt_indexes:
         pt_button = HoverableButton(i,
                                     partly_disabled=partly_disabled,
                                     disable_fancy=disable_fancy,
                                     is_checkable=is_checkable)
         pt_button.setMinimumSize(16, 16)
         pt_button.setMaximumSize(512, 512)
         if i in prechecked_elements:
             pt_button.setChecked(True)
         self.layout().addWidget(pt_button, pt_indexes[i][0],
                                 pt_indexes[i][1])
         # pt_button.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
         pt_button.hoverChanged.connect(self.signalMapper.map)
         pt_button.toggled.connect(self.signalMapper2.map)
         pt_button.rightClicked.connect(self.signalMapper3.map)
         pt_button.gainedFocus.connect(self.signalMapper4.map)
         pt_button.lostFocus.connect(self.signalMapper5.map)
         pt_button.pressed.connect(self.signalMapper6.map)
         self.signalMapper.setMapping(pt_button, pt_button)
         self.signalMapper2.setMapping(pt_button, pt_button)
         self.signalMapper3.setMapping(pt_button, pt_button)
         self.signalMapper4.setMapping(pt_button, pt_button)
         self.signalMapper5.setMapping(pt_button, pt_button)
         self.signalMapper6.setMapping(pt_button, pt_button)
     line = QFrame()
     line.setFrameShape(QFrame.HLine)
     line.setFrameShadow(QFrame.Sunken)
     line.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     self.layout().addWidget(line, 6, 3, 1, 15)
     # dissable elements/buttons for provided list:
     if state_list_enables:
         disabled_elements = set(pt_indexes).difference(state_list)
     else:
         disabled_elements = state_list
     for i in disabled_elements:
         self.getButton(pt_indexes[i]).setEnabled(False)
     lant_text = QLabel('Lan')
     act_text = QLabel('Act')
     lant_text.setAlignment(QtCore.Qt.AlignCenter)
     act_text.setAlignment(QtCore.Qt.AlignCenter)
     self.layout().addWidget(lant_text, 5, 2)
     self.layout().addWidget(act_text, 6, 2)
     lant_text.setEnabled(False)
     act_text.setEnabled(False)
Exemple #2
0
class ImageReviewWidget(QFrame):

    selectedChanged = pyqtSignal()

    def __init__(self, image):
        super().__init__()

        self.image = image
        self.checkBox = QCheckBox()
        self.checkBox.setChecked(True)
        self.checkBox.stateChanged.connect(self.checkStateChanged)
        hlayout = QHBoxLayout()
        hlayout.setMargin(0)
        hlayout.addStretch()
        hlayout.addWidget(self.checkBox)
        vlayout = QVBoxLayout()
        vlayout.setMargin(0)
        vlayout.addLayout(hlayout)
        self.label = QLabel()
        pixmap = QPixmap(PLACEHOLDER_THUMB, "SVG")
        thumb = pixmap.scaled(96, 96, Qt.KeepAspectRatio,
                              Qt.SmoothTransformation)
        self.label.setPixmap(thumb)
        self.label.setFixedSize(96, 96)

        url = f"{image['_links']['thumbnail']}?api_key={PlanetClient.getInstance().api_key()}"
        download_thumbnail(url, self)
        vlayout.addWidget(self.label)
        self.setLayout(vlayout)

        self.setFrameStyle(QFrame.Panel | QFrame.Raised)

    def checkStateChanged(self):
        self.selectedChanged.emit()
        self.label.setEnabled(self.checkBox.isChecked())

    def selected(self):
        return self.checkBox.isChecked()

    def set_thumbnail(self, img):
        self.thumbnail = QPixmap(img)
        thumb = self.thumbnail.scaled(96, 96, Qt.KeepAspectRatio,
                                      Qt.SmoothTransformation)
        self.label.setPixmap(thumb)
Exemple #3
0
class PlanetOrderBundleWidget(QFrame):

    selectionChanged = pyqtSignal()

    def __init__(self, bundleid, name, description, udm, can_harmonize,
                 rectified):
        super().__init__()

        self.bundleid = bundleid
        self.name = name
        self.description = description
        self.udm = udm
        self.can_harmonize = can_harmonize
        self.rectified = rectified

        layout = QVBoxLayout()
        hlayout = QHBoxLayout()
        hlayout.setMargin(0)
        self.labelName = QLabel(f"<b>{name}</b>")
        hlayout.addWidget(self.labelName)
        hlayout.addStretch()
        self.chkSelected = QCheckBox()
        self.chkSelected.stateChanged.connect(self.checkStateChanged)
        hlayout.addWidget(self.chkSelected)
        layout.addLayout(hlayout)
        self.labelDescription = QLabel(description)
        self.labelDescription.setWordWrap(True)
        layout.addWidget(self.labelDescription)
        hlayouttype = QHBoxLayout()
        hlayouttype.setMargin(0)
        self.radioTiff = QRadioButton("GeoTIFF")
        self.radioTiff.setChecked(True)
        self.radioTiff.toggled.connect(self.selectionChanged.emit)
        hlayouttype.addWidget(self.radioTiff)
        self.radioNitf = QRadioButton("NITF")
        self.radioNitf.toggled.connect(self.selectionChanged.emit)
        hlayouttype.addWidget(self.radioNitf)
        hlayouttype.addStretch()
        layout.addLayout(hlayouttype)
        if udm:
            hlayoutudm = QHBoxLayout()
            hlayoutudm.setMargin(0)
            self.labelUdm = IconLabel("UDM2", UDM_ICON)
            hlayoutudm.addWidget(self.labelUdm)
            hlayoutudm.addStretch()
            layout.addLayout(hlayoutudm)

        self.setFrameStyle(QFrame.Panel | QFrame.Raised)
        self.setLayout(layout)
        self.checkStateChanged()

    def checkStateChanged(self):
        self.radioTiff.setEnabled(self.chkSelected.isChecked())
        self.radioNitf.setEnabled(self.chkSelected.isChecked())
        self.labelName.setEnabled(self.chkSelected.isChecked())
        self.labelDescription.setEnabled(self.chkSelected.isChecked())
        if self.udm:
            self.labelUdm.setEnabled(self.chkSelected.isChecked())
        self.selectionChanged.emit()

    def selected(self):
        return self.chkSelected.isChecked()

    def setSelected(self, selected, emit=False):
        if not emit:
            self.blockSignals(True)
        self.chkSelected.setChecked(selected)
        self.blockSignals(False)

    def filetype(self):
        if self.radioTiff.isChecked():
            return "GeoTIFF"
        else:
            return "NITF"
class PlanetOrderBundleWidget(QFrame):

    selectionChanged = pyqtSignal()

    def __init__(self, bundleid, bundle, item_type):
        super().__init__()
        self.bundleid = bundleid
        self.name = bundle["name"]
        self.description = bundle["description"]
        self.udm = bundle.get("auxiliaryFiles", "").lower().startswith("udm2")
        assets = bundle["assets"]
        self.can_harmonize = ("ortho_analytic_4b_sr" in assets
                              or "ortho_analytic_8b_sr" in assets)
        self.can_harmonize = bundle.get("canHarmonize", False)
        self.can_clip = bundle.get("canClip", False)
        self.rectified = bundle["rectification"] == "orthorectified"
        bands = []
        asset_def = PlanetClient.getInstance(
        ).asset_types_for_item_type_as_dict(item_type)
        for asset in assets:
            asset_bands = asset_def[asset].get("bands", [])
            for band in asset_bands:
                bands.append(band["name"])
        bands = set(bands)
        layout = QVBoxLayout()
        hlayout = QHBoxLayout()
        hlayout.setMargin(0)
        self.labelName = QLabel(f"<b>{self.name}</b>")
        hlayout.addWidget(self.labelName)
        hlayout.addStretch()
        self.chkSelected = QCheckBox()
        self.chkSelected.stateChanged.connect(self.checkStateChanged)
        hlayout.addWidget(self.chkSelected)
        layout.addLayout(hlayout)
        self.labelDescription = QLabel(self.description)
        self.labelDescription.setWordWrap(True)
        layout.addWidget(self.labelDescription)
        self.labelBands = QLabel(
            f"Bands: {', '.join([str(b) for b in bands])}")
        layout.addWidget(self.labelBands)
        hlayouttype = QHBoxLayout()
        hlayouttype.setMargin(0)
        self.radioTiff = QRadioButton("GeoTIFF")
        self.radioTiff.setChecked(True)
        self.radioTiff.toggled.connect(self.selectionChanged.emit)
        hlayouttype.addWidget(self.radioTiff)
        self.radioNitf = QRadioButton("NITF")
        self.radioNitf.toggled.connect(self.selectionChanged.emit)
        hlayouttype.addWidget(self.radioNitf)
        hlayouttype.addStretch()
        layout.addLayout(hlayouttype)
        if self.udm:
            hlayoutudm = QHBoxLayout()
            hlayoutudm.setMargin(0)
            self.labelUdm = IconLabel("UDM2", UDM_ICON)
            hlayoutudm.addWidget(self.labelUdm)
            hlayoutudm.addStretch()
            layout.addLayout(hlayoutudm)
        layout.addStretch()
        self.setFrameStyle(QFrame.Panel | QFrame.Raised)
        self.setLayout(layout)
        self.checkStateChanged()

    def checkStateChanged(self):
        self.radioTiff.setEnabled(self.chkSelected.isChecked())
        self.radioNitf.setEnabled(self.chkSelected.isChecked())
        self.labelName.setEnabled(self.chkSelected.isChecked())
        self.labelDescription.setEnabled(self.chkSelected.isChecked())
        self.labelBands.setEnabled(self.chkSelected.isChecked())
        if self.udm:
            self.labelUdm.setEnabled(self.chkSelected.isChecked())
        self.selectionChanged.emit()

    def selected(self):
        return self.chkSelected.isChecked()

    def setSelected(self, selected, emit=False):
        if not emit:
            self.blockSignals(True)
        self.chkSelected.setChecked(selected)
        self.blockSignals(False)

    def filetype(self):
        if self.radioTiff.isChecked():
            return "GeoTIFF"
        else:
            return "NITF"
Exemple #5
0
class EnergyDialog(QDialog):

    def __init__(self, parent, params):

        QDialog.__init__(self, parent)

        self.parent = parent
        self.params = params

        self.setMinimumWidth(min_width)
        # self.setMinimumHeight(min_height)

        # Build dialog
        self.setWindowTitle('Options - Energy')  # TODO: softcode
        self.setWindowModality(QtCore.Qt.ApplicationModal)

        self.fra_form = QFrame(self)
        fra_form_lay = QFormLayout(self.fra_form)
        fra_form_lay.setContentsMargins(10, 10, 10, 10)

        self.lbl_pump_efficiency = QLabel('Pump efficiency [%]:')  # TODO: softocode
        self.txt_pump_efficiency = QLineEdit()
        fra_form_lay.addRow(self.lbl_pump_efficiency, self.txt_pump_efficiency)

        self.lbl_energy_price = QLabel('Energy price/kwh:')  # TODO: softocode
        self.txt_energy_price = QLineEdit()
        fra_form_lay.addRow(self.lbl_energy_price, self.txt_energy_price)

        self.lbl_price_pattern = QLabel('Price pattern:')  # TODO: softocode
        self.txt_price_pattern = QLineEdit() # TODO: replace with dropdown
        fra_form_lay.addRow(self.lbl_price_pattern, self.txt_price_pattern)

        self.lbl_demand_charge = QLabel('Demand charge:')  # TODO: softocode
        self.txt_demand_charge = QLineEdit()
        fra_form_lay.addRow(self.lbl_demand_charge, self.txt_demand_charge)

        # Buttons
        self.fra_buttons = QFrame(self)
        fra_buttons_lay = QHBoxLayout(self.fra_buttons)
        self.btn_Ok = QPushButton('OK')
        self.btn_Cancel = QPushButton('Cancel')
        fra_buttons_lay.addWidget(self.btn_Ok)
        fra_buttons_lay.addWidget(self.btn_Cancel)

        # Add to main
        fra_main_lay = QVBoxLayout(self)
        fra_main_lay.setContentsMargins(0, 0, 0, 0)
        fra_main_lay.addWidget(self.fra_form)
        fra_main_lay.addWidget(self.fra_buttons)

        self.setup()

    def setup(self):

        # Buttons
        self.btn_Cancel.clicked.connect(self.btn_cancel_clicked)
        self.btn_Ok.clicked.connect(self.btn_ok_clicked)

        # Validators
        self.txt_pump_efficiency.setValidator(RegExValidators.get_pos_decimals())
        self.txt_energy_price.setValidator(RegExValidators.get_pos_decimals())
        self.txt_price_pattern.setValidator(RegExValidators.get_pos_int())
        self.txt_demand_charge.setValidator(RegExValidators.get_pos_decimals())

    def show(self):
        super(EnergyDialog, self).show()
        self.txt_pump_efficiency.setText(str(self.params.energy.pump_efficiency))
        self.txt_energy_price.setText(str(self.params.energy.energy_price))
        self.txt_price_pattern.setText(str(self.params.energy.price_pattern) if self.params.energy.price_pattern is not None else '')

        self.lbl_price_pattern.setEnabled(False) # TODO
        self.txt_price_pattern.setEnabled(False) # TODO

        self.txt_demand_charge.setText(str(self.params.energy.demand_charge))

    def btn_cancel_clicked(self):
        self.setVisible(False)

    def btn_ok_clicked(self):

        self.params.energy.pump_efficiency =  float(self.txt_pump_efficiency.text())
        self.params.energy.energy_price = float(self.txt_energy_price.text())
        self.params.energy.price_pattern = self.txt_price_pattern.text()
        self.params.energy.demand_charge = float(self.txt_demand_charge.text())

        self.setVisible(False)