def _set_up_tools(self):
        if self._tools_set_up:
            return
        for a, b in self._order_bundles.tools():
            # Strip ' Scene' to reduce horizontal width of 2-column layout
            cb = QCheckBox(b, parent=self.grpBoxTools)
            cb.setChecked(False)
            cb.setProperty('tool', a)
            cb.setToolTip(b)
            self.grpBoxTools.layout().addWidget(cb)

        self._tools_set_up = True
    def get_missing_layers(self, dialog, m_layers, critical_level):

        grl_critical = dialog.findChild(QGridLayout, "grl_critical")
        grl_others = dialog.findChild(QGridLayout, "grl_others")
        for pos, item in enumerate(m_layers):
            try:
                if not item:
                    continue
                widget = dialog.findChild(QCheckBox, f"{item['layer']}")
                # If it is the case that a layer is necessary for two functions,
                # and the widget has already been put in another iteration
                if widget:
                    continue
                label = QLabel()
                label.setObjectName(f"lbl_{item['layer']}")
                label.setText(f'<b>{item["layer"]}</b><font size="2";> {item["qgis_message"]}</font>')

                critical_level = int(item['criticity']) if int(
                    item['criticity']) > critical_level else critical_level
                widget = QCheckBox()
                widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
                widget.setObjectName(f"{item['layer']}")
                widget.setProperty('field_id', item['id'])
                widget.setProperty('field_the_geom', item['field_the_geom'])

                if int(item['criticity']) == 3:
                    grl_critical.addWidget(label, pos, 0)
                    grl_critical.addWidget(widget, pos, 1)
                else:
                    grl_others.addWidget(label, pos, 0)
                    grl_others.addWidget(widget, pos, 1)
            except KeyError:
                description = "Key on returned json from ddbb is missed"
                self.controller.manage_exception(None, description)

        return critical_level
Пример #3
0
    def __init__(self, parent=None, plugin=None):
        super().__init__(parent=parent)
        self.setupUi(self)
        self._plugin = plugin

        # Set up sources (in 2 columns; layout is grid)
        checked = ['PSScene4Band']
        row_total = floor(len(DAILY_ITEM_TYPES) / 2)
        row = col = 0
        gl = QGridLayout(self.frameSources)
        gl.setContentsMargins(0, 0, 0, 0)
        for a, b in DAILY_ITEM_TYPES:
            # Strip ' Scene' to reduce horizontal width of 2-column layout
            cb = QCheckBox(b.replace(' Scene', ''), parent=self.frameSources)
            cb.setChecked(a in checked)
            cb.setProperty('api-name', a)
            cb.setToolTip(b)
            # noinspection PyUnresolvedReferences
            cb.stateChanged[int].connect(self.filtersChanged)
            gl.addWidget(cb, row, col)
            row += 1
            if row > row_total:
                row = 0
                col += 1

        self.frameSources.setLayout(gl)

        # TODO: (Eventually) Add multi-date range widget with and/or selector

        # noinspection PyUnresolvedReferences
        self.startDateEdit.valueChanged['QDateTime'].connect(
            self.filtersChanged)
        # noinspection PyUnresolvedReferences
        self.startDateEdit.valueChanged['QDateTime'].connect(
            self.set_min_enddate)
        # noinspection PyUnresolvedReferences
        self.startDateEdit.valueChanged['QDateTime'].connect(
            self.change_date_vis)
        # noinspection PyUnresolvedReferences
        self.endDateEdit.valueChanged['QDateTime'].connect(self.filtersChanged)
        # noinspection PyUnresolvedReferences
        self.endDateEdit.valueChanged['QDateTime'].connect(
            self.set_max_startdate)
        # noinspection PyUnresolvedReferences
        self.endDateEdit.valueChanged['QDateTime'].connect(
            self.change_date_vis)

        # Setup datetime boxes
        current_day = QDateTime().currentDateTimeUtc()
        self.startDateEdit.setDateTime(current_day.addMonths(-3))
        self.endDateEdit.setDateTime(current_day)

        self.cmbBoxDateType.clear()
        for i, (a, b) in enumerate(self.SORT_ORDER_DATE_TYPES):
            self.cmbBoxDateType.insertItem(i, b, userData=a)
        # Set a default (acquired)
        self.cmbBoxDateType.setCurrentIndex(0)
        # noinspection PyUnresolvedReferences
        self.cmbBoxDateType.currentIndexChanged[int].connect(
            self.filters_changed)

        self.cmbBoxDateSort.clear()
        for i, (a, b) in enumerate(self.SORT_ORDER_TYPES):
            self.cmbBoxDateSort.insertItem(i, b, userData=a)
        # Set a default
        self.cmbBoxDateSort.setCurrentIndex(0)
        # noinspection PyUnresolvedReferences
        self.cmbBoxDateSort.currentIndexChanged[int].connect(
            self.filters_changed)

        # TODO: (Eventually) Add multi-field searching, with +/- operation
        #       of adding new field/QLineEdit, without duplicates
        # noinspection PyUnresolvedReferences
        self.leStringIDs.textChanged['QString'].connect(self.filters_changed)

        # TODO: Figure out how area coverage filter works in Explorer

        # TODO: Consolidate range filters for basemap/mosaic reusability
        self.rangeCloudCover = PlanetExplorerRangeSlider(
            title='Cloud cover',
            filter_key='cloud_cover',
            prefix='',
            suffix='%',
            minimum=0,
            maximum=100,
            low=0,
            high=100,
            step=1,
            precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeCloudCover)
        self.rangeCloudCover.rangeChanged[float,
                                          float].connect(self.filters_changed)

        self.rangeAzimuth = PlanetExplorerRangeSlider(title='Sun Azimuth',
                                                      filter_key='sun_azimuth',
                                                      prefix='',
                                                      suffix='°',
                                                      minimum=0,
                                                      maximum=360,
                                                      low=0,
                                                      high=360,
                                                      step=1,
                                                      precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeAzimuth)
        self.rangeAzimuth.rangeChanged[float,
                                       float].connect(self.filters_changed)

        self.rangeElevation = PlanetExplorerRangeSlider(
            title='Sun Elevation',
            filter_key='sun_elevation',
            prefix='',
            suffix='°',
            minimum=0,
            maximum=90,
            low=0,
            high=90,
            step=1,
            precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeElevation)
        self.rangeElevation.rangeChanged[float,
                                         float].connect(self.filters_changed)

        self.rangeViewAngle = PlanetExplorerRangeSlider(
            title='View Angle',
            filter_key='view_angle',
            prefix='',
            suffix='°',
            minimum=-25,
            maximum=25,
            low=0,
            high=25,
            step=1,
            precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeViewAngle)
        self.rangeViewAngle.rangeChanged[float,
                                         float].connect(self.filters_changed)

        self.rangeGsd = PlanetExplorerRangeSlider(
            title='Ground Sample Distance',
            filter_key='gsd',
            prefix='',
            suffix='m',
            minimum=0,
            maximum=50,
            low=0,
            high=50,
            step=1,
            precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeGsd)
        self.rangeGsd.rangeChanged[float, float].connect(self.filters_changed)

        self.rangeAnomalousPx = PlanetExplorerRangeSlider(
            title='Anomalous Pixels',
            filter_key='anomalous_pixels',
            prefix='',
            suffix='%',
            minimum=0,
            maximum=100,
            low=0,
            high=100,
            step=1,
            precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeAnomalousPx)
        self.rangeAnomalousPx.rangeChanged[float,
                                           float].connect(self.filters_changed)

        self.rangeUsable = PlanetExplorerRangeSlider(title='Usable Pixels',
                                                     filter_key='usable_data',
                                                     prefix='',
                                                     suffix='%',
                                                     minimum=0,
                                                     maximum=100,
                                                     low=0,
                                                     high=100,
                                                     step=1,
                                                     precision=1)
        # Layout's parent widget takes ownership
        self.frameRangeSliders.layout().addWidget(self.rangeUsable)
        self.rangeUsable.rangeChanged[float,
                                      float].connect(self.filters_changed)

        # TODO: Add rest of range sliders

        # Ground control filter checkbox
        # noinspection PyUnresolvedReferences
        self.chkBxGroundControl.stateChanged[int].connect(self.filters_changed)

        # Access Filter checkbox
        # noinspection PyUnresolvedReferences
        self.chkBxCanDownload.stateChanged[int].connect(self.filters_changed)
Пример #4
0
    def __init__(self, parent=None, plugin=None):
        super().__init__(parent=parent)
        self.setupUi(self)
        self._plugin = plugin

        self.emitFiltersChanged = True

        # Set up checkboxes for old sources (for legacy saved searches)
        item_types = {
            k: v
            for k, v in PlanetClient.getInstance().item_types_names().items()
            if k != "PSScene"
        }
        row_total = floor(len(item_types) / 2)
        row = col = 0
        gl = QGridLayout(self.oldSourcesWidget)
        gl.setContentsMargins(0, 0, 0, 0)
        for a, b in item_types.items():
            # Strip ' Scene' to reduce horizontal width of 2-column layout, except for SkySat
            name = b.replace(" Scene", "") if b != "SkySat Scene" else b
            cb = QCheckBox(name, parent=self.oldSourcesWidget)
            cb.setProperty("api-name", a)
            gl.addWidget(cb, row, col)
            row += 1
            if row > row_total:
                row = 0
                col += 1
        self.oldSourcesWidget.setLayout(gl)

        sources = self.newSourcesWidget.findChildren(QCheckBox)
        for source in sources:
            apiname = source.property("api-name")
            if apiname is not None:
                source.stateChanged.connect(self.filtersChanged)

        self.chkPlanetScope.stateChanged.connect(self._pssceneToggled)

        layout = QVBoxLayout()
        layout.setMargin(0)
        self.legacyWarningWidget = LegacyWarningWidget()
        self.legacyWarningWidget.updateLegacySearch.connect(
            self.updateLegacySearch.emit)
        layout.addWidget(self.legacyWarningWidget)
        self.frameWarningLegacySearch.setLayout(layout)
        self.frameWarningLegacySearch.setVisible(False)

        self.startDateEdit.valueChanged["QDateTime"].connect(
            self.filtersChanged)
        self.startDateEdit.valueChanged["QDateTime"].connect(
            self.set_min_enddate)
        self.startDateEdit.valueChanged["QDateTime"].connect(
            self.change_date_vis)
        self.endDateEdit.valueChanged["QDateTime"].connect(self.filtersChanged)
        self.endDateEdit.valueChanged["QDateTime"].connect(
            self.set_max_startdate)
        self.endDateEdit.valueChanged["QDateTime"].connect(
            self.change_date_vis)

        current_day = QDateTime().currentDateTimeUtc()
        self.startDateEdit.setDateTime(current_day.addMonths(-3))
        self.endDateEdit.setDateTime(current_day)

        self.leStringIDs.textChanged.connect(self.filters_changed)

        for slider in slider_filters:
            sliderWidget = PlanetExplorerRangeSlider(**slider)
            self.frameRangeSliders.layout().addWidget(sliderWidget)
            sliderWidget.rangeChanged.connect(self.filters_changed)

        self.chkBxGroundControl.stateChanged[int].connect(self.filters_changed)
        self.chkBxCanDownload.stateChanged[int].connect(self.filters_changed)