| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,331 @@ | ||
| #include "qgsellipsesymbollayerv2.h" | ||
| #include "qgsfeature.h" | ||
| #include "qgsrendercontext.h" | ||
| #include <QPainter> | ||
| #include <QSet> | ||
|
|
||
| QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2(): mSymbolName( "circle" ), mSymbolWidth( 4 ), mSymbolHeight( 3 ), | ||
| mFillColor( Qt::black ), mOutlineColor( Qt::white ), mOutlineWidth( 0 ) | ||
| { | ||
| mPen.setColor( mOutlineColor ); | ||
| mPen.setWidth( 1.0 ); | ||
| mPen.setJoinStyle( Qt::MiterJoin ); | ||
| mBrush.setColor( mFillColor ); | ||
| mBrush.setStyle( Qt::SolidPattern ); | ||
|
|
||
| mAngle = 0; | ||
| mWidthField.first = -1; | ||
| mHeightField.first = -1; | ||
| mRotationField.first = -1; | ||
| mOutlineWidthField.first = -1; | ||
| mFillColorField.first = -1; | ||
| mOutlineColorField.first = -1; | ||
| mSymbolNameField.first = -1; | ||
| } | ||
|
|
||
| QgsEllipseSymbolLayerV2::~QgsEllipseSymbolLayerV2() | ||
| { | ||
| } | ||
|
|
||
| QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& properties ) | ||
| { | ||
| QgsEllipseSymbolLayerV2* layer = new QgsEllipseSymbolLayerV2(); | ||
| if ( properties.contains( "symbol_name" ) ) | ||
| { | ||
| layer->setSymbolName( properties[ "symbol_name" ] ); | ||
| } | ||
| if ( properties.contains( "symbol_width" ) ) | ||
| { | ||
| layer->setSymbolWidth( properties["symbol_width"].toDouble() ); | ||
| } | ||
| if ( properties.contains( "symbol_height" ) ) | ||
| { | ||
| layer->setSymbolHeight( properties["symbol_height"].toDouble() ); | ||
| } | ||
| if ( properties.contains( "angle" ) ) | ||
| { | ||
| layer->setAngle( properties["angle"].toDouble() ); | ||
| } | ||
| if ( properties.contains( "outline_width" ) ) | ||
| { | ||
| layer->setOutlineWidth( properties["outline_width"].toDouble() ); | ||
| } | ||
| if ( properties.contains( "fill_color" ) ) | ||
| { | ||
| layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) ); | ||
| } | ||
| if ( properties.contains( "outline_color" ) ) | ||
| { | ||
| layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) ); | ||
| } | ||
|
|
||
| //data defined properties | ||
| if ( properties.contains( "height_index" ) && properties.contains( "height_field" ) ) | ||
| { | ||
| layer->setHeightField( properties["height_index"].toInt(), properties["height_field"] ); | ||
| } | ||
| if ( properties.contains( "width_index" ) && properties.contains( "width_field" ) ) | ||
| { | ||
| layer->setWidthField( properties["width_index"].toInt(), properties["width_field"] ); | ||
| } | ||
| if ( properties.contains( "rotation_index" ) && properties.contains( "rotation_field" ) ) | ||
| { | ||
| layer->setRotationField( properties["rotation_index"].toInt(), properties["rotation_field"] ); | ||
| } | ||
| if ( properties.contains( "outline_width_index" ) && properties.contains( "outline_width_field" ) ) | ||
| { | ||
| layer->setOutlineWidthField( properties["outline_width_index"].toInt(), properties["outline_width_field"] ); | ||
| } | ||
| if ( properties.contains( "fill_color_index" ) && properties.contains( "fill_color_field" ) ) | ||
| { | ||
| layer->setFillColorField( properties["fill_color_index"].toInt(), properties["fill_color_field"] ); | ||
| } | ||
| if ( properties.contains( "outline_color_index" ) && properties.contains( "outline_color_field" ) ) | ||
| { | ||
| layer->setOutlineColorField( properties["outline_color_index"].toInt(), properties["outline_color_field"] ); | ||
| } | ||
| if ( properties.contains( "symbol_name_index" ) && properties.contains( "symbol_name_field" ) ) | ||
| { | ||
| layer->setSymbolNameField( properties["symbol_name_index"].toInt(), properties["symbol_name_field"] ); | ||
| } | ||
|
|
||
| return layer; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) | ||
| { | ||
| const QgsFeature* f = context.feature(); | ||
|
|
||
| if ( f ) | ||
| { | ||
| if ( mOutlineWidthField.first != -1 ) | ||
| { | ||
| double width = context.outputLineWidth( f->attributeMap()[mOutlineWidthField.first].toDouble() ); | ||
| mPen.setWidth( width ); | ||
| } | ||
| if ( mFillColorField.first != -1 ) | ||
| { | ||
| mBrush.setColor( QColor( f->attributeMap()[mFillColorField.first].toString() ) ); | ||
| } | ||
| if ( mOutlineColorField.first != -1 ) | ||
| { | ||
| mPen.setColor( QColor( f->attributeMap()[mOutlineColorField.first].toString() ) ); | ||
| } | ||
|
|
||
| if ( mWidthField.first != -1 || mHeightField.first != -1 || mSymbolNameField.first != -1 ) | ||
| { | ||
| QString symbolName = ( mSymbolNameField.first == -1 ) ? mSymbolName : f->attributeMap()[mSymbolNameField.first].toString(); | ||
| preparePath( symbolName, context, f ); | ||
| } | ||
| } | ||
|
|
||
| QPainter* p = context.renderContext().painter(); | ||
| if ( !p ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| //priority for rotation: 1. data defined, 2. symbol layer rotation (mAngle) | ||
| double rotation = 0.0; | ||
| if ( f && mRotationField.first != -1 ) | ||
| { | ||
| rotation = f->attributeMap()[mRotationField.first].toDouble(); | ||
| } | ||
| else if ( !doubleNear( mAngle, 0.0 ) ) | ||
| { | ||
| rotation = mAngle; | ||
| } | ||
|
|
||
| QMatrix transform; | ||
| transform.translate( point.x(), point.y() ); | ||
| if ( !doubleNear( rotation, 0.0 ) ) | ||
| { | ||
| transform.rotate( rotation ); | ||
| } | ||
|
|
||
| p->setPen( mPen ); | ||
| p->setBrush( mBrush ); | ||
| p->drawPath( transform.map( mPainterPath ) ); | ||
| } | ||
|
|
||
| QString QgsEllipseSymbolLayerV2::layerType() const | ||
| { | ||
| return "EllipseMarker"; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context ) | ||
| { | ||
| if ( !context.feature() || !hasDataDefinedProperty() ) | ||
| { | ||
| preparePath( mSymbolName, context ); | ||
| } | ||
| mPen.setColor( mOutlineColor ); | ||
| mPen.setWidth( context.outputLineWidth( mOutlineWidth ) ); | ||
| mBrush.setColor( mFillColor ); | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context ) | ||
| { | ||
| } | ||
|
|
||
| QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::clone() const | ||
| { | ||
| return QgsEllipseSymbolLayerV2::create( properties() ); | ||
| } | ||
|
|
||
| QgsStringMap QgsEllipseSymbolLayerV2::properties() const | ||
| { | ||
| QgsStringMap map; | ||
| map["symbol_name"] = mSymbolName; | ||
| map["symbol_width"] = QString::number( mSymbolWidth ); | ||
| map["width_index"] = QString::number( mWidthField.first ); | ||
| map["width_field"] = mWidthField.second; | ||
| map["symbol_height"] = QString::number( mSymbolHeight ); | ||
| map["height_index"] = QString::number( mHeightField.first ); | ||
| map["height_field"] = mHeightField.second; | ||
| map["angle"] = QString::number( mAngle ); | ||
| map["rotation_index"] = QString::number( mRotationField.first ); | ||
| map["rotation_field"] = mRotationField.second; | ||
| map["outline_width"] = QString::number( mOutlineWidth ); | ||
| map["outline_width_index"] = QString::number( mOutlineWidthField.first ); | ||
| map["outline_width_field"] = mOutlineWidthField.second; | ||
| map["fill_color"] = QgsSymbolLayerV2Utils::encodeColor( mFillColor ); | ||
| map["fill_color_index"] = QString::number( mFillColorField.first ); | ||
| map["fill_color_field"] = mFillColorField.second; | ||
| map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ); | ||
| map["outline_color_index"] = QString::number( mOutlineColorField.first ); | ||
| map["outline_color_field"] = mOutlineColorField.second; | ||
| map["symbol_name_index"] = QString::number( mSymbolNameField.first ); | ||
| map["symbol_name_field"] = mSymbolNameField.second; | ||
| return map; | ||
| } | ||
|
|
||
| bool QgsEllipseSymbolLayerV2::hasDataDefinedProperty() const | ||
| { | ||
| return ( mWidthField.first != -1 || mHeightField.first != -1 || mOutlineWidthField.first != -1 | ||
| || mFillColorField.first != -1 || mOutlineColorField.first != -1 ); | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, const QgsFeature* f ) | ||
| { | ||
| mPainterPath = QPainterPath(); | ||
|
|
||
| double width = 0; | ||
| if ( f && mWidthField.first != -1 ) | ||
| { | ||
| width = context.outputLineWidth( f->attributeMap()[mWidthField.first].toDouble() ); | ||
| } | ||
| else | ||
| { | ||
| width = context.outputLineWidth( mSymbolWidth ); | ||
| } | ||
|
|
||
| double height = 0; | ||
| if ( f && mHeightField.first != -1 ) | ||
| { | ||
| height = context.outputLineWidth( f->attributeMap()[mHeightField.first].toDouble() ); | ||
| } | ||
| else | ||
| { | ||
| height = context.outputLineWidth( mSymbolHeight ); | ||
| } | ||
|
|
||
| if ( symbolName == "circle" ) | ||
| { | ||
| mPainterPath.addEllipse( QRectF( -width / 2.0, -height / 2.0, width, height ) ); | ||
| } | ||
| else if ( symbolName == "rectangle" ) | ||
| { | ||
| mPainterPath.addRect( QRectF( -width / 2.0, -height / 2.0, width, height ) ); | ||
| } | ||
| else if ( symbolName == "cross" ) | ||
| { | ||
| mPainterPath.moveTo( 0, -height / 2.0 ); | ||
| mPainterPath.lineTo( 0, height / 2.0 ); | ||
| mPainterPath.moveTo( -width / 2.0, 0 ); | ||
| mPainterPath.lineTo( width / 2.0, 0 ); | ||
| } | ||
| else if ( symbolName == "triangle" ) | ||
| { | ||
| mPainterPath.moveTo( 0, -height / 2.0 ); | ||
| mPainterPath.lineTo( -width / 2.0, height / 2.0 ); | ||
| mPainterPath.lineTo( width / 2.0, height / 2.0 ); | ||
| mPainterPath.lineTo( 0, -height / 2.0 ); | ||
| } | ||
| } | ||
|
|
||
| QSet<QString> QgsEllipseSymbolLayerV2::usedAttributes() const | ||
| { | ||
| QSet<QString> dataDefinedAttributes; | ||
| if ( mWidthField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mWidthField.second ); | ||
| } | ||
| if ( mHeightField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mHeightField.second ); | ||
| } | ||
| if ( mRotationField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mRotationField.second ); | ||
| } | ||
| if ( mOutlineWidthField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mOutlineWidthField.second ); | ||
| } | ||
| if ( mFillColorField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mFillColorField.second ); | ||
| } | ||
| if ( mOutlineColorField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mOutlineColorField.second ); | ||
| } | ||
| if ( mSymbolNameField.first != -1 ) | ||
| { | ||
| dataDefinedAttributes.insert( mSymbolNameField.second ); | ||
| } | ||
| return dataDefinedAttributes; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setSymbolNameField( int index, const QString& field ) | ||
| { | ||
| mSymbolNameField.first = index; | ||
| mSymbolNameField.second = field; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setWidthField( int index, const QString& field ) | ||
| { | ||
| mWidthField.first = index; | ||
| mWidthField.second = field; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setHeightField( int index, const QString& field ) | ||
| { | ||
| mHeightField.first = index; | ||
| mHeightField.second = field; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setRotationField( int index, const QString& field ) | ||
| { | ||
| mRotationField.first = index; | ||
| mRotationField.second = field; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setOutlineWidthField( int index, const QString& field ) | ||
| { | ||
| mOutlineWidthField.first = index; | ||
| mOutlineWidthField.second = field; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setFillColorField( int index, const QString& field ) | ||
| { | ||
| mFillColorField.first = index; | ||
| mFillColorField.second = field; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2::setOutlineColorField( int index, const QString& field ) | ||
| { | ||
| mOutlineColorField.first = index; | ||
| mOutlineColorField.second = field; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #ifndef QGSELLIPSESYMBOLLAYERV2_H | ||
| #define QGSELLIPSESYMBOLLAYERV2_H | ||
|
|
||
| #include "qgsmarkersymbollayerv2.h" | ||
| #include <QPainterPath> | ||
|
|
||
| /**A symbol layer for rendering objects with major and minor axis (e.g. ellipse, rectangle )*/ | ||
| class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2 | ||
| { | ||
| public: | ||
| QgsEllipseSymbolLayerV2(); | ||
| ~QgsEllipseSymbolLayerV2(); | ||
|
|
||
| static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); | ||
|
|
||
| void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ); | ||
| QString layerType() const; | ||
| void startRender( QgsSymbolV2RenderContext& context ); | ||
| void stopRender( QgsSymbolV2RenderContext& context ); | ||
| QgsSymbolLayerV2* clone() const; | ||
| QgsStringMap properties() const; | ||
|
|
||
| void setSymbolName( const QString& name ){ mSymbolName = name; } | ||
| QString symbolName() const{ return mSymbolName; } | ||
|
|
||
| void setSymbolNameField( int index, const QString& field ); | ||
| const QPair<int, QString>& symbolNameField() const { return mSymbolNameField; } | ||
|
|
||
| void setSymbolWidth( double w ){ mSymbolWidth = w; } | ||
| double symbolWidth() const { return mSymbolWidth; } | ||
|
|
||
| void setWidthField( int index, const QString& field ); | ||
| const QPair<int, QString>& widthField() const { return mWidthField; } | ||
|
|
||
| void setSymbolHeight( double h ){ mSymbolHeight = h; } | ||
| double symbolHeight() const { return mSymbolHeight; } | ||
|
|
||
| void setHeightField( int index, const QString& field ); | ||
| const QPair<int, QString>& heightField() const { return mHeightField; } | ||
|
|
||
| void setRotationField( int index, const QString& field ); | ||
| const QPair<int, QString>& rotationField() const { return mRotationField; } | ||
|
|
||
| void setOutlineWidth( double w ){ mOutlineWidth = w; } | ||
| double outlineWidth() const { return mOutlineWidth; } | ||
|
|
||
| void setOutlineWidthField( int index, const QString& field ); | ||
| const QPair<int, QString>& outlineWidthField() const { return mOutlineWidthField; } | ||
|
|
||
| void setFillColor( const QColor& c ){ mFillColor = c;} | ||
| QColor fillColor() const { return mFillColor; } | ||
|
|
||
| void setFillColorField( int index, const QString& field ); | ||
| const QPair<int, QString>& fillColorField() const { return mFillColorField; } | ||
|
|
||
| void setOutlineColor( const QColor& c ){ mOutlineColor = c; } | ||
| QColor outlineColor() const { return mOutlineColor; } | ||
|
|
||
| void setOutlineColorField( int index, const QString& field ); | ||
| const QPair<int, QString>& outlineColorField() const { return mOutlineColorField; } | ||
|
|
||
| QSet<QString> usedAttributes() const; | ||
|
|
||
| private: | ||
| QString mSymbolName; | ||
| double mSymbolWidth; | ||
| double mSymbolHeight; | ||
| QColor mFillColor; | ||
| QColor mOutlineColor; | ||
| double mOutlineWidth; | ||
|
|
||
| /**Take width from attribute (-1 if fixed width)*/ | ||
| QPair<int, QString> mWidthField; | ||
| /**Take height from attribute (-1 if fixed height)*/ | ||
| QPair<int, QString> mHeightField; | ||
| /**Take symbol rotation from attribute (-1 if fixed rotation)*/ | ||
| QPair<int, QString> mRotationField; | ||
| /**Take outline width from attribute (-1 if fixed outline width)*/ | ||
| QPair<int, QString> mOutlineWidthField; | ||
| /**Take fill color from attribute (-1 if fixed fill color)*/ | ||
| QPair<int, QString> mFillColorField; | ||
| /**Take outline color from attribute (-1 if fixed outline color)*/ | ||
| QPair<int, QString> mOutlineColorField; | ||
| /**Take shape name from attribute (-1 if fixed shape type)*/ | ||
| QPair<int, QString> mSymbolNameField; | ||
|
|
||
| QPainterPath mPainterPath; | ||
|
|
||
| QPen mPen; | ||
| QBrush mBrush; | ||
|
|
||
| /**Setup mPainterPath | ||
| @param feature to render (0 if no data defined rendering)*/ | ||
| void preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, const QgsFeature* f = 0 ); | ||
|
|
||
| /**True if this symbol layer uses a data defined property*/ | ||
| bool hasDataDefinedProperty() const; | ||
| }; | ||
|
|
||
| #endif // QGSELLIPSESYMBOLLAYERV2_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,278 @@ | ||
| #include "qgsellipsesymbollayerv2widget.h" | ||
| #include "qgsellipsesymbollayerv2.h" | ||
| #include "qgsmaplayerregistry.h" | ||
| #include "qgsvectorlayer.h" | ||
| #include <QColorDialog> | ||
|
|
||
| QgsEllipseSymbolLayerV2Widget::QgsEllipseSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent ): QgsSymbolLayerV2Widget( parent, vl ) | ||
| { | ||
| setupUi( this ); | ||
| QStringList names; | ||
| names << "circle" << "rectangle" << "cross" << "triangle"; | ||
| QSize iconSize = mShapeListWidget->iconSize(); | ||
|
|
||
| QStringList::const_iterator nameIt = names.constBegin(); | ||
| for(; nameIt != names.constEnd(); ++nameIt ) | ||
| { | ||
| QgsEllipseSymbolLayerV2* lyr = new QgsEllipseSymbolLayerV2(); | ||
| lyr->setSymbolName( *nameIt ); | ||
| lyr->setOutlineColor( QColor( 0, 0, 0 ) ); | ||
| lyr->setFillColor( QColor( 200, 200, 200 ) ); | ||
| lyr->setSymbolWidth(4); | ||
| lyr->setSymbolHeight(2); | ||
| QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( lyr, QgsSymbolV2::MM, iconSize ); | ||
| QListWidgetItem* item = new QListWidgetItem( icon, "", mShapeListWidget ); | ||
| item->setToolTip( *nameIt ); | ||
| item->setData( Qt::UserRole, *nameIt ); | ||
| delete lyr; | ||
| } | ||
|
|
||
| blockComboSignals( true ); | ||
| fillDataDefinedComboBoxes(); | ||
| blockComboSignals( false ); | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer ) | ||
| { | ||
| if( layer->layerType() != "EllipseMarker" ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| mLayer = static_cast<QgsEllipseSymbolLayerV2*>( layer ); | ||
| mWidthSpinBox->setValue( mLayer->symbolWidth() ); | ||
| mHeightSpinBox->setValue( mLayer->symbolHeight() ); | ||
| mRotationSpinBox->setValue( mLayer->angle() ); | ||
| mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() ); | ||
|
|
||
| QList<QListWidgetItem *> symbolItemList = mShapeListWidget->findItems( mLayer->symbolName(), Qt::MatchExactly ); | ||
| if( symbolItemList.size() > 0 ) | ||
| { | ||
| mShapeListWidget->setCurrentItem( symbolItemList.at( 0 ) ); | ||
| } | ||
|
|
||
| //set combo entries to current values | ||
| blockComboSignals( true ); | ||
| if( mLayer ) | ||
| { | ||
| if( mLayer->widthField().first != -1 ) | ||
| { | ||
| mDDSymbolWidthComboBox->setCurrentIndex( mDDSymbolWidthComboBox->findText( mLayer->widthField().second ) ); | ||
| } | ||
| if( mLayer->heightField().first != -1 ) | ||
| { | ||
| mDDSymbolHeightComboBox->setCurrentIndex( mDDSymbolHeightComboBox->findText( mLayer->heightField().second ) ); | ||
| } | ||
| if( mLayer->rotationField().first != -1 ) | ||
| { | ||
| mDDRotationComboBox->setCurrentIndex( mDDRotationComboBox->findText( mLayer->rotationField().second ) ); | ||
| } | ||
| if( mLayer->outlineWidthField().first != -1 ) | ||
| { | ||
| mDDOutlineWidthComboBox->setCurrentIndex( mDDOutlineWidthComboBox->findText( mLayer->outlineWidthField().second ) ); | ||
| } | ||
| if( mLayer->fillColorField().first != -1 ) | ||
| { | ||
| mDDFillColorComboBox->setCurrentIndex( mDDFillColorComboBox->findText( mLayer->fillColorField().second ) ); | ||
| } | ||
| if( mLayer->outlineColorField().first != -1 ) | ||
| { | ||
| mDDOutlineColorComboBox->setCurrentIndex( mDDOutlineColorComboBox->findText( mLayer->outlineColorField().second ) ); | ||
| } | ||
| if( mLayer->symbolNameField().first != -1 ) | ||
| { | ||
| mDDShapeComboBox->setCurrentIndex( mDDShapeComboBox->findText( mLayer->symbolNameField().second ) ); | ||
| } | ||
| } | ||
| blockComboSignals( false ); | ||
| } | ||
|
|
||
| QgsSymbolLayerV2* QgsEllipseSymbolLayerV2Widget::symbolLayer() | ||
| { | ||
| return mLayer; | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mShapeListWidget_itemSelectionChanged() | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| QListWidgetItem* item = mShapeListWidget->currentItem(); | ||
| if( item ) | ||
| { | ||
| mLayer->setSymbolName( item->data( Qt::UserRole ).toString() ); | ||
| emit changed(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mWidthSpinBox_valueChanged( double d ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setSymbolWidth( d ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mHeightSpinBox_valueChanged( double d ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setSymbolHeight( d ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mRotationSpinBox_valueChanged( double d ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setAngle( d ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mOutlineWidthSpinBox_valueChanged( double d ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setOutlineWidth( d ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_btnChangeColorBorder_clicked() | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| QColor newColor = QColorDialog::getColor( mLayer->outlineColor() ); | ||
| if( newColor.isValid() ) | ||
| { | ||
| mLayer->setOutlineColor( newColor ); | ||
| emit changed(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_btnChangeColorFill_clicked() | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| QColor newColor = QColorDialog::getColor( mLayer->fillColor() ); | ||
| if( newColor.isValid() ) | ||
| { | ||
| mLayer->setFillColor( newColor ); | ||
| emit changed(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::fillDataDefinedComboBoxes() | ||
| { | ||
| mDDSymbolWidthComboBox->clear(); | ||
| mDDSymbolWidthComboBox->addItem( "", -1 ); | ||
| mDDSymbolHeightComboBox->clear(); | ||
| mDDSymbolHeightComboBox->addItem( "", -1 ); | ||
| mDDRotationComboBox->clear(); | ||
| mDDRotationComboBox->addItem( "", -1 ); | ||
| mDDOutlineWidthComboBox->clear(); | ||
| mDDOutlineWidthComboBox->addItem( "", -1 ); | ||
| mDDFillColorComboBox->clear(); | ||
| mDDFillColorComboBox->addItem( "", -1 ); | ||
| mDDOutlineColorComboBox->clear(); | ||
| mDDOutlineColorComboBox->addItem( "", -1 ); | ||
| mDDShapeComboBox->clear(); | ||
| mDDShapeComboBox->addItem( "", -1 ); | ||
|
|
||
| if( mVectorLayer ) | ||
| { | ||
| const QgsFieldMap& fm =mVectorLayer->pendingFields(); | ||
| QgsFieldMap::const_iterator fieldIt = fm.constBegin(); | ||
| for(; fieldIt != fm.constEnd(); ++fieldIt ) | ||
| { | ||
| QString fieldName = fieldIt.value().name(); | ||
| int index = fieldIt.key(); | ||
|
|
||
| mDDSymbolWidthComboBox->addItem( fieldName, index ); | ||
| mDDSymbolHeightComboBox->addItem( fieldName, index ); | ||
| mDDRotationComboBox->addItem( fieldName, index ); | ||
| mDDOutlineWidthComboBox->addItem( fieldName, index ); | ||
| mDDFillColorComboBox->addItem( fieldName, index ); | ||
| mDDOutlineColorComboBox->addItem( fieldName, index ); | ||
| mDDShapeComboBox->addItem( fieldName, index ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDSymbolWidthComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setWidthField( mDDSymbolWidthComboBox->itemData( idx ).toInt(), mDDSymbolWidthComboBox->itemText( idx ) ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDSymbolHeightComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setHeightField( mDDSymbolHeightComboBox->itemData( idx ).toInt(), mDDSymbolHeightComboBox->itemText( idx )); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDRotationComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setRotationField( mDDRotationComboBox->itemData( idx ).toInt(), mDDRotationComboBox->itemText( idx ) ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDOutlineWidthComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setOutlineWidthField( mDDOutlineWidthComboBox->itemData( idx ).toInt(), mDDOutlineWidthComboBox->itemText( idx ) ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDFillColorComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setFillColorField( mDDFillColorComboBox->itemData( idx ).toInt(), mDDFillColorComboBox->itemText( idx ) ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDOutlineColorComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setOutlineColorField( mDDOutlineColorComboBox->itemData( idx ).toInt(), mDDOutlineColorComboBox->itemText( idx ) ); | ||
| emit changed(); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::on_mDDShapeComboBox_currentIndexChanged( int idx ) | ||
| { | ||
| if( mLayer ) | ||
| { | ||
| mLayer->setSymbolNameField( mDDShapeComboBox->itemData( idx ).toInt(), mDDShapeComboBox->itemText( idx ) ); | ||
| } | ||
| } | ||
|
|
||
| void QgsEllipseSymbolLayerV2Widget::blockComboSignals( bool block ) | ||
| { | ||
| mDDSymbolWidthComboBox->blockSignals( block ); | ||
| mDDSymbolHeightComboBox->blockSignals( block ); | ||
| mDDRotationComboBox->blockSignals( block ); | ||
| mDDOutlineWidthComboBox->blockSignals( block ); | ||
| mDDFillColorComboBox->blockSignals( block ); | ||
| mDDOutlineColorComboBox->blockSignals( block); | ||
| mDDShapeComboBox->blockSignals( block ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #ifndef QGSELLIPSESYMBOLLAYERV2WIDGET_H | ||
| #define QGSELLIPSESYMBOLLAYERV2WIDGET_H | ||
|
|
||
| #include "ui_widget_ellipse.h" | ||
| #include "qgssymbollayerv2widget.h" | ||
|
|
||
| class QgsEllipseSymbolLayerV2; | ||
|
|
||
| class GUI_EXPORT QgsEllipseSymbolLayerV2Widget: public QgsSymbolLayerV2Widget, private Ui::WidgetEllipseBase | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| QgsEllipseSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = 0 ); | ||
|
|
||
| static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsEllipseSymbolLayerV2Widget( vl ); } | ||
|
|
||
| // from base class | ||
| virtual void setSymbolLayer( QgsSymbolLayerV2* layer ); | ||
| virtual QgsSymbolLayerV2* symbolLayer(); | ||
|
|
||
| protected: | ||
| QgsEllipseSymbolLayerV2* mLayer; | ||
|
|
||
| private: | ||
| void blockComboSignals( bool block ); | ||
| //insert available attributes for data defined symbolisation | ||
| void fillDataDefinedComboBoxes(); | ||
|
|
||
| private slots: | ||
| void on_mShapeListWidget_itemSelectionChanged(); | ||
| void on_mWidthSpinBox_valueChanged( double d ); | ||
| void on_mHeightSpinBox_valueChanged( double d ); | ||
| void on_mRotationSpinBox_valueChanged( double d ); | ||
| void on_mOutlineWidthSpinBox_valueChanged( double d ); | ||
| void on_btnChangeColorBorder_clicked(); | ||
| void on_btnChangeColorFill_clicked(); | ||
|
|
||
| void on_mDDSymbolWidthComboBox_currentIndexChanged( int idx ); | ||
| void on_mDDSymbolHeightComboBox_currentIndexChanged( int idx ); | ||
| void on_mDDRotationComboBox_currentIndexChanged( int idx ); | ||
| void on_mDDOutlineWidthComboBox_currentIndexChanged( int idx ); | ||
| void on_mDDFillColorComboBox_currentIndexChanged( int idx ); | ||
| void on_mDDOutlineColorComboBox_currentIndexChanged( int idx ); | ||
| void on_mDDShapeComboBox_currentIndexChanged( int idx ); | ||
| }; | ||
|
|
||
| #endif // QGSELLIPSESYMBOLLAYERV2WIDGET_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>WidgetEllipseBase</class> | ||
| <widget class="QWidget" name="WidgetEllipseBase"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>336</width> | ||
| <height>326</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Form</string> | ||
| </property> | ||
| <layout class="QGridLayout" name="gridLayout_2"> | ||
| <item row="0" column="0"> | ||
| <widget class="QTabWidget" name="tabWidget"> | ||
| <property name="currentIndex"> | ||
| <number>0</number> | ||
| </property> | ||
| <widget class="QWidget" name="tab"> | ||
| <attribute name="title"> | ||
| <string>Settings</string> | ||
| </attribute> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Border color</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1"> | ||
| <widget class="QgsColorButtonV2" name="btnChangeColorBorder"> | ||
| <property name="text"> | ||
| <string>Change</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>Fill color</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="1"> | ||
| <widget class="QgsColorButtonV2" name="btnChangeColorFill"> | ||
| <property name="text"> | ||
| <string>Change</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="0"> | ||
| <widget class="QLabel" name="mSymbolWidthLabel"> | ||
| <property name="text"> | ||
| <string>Symbol width</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="1"> | ||
| <widget class="QDoubleSpinBox" name="mWidthSpinBox"> | ||
| <property name="decimals"> | ||
| <number>6</number> | ||
| </property> | ||
| <property name="maximum"> | ||
| <double>999999999.000000000000000</double> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="0"> | ||
| <widget class="QLabel" name="mOutlineWidthLabel"> | ||
| <property name="text"> | ||
| <string>Outline width</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="1"> | ||
| <widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox"> | ||
| <property name="decimals"> | ||
| <number>6</number> | ||
| </property> | ||
| <property name="maximum"> | ||
| <double>999999999.000000000000000</double> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="5" column="0"> | ||
| <widget class="QLabel" name="mSymbolHeightLabel"> | ||
| <property name="text"> | ||
| <string>Symbol height</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="5" column="1"> | ||
| <widget class="QDoubleSpinBox" name="mHeightSpinBox"> | ||
| <property name="decimals"> | ||
| <number>6</number> | ||
| </property> | ||
| <property name="maximum"> | ||
| <double>999999999.000000000000000</double> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="6" column="0" colspan="2"> | ||
| <widget class="QListWidget" name="mShapeListWidget"> | ||
| <property name="dragDropMode"> | ||
| <enum>QAbstractItemView::DropOnly</enum> | ||
| </property> | ||
| <property name="iconSize"> | ||
| <size> | ||
| <width>20</width> | ||
| <height>20</height> | ||
| </size> | ||
| </property> | ||
| <property name="movement"> | ||
| <enum>QListView::Static</enum> | ||
| </property> | ||
| <property name="flow"> | ||
| <enum>QListView::LeftToRight</enum> | ||
| </property> | ||
| <property name="resizeMode"> | ||
| <enum>QListView::Adjust</enum> | ||
| </property> | ||
| <property name="spacing"> | ||
| <number>4</number> | ||
| </property> | ||
| <property name="gridSize"> | ||
| <size> | ||
| <width>30</width> | ||
| <height>24</height> | ||
| </size> | ||
| </property> | ||
| <property name="viewMode"> | ||
| <enum>QListView::IconMode</enum> | ||
| </property> | ||
| <property name="wordWrap"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <property name="selectionRectVisible"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="4" column="1"> | ||
| <widget class="QDoubleSpinBox" name="mRotationSpinBox"/> | ||
| </item> | ||
| <item row="4" column="0"> | ||
| <widget class="QLabel" name="mRotationLabel"> | ||
| <property name="text"> | ||
| <string>Rotation</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <widget class="QWidget" name="tab_2"> | ||
| <attribute name="title"> | ||
| <string>Data defined settings</string> | ||
| </attribute> | ||
| <layout class="QGridLayout" name="gridLayout_3"> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="mDdSymbolWidthLabel"> | ||
| <property name="text"> | ||
| <string>Symbol width</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1"> | ||
| <widget class="QComboBox" name="mDDSymbolWidthComboBox"/> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="mDdSymbolHeightLabel"> | ||
| <property name="text"> | ||
| <string>Symbol height</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="1"> | ||
| <widget class="QComboBox" name="mDDSymbolHeightComboBox"/> | ||
| </item> | ||
| <item row="3" column="0"> | ||
| <widget class="QLabel" name="mDDOutlineWidthLabel"> | ||
| <property name="text"> | ||
| <string>Outline width</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="1"> | ||
| <widget class="QComboBox" name="mDDOutlineWidthComboBox"/> | ||
| </item> | ||
| <item row="4" column="0"> | ||
| <widget class="QLabel" name="mDDFillColorLabel"> | ||
| <property name="text"> | ||
| <string>Fill color</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="4" column="1"> | ||
| <widget class="QComboBox" name="mDDFillColorComboBox"/> | ||
| </item> | ||
| <item row="5" column="0"> | ||
| <widget class="QLabel" name="mDDOutlineLabel"> | ||
| <property name="text"> | ||
| <string>Outline color</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="5" column="1"> | ||
| <widget class="QComboBox" name="mDDOutlineColorComboBox"/> | ||
| </item> | ||
| <item row="6" column="0"> | ||
| <widget class="QLabel" name="mDDShapeLabel"> | ||
| <property name="text"> | ||
| <string>Shape</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="6" column="1"> | ||
| <widget class="QComboBox" name="mDDShapeComboBox"/> | ||
| </item> | ||
| <item row="2" column="1"> | ||
| <widget class="QComboBox" name="mDDRotationComboBox"/> | ||
| </item> | ||
| <item row="2" column="0"> | ||
| <widget class="QLabel" name="mDDRotationLabel"> | ||
| <property name="text"> | ||
| <string>Rotation</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <customwidgets> | ||
| <customwidget> | ||
| <class>QgsColorButtonV2</class> | ||
| <extends>QPushButton</extends> | ||
| <header>qgscolorbutton.h</header> | ||
| </customwidget> | ||
| </customwidgets> | ||
| <resources/> | ||
| <connections/> | ||
| </ui> |