QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsvectorfieldsymbollayerwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorfieldsymbollayerwidget.cpp
3  ---------------------
4  begin : October 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
17 #include "qgsvectorlayer.h"
18 
20 {
21  setupUi( this );
22  if ( mVectorLayer )
23  {
24  const QgsFields& fm = mVectorLayer->pendingFields();
25  mXAttributeComboBox->addItem( "" );
26  mYAttributeComboBox->addItem( "" );
27  for ( int idx = 0; idx < fm.count(); ++idx )
28  {
29  QString fieldName = fm[idx].name();
30  mXAttributeComboBox->addItem( fieldName );
31  mYAttributeComboBox->addItem( fieldName );
32  }
33  }
34 }
35 
37 {
38 }
39 
41 {
42  if ( layer->layerType() != "VectorField" )
43  {
44  return;
45  }
46  mLayer = static_cast<QgsVectorFieldSymbolLayer*>( layer );
47  if ( !mLayer )
48  {
49  return;
50  }
51 
52  mXAttributeComboBox->setCurrentIndex( mXAttributeComboBox->findText( mLayer->xAttribute() ) );
53  mYAttributeComboBox->setCurrentIndex( mYAttributeComboBox->findText( mLayer->yAttribute() ) );
54  mScaleSpinBox->setValue( mLayer->scale() );
55 
58  {
59  mCartesianRadioButton->setChecked( true );
60  }
61  else if ( type == QgsVectorFieldSymbolLayer::Polar )
62  {
63  mPolarRadioButton->setChecked( true );
64  }
65  else if ( type == QgsVectorFieldSymbolLayer::Height )
66  {
67  mHeightRadioButton->setChecked( true );
68  }
69 
72  {
73  mClockwiseFromNorthRadioButton->setChecked( true );
74  }
76  {
77  mCounterclockwiseFromEastRadioButton->setChecked( true );
78  }
79 
81  if ( angleUnits == QgsVectorFieldSymbolLayer::Degrees )
82  {
83  mDegreesRadioButton->setChecked( true );
84  }
85  else if ( angleUnits == QgsVectorFieldSymbolLayer::Radians )
86  {
87  mRadiansRadioButton->setChecked( true );
88  }
89 
90  mDistanceUnitWidget->blockSignals( true );
91  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
92  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
93  mDistanceUnitWidget->blockSignals( false );
94 
95  emit changed();
96 }
97 
99 {
100  return mLayer;
101 }
102 
104 {
105  if ( mLayer )
106  {
107  mLayer->setScale( d );
108  emit changed();
109  }
110 }
111 
113 {
114  if ( mLayer )
115  {
116  mLayer->setXAttribute( mXAttributeComboBox->itemText( index ) );
117  emit changed();
118  }
119 }
120 
122 {
123  if ( mLayer )
124  {
125  mLayer->setYAttribute( mYAttributeComboBox->itemText( index ) );
126  emit changed();
127  }
128 }
129 
131 {
132  if ( mLayer && checked )
133  {
135  mXAttributeComboBox->setEnabled( true );
136  mYAttributeComboBox->setEnabled( true );
137  mXAttributeLabel->setText( tr( "X attribute" ) );
138  mYAttributeLabel->setText( tr( "Y attribute" ) );
139  emit changed();
140  }
141 }
142 
144 {
145  if ( mLayer && checked )
146  {
148  mXAttributeComboBox->setEnabled( true );
149  mYAttributeComboBox->setEnabled( true );
150  mXAttributeLabel->setText( tr( "Length attribute" ) );
151  mYAttributeLabel->setText( tr( "Angle attribute" ) );
152  emit changed();
153  }
154 }
155 
157 {
158  if ( mLayer && checked )
159  {
161  mXAttributeLabel->setText( "" );
162  mXAttributeComboBox->setEnabled( false );
163  mYAttributeLabel->setText( tr( "Height attribute" ) );
164  emit changed();
165  }
166 }
167 
169 {
170  if ( mLayer && checked )
171  {
173  emit changed();
174  }
175 }
176 
178 {
179  if ( mLayer && checked )
180  {
182  emit changed();
183  }
184 }
185 
187 {
188  if ( mLayer && checked )
189  {
191  emit changed();
192  }
193 }
194 
196 {
197  if ( mLayer && checked )
198  {
200  emit changed();
201  }
202 }
203 
205 {
206  if ( mLayer )
207  {
209  emit changed();
210  }
211 }
212 
213