void QgsSymbolV2PropertiesDialog::lockLayer() { QgsSymbolLayerV2* layer = currentLayer(); if ( layer == NULL ) return; layer->setLocked( btnLock->isChecked() ); }
void QgsSymbolV2PropertiesDialog::updateLockButton() { QgsSymbolLayerV2* layer = currentLayer(); if ( layer == NULL ) return; btnLock->setChecked( layer->isLocked() ); }
void QgsSymbolV2PropertiesDialog::layerTypeChanged() { QgsSymbolLayerV2* layer = currentLayer(); if ( layer == NULL ) return; QString newLayerType = cboLayerType->itemData( cboLayerType->currentIndex() ).toString(); if ( layer->layerType() == newLayerType ) return; // get creation function for new layer from registry QgsSymbolLayerV2Registry* pReg = QgsSymbolLayerV2Registry::instance(); QgsSymbolLayerV2AbstractMetadata* am = pReg->symbolLayerMetadata( newLayerType ); if ( am == NULL ) // check whether the metadata is assigned return; // change layer to a new (with different type) QgsSymbolLayerV2* newLayer = am->createSymbolLayer( QgsStringMap() ); if ( newLayer == NULL ) return; mSymbol->changeSymbolLayer( currentLayerIndex(), newLayer ); updateSymbolLayerWidget( newLayer ); // update symbol layer item SymbolLayerItem* item = currentLayerItem(); item->setLayer( newLayer ); item->updatePreview(); updatePreview(); }
void QgsSymbolLevelsV2Dialog::populateTable() { for ( int row = 0; row < mList.count(); row++ ) { QgsSymbolV2* sym = mList[row].second; QString label = mList[row].first; QTableWidgetItem *itemLabel = new QTableWidgetItem( label ); itemLabel->setFlags( itemLabel->flags() ^ Qt::ItemIsEditable ); tableLevels->setItem( row, 0, itemLabel ); for ( int layer = 0; layer < mMaxLayers; layer++ ) { QTableWidgetItem* item; if ( layer >= sym->symbolLayerCount() ) { item = new QTableWidgetItem(); item->setFlags( Qt::ItemFlags() ); } else { QgsSymbolLayerV2* sl = sym->symbolLayer( layer ); QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( sl, QgsSymbolV2::MM, QSize( 16, 16 ) ); item = new QTableWidgetItem( icon, QString::number( sl->renderingPass() ) ); } tableLevels->setItem( row, layer + 1, item ); tableLevels->resizeColumnToContents( 0 ); } } }
QgsSymbolLayerV2* QgsVectorFieldSymbolLayer::clone() const { QgsSymbolLayerV2* clonedLayer = QgsVectorFieldSymbolLayer::create( properties() ); if ( mLineSymbol ) { clonedLayer->setSubSymbol( mLineSymbol->clone() ); } return clonedLayer; }
QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::clone() const { QgsSymbolLayerV2* clonedLayer = QgsLinePatternFillSymbolLayer::create( properties() ); if ( mOutline ) { clonedLayer->setSubSymbol( mOutline->clone() ); } return clonedLayer; }
QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::clone() const { QgsSymbolLayerV2* clonedLayer = QgsPointPatternFillSymbolLayer::create( properties() ); if ( mMarkerSymbol ) { clonedLayer->setSubSymbol( mMarkerSymbol->clone() ); } return clonedLayer; }
QgsSymbolLayerV2List QgsSymbolV2::cloneLayers() const { QgsSymbolLayerV2List lst; for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { QgsSymbolLayerV2* layer = ( *it )->clone(); layer->setLocked(( *it )->isLocked() ); layer->setRenderingPass(( *it )->renderingPass() ); lst.append( layer ); } return lst; }
Qgs25DRenderer::Qgs25DRenderer() : QgsFeatureRendererV2( "25dRenderer" ) { mSymbol.reset( new QgsFillSymbolV2() ); mSymbol->deleteSymbolLayer( 0 ); // We never asked for the default layer QgsSymbolLayerV2* floor = QgsSimpleFillSymbolLayerV2::create(); QgsStringMap wallProperties; wallProperties.insert( "geometryModifier", WALL_EXPRESSION ); wallProperties.insert( "symbolType", "Fill" ); QgsSymbolLayerV2* walls = QgsGeometryGeneratorSymbolLayerV2::create( wallProperties ); QgsStringMap roofProperties; roofProperties.insert( "geometryModifier", ROOF_EXPRESSION ); roofProperties.insert( "symbolType", "Fill" ); QgsSymbolLayerV2* roof = QgsGeometryGeneratorSymbolLayerV2::create( roofProperties ); floor->setLocked( true ); mSymbol->appendSymbolLayer( floor ); mSymbol->appendSymbolLayer( walls ); mSymbol->appendSymbolLayer( roof ); QgsEffectStack* effectStack = new QgsEffectStack(); QgsOuterGlowEffect* glowEffect = new QgsOuterGlowEffect(); glowEffect->setBlurLevel( 5 ); glowEffect->setSpreadUnit( QgsSymbolV2::MapUnit ); effectStack->appendEffect( glowEffect ); floor->setPaintEffect( effectStack ); // These methods must only be used after the above initialization! setRoofColor( QColor( "#b1a97c" ) ); setWallColor( QColor( "#777777" ) ); wallLayer()->setDataDefinedProperty( "color", new QgsDataDefined( QString( WALL_SHADING_EXPRESSION ) ) ); setShadowSpread( 4 ); setShadowColor( QColor( "#111111" ) ); QgsFeatureRequest::OrderBy orderBy; orderBy << QgsFeatureRequest::OrderByClause( ORDER_BY_EXPRESSION, false ); setOrderBy( orderBy ); setOrderByEnabled( true ); }
void QgsSymbolV2PropertiesDialog::layerChanged() { updateUi(); // get layer info QgsSymbolLayerV2* layer = currentLayer(); if ( layer == NULL ) return; // update layer type combo box int idx = cboLayerType->findData( layer->layerType() ); cboLayerType->setCurrentIndex( idx ); updateSymbolLayerWidget( layer ); updateLockButton(); }
QgsSymbolLayerV2* QgsSVGFillSymbolLayer::clone() const { QgsSymbolLayerV2* clonedLayer = 0; if ( !mSvgFilePath.isEmpty() ) { clonedLayer = new QgsSVGFillSymbolLayer( mSvgFilePath, mPatternWidth, mAngle ); QgsSVGFillSymbolLayer* sl = static_cast<QgsSVGFillSymbolLayer*>( clonedLayer ); sl->setSvgFillColor( mSvgFillColor ); sl->setSvgOutlineColor( mSvgOutlineColor ); sl->setSvgOutlineWidth( mSvgOutlineWidth ); } else { clonedLayer = new QgsSVGFillSymbolLayer( mSvgData, mPatternWidth, mAngle ); } if ( mOutline ) { clonedLayer->setSubSymbol( mOutline->clone() ); } return clonedLayer; }
void QgsLayerPropertiesWidget::layerTypeChanged() { QgsSymbolLayerV2* layer = mLayer; if ( !layer ) return; QString newLayerType = cboLayerType->itemData( cboLayerType->currentIndex() ).toString(); if ( layer->layerType() == newLayerType ) return; // get creation function for new layer from registry QgsSymbolLayerV2Registry* pReg = QgsSymbolLayerV2Registry::instance(); QgsSymbolLayerV2AbstractMetadata* am = pReg->symbolLayerMetadata( newLayerType ); if ( am == NULL ) // check whether the metadata is assigned return; // change layer to a new (with different type) QgsSymbolLayerV2* newLayer = am->createSymbolLayer( QgsStringMap() ); if ( newLayer == NULL ) return; updateSymbolLayerWidget( newLayer ); emit changeLayer( newLayer ); }
void QgsSymbolLevelsV2Dialog::populateTable() { for ( int row = 0; row < mList.count(); row++ ) { QgsSymbolV2* sym = mList[row].second; for ( int layer = 0; layer < mMaxLayers; layer++ ) { QTableWidgetItem* item; if ( layer >= sym->symbolLayerCount() ) { item = new QTableWidgetItem(); item->setFlags( Qt::ItemFlags() ); } else { QgsSymbolLayerV2* sl = sym->symbolLayer( layer ); QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( sl, QgsSymbolV2::MM, QSize( 16, 16 ) ); item = new QTableWidgetItem( icon, QString::number( sl->renderingPass() ) ); } tableLevels->setItem( row, layer, item ); } } }
void QgsPointPatternFillSymbolLayer::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const { for ( int i = 0; i < mMarkerSymbol->symbolLayerCount(); i++ ) { QDomElement symbolizerElem = doc.createElement( "se:PolygonSymbolizer" ); if ( !props.value( "uom", "" ).isEmpty() ) symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) ); element.appendChild( symbolizerElem ); // <Geometry> QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) ); QDomElement fillElem = doc.createElement( "se:Fill" ); symbolizerElem.appendChild( fillElem ); QDomElement graphicFillElem = doc.createElement( "se:GraphicFill" ); fillElem.appendChild( graphicFillElem ); // store distanceX, distanceY, displacementX, displacementY in a <VendorOption> QString dist = QgsSymbolLayerV2Utils::encodePoint( QPointF( mDistanceX, mDistanceY ) ); QDomElement distanceElem = QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "distance", dist ); symbolizerElem.appendChild( distanceElem ); QgsSymbolLayerV2 *layer = mMarkerSymbol->symbolLayer( i ); QgsMarkerSymbolLayerV2 *markerLayer = static_cast<QgsMarkerSymbolLayerV2 *>( layer ); if ( !markerLayer ) { QString errorMsg = QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->layerType() ); graphicFillElem.appendChild( doc.createComment( errorMsg ) ); } else { markerLayer->writeSldMarker( doc, graphicFillElem, props ); } } }
void QgsMarkerLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const { for ( int i = 0; i < mMarker->symbolLayerCount(); i++ ) { QDomElement symbolizerElem = doc.createElement( "se:LineSymbolizer" ); if ( !props.value( "uom", "" ).isEmpty() ) symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) ); element.appendChild( symbolizerElem ); // <Geometry> QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) ); QString gap; switch ( mPlacement ) { case FirstVertex: symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "firstPoint" ) ); break; case LastVertex: symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "lastPoint" ) ); break; case CentralPoint: symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "centralPoint" ) ); break; case Vertex: // no way to get line/polygon's vertices, use a VendorOption symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "points" ) ); break; default: gap = QString::number( mInterval ); break; } if ( !mRotateMarker ) { // markers in LineSymbolizer must be drawn following the line orientation, // use a VendorOption when no marker rotation symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "rotateMarker", "0" ) ); } // <Stroke> QDomElement strokeElem = doc.createElement( "se:Stroke" ); symbolizerElem.appendChild( strokeElem ); // <GraphicStroke> QDomElement graphicStrokeElem = doc.createElement( "se:GraphicStroke" ); strokeElem.appendChild( graphicStrokeElem ); QgsSymbolLayerV2 *layer = mMarker->symbolLayer( i ); QgsMarkerSymbolLayerV2 *markerLayer = static_cast<QgsMarkerSymbolLayerV2 *>( layer ); if ( !markerLayer ) { graphicStrokeElem.appendChild( doc.createComment( QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->layerType() ) ) ); } else { markerLayer->writeSldMarker( doc, graphicStrokeElem, props ); } if ( !gap.isEmpty() ) { QDomElement gapElem = doc.createElement( "se:Gap" ); QgsSymbolLayerV2Utils::createFunctionElement( doc, gapElem, gap ); graphicStrokeElem.appendChild( gapElem ); } if ( !qgsDoubleNear( mOffset, 0.0 ) ) { QDomElement perpOffsetElem = doc.createElement( "se:PerpendicularOffset" ); perpOffsetElem.appendChild( doc.createTextNode( QString::number( mOffset ) ) ); symbolizerElem.appendChild( perpOffsetElem ); } } }
QgsSymbol* QgsSymbologyV2Conversion::symbolV2toV1( QgsSymbolV2* s ) { if ( s == NULL || s->symbolLayerCount() == 0 ) return NULL; // we will use only the first symbol layer QgsSymbolLayerV2* sl = s->symbolLayer( 0 ); switch ( sl->type() ) { case QgsSymbolV2::Marker: { QgsMarkerSymbolLayerV2* msl = static_cast<QgsMarkerSymbolLayerV2*>( sl ); QgsSymbol* sOld = new QgsSymbol( QGis::Point ); sOld->setFillColor( sl->color() ); sOld->setFillStyle( Qt::SolidPattern ); sOld->setPointSize( msl->size() ); if ( sl->layerType() == "SimpleMarker" ) { QgsSimpleMarkerSymbolLayerV2* smsl = static_cast<QgsSimpleMarkerSymbolLayerV2*>( sl ); sOld->setColor( smsl->borderColor() ); sOld->setNamedPointSymbol( "hard:" + smsl->name() ); } else if ( sl->layerType() == "SvgMarker" ) { QgsSvgMarkerSymbolLayerV2* smsl = static_cast<QgsSvgMarkerSymbolLayerV2*>( sl ); sOld->setNamedPointSymbol( "svg:" + smsl->path() ); } return sOld; } break; case QgsSymbolV2::Line: { QgsLineSymbolLayerV2* lsl = static_cast<QgsLineSymbolLayerV2*>( sl ); QgsSymbol* sOld = new QgsSymbol( QGis::Line ); sOld->setColor( sl->color() ); sOld->setLineWidth( lsl->width() ); if ( sl->layerType() == "SimpleLine" ) { // add specific settings QgsSimpleLineSymbolLayerV2* slsl = static_cast<QgsSimpleLineSymbolLayerV2*>( sl ); sOld->setLineStyle( slsl->penStyle() ); } return sOld; } case QgsSymbolV2::Fill: { QgsSymbol* sOld = new QgsSymbol( QGis::Polygon ); sOld->setFillColor( sl->color() ); if ( sl->layerType() == "SimpleFill" ) { // add specifc settings QgsSimpleFillSymbolLayerV2* sfsl = static_cast<QgsSimpleFillSymbolLayerV2*>( sl ); sOld->setColor( sfsl->borderColor() ); sOld->setLineWidth( sfsl->borderWidth() ); sOld->setLineStyle( sfsl->borderStyle() ); sOld->setFillStyle( sfsl->brushStyle() ); } return sOld; } } return NULL; // should never get here }