def testQgsPointPatternFillSymbolLayer(self): """ Test point pattern fill """ # test colors, need to make sure colors are passed/retrieved from subsymbol mSymbolLayer = QgsPointPatternFillSymbolLayer.create() mSymbolLayer.setColor(QColor(150, 50, 100)) self.assertEqual(mSymbolLayer.color(), QColor(150, 50, 100)) self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(150, 50, 100)) mSymbolLayer.subSymbol().setColor(QColor(250, 150, 200)) self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(250, 150, 200)) self.assertEqual(mSymbolLayer.color(), QColor(250, 150, 200))
def testQgsPointPatternFillSymbolLayer(self): """ Test point pattern fill """ mSymbolLayer = QgsPointPatternFillSymbolLayer.create() ctx = QgsRenderContext() self.assertCountEqual(mSymbolLayer.usedAttributes(ctx), {}) # test colors, need to make sure colors are passed/retrieved from subsymbol mSymbolLayer.setColor(QColor(150, 50, 100)) self.assertEqual(mSymbolLayer.color(), QColor(150, 50, 100)) self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(150, 50, 100)) mSymbolLayer.subSymbol().setColor(QColor(250, 150, 200)) self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(250, 150, 200)) self.assertEqual(mSymbolLayer.color(), QColor(250, 150, 200))
def __getQgsPolygonSymbolLayer(self, msstyle): props = {} type_marker = '' symbol = msstyle.get('symbol', False) if symbol: (type_marker, symbolname, msSymbol, props) = self.__getMsSymbol(symbol, props, True) opacity = self.__getMsOpacity(msstyle) color = self.__getMsColor(msstyle, props, opacity) self.__getMsOutlinecolor(msstyle, props, opacity) self.__getMsLinecap(msstyle, props) self.__getMsLinejoin(msstyle, props) self.__getMsPattern(msstyle, props) self.__getMsWidth(msstyle, props) self.__getMsOutline(msstyle, props) self.__getMsScale(msstyle, props) offset = self.__getMsOffset(msstyle, props) if not type_marker: #-linea sencilla exterior-# #-relleno simple (sin estilo de relleno preconfigurados)-# if not color: self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER) qgsSymbol = QgsSimpleLineSymbolLayerV2.create(props) else: self.deleteProperties(props, _qgis.SIMPLE_FILL_SYMBOL_LAYER) qgsSymbol = QgsSimpleFillSymbolLayerV2.create(props) #-relleno de gradientes-# #el gradiente es para renderer por categorias continuas #no aplica, porque aca es para gradiente de un simbolo else: props_parent = {} self.__setMsOffsetXY(offset, props) self.__getMsAngle(msstyle, props, props_parent) gap = self.__getMsGap(msstyle) size = self.__getMsSize(msstyle, props) self.__getMarkerDisplacementAndRotate(msstyle, gap, size, props_parent) geomtransform = msstyle.get('geomtransform', '').lower() if geomtransform == 'centroid': #-relleno de centroides-# self.__getMsAnchorpoint(msSymbol, props) qgsSubSymbol = self.__getQgsMarkerSubSymbol( type_marker, msSymbol, size, props) #self.deleteProperties(props_parent, _qgis.CENTROID_FILL_SYMBOL_LAYER) qgsSymbol = QgsCentroidFillSymbolLayerV2.create({}) qgsSymbol.setSubSymbol(qgsSubSymbol) elif not color: #-Linea exterior:linea de marcador-# self.__getMsAnchorpoint(msSymbol, props) qgsSubSymbol = self.__getQgsMarkerSubSymbol( type_marker, msSymbol, size, props) self.deleteProperties(props_parent, _qgis.MARKER_LINE_SYMBOL_LAYER) qgsSymbol = QgsMarkerLineSymbolLayerV2.create(props_parent) qgsSymbol.setSubSymbol(qgsSubSymbol) elif type_marker == _ms.MS_SYMBOL_HATCH: if not props['use_custom_dash']: #-relleno simple (con estilo de relleno)-# self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER) qgsSymbol = QgsSimpleLineSymbolLayerV2.create(props) else: #-Patron de relleno de linea-# self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER) qgsSubSymbol = self.__getSubSymbol( QgsLineSymbolV2, QgsSimpleLineSymbolLayerV2, QGis.Line, props) self.deleteProperties(props_parent, _qgis.LINE_PATTERN_FILL_SYMBOL_LAYER) qgsSymbol = QgsLinePatternFillSymbolLayer.create( props_parent) qgsSymbol.setSubSymbol(qgsSubSymbol) elif type_marker == _ms.MS_SYMBOL_PIXMAP: #-relleno de imagen raster-# self.deleteProperties(props, _qgis.RASTER_FILL_SYMBOL_LAYER) qgsSymbol = QgsRasterFillSymbolLayer.create(props) elif type_marker == _ms.MS_SYMBOL_SVG: #-relleno SVG-# self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER) qgsSubSymbol = self.__getSubSymbol(QgsLineSymbolV2, QgsSimpleLineSymbolLayerV2, QGis.Line, props) self.deleteProperties(props_parent, _qgis.SVG_FILL_SYMBOL_LAYER) qgsSymbol = QgsSVGFillSymbolLayer.create(props_parent) qgsSymbol.setSubSymbol(qgsSubSymbol) else: #-patron de relleno de puntos-# self.__getMsAnchorpoint(msSymbol, props) qgsSubSymbol = self.__getQgsMarkerSubSymbol( type_marker, msSymbol, size, props) self.deleteProperties(props_parent, _qgis.POINT_PATTERN_FILL_SYMBOL_LAYER) qgsSymbol = QgsPointPatternFillSymbolLayer.create(props_parent) qgsSymbol.setSubSymbol(qgsSubSymbol) #qgsSymbol.setAlpha((opacity*1.0)/100) #print(props) return qgsSymbol