Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
200 changes: 200 additions & 0 deletions
200
src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,200 @@ | |||
#include "qgsvectorfieldsymbollayerwidget.h" | |||
#include "qgssymbolv2propertiesdialog.h" | |||
#include "qgsvectorfieldsymbollayer.h" | |||
#include "qgsvectorlayer.h" | |||
|
|||
QgsVectorFieldSymbolLayerWidget::QgsVectorFieldSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent ): QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 ) | |||
{ | |||
setupUi( this ); | |||
if( mVectorLayer ) | |||
{ | |||
const QgsFieldMap& fm = mVectorLayer->pendingFields(); | |||
QgsFieldMap::const_iterator fieldIt = fm.constBegin(); | |||
mXAttributeComboBox->addItem( "", -1 ); | |||
mYAttributeComboBox->addItem( "", -1 ); | |||
for ( ; fieldIt != fm.constEnd(); ++fieldIt ) | |||
{ | |||
QString fieldName = fieldIt.value().name(); | |||
int index = fieldIt.key(); | |||
mXAttributeComboBox->addItem( fieldName, index ); | |||
mYAttributeComboBox->addItem( fieldName, index ); | |||
} | |||
} | |||
} | |||
|
|||
QgsVectorFieldSymbolLayerWidget::~QgsVectorFieldSymbolLayerWidget() | |||
{ | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::setSymbolLayer( QgsSymbolLayerV2* layer ) | |||
{ | |||
if( layer->layerType() != "VectorField" ) | |||
{ | |||
return; | |||
} | |||
mLayer = static_cast<QgsVectorFieldSymbolLayer*>( layer ); | |||
if( !mLayer ) | |||
{ | |||
return; | |||
} | |||
|
|||
mXAttributeComboBox->setCurrentIndex( mXAttributeComboBox->findData( mLayer->xAttribute() ) ); | |||
mYAttributeComboBox->setCurrentIndex( mYAttributeComboBox->findData( mLayer->yAttribute() ) ); | |||
mScaleSpinBox->setValue( mLayer->scale() ); | |||
|
|||
QgsVectorFieldSymbolLayer::VectorFieldType type = mLayer->vectorFieldType(); | |||
if( type == QgsVectorFieldSymbolLayer::Cartesian ) | |||
{ | |||
mCartesianRadioButton->setChecked( true ); | |||
} | |||
else if( type == QgsVectorFieldSymbolLayer::Polar ) | |||
{ | |||
mPolarRadioButton->setChecked( true ); | |||
} | |||
else if( type == QgsVectorFieldSymbolLayer::Height ) | |||
{ | |||
mHeightRadioButton->setChecked( true ); | |||
} | |||
|
|||
QgsVectorFieldSymbolLayer::AngleOrientation orientation = mLayer->angleOrientation(); | |||
if( orientation == QgsVectorFieldSymbolLayer::ClockwiseFromNorth ) | |||
{ | |||
mClockwiseFromNorthRadioButton->setChecked( true ); | |||
} | |||
else if( orientation == QgsVectorFieldSymbolLayer::CounterclockwiseFromEast ) | |||
{ | |||
mCounterclockwiseFromEastRadioButton->setChecked( true ); | |||
} | |||
|
|||
QgsVectorFieldSymbolLayer::AngleUnits angleUnits = mLayer->angleUnits(); | |||
if( angleUnits == QgsVectorFieldSymbolLayer::Degrees ) | |||
{ | |||
mDegreesRadioButton->setChecked( true ); | |||
} | |||
else if( angleUnits == QgsVectorFieldSymbolLayer::Radians ) | |||
{ | |||
mRadiansRadioButton->setChecked( true ); | |||
} | |||
updateMarkerIcon(); | |||
} | |||
|
|||
QgsSymbolLayerV2* QgsVectorFieldSymbolLayerWidget::symbolLayer() | |||
{ | |||
return mLayer; | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mScaleSpinBox_valueChanged( double d ) | |||
{ | |||
if( mLayer ) | |||
{ | |||
mLayer->setScale( d ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mXAttributeComboBox_currentIndexChanged( int index ) | |||
{ | |||
if( mLayer ) | |||
{ | |||
mLayer->setXAttribute( mXAttributeComboBox->itemData( index ).toInt() ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mYAttributeComboBox_currentIndexChanged( int index ) | |||
{ | |||
if( mLayer ) | |||
{ | |||
mLayer->setYAttribute( mYAttributeComboBox->itemData( index ).toInt() ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mLineStylePushButton_clicked() | |||
{ | |||
if ( !mLayer ) | |||
{ | |||
return; | |||
} | |||
|
|||
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this ); | |||
if ( dlg.exec() == QDialog::Rejected ) | |||
{ | |||
return; | |||
} | |||
|
|||
updateMarkerIcon(); | |||
emit changed(); | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::updateMarkerIcon() | |||
{ | |||
if ( mLayer ) | |||
{ | |||
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mLayer->subSymbol(), mLineStylePushButton->iconSize() ); | |||
mLineStylePushButton->setIcon( icon ); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mCartesianRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setVectorFieldType( QgsVectorFieldSymbolLayer::Cartesian ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mPolarRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setVectorFieldType( QgsVectorFieldSymbolLayer::Polar ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mHeightRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setVectorFieldType( QgsVectorFieldSymbolLayer::Height ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mDegreesRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setAngleUnits( QgsVectorFieldSymbolLayer::Degrees ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mRadiansRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setAngleUnits( QgsVectorFieldSymbolLayer::Radians ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mClockwiseFromNorthRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setAngleOrientation( QgsVectorFieldSymbolLayer::ClockwiseFromNorth ); | |||
emit changed(); | |||
} | |||
} | |||
|
|||
void QgsVectorFieldSymbolLayerWidget::on_mCounterclockwiseFromEastRadioButton_toggled( bool checked ) | |||
{ | |||
if( mLayer && checked ) | |||
{ | |||
mLayer->setAngleOrientation( QgsVectorFieldSymbolLayer::CounterclockwiseFromEast ); | |||
emit changed(); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
#ifndef QGSVECTORFIELDSYMBOLLAYERWIDGET_H | |||
#define QGSVECTORFIELDSYMBOLLAYERWIDGET_H | |||
|
|||
#include "qgssymbollayerv2widget.h" | |||
#include "ui_widget_vectorfield.h" | |||
|
|||
class QgsVectorFieldSymbolLayer; | |||
|
|||
class QgsVectorFieldSymbolLayerWidget: public QgsSymbolLayerV2Widget, private Ui::WidgetVectorFieldBase | |||
{ | |||
Q_OBJECT | |||
public: | |||
QgsVectorFieldSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = 0 ); | |||
~QgsVectorFieldSymbolLayerWidget(); | |||
|
|||
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsVectorFieldSymbolLayerWidget( vl ); } | |||
|
|||
// from base class | |||
virtual void setSymbolLayer( QgsSymbolLayerV2* layer ); | |||
virtual QgsSymbolLayerV2* symbolLayer(); | |||
|
|||
protected: | |||
QgsVectorFieldSymbolLayer* mLayer; | |||
void updateMarkerIcon(); | |||
|
|||
private slots: | |||
void on_mScaleSpinBox_valueChanged( double d ); | |||
void on_mXAttributeComboBox_currentIndexChanged( int index ); | |||
void on_mYAttributeComboBox_currentIndexChanged( int index ); | |||
void on_mLineStylePushButton_clicked(); | |||
void on_mCartesianRadioButton_toggled( bool checked ); | |||
void on_mPolarRadioButton_toggled( bool checked ); | |||
void on_mHeightRadioButton_toggled( bool checked ); | |||
void on_mDegreesRadioButton_toggled( bool checked ); | |||
void on_mRadiansRadioButton_toggled( bool checked ); | |||
void on_mClockwiseFromNorthRadioButton_toggled( bool checked ); | |||
void on_mCounterclockwiseFromEastRadioButton_toggled( bool checked ); | |||
}; | |||
|
|||
#endif // QGSVECTORFIELDSYMBOLLAYERWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
#ifndef QGSVECTORFIELDWIDGET_H | |||
#define QGSVECTORFIELDWIDGET_H | |||
|
|||
#endif // QGSVECTORFIELDWIDGET_H |