Exemple #1
0
def addSelectedIdentifyDataToTableWidget(IdentifySelectedDialog, setupObject, selectedPUDetailsDict):
    featIDList = list(setupObject.targetDict.keys())
    featIDList.sort()
    for rowNumber in range(0, len(featIDList)):
        featID = featIDList[rowNumber]
        IdentifySelectedDialog.identifySelectedTableWidget.insertRow(rowNumber)
        featIDTableItem = QTableWidgetItem(str(featID))
        featNameTableItem = QTableWidgetItem(str(setupObject.targetDict[featID][0]))
        avaIDTableItem = QTableWidgetItem(str(returnStringAmountPerStatus(setupObject, selectedPUDetailsDict, 'Available', featID)))
        conIDTableItem = QTableWidgetItem(str(returnStringAmountPerStatus(setupObject, selectedPUDetailsDict, 'Conserved', featID)))
        earIDTableItem = QTableWidgetItem(str(returnStringAmountPerStatus(setupObject, selectedPUDetailsDict, 'Earmarked', featID)))
        exlIDTableItem = QTableWidgetItem(str(returnStringAmountPerStatus(setupObject, selectedPUDetailsDict, 'Excluded', featID)))
        featTarget = returnRoundedValue(setupObject, setupObject.targetDict[featID][3])
        featTargetTableItem = QTableWidgetItem(featTarget)
        featShortfallTableItem = QTableWidgetItem(returnStringShortfall(setupObject, featID))

        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 0, featIDTableItem)
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 1, featNameTableItem)
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 2, avaIDTableItem)
        conIDTableItem.setForeground(QColor.fromRgb(0, 153, 51))
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 3, conIDTableItem)
        earIDTableItem.setForeground(QColor.fromRgb(51, 204, 51))
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 4, earIDTableItem)
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 5, exlIDTableItem)
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 6, featTargetTableItem)
        if returnStringShortfall(setupObject, featID) == 'Target met':
            featShortfallTableItem.setForeground(QColor.fromRgb(128, 128, 128))
        IdentifySelectedDialog.identifySelectedTableWidget.setItem(rowNumber, 7, featShortfallTableItem)
def addTargetTableRow(targetTable, setupObject, aRow, targetHeaderList,
                      decPrecHeaderNameList, insertRowNumber):
    targetTable.targetTableWidget.insertRow(insertRowNumber)
    for aColValue in range(len(targetHeaderList)):
        headerName = targetHeaderList[aColValue].lower()
        tableValue = aRow[aColValue]
        if headerName in decPrecHeaderNameList:
            tableValue = round(float(tableValue), setupObject.decimalPlaces)
            tableValue = format(tableValue,
                                '.' + str(setupObject.decimalPlaces) + 'f')
        if headerName in setupObject.numericColsList:
            targTableItem = QCustomTableWidgetItem(tableValue)
        else:
            targTableItem = QTableWidgetItem(str(tableValue))
        if headerName == 'target':
            targetValue = tableValue
        elif headerName == 'conserved':
            conservedValue = tableValue
        if headerName == 'pc_target' and str(tableValue) == '-1':
            targTableItem.setForeground(QColor.fromRgb(128, 128, 128))
        elif headerName == 'pc_target' and float(tableValue) >= 0:
            if float(conservedValue) < float(targetValue):
                targTableItem.setForeground(QColor.fromRgb(255, 0, 0))
            else:
                targTableItem.setForeground(QColor.fromRgb(0, 102, 51))

        targetTable.targetTableWidget.setItem(insertRowNumber, aColValue,
                                              targTableItem)

        targetTable.targetTableWidget.horizontalHeader().setStyleSheet(
            setupObject.TableHeadingStyle)
        targetTable.targetTableWidget.verticalHeader().hide()
Exemple #3
0
    def canvasPressEvent(self, event):
        self.dragging = False
        self.selectrect.setRect(0, 0, 0, 0)

        self.selectband = QgsRubberBand(self.canvas,
                                        QgsWkbTypes.PolygonGeometry)
        self.selectband.setColor(QColor.fromRgb(0, 0, 255, 65))
        self.selectband.setWidth(5)
Exemple #4
0
    def __init__(self, methodName):
        """Run once on class initialization."""
        unittest.TestCase.__init__(self, methodName)

        # create composition
        self.mMapSettings = QgsMapSettings()
        self.mComposition = QgsComposition(self.mMapSettings, QgsProject.instance())
        self.mComposition.setPaperSize(297, 210)

        self.mComposerRect1 = QgsComposerShape(20, 20, 150, 100, self.mComposition)
        self.mComposerRect1.setShapeType(QgsComposerShape.Rectangle)
        self.mComposerRect1.setBackgroundColor(QColor.fromRgb(255, 150, 0))
        self.mComposition.addComposerShape(self.mComposerRect1)

        self.mComposerRect2 = QgsComposerShape(50, 50, 150, 100, self.mComposition)
        self.mComposerRect2.setShapeType(QgsComposerShape.Rectangle)
        self.mComposerRect2.setBackgroundColor(QColor.fromRgb(0, 100, 150))
        self.mComposition.addComposerShape(self.mComposerRect2)
Exemple #5
0
    def __init__(self, methodName):
        """Run once on class initialization."""
        unittest.TestCase.__init__(self, methodName)

        # create composition
        self.mMapSettings = QgsMapSettings()
        self.mComposition = QgsComposition(QgsProject.instance())
        self.mComposition.setPaperSize(297, 210)

        self.mComposerRect1 = QgsComposerShape(20, 20, 150, 100, self.mComposition)
        self.mComposerRect1.setShapeType(QgsComposerShape.Rectangle)
        self.mComposerRect1.setBackgroundColor(QColor.fromRgb(255, 150, 0))
        self.mComposition.addComposerShape(self.mComposerRect1)

        self.mComposerRect2 = QgsComposerShape(50, 50, 150, 100, self.mComposition)
        self.mComposerRect2.setShapeType(QgsComposerShape.Rectangle)
        self.mComposerRect2.setBackgroundColor(QColor.fromRgb(0, 100, 150))
        self.mComposition.addComposerShape(self.mComposerRect2)
Exemple #6
0
    def addLandUsetoLayer(self):
        chsnlanduse = self.dlg.CB_newlanduse.currentText()
        chsnlanduselayer = self.dlg.CB_newlanduselayer.currentText()

        landuserastvalue = {'Trees on grass': 1, 'Trees on avenue': 2, 'Grass field': 3,
                            'Green roofs': 4, 'Cool roofs': 5, 'Facade greening': 6,
                            'Solar Panels': 7, 'Pond/river': 8, 'Fountain': 9, 'Surface albedo change': 10}

        vLayer = QgsProject.instance().mapLayersByName(chsnlanduselayer)[0]
        vLayer.startEditing()
        if QgsVectorDataProvider.AddAttributes:
            vLayer.dataProvider().addAttributes([QgsField("Land use", QVariant.String),
                                                 QgsField("LandUseValue", QVariant.Int)])
            vLayer.updateFields()

        caps = vLayer.dataProvider().capabilities()
        if caps & QgsVectorDataProvider.ChangeAttributeValues:
            attrs = {1: chsnlanduse, 2: int(landuserastvalue.get(chsnlanduse))}
            vLayer.dataProvider().changeAttributeValues({1: attrs})

        vLayer.commitChanges()

        # change color of polygons
        single_symbol_renderer = vLayer.renderer()

        symbol = single_symbol_renderer.symbol()

        for feature in vLayer.getFeatures():
            if feature['LandUseValue'] < 4:
                symbol.setColor(QColor.fromRgb(178, 223, 138))
            elif feature['LandUseValue'] > 3 and feature['LandUseValue'] < 8:
                symbol.setColor(QColor.fromRgb(215, 25, 28))
            elif feature['LandUseValue'] > 7 and feature['LandUseValue'] < 10:
                symbol.setColor(QColor.fromRgb(82, 185, 248))
            else:
                symbol.setColor(QColor.fromRgb(154, 157, 153))

        # more efficient than refreshing the whole canvas, which requires a redraw of ALL layers
        vLayer.triggerRepaint()

        # update table of contents for layer
        iface.layerTreeView().refreshLayerSymbology(vLayer.id())

        self.fillObjectsTable(vLayer)
    def __init__(self, methodName):
        """Run once on class initialization."""
        unittest.TestCase.__init__(self, methodName)

        # create composition
        self.mComposition = QgsComposition(QgsProject.instance())
        self.mComposition.setPaperSize(297, 210)

        self.mComposerShape = QgsComposerShape(20, 20, 150, 100, self.mComposition)
        self.mComposerShape.setBackgroundColor(QColor.fromRgb(255, 150, 0))
        self.mComposition.addComposerShape(self.mComposerShape)
    def __init__(self, methodName):
        """Run once on class initialization."""
        unittest.TestCase.__init__(self, methodName)

        # create composition
        self.mComposition = QgsComposition(QgsProject.instance())
        self.mComposition.setPaperSize(297, 210)

        self.mComposerShape = QgsComposerShape(20, 20, 150, 100, self.mComposition)
        self.mComposerShape.setBackgroundColor(QColor.fromRgb(255, 150, 0))
        self.mComposition.addComposerShape(self.mComposerShape)
Exemple #9
0
    def create_layer(self, points, layer_name, type_geometry, style_width,
                     layer_id, color_list):
        # get default CRS
        canvas = self.iface.mapCanvas()
        map_settings = canvas.mapSettings()
        srs = map_settings.destinationCrs()

        # create an empty memory layer
        if layer_id is not None:
            vl = QgsVectorLayer(type_geometry + "?crs=" + srs.authid(),
                                layer_name + str(layer_id + 1), "memory")
        else:
            vl = QgsVectorLayer(type_geometry + "?crs=" + srs.authid(),
                                layer_name, "memory")

        # define and add a field ID to memory layer "Route"
        provider = vl.dataProvider()
        provider.addAttributes([QgsField("ID", QVariant.Int)])

        # create a new feature for the layer "Route"
        ft = QgsFeature()
        # set the value 1 to the new field "ID"
        ft.setAttributes([1])
        if type_geometry == GeometryTypes.LINE:
            line_points = []

            for i in range(len(points)):
                if (i + 1) < len(points):
                    line_points.append(QgsPoint(points[i][0], points[i][1]))
            # set the geometry defined from the point
            ft.setGeometry(QgsGeometry.fromPolyline(line_points))
        else:
            ft.setGeometry(
                QgsGeometry.fromPointXY(QgsPointXY(points[0], points[1])))
        # finally insert the feature
        provider.addFeatures([ft])

        if type_geometry == GeometryTypes.LINE:
            # set color
            render_ctx = QgsRenderContext()
            renderer = vl.renderer()
            symbols = renderer.symbols(render_ctx)
            sym = symbols[0]

            if layer_id and color_list:
                color = color_list[layer_id]
                sym.setColor(QColor.fromRgb(color[0], color[1], color[2]))

            sym.setWidth(style_width)

        # add layer to the registry and over the map canvas
        # QgsMapLayerRegistry.instance().addMapLayer(vl)
        QgsProject.instance().addMapLayer(vl)
def addIdentifyDataToTableWidget(identifyTableWidget, setupObject,
                                 targetMetDict, identDict):
    featIDList = list(identDict.keys())
    featIDList.sort()
    for aRow in range(0, len(featIDList)):
        identifyTableWidget.insertRow(aRow)
        featID = featIDList[aRow]
        featIdentifyList = identDict[featID]
        for aCol in range(0, len(featIdentifyList)):
            featValue = featIdentifyList[aCol]
            featIDItem = QTableWidgetItem(featValue)
            if aCol == 6:
                targetMetStatus = targetMetDict[featID]
                if targetMetStatus == 'Met':
                    featIDItem.setForeground(QColor.fromRgb(0, 102, 51))
                elif targetMetStatus == 'Not met':
                    featIDItem.setForeground(QColor.fromRgb(255, 0, 0))
                else:
                    featIDItem.setForeground(QColor.fromRgb(128, 128, 128))
            identifyTableWidget.setItem(aRow, aCol, featIDItem)

    identifyTableWidget.horizontalHeader().setStyleSheet(
        setupObject.TableHeadingStyle)
    identifyTableWidget.verticalHeader().hide()
Exemple #11
0
    def envelope2layer(self, envelope):
        """Transform metadata envelope into a QGIS layer."""
        # layer
        md_lyr = QgsVectorLayer("Polygon?crs=epsg:4326", "Metadata envelope",
                                "memory")
        symbols = md_lyr.renderer().symbols(QgsRenderContext())
        symbol = symbols[0]
        symbol.setColor(QColor.fromRgb(255, 20, 147))
        symbol.setOpacity(0.25)

        if envelope.get("type") == "Polygon":
            # parse coordinates
            coords = envelope.get("coordinates")[0]
            poly_pts = [
                QgsPointXY(round(i[0], 3), round(i[1], 3)) for i in coords
            ]
            # add geometry to layer
            poly = QgsFeature()
            poly.setGeometry(QgsGeometry.fromPolygonXY([poly_pts]))
            md_lyr.dataProvider().addFeatures([poly])
            md_lyr.updateExtents()
        elif envelope.get("type") == "MultiPolygon":
            coords = envelope.get("bbox")
            bbox = QgsRectangle(
                round(coords[0], 3),
                round(coords[1], 3),
                round(coords[2], 3),
                round(coords[3], 3),
            )
            poly = QgsFeature()
            poly.setGeometry(QgsGeometry.fromWkt(bbox.asWktPolygon()))
            md_lyr.dataProvider().addFeatures([poly])
            md_lyr.updateExtents()
        elif envelope.get("type") == "Point":
            return md_lyr
        else:
            pass
        # method ending
        return md_lyr
    def envelope2layer(self, envelope):
        """Transform metadata envelope into a QGIS layer."""
        # layer
        md_lyr = QgsVectorLayer("Polygon?crs=epsg:4326",
                                "Metadata envelope",
                                "memory")
        md_lyr.setLayerTransparency(75)
        symbols = md_lyr.rendererV2().symbols()
        symbol = symbols[0]
        symbol.setColor(QColor.fromRgb(255,20,147))

        if envelope.get("type") == "Polygon":
            # parse coordinates
            coords = envelope.get("coordinates")[0]
            poly_pts = [QgsPoint(round(i[0], 3),
                                 round(i[1], 3))
                        for i in coords]
            # add geometry to layer
            poly = QgsFeature()
            poly.setGeometry(QgsGeometry.fromPolygon([poly_pts]))
            md_lyr.dataProvider().addFeatures([poly])
            md_lyr.updateExtents()
        elif envelope.get("type") == "MultiPolygon":
            coords = envelope.get("bbox")
            bbox = QgsRectangle(round(coords[0], 3),
                                round(coords[1], 3),
                                round(coords[2], 3),
                                round(coords[3], 3),)
            poly = QgsFeature()
            poly.setGeometry(QgsGeometry.fromWkt(bbox.asWktPolygon()))
            md_lyr.dataProvider().addFeatures([poly])
            md_lyr.updateExtents()
        elif envelope.get("type") == "Point":
            return md_lyr
        else:
            pass
        # method ending
        return md_lyr
Exemple #13
0
    def __init__(self, canvas, layerfrom, layerto, mapping, validation_method):
        """
            mapping - A dict of field - field mapping with values to
                            copy to the new layer
        """
        QgsMapTool.__init__(self, canvas)
        self.layerfrom = layerfrom
        self.layerto = layerto
        self.fields = mapping
        self.validation_method = validation_method
        self.band = QgsRubberBand(canvas, QgsWkbTypes.PolygonGeometry)
        self.band.setColor(QColor.fromRgb(255, 0, 0, 65))
        self.band.setWidth(5)

        self.cursor = QCursor(
            QPixmap([
                "16 16 3 1", "      c None", ".     c #FF0000",
                "+     c #FFFFFF", "                ", "       +.+      ",
                "      ++.++     ", "     +.....+    ", "    +.     .+   ",
                "   +.   .   .+  ", "  +.    .    .+ ", " ++.    .    .++",
                " ... ...+... ...", " ++.    .    .++", "  +.    .    .+ ",
                "   +.   .   .+  ", "   ++.     .+   ", "    ++.....+    ",
                "      ++.++     ", "       +.+      "
            ]))
    def __init__(self, file_name):
        super().__init__()

        # Creación del Lienzo / Canvas
        self.canvas = QgsMapCanvas(self)
        self.setWindowTitle("Map of Track  /  Mapa del Recorrido")
        self.canvas.setCanvasColor(Qt.white)

        self.initGui()

        if not file_name == None:
            vlayer = QgsVectorLayer(file_name, "Track Converted", "ogr")
            #vlayer.updateExtents()
            self.project.instance().addMapLayer(vlayer)
            vlayer.renderer().symbol().setWidth(2)
            vlayer.renderer().symbol().setColor(QColor.fromRgb(250, 0, 0))
            self.view.refreshLayerSymbology(vlayer.id())

            uri = 'crs=EPSG:4326&dpiMode=7&format=image/jpeg&layers=IGNBaseTodo&styles=default&tileMatrixSet=EPSG:4326&url=http://www.ign.es/wmts/ign-base'
            map_spain = QgsRasterLayer(uri, "Spain", "wms")
            self.root.insertLayer(1, map_spain)
            self.project.instance().addMapLayer(map_spain)
            if not map_spain.isValid():
                print("Track failed to load! /n" + file_name)
            else:
                print("Track Load Correct! " + file_name)

        else:
            uri = 'crs=EPSG:4326&dpiMode=7&format=image/jpeg&layers=IGNBaseTodo&styles=default&tileMatrixSet=EPSG:4326&url=http://www.ign.es/wmts/ign-base'
            map_spain = QgsRasterLayer(uri, "Spain", "wms")
            self.project.instance().addMapLayer(map_spain)

            if not map_spain.isValid():
                print("Track failed to load! /n" + file_name)
            else:
                print("Track Load Correct! " + file_name)
    def startDraw(self):
        # Create and add the new layer
        layer = QgsVectorLayer('Polygon?crs=epsg:4326', providerLib='memory')
        layer.renderer().symbol().setColor(QColor.fromRgb(160, 82, 45))
        layer.setName(f'search aoi')
        QgsProject.instance().addMapLayer(layer)

        # Use the add feature tool
        self.iface.setActiveLayer(layer)

        # Function called when the feature is added to the layer
        def featureAdded():
            # Disconnect from the signal
            layer.featureAdded.disconnect()
            # Save changes and end edit mode
            layer.commitChanges()
            # Select the feature then fill the input
            feature = layer.selectAll()
            self.fillPolygonInput()

        # Connect the layer to the signal featureAdded
        layer.featureAdded.connect(featureAdded)
        layer.startEditing()
        self.iface.actionAddFeature().trigger()
Exemple #16
0
    def initGui(self):
        # create action that will start plugin configuration
        self.action = QAction(
            QIcon(":icons/qgsazimuth.png"),
            "Azimuth and distance",
            self.iface.mainWindow(),
        )
        self.action.setWhatsThis("Azimuth and distance")
        self.action.triggered.connect(self.run)

        self.bandpoint = QgsRubberBand(self.canvas, QgsWkbTypes.PointGeometry)
        self.bandpoint.setIcon(QgsRubberBand.ICON_CROSS)
        self.bandpoint.setColor(QColor.fromRgb(255, 50, 255))
        self.bandpoint.setWidth(3)
        self.bandpoint.setIconSize(20)

        # add toolbar button and menu item
        self.iface.addPluginToMenu("&Topography", self.action)
        self.iface.addToolBarIcon(self.action)

        self.dock = Dock(self.iface.mainWindow())
        self.iface.addDockWidget(Qt.BottomDockWidgetArea, self.dock)
        self.dock.hide()
        self.pluginGui = self.dock.widget()

        self.dock.closed.connect(self.cleanup)
        self.pluginGui.pushButton_vertexAdd.clicked.connect(self.addRow)
        self.pluginGui.pushButton_vertexInsert.clicked.connect(self.insertRow)
        self.pluginGui.pushButton_segListRowDel.clicked.connect(self.delRow)
        self.pluginGui.pushButton_segListLoad.clicked.connect(self.loadList)
        self.pluginGui.pushButton_segListClear.clicked.connect(self.clearList)
        self.pluginGui.pushButton_objectDraw.clicked.connect(self.addgeometry)
        self.pluginGui.pushButton_startCapture.clicked.connect(self.startgetpoint)
        self.pluginGui.pushButton_segListSave.clicked.connect(self.saveList)
        self.pluginGui.pushButton_useLast.clicked.connect(self.use_last_vertex)

        self.pluginGui.pickAngle1_button.clicked.connect(self.select_angle1)
        self.pluginGui.pickAngle2_button.clicked.connect(self.select_angle2)
        self.pluginGui.clearMarkers_button.clicked.connect(self.clear_markers)
        self.pluginGui.copyDiff_button.clicked.connect(self.copy_diff_offset)

        # self.pluginGui.table_segmentList.cellChanged.connect(self.render_temp_band)

        self.pluginGui.table_segmentList.setCurrentCell(0, 0)

        self.tool = GetCoordTool(self.canvas)
        self.tool.finished.connect(self.getpoint)
        self.tool.locationChanged.connect(self.pluginGui.update_startpoint)
        self.tool.locationChanged.connect(self.update_marker_location)

        self.angletool = LineTool(self.canvas)
        self.angletool.geometryComplete.connect(self.update_angle1)
        self.angletool.locationChanged.connect(self.update_marker_location)

        self.angletool2 = LineTool(self.canvas)
        self.angletool2.geometryComplete.connect(self.update_angle2)
        self.angletool2.locationChanged.connect(self.update_marker_location)

        self.pluginGui.azimuth1_edit.textChanged.connect(self.update_angle_calc)
        self.pluginGui.azimuth2_edit.textChanged.connect(self.update_angle_calc)

        self.pluginGui.lineEdit_magNorth.textChanged.connect(self.update_offsetlabel)
        self.pluginGui.radioButton_defaultNorth.toggled.connect(self.update_offsetlabel)
    def add_layers(self):#not tested and not ready, must fix basic styles (preferrably colors based on some definition dicitonary
        MyGroup = self.root.insertGroup(0, "stratigraphy_layers_for_qgis2threejs")#verify this is inserted at top

        canvas = self.iface.mapCanvas()

        list_with_all_strat_layer = []
        for key in self.strat_layers_dict:
            list_with_all_strat_layer.append(key)
        #print list_with_all_strat_layer#debug

        list_with_all_strat_layer.append('strat_obs_p_for_qgsi2threejs')

        colors = []

        layer_list = []
        utils.add_layers_to_list(layer_list, list_with_all_strat_layer, geometrycolumn='geometry',
                           dbconnection=self.dbconnection)

        for strat_layer_view in list_with_all_strat_layer:
            try:
                supplied_color = self.symbolcolors_dict[strat_layer_view]
            except KeyError:
                color = None
            else:
                try:
                    # matplotlib 2
                    color = mpl.colors.to_rgbsupplied_color()
                except AttributeError:
                    try:
                        # matplotlib 1
                        converter = mpl.colors.ColorConverter()
                        color = converter.to_rgb(supplied_color)
                        color = [x * 255 for x in color]
                    except Exception as e:
                        utils.MessagebarAndLog.warning(
                            bar_msg=ru(QCoreApplication.translate('PrepareForQgis2Threejs', 'Setting color from dict failed')),
                            log_msg=ru(QCoreApplication.translate('PrepareForQgis2Threejs', 'Error msg %s'))%str(e))
                        color = None

            colors.append(color)

        for idx, layer in enumerate(layer_list):#now loop over all the layers, add them to canvas and set colors
            if not layer.isValid():
                try:
                    print(layer.name() + ' is not valid layer')
                except:
                    pass
                pass
            else:
                # TODO: Made this a comment, but there might be some hidden feature thats still needed!
                #map_canvas_layer_list.append(QgsMapCanvasLayer(layer))

                #now try to load the style file
                stylefile = os.path.join(os.sep,os.path.dirname(__file__),"..","definitions",layer.name() + ".qml")
                try:
                    layer.loadNamedStyle(stylefile)
                except:
                    try:
                        print("Loading stylefile %s failed."%stylefile)
                    except:
                        pass

                color = colors[idx]
                if color:
                    current_symbol = layer.renderer().symbol()
                    current_symbol.setColor(QColor.fromRgb(color[0], color[1], color[2]))

                QgsProject.instance().addMapLayers([layer],False)
                MyGroup.insertLayer(0,layer)
                                
            #finally refresh canvas
            canvas.refresh()
Exemple #18
0
class FmvLayerStyles(object):

    # sensor holder
    S = {}

    # platform holder
    P = {}

    # trajectory holder
    T = {}

    # beam holder
    B = {}

    # frame center holder
    F = {}

    # frame axis holder
    FA = {}

    # drawings Point holder
    DP = {}

    # drawings Line holder
    DL = {}

    # drawing Polygons holder
    DPL = {}

    #
    # SENSOR STYLES (based on meta attribute "Image Source Sensor")
    #

    # Default
    S["DEFAULT"] = {}
    S["DEFAULT"]["COLOR"] = "126,217,255,60"
    S["DEFAULT"]["OUTLINE_COLOR"] = "#5392fa"
    S["DEFAULT"]["OUTLINE_STYLE"] = "solid"
    S["DEFAULT"]["OUTLINE_WIDTH"] = "2"

    # IR sensor
    S["IR"] = {}
    S["IR"]["COLOR"] = "234, 135, 8, 60"
    S["IR"]["OUTLINE_COLOR"] = "#ba340f"
    S["IR"]["OUTLINE_STYLE"] = "solid"
    S["IR"]["OUTLINE_WIDTH"] = "2"

    # EOW sensor
    S["EOW"] = {}
    S["EOW"]["COLOR"] = "126, 217, 255, 60"
    S["EOW"]["OUTLINE_COLOR"] = "#5392fa"
    S["EOW"]["OUTLINE_STYLE"] = "solid"
    S["EOW"]["OUTLINE_WIDTH"] = "2"

    # BLEND sensor
    S["BLEND"] = {}
    S["BLEND"]["COLOR"] = "255, 255, 255, 60"
    S["BLEND"]["OUTLINE_COLOR"] = "#a7a7a7"
    S["BLEND"]["OUTLINE_STYLE"] = "solid"
    S["BLEND"]["OUTLINE_WIDTH"] = "2"

    # Short Wave Infra Red sensor
    S["EON_SWIR"] = {}
    S["EON_SWIR"]["COLOR"] = "234, 135, 8, 60"
    S["EON_SWIR"]["OUTLINE_COLOR"] = "#ba340f"
    S["EON_SWIR"]["OUTLINE_STYLE"] = "solid"
    S["EON_SWIR"]["OUTLINE_WIDTH"] = "2"

    # EON sensor
    S["EON"] = {}
    S["EON"]["COLOR"] = "249, 167, 62, 60"
    S["EON"]["OUTLINE_COLOR"] = "#ba340f"
    S["EON"]["OUTLINE_STYLE"] = "solid"
    S["EON"]["OUTLINE_WIDTH"] = "2"

    # FLIR SS380-HD HDIR sensor
    S["FLIR SS380-HD HDIR"] = {}
    S["FLIR SS380-HD HDIR"]["COLOR"] = "234, 135, 8, 60"
    S["FLIR SS380-HD HDIR"]["OUTLINE_COLOR"] = "#ba340f"
    S["FLIR SS380-HD HDIR"]["OUTLINE_STYLE"] = "solid"
    S["FLIR SS380-HD HDIR"]["OUTLINE_WIDTH"] = "2"

    # SP sensor
    S["SP"] = {}
    S["SP"]["COLOR"] = "219, 204, 0, 60"
    S["SP"]["OUTLINE_COLOR"] = "#9E9300"
    S["SP"]["OUTLINE_STYLE"] = "solid"
    S["SP"]["OUTLINE_WIDTH"] = "2"
    #
    # PLATFORM STYLES (based on meta attribute platform)
    #

    # Default
    P["DEFAULT"] = {}
    P["DEFAULT"]["NAME"] = ":/imgFMV/images/platforms/platform_default.svg"
    P["DEFAULT"]["OUTLINE"] = "255, 255, 255, 60"
    P["DEFAULT"]["OUTLINE_WIDTH"] = "1"
    P["DEFAULT"]["SIZE"] = "18"

    # Super Puma Platform
    P["Super Puma TH06"] = {}
    P["Super Puma TH06"]["NAME"] = ":/imgFMV/images/platforms/plat_super_puma.svg"
    P["Super Puma TH06"]["OUTLINE"] = "255, 255, 255, 60"
    P["Super Puma TH06"]["OUTLINE_WIDTH"] = "1"
    P["Super Puma TH06"]["SIZE"] = "18"

    # N97826 Platform
    P["N97826"] = {}
    P["N97826"]["NAME"] = ":/imgFMV/images/platforms/plat_N97826.svg"
    P["N97826"]["OUTLINE"] = "255, 255, 255, 60"
    P["N97826"]["OUTLINE_WIDTH"] = "1"
    P["N97826"]["SIZE"] = "18"

    # VH-ZXX Platform
    P["VH-ZXX"] = {}
    P["VH-ZXX"]["NAME"] = ":/imgFMV/images/platforms/plat_VH-ZXX.svg"
    P["VH-ZXX"]["OUTLINE"] = "255, 255, 255, 60"
    P["VH-ZXX"]["OUTLINE_WIDTH"] = "1"
    P["VH-ZXX"]["SIZE"] = "18"

    # ADS15 Platform
    P["ADS15"] = {}
    P["ADS15"]["NAME"] = ":/imgFMV/images/platforms/plat_ADS15.svg"
    P["ADS15"]["OUTLINE"] = "255, 255, 255, 60"
    P["ADS15"]["OUTLINE_WIDTH"] = "1"
    P["ADS15"]["SIZE"] = "18"

    #
    # FRAMECENTER POINT STYLES
    #
    F["DEFAULT"] = {}
    F["DEFAULT"]["NAME"] = "cross"
    F["DEFAULT"]["LINE_COLOR"] = "#000000"
    F["DEFAULT"]["LINE_WIDTH"] = "0"
    F["DEFAULT"]["SIZE"] = "10"

    #
    # FRAME AXIS STYLES
    #
    FA["DEFAULT"] = {}
    FA["DEFAULT"]["OUTLINE_WIDTH"] = "2"
    FA["DEFAULT"]["OUTLINE_STYLE"] = "dash"

    #
    # TRAJECTORY STYLES
    #
    T["DEFAULT"] = {}
    T["DEFAULT"]["NAME"] = "dash blue"
    T["DEFAULT"]["COLOR"] = "#0000ff"
    T["DEFAULT"]["WIDTH"] = "2"
    T["DEFAULT"]["customdash"] = "3;2"
    T["DEFAULT"]["use_custom_dash"] = "1"

    #
    # BEAM STYLES
    #
    B["DEFAULT"] = {}
    B["DEFAULT"]["COLOR"] = qRgba(138, 138, 138, 180)

    #
    # DRAWINGS POINT STYLES
    #
    DP["DEFAULT"] = {}
    DP["DEFAULT"]["NAME"] = "cross"
    DP["DEFAULT"]["LINE_COLOR"] = "#DC143C"
    DP["DEFAULT"]["LINE_WIDTH"] = "1"
    DP["DEFAULT"]["SIZE"] = "10"
    DP["DEFAULT"]["LABEL_FONT"] = "Arial"
    DP["DEFAULT"]["LABEL_FONT_SIZE"] = 12
    DP["DEFAULT"]["LABEL_FONT_COLOR"] = "#DC143C"
    DP["DEFAULT"]["LABEL_SIZE"] = 12
    DP["DEFAULT"]["LABEL_BUFFER_COLOR"] = "white"

    #
    # DRAWINGS LINE STYLES
    #
    DL["DEFAULT"] = {}
    DL["DEFAULT"]["COLOR"] = QColor.fromRgb(252, 215, 108)
    DL["DEFAULT"]["WIDTH"] = 1

    #
    # DRAWINGS POLYGONS STYLES
    #
    DPL["DEFAULT"] = {}
    DPL["DEFAULT"]["COLOR"] = "252, 215, 108, 100"
    DPL["DEFAULT"]["OUTLINE_COLOR"] = "#FCD76C"
    DPL["DEFAULT"]["OUTLINE_STYLE"] = "solid"
    DPL["DEFAULT"]["OUTLINE_WIDTH"] = "1"

    @staticmethod
    def getPlatform(name):
        style = None
        try:
            style = FmvLayerStyles.P[name]
        except Exception:
            style = FmvLayerStyles.P["DEFAULT"]
        return style

    @staticmethod
    def getSensor(name):
        style = None
        try:
            style = FmvLayerStyles.S[name]
        except Exception:
            style = FmvLayerStyles.S["DEFAULT"]
        return style

    @staticmethod
    def getTrajectory(name):
        style = None
        try:
            style = FmvLayerStyles.T[name]
        except Exception:
            style = FmvLayerStyles.T["DEFAULT"]
        return style

    @staticmethod
    def getBeam(name):
        style = None
        try:
            style = FmvLayerStyles.B[name]
        except Exception:
            style = FmvLayerStyles.B["DEFAULT"]
        return style

    @staticmethod
    def getDrawingPoint():
        style = FmvLayerStyles.DP["DEFAULT"]
        return style

    @staticmethod
    def getFrameCenterPoint():
        style = FmvLayerStyles.F["DEFAULT"]
        return style

    @staticmethod
    def getFrameAxis():
        style = FmvLayerStyles.FA["DEFAULT"]
        return style

    @staticmethod
    def getDrawingLine():
        style = FmvLayerStyles.DL["DEFAULT"]
        return style

    @staticmethod
    def getDrawingPolygon():
        style = FmvLayerStyles.DPL["DEFAULT"]
        return style
Exemple #19
0
    def paint(self, painter, option, index):
        if index.column() != 0:
            QStyledItemDelegate.paint(self, painter, option, index)
            return
        model: Any[PlanetSearchResultsModel | QAbstractItemModel] = \
            index.model()
        node: PlanetNode = model.get_node(index)

        # TODO: Style these, too?
        # if node.node_type() in [NodeT.LOADING, NodeT.LOAD_MORE]:
        #     QStyledItemDelegate.paint(self, painter, option, index)
        #     return

        option_vi = QStyleOptionViewItem(option)
        self.initStyleOption(option_vi, index)

        # noinspection PyUnusedLocal
        style = QApplication.style() \
            if option_vi.widget is None else option_vi.widget.style()
        # style = self.parent().style()

        opt_rect = option_vi.rect

        doc = QTextDocument()
        doc.setHtml(option_vi.text)
        #print(option_vi.text)

        option_vi.text = ''
        style.drawControl(QStyle.CE_ItemViewItem, option_vi, painter)

        ctx = QAbstractTextDocumentLayout.PaintContext()

        # Highlighting text if item is selected
        # if option_vi.state & QStyle.State_Selected:
        #     ctx.palette.setColor(
        #         QPalette.Text,
        #         option_vi.palette.color(
        #             QPalette.Active, QPalette.HighlightedText))

        text_rect = style.subElementRect(QStyle.SE_ItemViewItemText, option_vi)
        painter.save()

        painter.translate(text_rect.topLeft())
        painter.setClipRect(text_rect.translated(-text_rect.topLeft()))
        doc.documentLayout().draw(painter, ctx)

        painter.restore()

        if option.state & QStyle.State_MouseOver:
            if node.has_footprint() or node.has_group_footprint():
                painter.save()

                painter.setPen(
                    QPen(QBrush(QColor.fromRgb(0, 157, 165, 245)), 1.5))
                painter.setBrush(Qt.NoBrush)
                painter.drawRect(opt_rect.marginsRemoved(QMargins(1, 1, 1, 1)))

                painter.restore()

            if node.has_footprint() or node.has_group_footprint():
                # noinspection PyUnresolvedReferences
                self.previewFootprint.emit(node)
            else:
                # noinspection PyUnresolvedReferences
                self.clearFootprint.emit()

        if not node.can_be_downloaded():
            # Note: Needs to come last, so it covers checkbox control
            # TODO: Figure out way of having checkbox not drawn, but still
            #       set Node's unchecked state

            # opt_btn = QStyleOptionButton()
            # opt_btn.operator = option
            ci_rect: QRect = style.subElementRect(
                QStyle.SE_ViewItemCheckIndicator, option_vi)

            # opt_btn.rect = ci_rect
            # but_opt = QStyleOptionButton(option)
            # opt_btn.state = QStyle.State_Off
            # style.drawControl(QStyle.CE_CheckBox, opt_btn, painter)

            painter.save()

            painter.setPen(Qt.NoPen)
            painter.setBrush(QBrush(QColor.fromRgb(250, 250, 250, 255)))
            painter.drawRoundedRect(ci_rect,
                                    ci_rect.height() / 6,
                                    ci_rect.height() / 6)

            LOCK_ICON.paint(painter, ci_rect, Qt.AlignCenter, QIcon.Normal)

            painter.restore()
Exemple #20
0
    def add_layers(
        self
    ):  #not tested and not ready, must fix basic styles (preferrably colors based on some definition dicitonary
        MyGroup = self.root.insertGroup(0,
                                        "stratigraphy_layers_for_qgis2threejs"
                                        )  #verify this is inserted at top

        canvas = self.iface.mapCanvas()

        list_with_all_strat_layer = []
        for key in self.strat_layers_dict:
            list_with_all_strat_layer.append(key)
        #print list_with_all_strat_layer#debug

        list_with_all_strat_layer.append('strat_obs_p_for_qgsi2threejs')

        colors = []

        layer_list = []
        utils.add_layers_to_list(layer_list,
                                 list_with_all_strat_layer,
                                 geometrycolumn='geometry',
                                 dbconnection=self.dbconnection)

        for strat_layer_view in list_with_all_strat_layer:
            try:
                supplied_color = self.symbolcolors_dict[strat_layer_view]
            except KeyError:
                color = None
            else:
                try:
                    # matplotlib 2
                    color = mpl.colors.to_rgbsupplied_color()
                except AttributeError:
                    try:
                        # matplotlib 1
                        converter = mpl.colors.ColorConverter()
                        color = converter.to_rgb(supplied_color)
                        color = [x * 255 for x in color]
                    except Exception as e:
                        utils.MessagebarAndLog.warning(
                            bar_msg=ru(
                                QCoreApplication.translate(
                                    'PrepareForQgis2Threejs',
                                    'Setting color from dict failed')),
                            log_msg=ru(
                                QCoreApplication.translate(
                                    'PrepareForQgis2Threejs',
                                    'Error msg %s')) % str(e))
                        color = None

            colors.append(color)

        for idx, layer in enumerate(
                layer_list
        ):  #now loop over all the layers, add them to canvas and set colors
            if not layer.isValid():
                try:
                    print(layer.name() + ' is not valid layer')
                except:
                    pass
                pass
            else:
                # TODO: Made this a comment, but there might be some hidden feature thats still needed!
                #map_canvas_layer_list.append(QgsMapCanvasLayer(layer))

                #now try to load the style file
                stylefile = os.path.join(os.sep, os.path.dirname(__file__),
                                         "..", "definitions",
                                         layer.name() + ".qml")
                try:
                    layer.loadNamedStyle(stylefile)
                except:
                    try:
                        print("Loading stylefile %s failed." % stylefile)
                    except:
                        pass

                color = colors[idx]
                if color:
                    current_symbol = layer.renderer().symbol()
                    current_symbol.setColor(
                        QColor.fromRgb(color[0], color[1], color[2]))

                QgsProject.instance().addMapLayers([layer], False)
                MyGroup.insertLayer(0, layer)

            #finally refresh canvas
            canvas.refresh()
    def search(self):
        try:
            # Current service
            service = self.tab.tabText(self.tab.currentIndex())

            # Params
            params = {'geometry': self.polygonInput.text()}

            # Set auth and add params according to service
            if service == 'BaseMap':
                # ! Auth
                self.bmSetAuth()

                # Set request attributes
                url = 'https://view.geoapi-airbusds.com/api/v1/images'
                auth = self.bmAuth
                headers = None

                # Update params
                params.update({
                    'size': self.maxResultsInput.value(),
                    'insertdtstart': '1970-01-01T00:00:00',
                    'insertdtend': self.now()
                })

                # Dates
                if self.bmFromCheck.isChecked():
                    params['insertdtstart'] = self.bmFromInput.dateTime(
                    ).toString(Qt.ISODate)
                if self.bmToCheck.isChecked():
                    params['insertdtend'] = self.bmToInput.dateTime().toString(
                        Qt.ISODate)

            else:
                # ! Auth
                self.dtSetAuth()

                url = 'https://search.oneatlas.geoapi-airbusds.com/api/v1/opensearch'
                auth = None
                headers = self.dtHeaders

                # Constellations (at least one)
                constellations = []
                if self.dtSpotCheck.isChecked():
                    constellations.append('SPOT')
                if self.dtPleiadesCheck.isChecked():
                    constellations.append('PHR')

                # Dates
                # MAYBE remove hours from dates
                dateFrom, dateTo = '1970-01-01T00:00:00', self.now()
                if self.dtFromCheck.isChecked():
                    dateFrom = self.dtFromInput.dateTime().toString(Qt.ISODate)
                if self.dtToCheck.isChecked():
                    dateTo = self.dtToInput.dateTime().toString(Qt.ISODate)

                # Angles
                angleMin, angleMax = 0, 30
                if self.dtAngleMinCheck.isChecked():
                    angleMin = self.dtAngleMinInput.value()
                if self.dtAngleMaxCheck.isChecked():
                    angleMax = self.dtAngleMaxInput.value()

                # Covers (directlly update params)
                if self.dtCloudCheck.isChecked():
                    params['cloudCover'] = f'[0,{self.dtCloudInput.value()}]'
                if self.dtSnowCheck.isChecked():
                    params['snowCover'] = f'[0,{self.dtSnowInput.value()}]'

                # Workspaces (at leat one)
                workspaces = []
                if self.dtPublicCheck.isChecked():
                    workspaces.append('0e33eb50-3404-48ad-b835-b0b4b72a5625')
                if self.dtPrivateCheck.isChecked():
                    workspaces.append(self.dtWorkspaceId)

                # Update all params with right format
                params.update({
                    'itemsPerPage': self.maxResultsInput.value(),
                    'constellation': ','.join(constellations),
                    'acquisitionDate': f'[{dateFrom},{dateTo}]',
                    'incidenceAngle': f'[{angleMin},{angleMax}]',
                    'workspace': ','.join(workspaces)
                })

            # Finally do the api call
            t = datetime.datetime.now()
            print(f'START {service} search')
            r = self.session.get(url,
                                 auth=auth,
                                 headers=headers,
                                 params=params)
            rSearch = r.json()

            # Exception request error
            if r.status_code != 200:
                self.error(
                    f'{service} search error {r.status_code}\n{rSearch["message"]}'
                )
                return

            # Create the search result layer with fields according to current service
            layer = QgsVectorLayer(
                f'Polygon?crs=epsg:4326&index=yes&{FIELDS[service]}',
                providerLib='memory',
                baseName=f'{service} search results')

            # Extract features
            features = []
            self.errorFeatures = []
            for rFeature in rSearch['features']:
                # Add a feature of the bbox on the new layer
                feature = QgsFeature(layer.fields())
                # Try to get each attributes
                feature['service'] = service
                feature['constellation'] = self.getPropertie(
                    rFeature, 'constellation')
                feature['incidenceAngle'] = self.getPropertie(
                    rFeature, 'incidenceAngle')
                feature['cloudCover'] = self.getPropertie(
                    rFeature, 'cloudCover')
                if service == 'BaseMap':
                    feature['id'] = rFeature['id']
                    feature['insertionDate'] = self.getPropertie(
                        rFeature, 'insertionDate')
                    feature['wmts'] = self.getPropertie(rFeature, 'wmts')
                    # Bbox
                    fBbox = rFeature['properties']['bbox']
                    rectangle = QgsRectangle(fBbox[0], fBbox[1], fBbox[2],
                                             fBbox[3])
                else:
                    feature['id'] = self.getPropertie(rFeature, 'id')
                    feature['acquisitionDate'] = self.getPropertie(
                        rFeature, 'acquisitionDate')
                    feature['snowCover'] = self.getPropertie(
                        rFeature, 'snowCover')
                    try:
                        for json in rFeature['_links']['imagesWmts']:
                            feature[f'wmts_{json["name"]}'] = json['href']
                        for json in rFeature['_links']['imagesWcs']:
                            if 'buffer' in rFeature['rights']:
                                feature[f'wcs_{json["name"]}'] = json['href']
                            else:
                                feature[f'wcs_{json["name"]}'] = None
                    except Exception as e:
                        print(
                            f'ERROR * eF = qgis.utils.plugins["OneAtlas"].mySearch.errorFeatures[{len(self.errorFeatures)}]'
                        )
                        print(str(e))
                        self.errorFeatures.append(rFeature)
                        continue
                    # Bbox
                    coordinates = rFeature['geometry']['coordinates'][0]
                    rectangle = QgsRectangle(coordinates[0][0],
                                             coordinates[0][1],
                                             coordinates[2][0],
                                             coordinates[2][1])
                # Add geometry from rectangle
                feature.setGeometry(
                    QgsGeometry.fromWkt(rectangle.asWktPolygon()))
                # Add feature to list
                features.append(feature)

            # Total
            if service == 'BaseMap':
                # Note : rSearch['totalResults'] is maybe the number of total element in bbox ?
                #   and numberOfElements is the true total result
                total = rSearch['numberOfElements']
                color = QColor.fromRgb(0, 250, 0)
            else:
                total = rSearch['totalResults']
                color = QColor.fromRgb(0, 250, 250)

            if len(self.errorFeatures) > 0:
                total -= len(self.errorFeatures)
                print(f'* {len(self.errorFeatures)} error feature')

            # Notification for number of total results
            msgBox = QMessageBox()
            msgBox.setWindowTitle(WINDOW_TITLE)
            msgBox.setText(f'There are {total} results')
            if total > len(features):
                msgBox.setIcon(QMessageBox.Warning)
                msgBox.setInformativeText(
                    f'The maximum is configured to {self.maxResultsInput.value()}\nPlease refine your criteria or your AOI'
                )
                msgBox.setStandardButtons(QMessageBox.Retry
                                          | QMessageBox.Ignore)
                msgBox.setDefaultButton(QMessageBox.Retry)
            else:
                msgBox.setIcon(QMessageBox.Information)
                msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Ok)
                msgBox.setDefaultButton(QMessageBox.Ok)
            msgBox.button(QMessageBox.Retry).setText('Refine')
            msgBox.button(QMessageBox.Retry).setIcon(
                QIcon(os.path.dirname(__file__) + f'/search.png'))

            reply = msgBox.exec_()
            if reply == QMessageBox.Retry or len(features) == 0:
                return

            # Add result feature to the new layer
            (res, outFeats) = layer.dataProvider().addFeatures(features)

            # Change layer syle programmatically
            # Note : if we styling before save and add layer, we avoid to update legend style
            #   => self.iface.layerTreeView().refreshLayerSymbology(vlayer.id())
            symbol = layer.renderer().symbol()
            symbol.setOpacity(0.2)
            symbol.setColor(color)

            QgsProject.instance().addMapLayer(layer)
            # And refresh view
            layer.triggerRepaint()
            self.close()
        except:
            return
Exemple #22
0
class FmvLayerStyles(object):

    # sensor holder
    S = {}

    # platform holder
    P = {}

    # trajectory holder
    T = {}

    # beam holder
    B = {}

    # frame center holder
    F = {}

    # frame axis holder
    FA = {}

    # drawings Point holder
    DP = {}

    # drawings Line holder
    DL = {}

    # drawing Polygons holder
    DPL = {}

    #
    # SENSOR STYLES (based on meta attribute "Image Source Sensor")
    #

    # Default
    S['DEFAULT'] = {}
    S['DEFAULT']['COLOR'] = '126, 217, 255, 60'
    S['DEFAULT']['OUTLINE_COLOR'] = '#5392fa'
    S['DEFAULT']['OUTLINE_STYLE'] = 'solid'
    S['DEFAULT']['OUTLINE_WIDTH'] = '1'

    # IR sensor
    S['IR'] = {}
    S['IR']['COLOR'] = '234, 135, 8, 60'
    S['IR']['OUTLINE_COLOR'] = '#ba340f'
    S['IR']['OUTLINE_STYLE'] = 'solid'
    S['IR']['OUTLINE_WIDTH'] = '1'

    # EOW sensor
    S['EOW'] = {}
    S['EOW']['COLOR'] = '126, 217, 255, 60'
    S['EOW']['OUTLINE_COLOR'] = '#5392fa'
    S['EOW']['OUTLINE_STYLE'] = 'solid'
    S['EOW']['OUTLINE_WIDTH'] = '1'

    # BLEND sensor
    S['BLEND'] = {}
    S['BLEND']['COLOR'] = '255, 255, 255, 60'
    S['BLEND']['OUTLINE_COLOR'] = '#a7a7a7'
    S['BLEND']['OUTLINE_STYLE'] = 'solid'
    S['BLEND']['OUTLINE_WIDTH'] = '1'

    # Short Wave Infra Red sensor
    S['EON_SWIR'] = {}
    S['EON_SWIR']['COLOR'] = '234, 135, 8, 60'
    S['EON_SWIR']['OUTLINE_COLOR'] = '#ba340f'
    S['EON_SWIR']['OUTLINE_STYLE'] = 'solid'
    S['EON_SWIR']['OUTLINE_WIDTH'] = '1'

    # EON sensor
    S['EON'] = {}
    S['EON']['COLOR'] = '249, 167, 62, 60'
    S['EON']['OUTLINE_COLOR'] = '#ba340f'
    S['EON']['OUTLINE_STYLE'] = 'solid'
    S['EON']['OUTLINE_WIDTH'] = '1'

    # FLIR SS380-HD HDIR sensor
    S['FLIR SS380-HD HDIR'] = {}
    S['FLIR SS380-HD HDIR']['COLOR'] = '234, 135, 8, 60'
    S['FLIR SS380-HD HDIR']['OUTLINE_COLOR'] = '#ba340f'
    S['FLIR SS380-HD HDIR']['OUTLINE_STYLE'] = 'solid'
    S['FLIR SS380-HD HDIR']['OUTLINE_WIDTH'] = '1'

    # SP sensor
    S['SP'] = {}
    S['SP']['COLOR'] = '219, 204, 0, 60'
    S['SP']['OUTLINE_COLOR'] = '#9E9300'
    S['SP']['OUTLINE_STYLE'] = 'solid'
    S['SP']['OUTLINE_WIDTH'] = '1'
    #
    # PLATFORM STYLES (based on meta attribute platform)
    #

    # Default
    P['DEFAULT'] = {}
    P['DEFAULT']['NAME'] = ':/imgFMV/images/platforms/platform_default.svg'
    P['DEFAULT']['OUTLINE'] = '255, 255, 255, 60'
    P['DEFAULT']['OUTLINE_WIDTH'] = '1'
    P['DEFAULT']['SIZE'] = '18'

    # Super Puma Platform
    P['Super Puma TH06'] = {}
    P['Super Puma TH06'][
        'NAME'] = ':/imgFMV/images/platforms/plat_super_puma.svg'
    P['Super Puma TH06']['OUTLINE'] = '255, 255, 255, 60'
    P['Super Puma TH06']['OUTLINE_WIDTH'] = '1'
    P['Super Puma TH06']['SIZE'] = '18'

    # N97826 Platform
    P['N97826'] = {}
    P['N97826']['NAME'] = ':/imgFMV/images/platforms/plat_N97826.svg'
    P['N97826']['OUTLINE'] = '255, 255, 255, 60'
    P['N97826']['OUTLINE_WIDTH'] = '1'
    P['N97826']['SIZE'] = '18'

    # VH-ZXX Platform
    P['VH-ZXX'] = {}
    P['VH-ZXX']['NAME'] = ':/imgFMV/images/platforms/plat_VH-ZXX.svg'
    P['VH-ZXX']['OUTLINE'] = '255, 255, 255, 60'
    P['VH-ZXX']['OUTLINE_WIDTH'] = '1'
    P['VH-ZXX']['SIZE'] = '18'

    # ADS15 Platform
    P['ADS15'] = {}
    P['ADS15']['NAME'] = ':/imgFMV/images/platforms/plat_ADS15.svg'
    P['ADS15']['OUTLINE'] = '255, 255, 255, 60'
    P['ADS15']['OUTLINE_WIDTH'] = '1'
    P['ADS15']['SIZE'] = '18'

    #
    # FRAMECENTER POINT STYLES
    #
    F['DEFAULT'] = {}
    F['DEFAULT']['NAME'] = 'cross'
    F['DEFAULT']['LINE_COLOR'] = '#000000'
    F['DEFAULT']['LINE_WIDTH'] = '0'
    F['DEFAULT']['SIZE'] = '3'

    #
    # FRAME AXIS STYLES
    #
    FA['DEFAULT'] = {}
    FA['DEFAULT']['OUTLINE_STYLE'] = 'dash'

    #
    # TRAJECTORY STYLES
    #
    T['DEFAULT'] = {}
    T['DEFAULT']['NAME'] = 'dash blue'
    T['DEFAULT']['COLOR'] = '#0000ff'
    T['DEFAULT']['WIDTH'] = '0.5'
    T['DEFAULT']['customdash'] = '3;2'
    T['DEFAULT']['use_custom_dash'] = '1'

    #
    # BEAM STYLES
    #
    B['DEFAULT'] = {}
    B['DEFAULT']['COLOR'] = qRgba(138, 138, 138, 180)

    #
    # DRAWINGS POINT STYLES
    #
    DP['DEFAULT'] = {}
    DP['DEFAULT']['NAME'] = 'cross'
    DP['DEFAULT']['LINE_COLOR'] = '#DC143C'
    DP['DEFAULT']['LINE_WIDTH'] = '1'
    DP['DEFAULT']['SIZE'] = '4'
    DP['DEFAULT']['LABEL_FONT'] = 'Arial'
    DP['DEFAULT']['LABEL_FONT_SIZE'] = 12
    DP['DEFAULT']['LABEL_FONT_COLOR'] = '#DC143C'
    DP['DEFAULT']['LABEL_SIZE'] = 12
    DP['DEFAULT']['LABEL_BUFFER_COLOR'] = 'white'

    #
    # DRAWINGS LINE STYLES
    #
    DL['DEFAULT'] = {}
    DL['DEFAULT']['COLOR'] = QColor.fromRgb(252, 215, 108)
    DL['DEFAULT']['WIDTH'] = 1

    #
    # DRAWINGS POLYGONS STYLES
    #
    DPL['DEFAULT'] = {}
    DPL['DEFAULT']['COLOR'] = '252, 215, 108, 100'
    DPL['DEFAULT']['OUTLINE_COLOR'] = '#FCD76C'
    DPL['DEFAULT']['OUTLINE_STYLE'] = 'solid'
    DPL['DEFAULT']['OUTLINE_WIDTH'] = '1'

    @staticmethod
    def getPlatform(name):
        style = None
        try:
            style = FmvLayerStyles.P[name]
        except Exception:
            style = FmvLayerStyles.P['DEFAULT']
        return style

    @staticmethod
    def getSensor(name):
        style = None
        try:
            style = FmvLayerStyles.S[name]
        except Exception:
            style = FmvLayerStyles.S['DEFAULT']
        return style

    @staticmethod
    def getTrajectory(name):
        style = None
        try:
            style = FmvLayerStyles.T[name]
        except Exception:
            style = FmvLayerStyles.T['DEFAULT']
        return style

    @staticmethod
    def getBeam(name):
        style = None
        try:
            style = FmvLayerStyles.B[name]
        except Exception:
            style = FmvLayerStyles.B['DEFAULT']
        return style

    @staticmethod
    def getDrawingPoint():
        style = FmvLayerStyles.DP['DEFAULT']
        return style

    @staticmethod
    def getFrameCenterPoint():
        style = FmvLayerStyles.F['DEFAULT']
        return style

    @staticmethod
    def getFrameAxis():
        style = FmvLayerStyles.FA['DEFAULT']
        return style

    @staticmethod
    def getDrawingLine():
        style = FmvLayerStyles.DL['DEFAULT']
        return style

    @staticmethod
    def getDrawingPolygon():
        style = FmvLayerStyles.DPL['DEFAULT']
        return style