QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgssymbollayerv2widget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerv2widget.cpp - symbol layer widgets
3 
4  ---------------------
5  begin : November 2009
6  copyright : (C) 2009 by Martin Dobias
7  email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgssymbollayerv2widget.h"
18 
19 #include "qgslinesymbollayerv2.h"
20 #include "qgsmarkersymbollayerv2.h"
21 #include "qgsfillsymbollayerv2.h"
22 
23 #include "characterwidget.h"
24 #include "qgsdashspacedialog.h"
27 #include "qgssvgcache.h"
28 #include "qgssymbollayerv2utils.h"
29 #include "qgsvectorcolorrampv2.h"
31 
32 #include "qgsstylev2.h" //for symbol selector dialog
33 
34 #include "qgsapplication.h"
35 
36 #include "qgslogger.h"
37 
38 #include <QAbstractButton>
39 #include <QColorDialog>
40 #include <QCursor>
41 #include <QDir>
42 #include <QFileDialog>
43 #include <QPainter>
44 #include <QSettings>
45 #include <QStandardItemModel>
46 #include <QSvgRenderer>
47 
48 QString QgsSymbolLayerV2Widget::dataDefinedPropertyLabel( const QString &entryName )
49 {
50  QString label = entryName;
51  if ( entryName == "size" )
52  {
53  label = tr( "Size" );
54  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
55  if ( layer )
56  {
57  switch ( layer->scaleMethod() )
58  {
60  label += " (" + tr( "area" ) + ")";
61  break;
63  label += " (" + tr( "diameter" ) + ")";
64  break;
65  }
66  }
67  }
68  return label;
69 }
70 
72  : QgsSymbolLayerV2Widget( parent, vl )
73 {
74  mLayer = NULL;
75 
76  setupUi( this );
77  mPenWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
78  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
79  mDashPatternUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
80 
81  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
82  btnChangeColor->setColorDialogTitle( tr( "Select line color" ) );
83  btnChangeColor->setContext( "symbology" );
84 
85  if ( vl && vl->geometryType() != QGis::Polygon )
86  {
87  //draw inside polygon checkbox only makes sense for polygon layers
88  mDrawInsideCheckBox->hide();
89  }
90 
91  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
92  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
93  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
94  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
95  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
96  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
98 
99 }
100 
102 {
103  if ( !layer || layer->layerType() != "SimpleLine" )
104  return;
105 
106  // layer type is correct, we can do the cast
107  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
108 
109  // set units
110  mPenWidthUnitWidget->blockSignals( true );
111  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
112  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
113  mPenWidthUnitWidget->blockSignals( false );
114  mOffsetUnitWidget->blockSignals( true );
115  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
116  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
117  mOffsetUnitWidget->blockSignals( false );
118  mDashPatternUnitWidget->blockSignals( true );
119  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
120  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
121  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
122  mDashPatternUnitWidget->blockSignals( false );
123 
124  // set values
125  spinWidth->blockSignals( true );
126  spinWidth->setValue( mLayer->width() );
127  spinWidth->blockSignals( false );
128  btnChangeColor->blockSignals( true );
129  btnChangeColor->setColor( mLayer->color() );
130  btnChangeColor->blockSignals( false );
131  spinOffset->blockSignals( true );
132  spinOffset->setValue( mLayer->offset() );
133  spinOffset->blockSignals( false );
134  cboPenStyle->blockSignals( true );
135  cboJoinStyle->blockSignals( true );
136  cboCapStyle->blockSignals( true );
137  cboPenStyle->setPenStyle( mLayer->penStyle() );
138  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
139  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
140  cboPenStyle->blockSignals( false );
141  cboJoinStyle->blockSignals( false );
142  cboCapStyle->blockSignals( false );
143 
144  //use a custom dash pattern?
145  bool useCustomDashPattern = mLayer->useCustomDashPattern();
146  mChangePatternButton->setEnabled( useCustomDashPattern );
147  label_3->setEnabled( !useCustomDashPattern );
148  cboPenStyle->setEnabled( !useCustomDashPattern );
149  mCustomCheckBox->blockSignals( true );
150  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
151  mCustomCheckBox->blockSignals( false );
152 
153  //draw inside polygon?
154  bool drawInsidePolygon = mLayer->drawInsidePolygon();
155  mDrawInsideCheckBox->blockSignals( true );
156  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
157  mDrawInsideCheckBox->blockSignals( false );
158 
160 }
161 
163 {
164  return mLayer;
165 }
166 
168 {
169  mLayer->setWidth( spinWidth->value() );
171  emit changed();
172 }
173 
175 {
176  mLayer->setColor( color );
178  emit changed();
179 }
180 
182 {
183  mLayer->setPenStyle( cboPenStyle->penStyle() );
184  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
185  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
186  emit changed();
187 }
188 
190 {
191  mLayer->setOffset( spinOffset->value() );
193  emit changed();
194 }
195 
197 {
198  bool checked = ( state == Qt::Checked );
199  mChangePatternButton->setEnabled( checked );
200  label_3->setEnabled( !checked );
201  cboPenStyle->setEnabled( !checked );
202 
203  mLayer->setUseCustomDashPattern( checked );
204  emit changed();
205 }
206 
208 {
210  if ( d.exec() == QDialog::Accepted )
211  {
212  mLayer->setCustomDashVector( d.dashDotVector() );
214  emit changed();
215  }
216 }
217 
219 {
220  if ( mLayer )
221  {
222  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mPenWidthUnitWidget->getUnit() );
223  mLayer->setWidthUnit( unit );
224  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
225  emit changed();
226  }
227 }
228 
230 {
231  if ( mLayer )
232  {
233  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
234  mLayer->setOffsetUnit( unit );
235  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
236  emit changed();
237  }
238 }
239 
241 {
242  if ( mLayer )
243  {
244  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDashPatternUnitWidget->getUnit() );
246  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
247  emit changed();
248  }
249 }
250 
252 {
253  bool checked = ( state == Qt::Checked );
254  mLayer->setDrawInsidePolygon( checked );
255  emit changed();
256 }
257 
259 {
260  if ( !mLayer )
261  {
262  return;
263  }
264 
265  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
266  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ),
268  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Pen width" ), mLayer->dataDefinedPropertyString( "width" ),
270  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
272  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "customdash", tr( "Dash pattern" ), mLayer->dataDefinedPropertyString( "customdash" ), "<dash>;<space>" );
273  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "joinstyle", tr( "Join style" ), mLayer->dataDefinedPropertyString( "joinstyle" ), "'bevel'|'miter'|'round'" );
274  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "capstyle", tr( "Cap style" ), mLayer->dataDefinedPropertyString( "capstyle" ), "'square'|'flat'|'round'" );
275  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
276 
277  if ( d.exec() == QDialog::Accepted )
278  {
279  //empty all existing properties first
281 
282  QMap<QString, QString> properties = d.dataDefinedProperties();
283  QMap<QString, QString>::const_iterator it = properties.constBegin();
284  for ( ; it != properties.constEnd(); ++it )
285  {
286  if ( !it.value().isEmpty() )
287  {
288  mLayer->setDataDefinedProperty( it.key(), it.value() );
289  }
290  }
291  emit changed();
292  }
293 }
294 
296 {
297  if ( !mLayer )
298  {
299  return;
300  }
301  QgsSimpleLineSymbolLayerV2* layerCopy = dynamic_cast<QgsSimpleLineSymbolLayerV2*>( mLayer->clone() );
302  if ( !layerCopy )
303  {
304  return;
305  }
306  layerCopy->setUseCustomDashPattern( true );
307  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
308  mChangePatternButton->setIcon( buttonIcon );
309  delete layerCopy;
310 }
311 
312 
314 
315 
317  : QgsSymbolLayerV2Widget( parent, vl )
318 {
319  mLayer = NULL;
320 
321  setupUi( this );
322  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
323  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
324  mOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
325 
326  btnChangeColorFill->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
327  btnChangeColorFill->setColorDialogTitle( tr( "Select fill color" ) );
328  btnChangeColorFill->setContext( "symbology" );
329  btnChangeColorFill->setShowNoColor( true );
330  btnChangeColorFill->setNoColorString( tr( "Transparent fill" ) );
331  btnChangeColorBorder->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
332  btnChangeColorBorder->setColorDialogTitle( tr( "Select border color" ) );
333  btnChangeColorBorder->setContext( "symbology" );
334  btnChangeColorBorder->setShowNoColor( true );
335  btnChangeColorBorder->setNoColorString( tr( "Transparent border" ) );
336 
337  QSize size = lstNames->iconSize();
338  QStringList names;
339  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
340  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
341  double markerSize = DEFAULT_POINT_SIZE * 2;
342  for ( int i = 0; i < names.count(); ++i )
343  {
344  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
346  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
347  item->setData( Qt::UserRole, names[i] );
348  delete lyr;
349  }
350 
351  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
352  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
353  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
354  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
355  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
356  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
357  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
358 }
359 
361 {
362  if ( layer->layerType() != "SimpleMarker" )
363  return;
364 
365  // layer type is correct, we can do the cast
366  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
367 
368  // set values
369  QString name = mLayer->name();
370  for ( int i = 0; i < lstNames->count(); ++i )
371  {
372  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
373  {
374  lstNames->setCurrentRow( i );
375  break;
376  }
377  }
378  btnChangeColorBorder->blockSignals( true );
379  btnChangeColorBorder->setColor( mLayer->borderColor() );
380  btnChangeColorBorder->blockSignals( false );
381  btnChangeColorFill->blockSignals( true );
382  btnChangeColorFill->setColor( mLayer->color() );
383  btnChangeColorFill->blockSignals( false );
384  spinSize->blockSignals( true );
385  spinSize->setValue( mLayer->size() );
386  spinSize->blockSignals( false );
387  spinAngle->blockSignals( true );
388  spinAngle->setValue( mLayer->angle() );
389  spinAngle->blockSignals( false );
390  mOutlineStyleComboBox->blockSignals( true );
391  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
392  mOutlineStyleComboBox->blockSignals( false );
393  mOutlineWidthSpinBox->blockSignals( true );
394  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
395  mOutlineWidthSpinBox->blockSignals( false );
396 
397  // without blocking signals the value gets changed because of slot setOffset()
398  spinOffsetX->blockSignals( true );
399  spinOffsetX->setValue( mLayer->offset().x() );
400  spinOffsetX->blockSignals( false );
401  spinOffsetY->blockSignals( true );
402  spinOffsetY->setValue( mLayer->offset().y() );
403  spinOffsetY->blockSignals( false );
404 
405  mSizeUnitWidget->blockSignals( true );
406  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
407  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
408  mSizeUnitWidget->blockSignals( false );
409  mOffsetUnitWidget->blockSignals( true );
410  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
411  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
412  mOffsetUnitWidget->blockSignals( false );
413  mOutlineWidthUnitWidget->blockSignals( true );
414  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
415  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
416  mOutlineWidthUnitWidget->blockSignals( false );
417 
418  //anchor points
419  mHorizontalAnchorComboBox->blockSignals( true );
420  mVerticalAnchorComboBox->blockSignals( true );
421  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
422  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
423  mHorizontalAnchorComboBox->blockSignals( false );
424  mVerticalAnchorComboBox->blockSignals( false );
425 }
426 
428 {
429  return mLayer;
430 }
431 
433 {
434  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
435  emit changed();
436 }
437 
439 {
440  mLayer->setBorderColor( color );
441  emit changed();
442 }
443 
445 {
446  mLayer->setColor( color );
447  emit changed();
448 }
449 
451 {
452  mLayer->setSize( spinSize->value() );
453  emit changed();
454 }
455 
457 {
458  mLayer->setAngle( spinAngle->value() );
459  emit changed();
460 }
461 
463 {
464  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
465  emit changed();
466 }
467 
469 {
470  Q_UNUSED( index );
471 
472  if ( mLayer )
473  {
474  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
475  emit changed();
476  }
477 }
478 
480 {
481  if ( mLayer )
482  {
483  mLayer->setOutlineWidth( d );
484  emit changed();
485  }
486 }
487 
489 {
490  if ( mLayer )
491  {
492  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
493  mLayer->setSizeUnit( unit );
494  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
495  emit changed();
496  }
497 }
498 
500 {
501  if ( mLayer )
502  {
503  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
504  mLayer->setOffsetUnit( unit );
505  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
506  emit changed();
507  }
508 }
509 
511 {
512  if ( mLayer )
513  {
514  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOutlineWidthUnitWidget->getUnit() );
515  mLayer->setOutlineWidthUnit( unit );
516  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
517  emit changed();
518  }
519 }
520 
522 {
523  if ( !mLayer )
524  {
525  return;
526  }
527 
528  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
529  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "name", tr( "Name" ), mLayer->dataDefinedPropertyString( "name" ),
530  "'square'|'rectangle'|'diamond'|'pentagon'|'triangle'|'equilateral_triangle'|'star'|'regular_star'|'arrow'|'filled_arrowhead'|'circle'|'cross'|'x'|'cross2'|'line'|'arrowhead'" );
531  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Fill color" ), mLayer->dataDefinedPropertyString( "color" ),
533  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color_border", tr( "Border color" ), mLayer->dataDefinedPropertyString( "color_border" ),
535  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline_width", tr( "Outline width" ), mLayer->dataDefinedPropertyString( "outline_width" ),
539  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
541  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
543  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "horizontal_anchor_point", tr( "Horizontal anchor point" ), mLayer->dataDefinedPropertyString( "horizontal_anchor_point" ),
545  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "vertical_anchor_point", tr( "Vertical anchor point" ), mLayer->dataDefinedPropertyString( "vertical_anchor_point" ),
547  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
548  if ( d.exec() == QDialog::Accepted )
549  {
550  //empty all existing properties first
552 
553  QMap<QString, QString> properties = d.dataDefinedProperties();
554  QMap<QString, QString>::const_iterator it = properties.constBegin();
555  for ( ; it != properties.constEnd(); ++it )
556  {
557  if ( !it.value().isEmpty() )
558  {
559  mLayer->setDataDefinedProperty( it.key(), it.value() );
560  }
561  }
562  emit changed();
563  }
564 }
565 
567 {
568  if ( mLayer )
569  {
571  emit changed();
572  }
573 }
574 
576 {
577  if ( mLayer )
578  {
580  emit changed();
581  }
582 }
583 
584 
586 
588  : QgsSymbolLayerV2Widget( parent, vl )
589 {
590  mLayer = NULL;
591 
592  setupUi( this );
593  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
594  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
595 
596  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
597  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
598  btnChangeColor->setContext( "symbology" );
599  btnChangeColor->setShowNoColor( true );
600  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
601  btnChangeBorderColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
602  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
603  btnChangeBorderColor->setContext( "symbology" );
604  btnChangeBorderColor->setShowNoColor( true );
605  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
606 
607  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
608  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
609  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
610  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
611  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
612  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
613  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
614  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
615 }
616 
618 {
619  if ( layer->layerType() != "SimpleFill" )
620  return;
621 
622  // layer type is correct, we can do the cast
623  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
624 
625  // set values
626  btnChangeColor->blockSignals( true );
627  btnChangeColor->setColor( mLayer->color() );
628  btnChangeColor->blockSignals( false );
629  cboFillStyle->blockSignals( true );
630  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
631  cboFillStyle->blockSignals( false );
632  btnChangeBorderColor->blockSignals( true );
633  btnChangeBorderColor->setColor( mLayer->borderColor() );
634  btnChangeBorderColor->blockSignals( false );
635  cboBorderStyle->blockSignals( true );
636  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
637  cboBorderStyle->blockSignals( false );
638  spinBorderWidth->blockSignals( true );
639  spinBorderWidth->setValue( mLayer->borderWidth() );
640  spinBorderWidth->blockSignals( false );
641  cboJoinStyle->blockSignals( true );
642  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
643  cboJoinStyle->blockSignals( false );
644  spinOffsetX->blockSignals( true );
645  spinOffsetX->setValue( mLayer->offset().x() );
646  spinOffsetX->blockSignals( false );
647  spinOffsetY->blockSignals( true );
648  spinOffsetY->setValue( mLayer->offset().y() );
649  spinOffsetY->blockSignals( false );
650 
651  mBorderWidthUnitWidget->blockSignals( true );
652  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
653  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
654  mBorderWidthUnitWidget->blockSignals( false );
655  mOffsetUnitWidget->blockSignals( true );
656  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
657  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
658  mOffsetUnitWidget->blockSignals( false );
659 }
660 
662 {
663  return mLayer;
664 }
665 
667 {
668  mLayer->setColor( color );
669  emit changed();
670 }
671 
673 {
674  mLayer->setBorderColor( color );
675  emit changed();
676 }
677 
679 {
680  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
681  emit changed();
682 }
683 
685 {
686  mLayer->setBorderWidth( spinBorderWidth->value() );
687  emit changed();
688 }
689 
691 {
692  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
693  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
694  emit changed();
695 }
696 
698 {
699  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
700  emit changed();
701 }
702 
704 {
705  if ( mLayer )
706  {
707  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
708  mLayer->setBorderWidthUnit( unit );
709  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
710  emit changed();
711  }
712 }
713 
715 {
716  if ( mLayer )
717  {
718  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
719  mLayer->setOffsetUnit( unit );
720  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
721  emit changed();
722  }
723 }
724 
726 {
727  if ( !mLayer )
728  {
729  return;
730  }
731 
732  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
734  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color_border", tr( "Border color" ), mLayer->dataDefinedPropertyString( "color_border" ),
736  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width_border", tr( "Border width" ), mLayer->dataDefinedPropertyString( "width_border" ),
738  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
739  if ( d.exec() == QDialog::Accepted )
740  {
741  //empty all existing properties first
743 
744  QMap<QString, QString> properties = d.dataDefinedProperties();
745  QMap<QString, QString>::const_iterator it = properties.constBegin();
746  for ( ; it != properties.constEnd(); ++it )
747  {
748  if ( !it.value().isEmpty() )
749  {
750  mLayer->setDataDefinedProperty( it.key(), it.value() );
751  }
752  }
753  emit changed();
754  }
755 }
756 
758 
760  : QgsSymbolLayerV2Widget( parent, vl )
761 {
762  mLayer = NULL;
763 
764  setupUi( this );
765  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
766 
767  cboGradientColorRamp->setShowGradientOnly( true );
768  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
769 
770  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
771  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
772  btnChangeColor->setContext( "symbology" );
773  btnChangeColor->setShowNoColor( true );
774  btnChangeColor->setNoColorString( tr( "Transparent" ) );
775  btnChangeColor2->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
776  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
777  btnChangeColor2->setContext( "symbology" );
778  btnChangeColor2->setShowNoColor( true );
779  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
780 
781  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
782  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
783  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ) , this, SLOT( applyColorRamp() ) );
784  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
785  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
786  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
787  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
788  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
789  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
790  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
791  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
792  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
793  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
794  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
795  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
796 }
797 
799 {
800  if ( layer->layerType() != "GradientFill" )
801  return;
802 
803  // layer type is correct, we can do the cast
804  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
805 
806  // set values
807  btnChangeColor->blockSignals( true );
808  btnChangeColor->setColor( mLayer->color() );
809  btnChangeColor->blockSignals( false );
810  btnChangeColor2->blockSignals( true );
811  btnChangeColor2->setColor( mLayer->color2() );
812  btnChangeColor2->blockSignals( false );
813 
815  {
816  radioTwoColor->setChecked( true );
817  cboGradientColorRamp->setEnabled( false );
818  }
819  else
820  {
821  radioColorRamp->setChecked( true );
822  btnChangeColor->setEnabled( false );
823  btnChangeColor2->setEnabled( false );
824  }
825 
826  // set source color ramp
827  if ( mLayer->colorRamp() )
828  {
829  cboGradientColorRamp->blockSignals( true );
830  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
831  cboGradientColorRamp->blockSignals( false );
832  }
833 
834  cboGradientType->blockSignals( true );
835  switch ( mLayer->gradientType() )
836  {
838  cboGradientType->setCurrentIndex( 0 );
839  break;
841  cboGradientType->setCurrentIndex( 1 );
842  break;
844  cboGradientType->setCurrentIndex( 2 );
845  break;
846  }
847  cboGradientType->blockSignals( false );
848 
849  cboCoordinateMode->blockSignals( true );
850  switch ( mLayer->coordinateMode() )
851  {
853  cboCoordinateMode->setCurrentIndex( 1 );
854  checkRefPoint1Centroid->setEnabled( false );
855  checkRefPoint2Centroid->setEnabled( false );
856  break;
858  default:
859  cboCoordinateMode->setCurrentIndex( 0 );
860  break;
861  }
862  cboCoordinateMode->blockSignals( false );
863 
864  cboGradientSpread->blockSignals( true );
865  switch ( mLayer->gradientSpread() )
866  {
868  cboGradientSpread->setCurrentIndex( 0 );
869  break;
871  cboGradientSpread->setCurrentIndex( 1 );
872  break;
874  cboGradientSpread->setCurrentIndex( 2 );
875  break;
876  }
877  cboGradientSpread->blockSignals( false );
878 
879  spinRefPoint1X->blockSignals( true );
880  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
881  spinRefPoint1X->blockSignals( false );
882  spinRefPoint1Y->blockSignals( true );
883  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
884  spinRefPoint1Y->blockSignals( false );
885  checkRefPoint1Centroid->blockSignals( true );
886  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
888  {
889  spinRefPoint1X->setEnabled( false );
890  spinRefPoint1Y->setEnabled( false );
891  }
892  checkRefPoint1Centroid->blockSignals( false );
893  spinRefPoint2X->blockSignals( true );
894  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
895  spinRefPoint2X->blockSignals( false );
896  spinRefPoint2Y->blockSignals( true );
897  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
898  spinRefPoint2Y->blockSignals( false );
899  checkRefPoint2Centroid->blockSignals( true );
900  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
902  {
903  spinRefPoint2X->setEnabled( false );
904  spinRefPoint2Y->setEnabled( false );
905  }
906  checkRefPoint2Centroid->blockSignals( false );
907 
908  spinOffsetX->blockSignals( true );
909  spinOffsetX->setValue( mLayer->offset().x() );
910  spinOffsetX->blockSignals( false );
911  spinOffsetY->blockSignals( true );
912  spinOffsetY->setValue( mLayer->offset().y() );
913  spinOffsetY->blockSignals( false );
914  mSpinAngle->blockSignals( true );
915  mSpinAngle->setValue( mLayer->angle() );
916  mSpinAngle->blockSignals( false );
917 
918  mOffsetUnitWidget->blockSignals( true );
919  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
920  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
921  mOffsetUnitWidget->blockSignals( false );
922 }
923 
925 {
926  return mLayer;
927 }
928 
930 {
931  mLayer->setColor( color );
932  emit changed();
933 }
934 
936 {
937  mLayer->setColor2( color );
938  emit changed();
939 }
940 
942 {
943  if ( radioTwoColor->isChecked() )
944  {
946  }
947  else
948  {
950  }
951  emit changed();
952 }
953 
955 {
956  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
957  if ( ramp == NULL )
958  return;
959 
960  mLayer->setColorRamp( ramp );
961  emit changed();
962 }
963 
965 {
966  if ( mLayer->colorRamp()->type() == "gradient" )
967  {
969  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
970  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
971 
972  if ( dlg.exec() && gradRamp )
973  {
974  mLayer->setColorRamp( gradRamp );
975  cboGradientColorRamp->blockSignals( true );
976  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
977  cboGradientColorRamp->blockSignals( false );
978  emit changed();
979  }
980  else
981  {
982  delete ramp;
983  }
984  }
985 }
986 
988 {
989  switch ( index )
990  {
991  case 0:
993  //set sensible default reference points
994  spinRefPoint1X->setValue( 0.5 );
995  spinRefPoint1Y->setValue( 0 );
996  spinRefPoint2X->setValue( 0.5 );
997  spinRefPoint2Y->setValue( 1 );
998  break;
999  case 1:
1001  //set sensible default reference points
1002  spinRefPoint1X->setValue( 0 );
1003  spinRefPoint1Y->setValue( 0 );
1004  spinRefPoint2X->setValue( 1 );
1005  spinRefPoint2Y->setValue( 1 );
1006  break;
1007  case 2:
1009  spinRefPoint1X->setValue( 0.5 );
1010  spinRefPoint1Y->setValue( 0.5 );
1011  spinRefPoint2X->setValue( 1 );
1012  spinRefPoint2Y->setValue( 1 );
1013  break;
1014  }
1015  emit changed();
1016 }
1017 
1019 {
1020 
1021  switch ( index )
1022  {
1023  case 0:
1024  //feature coordinate mode
1026  //allow choice of centroid reference positions
1027  checkRefPoint1Centroid->setEnabled( true );
1028  checkRefPoint2Centroid->setEnabled( true );
1029  break;
1030  case 1:
1031  //viewport coordinate mode
1033  //disable choice of centroid reference positions
1034  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1035  checkRefPoint1Centroid->setEnabled( false );
1036  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1037  checkRefPoint2Centroid->setEnabled( false );
1038  break;
1039  }
1040 
1041  emit changed();
1042 }
1043 
1045 {
1046  switch ( index )
1047  {
1048  case 0:
1050  break;
1051  case 1:
1053  break;
1054  case 2:
1056  break;
1057  }
1058 
1059  emit changed();
1060 }
1061 
1063 {
1064  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1065  emit changed();
1066 }
1067 
1069 {
1070  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1071  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1072  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1073  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1074  emit changed();
1075 }
1076 
1078 {
1079  mLayer->setAngle( value );
1080  emit changed();
1081 }
1082 
1084 {
1085  if ( mLayer )
1086  {
1087  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1088  mLayer->setOffsetUnit( unit );
1089  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1090  emit changed();
1091  }
1092 }
1093 
1095 {
1096  if ( !mLayer )
1097  {
1098  return;
1099  }
1100 
1101  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1102  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color (start)" ), mLayer->dataDefinedPropertyString( "color" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1103  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color2", tr( "Color (end)" ), mLayer->dataDefinedPropertyString( "color2" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1104  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
1106  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "gradient_type", tr( "Gradient type" ), mLayer->dataDefinedPropertyString( "gradient_type" ), QgsDataDefinedSymbolDialog::gradientTypeHelpText() );
1107  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "coordinate_mode", tr( "Coordinate mode" ), mLayer->dataDefinedPropertyString( "coordinate_mode" ), QgsDataDefinedSymbolDialog::gradientCoordModeHelpText() );
1108  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "spread", tr( "Spread" ), mLayer->dataDefinedPropertyString( "spread" ),
1110  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_x", tr( "Reference Point 1 (x)" ), mLayer->dataDefinedPropertyString( "reference1_x" ),
1112  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_y", tr( "Reference Point 1 (y)" ), mLayer->dataDefinedPropertyString( "reference1_y" ),
1114  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_iscentroid", tr( "Reference Point 1 (is centroid)" ), mLayer->dataDefinedPropertyString( "reference1_iscentroid" ),
1116  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_x", tr( "Reference Point 2 (x)" ), mLayer->dataDefinedPropertyString( "reference2_x" ),
1118  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_y", tr( "Reference Point 2 (y)" ), mLayer->dataDefinedPropertyString( "reference2_y" ),
1120  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_iscentroid", tr( "Reference Point 2 (is centroid)" ), mLayer->dataDefinedPropertyString( "reference2_iscentroid" ),
1122 
1123  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1124  if ( d.exec() == QDialog::Accepted )
1125  {
1126  //empty all existing properties first
1128 
1129  QMap<QString, QString> properties = d.dataDefinedProperties();
1130  QMap<QString, QString>::const_iterator it = properties.constBegin();
1131  for ( ; it != properties.constEnd(); ++it )
1132  {
1133  if ( !it.value().isEmpty() )
1134  {
1135  mLayer->setDataDefinedProperty( it.key(), it.value() );
1136  }
1137  }
1138  emit changed();
1139  }
1140 }
1141 
1143 
1145  : QgsSymbolLayerV2Widget( parent, vl )
1146 {
1147  mLayer = NULL;
1148 
1149  setupUi( this );
1150  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1151  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1152 
1153  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
1154  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1155  btnChangeColor->setContext( "symbology" );
1156  btnChangeColor->setShowNoColor( true );
1157  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1158  btnChangeColor2->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
1159  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1160  btnChangeColor2->setContext( "symbology" );
1161  btnChangeColor2->setShowNoColor( true );
1162  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1163 
1164  cboGradientColorRamp->setShowGradientOnly( true );
1165  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1166 
1167  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ) , this, SLOT( applyColorRamp() ) );
1168  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1169  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1170  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1171  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1172  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1173 
1174  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1175  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1176 }
1177 
1179 {
1180  if ( layer->layerType() != "ShapeburstFill" )
1181  return;
1182 
1183  // layer type is correct, we can do the cast
1184  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1185 
1186  // set values
1187  btnChangeColor->blockSignals( true );
1188  btnChangeColor->setColor( mLayer->color() );
1189  btnChangeColor->blockSignals( false );
1190  btnChangeColor2->blockSignals( true );
1191  btnChangeColor2->setColor( mLayer->color2() );
1192  btnChangeColor2->blockSignals( false );
1193 
1195  {
1196  radioTwoColor->setChecked( true );
1197  cboGradientColorRamp->setEnabled( false );
1198  }
1199  else
1200  {
1201  radioColorRamp->setChecked( true );
1202  btnChangeColor->setEnabled( false );
1203  btnChangeColor2->setEnabled( false );
1204  }
1205 
1206  mSpinBlurRadius->blockSignals( true );
1207  mBlurSlider->blockSignals( true );
1208  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1209  mBlurSlider->setValue( mLayer->blurRadius() );
1210  mSpinBlurRadius->blockSignals( false );
1211  mBlurSlider->blockSignals( false );
1212 
1213  mSpinMaxDistance->blockSignals( true );
1214  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1215  mSpinMaxDistance->blockSignals( false );
1216 
1217  mRadioUseWholeShape->blockSignals( true );
1218  mRadioUseMaxDistance->blockSignals( true );
1219  if ( mLayer->useWholeShape() )
1220  {
1221  mRadioUseWholeShape->setChecked( true );
1222  mSpinMaxDistance->setEnabled( false );
1223  mDistanceUnitWidget->setEnabled( false );
1224  }
1225  else
1226  {
1227  mRadioUseMaxDistance->setChecked( true );
1228  mSpinMaxDistance->setEnabled( true );
1229  mDistanceUnitWidget->setEnabled( true );
1230  }
1231  mRadioUseWholeShape->blockSignals( false );
1232  mRadioUseMaxDistance->blockSignals( false );
1233 
1234  mDistanceUnitWidget->blockSignals( true );
1235  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1236  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1237  mDistanceUnitWidget->blockSignals( false );
1238 
1239  mIgnoreRingsCheckBox->blockSignals( true );
1240  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1241  mIgnoreRingsCheckBox->blockSignals( false );
1242 
1243  // set source color ramp
1244  if ( mLayer->colorRamp() )
1245  {
1246  cboGradientColorRamp->blockSignals( true );
1247  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1248  cboGradientColorRamp->blockSignals( false );
1249  }
1250 
1251  spinOffsetX->blockSignals( true );
1252  spinOffsetX->setValue( mLayer->offset().x() );
1253  spinOffsetX->blockSignals( false );
1254  spinOffsetY->blockSignals( true );
1255  spinOffsetY->setValue( mLayer->offset().y() );
1256  spinOffsetY->blockSignals( false );
1257  mOffsetUnitWidget->blockSignals( true );
1258  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1259  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1260  mOffsetUnitWidget->blockSignals( false );
1261 }
1262 
1264 {
1265  return mLayer;
1266 }
1267 
1269 {
1270  if ( mLayer )
1271  {
1272  mLayer->setColor( color );
1273  emit changed();
1274  }
1275 }
1276 
1278 {
1279  if ( mLayer )
1280  {
1281  mLayer->setColor2( color );
1282  emit changed();
1283  }
1284 }
1285 
1287 {
1288  if ( !mLayer )
1289  {
1290  return;
1291  }
1292 
1293  if ( radioTwoColor->isChecked() )
1294  {
1296  }
1297  else
1298  {
1300  }
1301  emit changed();
1302 }
1303 
1305 {
1306  if ( mLayer )
1307  {
1308  mLayer->setBlurRadius( value );
1309  emit changed();
1310  }
1311 }
1312 
1314 {
1315  if ( mLayer )
1316  {
1317  mLayer->setMaxDistance( value );
1318  emit changed();
1319  }
1320 }
1321 
1323 {
1324  if ( mLayer )
1325  {
1326  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
1327  mLayer->setDistanceUnit( unit );
1328  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1329  emit changed();
1330  }
1331 }
1332 
1334 {
1335  if ( mLayer )
1336  {
1337  mLayer->setUseWholeShape( value );
1338  mDistanceUnitWidget->setEnabled( !value );
1339  emit changed();
1340  }
1341 }
1342 
1344 {
1345  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1346  if ( ramp == NULL )
1347  return;
1348 
1349  mLayer->setColorRamp( ramp );
1350  emit changed();
1351 }
1352 
1354 {
1355  if ( mLayer->colorRamp()->type() == "gradient" )
1356  {
1358  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
1359  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
1360 
1361  if ( dlg.exec() && gradRamp )
1362  {
1363  mLayer->setColorRamp( gradRamp );
1364  cboGradientColorRamp->blockSignals( true );
1365  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1366  cboGradientColorRamp->blockSignals( false );
1367  emit changed();
1368  }
1369  else
1370  {
1371  delete ramp;
1372  }
1373  }
1374 }
1375 
1377 {
1378  if ( mLayer )
1379  {
1380  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1381  emit changed();
1382  }
1383 }
1384 
1386 {
1387  if ( mLayer )
1388  {
1389  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1390  mLayer->setOffsetUnit( unit );
1391  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1392  emit changed();
1393  }
1394 }
1395 
1397 {
1398  if ( !mLayer )
1399  {
1400  return;
1401  }
1402 
1403  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1404  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color (start)" ), mLayer->dataDefinedPropertyString( "color" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1405  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color2", tr( "Color (end)" ), mLayer->dataDefinedPropertyString( "color2" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1406  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "blur_radius", tr( "Blur radius" ), mLayer->dataDefinedPropertyString( "blur_radius" ),
1407  tr( "Integer between 0 and 18" ) );
1408  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "use_whole_shape", tr( "Use whole shape" ), mLayer->dataDefinedPropertyString( "use_whole_shape" ), QgsDataDefinedSymbolDialog::boolHelpText() );
1409  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "max_distance", tr( "Maximum distance" ), mLayer->dataDefinedPropertyString( "max_distance" ), QgsDataDefinedSymbolDialog::doubleHelpText() );
1410  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "ignore_rings", tr( "Ignore rings" ), mLayer->dataDefinedPropertyString( "ignore_rings" ), QgsDataDefinedSymbolDialog::boolHelpText() );
1411 
1412  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1413  if ( d.exec() == QDialog::Accepted )
1414  {
1415  //empty all existing properties first
1417 
1418  QMap<QString, QString> properties = d.dataDefinedProperties();
1419  QMap<QString, QString>::const_iterator it = properties.constBegin();
1420  for ( ; it != properties.constEnd(); ++it )
1421  {
1422  if ( !it.value().isEmpty() )
1423  {
1424  mLayer->setDataDefinedProperty( it.key(), it.value() );
1425  }
1426  }
1427  emit changed();
1428  }
1429 }
1430 
1432 {
1433  bool checked = ( state == Qt::Checked );
1434  mLayer->setIgnoreRings( checked );
1435  emit changed();
1436 }
1437 
1439 
1441  : QgsSymbolLayerV2Widget( parent, vl )
1442 {
1443  mLayer = NULL;
1444 
1445  setupUi( this );
1446  mIntervalUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1447  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1448  mOffsetAlongLineUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1449 
1450  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1451  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1452  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1453  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1454  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1455  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1456  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1457  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1458  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1459 }
1460 
1462 {
1463  if ( layer->layerType() != "MarkerLine" )
1464  return;
1465 
1466  // layer type is correct, we can do the cast
1467  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1468 
1469  // set values
1470  spinInterval->blockSignals( true );
1471  spinInterval->setValue( mLayer->interval() );
1472  spinInterval->blockSignals( false );
1473  mSpinOffsetAlongLine->blockSignals( true );
1474  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1475  mSpinOffsetAlongLine->blockSignals( false );
1476  chkRotateMarker->blockSignals( true );
1477  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1478  chkRotateMarker->blockSignals( false );
1479  spinOffset->blockSignals( true );
1480  spinOffset->setValue( mLayer->offset() );
1481  spinOffset->blockSignals( false );
1483  radInterval->setChecked( true );
1485  radVertex->setChecked( true );
1487  radVertexLast->setChecked( true );
1489  radCentralPoint->setChecked( true );
1490  else
1491  radVertexFirst->setChecked( true );
1492 
1493  // set units
1494  mIntervalUnitWidget->blockSignals( true );
1495  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1496  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1497  mIntervalUnitWidget->blockSignals( false );
1498  mOffsetUnitWidget->blockSignals( true );
1499  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1500  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1501  mOffsetUnitWidget->blockSignals( false );
1502  mOffsetAlongLineUnitWidget->blockSignals( true );
1503  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1504  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1505  mOffsetAlongLineUnitWidget->blockSignals( false );
1506 
1507  setPlacement(); // update gui
1508 }
1509 
1511 {
1512  return mLayer;
1513 }
1514 
1516 {
1517  mLayer->setInterval( val );
1518  emit changed();
1519 }
1520 
1522 {
1523  mLayer->setOffsetAlongLine( val );
1524  emit changed();
1525 }
1526 
1528 {
1529  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1530  emit changed();
1531 }
1532 
1534 {
1535  mLayer->setOffset( spinOffset->value() );
1536  emit changed();
1537 }
1538 
1540 {
1541  bool interval = radInterval->isChecked();
1542  spinInterval->setEnabled( interval );
1543  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1544  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1545  if ( radInterval->isChecked() )
1547  else if ( radVertex->isChecked() )
1549  else if ( radVertexLast->isChecked() )
1551  else if ( radVertexFirst->isChecked() )
1553  else
1555 
1556  emit changed();
1557 }
1558 
1560 {
1561  if ( mLayer )
1562  {
1563  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mIntervalUnitWidget->getUnit() );
1564  mLayer->setIntervalUnit( unit );
1565  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1566  emit changed();
1567  }
1568 }
1569 
1571 {
1572  if ( mLayer )
1573  {
1574  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1575  mLayer->setOffsetUnit( unit );
1576  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1577  emit changed();
1578  }
1579 }
1580 
1582 {
1583  if ( mLayer )
1584  {
1585  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetAlongLineUnitWidget->getUnit() );
1586  mLayer->setOffsetAlongLineUnit( unit );
1587  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1588  }
1589  emit changed();
1590 }
1591 
1593 {
1594  if ( !mLayer )
1595  {
1596  return;
1597  }
1598 
1599  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1600  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "interval", tr( "Interval" ), mLayer->dataDefinedPropertyString( "interval" ),
1602  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Line offset" ), mLayer->dataDefinedPropertyString( "offset" ),
1604  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "placement", tr( "Placement" ), mLayer->dataDefinedPropertyString( "placement" ),
1605  tr( "'vertex'|'lastvertex'|'firstvertex'|'centerpoint'" ) );
1606  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset_along_line", tr( "Offset along line" ), mLayer->dataDefinedPropertyString( "offset_along_line" ),
1608  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1609  if ( d.exec() == QDialog::Accepted )
1610  {
1611  //empty all existing properties first
1613 
1614  QMap<QString, QString> properties = d.dataDefinedProperties();
1615  QMap<QString, QString>::const_iterator it = properties.constBegin();
1616  for ( ; it != properties.constEnd(); ++it )
1617  {
1618  if ( !it.value().isEmpty() )
1619  {
1620  mLayer->setDataDefinedProperty( it.key(), it.value() );
1621  }
1622  }
1623  emit changed();
1624  }
1625 }
1626 
1628 
1629 
1631  : QgsSymbolLayerV2Widget( parent, vl )
1632 {
1633  mLayer = NULL;
1634 
1635  setupUi( this );
1636  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1637  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1638  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1639  viewGroups->setHeaderHidden( true );
1640 
1641  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1642  mChangeColorButton->setContext( "symbology" );
1643  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1644  mChangeColorButton->setContext( "symbology" );
1645 
1646  populateList();
1647 
1648  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1649  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1650  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1651  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1652  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1653  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1654 }
1655 
1656 #include <QTime>
1657 #include <QAbstractListModel>
1658 #include <QPixmapCache>
1659 #include <QStyle>
1660 
1661 class QgsSvgListModel : public QAbstractListModel
1662 {
1663  public:
1664  QgsSvgListModel( QObject* parent ) : QAbstractListModel( parent )
1665  {
1667  }
1668 
1669  // Constructor to create model for icons in a specific path
1670  QgsSvgListModel( QObject* parent, QString path ) : QAbstractListModel( parent )
1671  {
1673  }
1674 
1675  int rowCount( const QModelIndex & parent = QModelIndex() ) const
1676  {
1677  Q_UNUSED( parent );
1678  return mSvgFiles.count();
1679  }
1680 
1681  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const
1682  {
1683  QString entry = mSvgFiles.at( index.row() );
1684 
1685  if ( role == Qt::DecorationRole ) // icon
1686  {
1687  QPixmap pixmap;
1688  if ( !QPixmapCache::find( entry, pixmap ) )
1689  {
1690  // render SVG file
1691  QColor fill, outline;
1692  double outlineWidth;
1693  bool fillParam, outlineParam, outlineWidthParam;
1694  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1695 
1696  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1697  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1698  pixmap = QPixmap::fromImage( img );
1699  QPixmapCache::insert( entry, pixmap );
1700  }
1701 
1702  return pixmap;
1703  }
1704  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1705  {
1706  return entry;
1707  }
1708 
1709  return QVariant();
1710  }
1711 
1712  protected:
1713  QStringList mSvgFiles;
1714 };
1715 
1716 class QgsSvgGroupsModel : public QStandardItemModel
1717 {
1718  public:
1719  QgsSvgGroupsModel( QObject* parent ) : QStandardItemModel( parent )
1720  {
1721  QStringList svgPaths = QgsApplication::svgPaths();
1722  QStandardItem *parentItem = invisibleRootItem();
1723 
1724  for ( int i = 0; i < svgPaths.size(); i++ )
1725  {
1726  QDir dir( svgPaths[i] );
1727  QStandardItem *baseGroup;
1728 
1729  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1730  {
1731  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1732  }
1733  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1734  {
1735  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1736  }
1737  else
1738  {
1739  baseGroup = new QStandardItem( dir.dirName() );
1740  }
1741  baseGroup->setData( QVariant( svgPaths[i] ) );
1742  baseGroup->setEditable( false );
1743  baseGroup->setCheckable( false );
1744  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1745  baseGroup->setToolTip( dir.path() );
1746  parentItem->appendRow( baseGroup );
1747  createTree( baseGroup );
1748  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1749  }
1750  }
1751  private:
1752  void createTree( QStandardItem* &parentGroup )
1753  {
1754  QDir parentDir( parentGroup->data().toString() );
1755  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1756  {
1757  QStandardItem* group = new QStandardItem( item );
1758  group->setData( QVariant( parentDir.path() + "/" + item ) );
1759  group->setEditable( false );
1760  group->setCheckable( false );
1761  group->setToolTip( parentDir.path() + "/" + item );
1762  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1763  parentGroup->appendRow( group );
1764  createTree( group );
1765  }
1766  }
1767 };
1768 
1770 {
1771  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1772  viewGroups->setModel( g );
1773  // Set the tree expanded at the first level
1774  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1775  for ( int i = 0; i < rows; i++ )
1776  {
1777  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1778  }
1779 
1780  // Initally load the icons in the List view without any grouping
1781  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1782  viewImages->setModel( m );
1783 }
1784 
1786 {
1787  QString path = idx.data( Qt::UserRole + 1 ).toString();
1788 
1789  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1790  viewImages->setModel( m );
1791 
1792  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1793  emit changed();
1794 }
1795 
1797 {
1798  if ( !layer )
1799  {
1800  return;
1801  }
1802 
1803  //activate gui for svg parameters only if supported by the svg file
1804  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1805  QColor defaultFill, defaultOutline;
1806  double defaultOutlineWidth;
1807  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1808  mChangeColorButton->setEnabled( hasFillParam );
1809  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1810  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1811 
1812  if ( hasFillParam )
1813  {
1814  if ( layer->fillColor().isValid() )
1815  {
1816  mChangeColorButton->setColor( layer->fillColor() );
1817  }
1818  else
1819  {
1820  mChangeColorButton->setColor( defaultFill );
1821  }
1822  }
1823  if ( hasOutlineParam )
1824  {
1825  if ( layer->outlineColor().isValid() )
1826  {
1827  mChangeBorderColorButton->setColor( layer->outlineColor() );
1828  }
1829  else
1830  {
1831  mChangeBorderColorButton->setColor( defaultOutline );
1832  }
1833  }
1834 
1835  mFileLineEdit->blockSignals( true );
1836  mFileLineEdit->setText( layer->path() );
1837  mFileLineEdit->blockSignals( false );
1838 
1839  mBorderWidthSpinBox->blockSignals( true );
1840  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1841  mBorderWidthSpinBox->blockSignals( false );
1842 }
1843 
1844 
1846 {
1847  if ( !layer )
1848  {
1849  return;
1850  }
1851 
1852  if ( layer->layerType() != "SvgMarker" )
1853  return;
1854 
1855  // layer type is correct, we can do the cast
1856  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1857 
1858  // set values
1859 
1860  QAbstractItemModel* m = viewImages->model();
1861  QItemSelectionModel* selModel = viewImages->selectionModel();
1862  for ( int i = 0; i < m->rowCount(); i++ )
1863  {
1864  QModelIndex idx( m->index( i, 0 ) );
1865  if ( m->data( idx ).toString() == mLayer->path() )
1866  {
1867  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1868  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1869  setName( idx );
1870  break;
1871  }
1872  }
1873 
1874  spinSize->blockSignals( true );
1875  spinSize->setValue( mLayer->size() );
1876  spinSize->blockSignals( false );
1877  spinAngle->blockSignals( true );
1878  spinAngle->setValue( mLayer->angle() );
1879  spinAngle->blockSignals( false );
1880 
1881  // without blocking signals the value gets changed because of slot setOffset()
1882  spinOffsetX->blockSignals( true );
1883  spinOffsetX->setValue( mLayer->offset().x() );
1884  spinOffsetX->blockSignals( false );
1885  spinOffsetY->blockSignals( true );
1886  spinOffsetY->setValue( mLayer->offset().y() );
1887  spinOffsetY->blockSignals( false );
1888 
1889  mSizeUnitWidget->blockSignals( true );
1890  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1891  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1892  mSizeUnitWidget->blockSignals( false );
1893  mBorderWidthUnitWidget->blockSignals( true );
1894  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1895  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1896  mBorderWidthUnitWidget->blockSignals( false );
1897  mOffsetUnitWidget->blockSignals( true );
1898  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1899  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1900  mOffsetUnitWidget->blockSignals( false );
1901 
1902  //anchor points
1903  mHorizontalAnchorComboBox->blockSignals( true );
1904  mVerticalAnchorComboBox->blockSignals( true );
1905  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1906  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1907  mHorizontalAnchorComboBox->blockSignals( false );
1908  mVerticalAnchorComboBox->blockSignals( false );
1909 
1910  setGuiForSvg( mLayer );
1911 }
1912 
1914 {
1915  return mLayer;
1916 }
1917 
1918 void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
1919 {
1920  QString name = idx.data( Qt::UserRole ).toString();
1921  mLayer->setPath( name );
1922  mFileLineEdit->setText( name );
1923 
1924  setGuiForSvg( mLayer );
1925  emit changed();
1926 }
1927 
1929 {
1930  mLayer->setSize( spinSize->value() );
1931  emit changed();
1932 }
1933 
1935 {
1936  mLayer->setAngle( spinAngle->value() );
1937  emit changed();
1938 }
1939 
1941 {
1942  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1943  emit changed();
1944 }
1945 
1947 {
1948  QSettings s;
1949  QString file = QFileDialog::getOpenFileName( 0,
1950  tr( "Select SVG file" ),
1951  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1952  tr( "SVG files" ) + " (*.svg)" );
1953  QFileInfo fi( file );
1954  if ( file.isEmpty() || !fi.exists() )
1955  {
1956  return;
1957  }
1958  mFileLineEdit->setText( file );
1959  mLayer->setPath( file );
1960  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1961  emit changed();
1962 }
1963 
1965 {
1966  if ( !QFileInfo( text ).exists() )
1967  {
1968  return;
1969  }
1970  mLayer->setPath( text );
1971  setGuiForSvg( mLayer );
1972  emit changed();
1973 }
1974 
1976 {
1977  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1978  {
1979  QUrl url( mFileLineEdit->text() );
1980  if ( !url.isValid() )
1981  {
1982  return;
1983  }
1984  }
1985 
1986  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1987  mLayer->setPath( mFileLineEdit->text() );
1988  QApplication::restoreOverrideCursor();
1989 
1990  setGuiForSvg( mLayer );
1991  emit changed();
1992 }
1993 
1995 {
1996  if ( !mLayer )
1997  {
1998  return;
1999  }
2000 
2001  mLayer->setFillColor( color );
2002  emit changed();
2003 }
2004 
2006 {
2007  if ( !mLayer )
2008  {
2009  return;
2010  }
2011 
2012  mLayer->setOutlineColor( color );
2013  emit changed();
2014 }
2015 
2017 {
2018  if ( mLayer )
2019  {
2020  mLayer->setOutlineWidth( d );
2021  emit changed();
2022  }
2023 }
2024 
2026 {
2027  if ( mLayer )
2028  {
2029  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
2030  mLayer->setSizeUnit( unit );
2031  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2032  emit changed();
2033  }
2034 }
2035 
2037 {
2038  if ( mLayer )
2039  {
2040  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
2041  mLayer->setOutlineWidthUnit( unit );
2042  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
2043  emit changed();
2044  }
2045 }
2046 
2048 {
2049  if ( mLayer )
2050  {
2051  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2052  mLayer->setOffsetUnit( unit );
2053  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2054  emit changed();
2055  }
2056 }
2057 
2059 {
2060  if ( !mLayer )
2061  {
2062  return;
2063  }
2064 
2065  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2068  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline-width", tr( "Border width" ), mLayer->dataDefinedPropertyString( "outline-width" ),
2070  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
2072  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
2074  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "name", tr( "SVG file" ), mLayer->dataDefinedPropertyString( "name" ),
2076  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "fill", tr( "Color" ), mLayer->dataDefinedPropertyString( "fill" ),
2078  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline", tr( "Border color" ), mLayer->dataDefinedPropertyString( "outline" ),
2080  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "horizontal_anchor_point", tr( "Horizontal anchor point" ), mLayer->dataDefinedPropertyString( "horizontal_anchor_point" ),
2082  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "vertical_anchor_point", tr( "Vertical anchor point" ), mLayer->dataDefinedPropertyString( "vertical_anchor_point" ),
2084  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2085  if ( d.exec() == QDialog::Accepted )
2086  {
2087  //empty all existing properties first
2089 
2090  QMap<QString, QString> properties = d.dataDefinedProperties();
2091  QMap<QString, QString>::const_iterator it = properties.constBegin();
2092  for ( ; it != properties.constEnd(); ++it )
2093  {
2094  if ( !it.value().isEmpty() )
2095  {
2096  mLayer->setDataDefinedProperty( it.key(), it.value() );
2097  }
2098  }
2099  emit changed();
2100  }
2101 }
2102 
2104 {
2105  if ( mLayer )
2106  {
2108  emit changed();
2109  }
2110 }
2111 
2113 {
2114  if ( mLayer )
2115  {
2117  emit changed();
2118  }
2119 }
2120 
2122 
2123 #include <QFileDialog>
2124 
2126 {
2127  mLayer = 0;
2128  setupUi( this );
2129  mTextureWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2130  mSvgOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2131  mSvgTreeView->setHeaderHidden( true );
2132  insertIcons();
2133 
2134  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
2135  mChangeColorButton->setContext( "symbology" );
2136  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
2137  mChangeBorderColorButton->setContext( "symbology" );
2138 
2139  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2140  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
2141 }
2142 
2144 {
2145  if ( !layer )
2146  {
2147  return;
2148  }
2149 
2150  if ( layer->layerType() != "SVGFill" )
2151  {
2152  return;
2153  }
2154 
2155  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
2156  if ( mLayer )
2157  {
2158  double width = mLayer->patternWidth();
2159  mTextureWidthSpinBox->blockSignals( true );
2160  mTextureWidthSpinBox->setValue( width );
2161  mTextureWidthSpinBox->blockSignals( false );
2162  mSVGLineEdit->setText( mLayer->svgFilePath() );
2163  mRotationSpinBox->blockSignals( true );
2164  mRotationSpinBox->setValue( mLayer->angle() );
2165  mRotationSpinBox->blockSignals( false );
2166  mTextureWidthUnitWidget->blockSignals( true );
2167  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2168  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2169  mTextureWidthUnitWidget->blockSignals( false );
2170  mSvgOutlineWidthUnitWidget->blockSignals( true );
2171  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2172  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2173  mSvgOutlineWidthUnitWidget->blockSignals( false );
2174  mChangeColorButton->blockSignals( true );
2175  mChangeColorButton->setColor( mLayer->svgFillColor() );
2176  mChangeColorButton->blockSignals( false );
2177  mChangeBorderColorButton->blockSignals( true );
2178  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2179  mChangeBorderColorButton->blockSignals( false );
2180  mBorderWidthSpinBox->blockSignals( true );
2181  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2182  mBorderWidthSpinBox->blockSignals( false );
2183  }
2184  updateParamGui( false );
2185 }
2186 
2188 {
2189  return mLayer;
2190 }
2191 
2193 {
2194  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2195  if ( !filePath.isNull() )
2196  {
2197  mSVGLineEdit->setText( filePath );
2198  emit changed();
2199  }
2200 }
2201 
2203 {
2204  if ( mLayer )
2205  {
2206  mLayer->setPatternWidth( d );
2207  emit changed();
2208  }
2209 }
2210 
2212 {
2213  if ( !mLayer )
2214  {
2215  return;
2216  }
2217 
2218  QFileInfo fi( text );
2219  if ( !fi.exists() )
2220  {
2221  return;
2222  }
2223  mLayer->setSvgFilePath( text );
2224  updateParamGui();
2225  emit changed();
2226 }
2227 
2229 {
2230  if ( !mLayer )
2231  {
2232  return;
2233  }
2234 
2235  QFileInfo fi( mSVGLineEdit->text() );
2236  if ( !fi.exists() )
2237  {
2238  QUrl url( mSVGLineEdit->text() );
2239  if ( !url.isValid() )
2240  {
2241  return;
2242  }
2243  }
2244 
2245  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2246  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2247  QApplication::restoreOverrideCursor();
2248 
2249  updateParamGui();
2250  emit changed();
2251 }
2252 
2253 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2254 {
2255  QString file = item.data( Qt::UserRole ).toString();
2256  mLayer->setSvgFilePath( file );
2257  mSVGLineEdit->setText( file );
2258 
2259  updateParamGui();
2260  emit changed();
2261 }
2262 
2264 {
2265  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2266  mSvgTreeView->setModel( g );
2267  // Set the tree expanded at the first level
2268  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2269  for ( int i = 0; i < rows; i++ )
2270  {
2271  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2272  }
2273 
2274  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2275  mSvgListView->setModel( m );
2276 }
2277 
2278 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2279 {
2280  QString path = idx.data( Qt::UserRole + 1 ).toString();
2281 
2282  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2283  mSvgListView->setModel( m );
2284 
2285  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2286  emit changed();
2287 }
2288 
2289 
2291 {
2292  if ( mLayer )
2293  {
2294  mLayer->setAngle( d );
2295  emit changed();
2296  }
2297 }
2298 
2300 {
2301  //activate gui for svg parameters only if supported by the svg file
2302  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2303  QColor defaultFill, defaultOutline;
2304  double defaultOutlineWidth;
2305  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2306  if ( hasFillParam && resetValues )
2307  {
2308  mChangeColorButton->setColor( defaultFill );
2309  }
2310  mChangeColorButton->setEnabled( hasFillParam );
2311  if ( hasOutlineParam && resetValues )
2312  {
2313  mChangeBorderColorButton->setColor( defaultOutline );
2314  }
2315  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2316  if ( hasOutlineWidthParam && resetValues )
2317  {
2318  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2319  }
2320  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2321 }
2322 
2324 {
2325  if ( !mLayer )
2326  {
2327  return;
2328  }
2329 
2330  mLayer->setSvgFillColor( color );
2331  emit changed();
2332 }
2333 
2335 {
2336  if ( !mLayer )
2337  {
2338  return;
2339  }
2340 
2341  mLayer->setSvgOutlineColor( color );
2342  emit changed();
2343 }
2344 
2346 {
2347  if ( mLayer )
2348  {
2349  mLayer->setSvgOutlineWidth( d );
2350  emit changed();
2351  }
2352 }
2353 
2355 {
2356  if ( mLayer )
2357  {
2358  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mTextureWidthUnitWidget->getUnit() );
2359  mLayer->setPatternWidthUnit( unit );
2360  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2361  emit changed();
2362  }
2363 }
2364 
2366 {
2367  if ( mLayer )
2368  {
2369  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSvgOutlineWidthUnitWidget->getUnit() );
2370  mLayer->setSvgOutlineWidthUnit( unit );
2371  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2372  emit changed();
2373  }
2374 }
2375 
2377 {
2378  if ( !mLayer )
2379  {
2380  return;
2381  }
2382 
2383  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2384  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Texture width" ), mLayer->dataDefinedPropertyString( "width" ),
2386  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgFile", tr( "SVG file" ), mLayer->dataDefinedPropertyString( "svgFile" ),
2388  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Rotation" ), mLayer->dataDefinedPropertyString( "angle" ),
2390  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgFillColor", tr( "Color" ), mLayer->dataDefinedPropertyString( "svgFillColor" ),
2392  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgOutlineColor", tr( "Border color" ), mLayer->dataDefinedPropertyString( "svgOutlineColor" ),
2394  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgOutlineWidth", tr( "Border width" ), mLayer->dataDefinedPropertyString( "svgOutlineWidth" ),
2396  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2397  if ( d.exec() == QDialog::Accepted )
2398  {
2399  //empty all existing properties first
2401 
2402  QMap<QString, QString> properties = d.dataDefinedProperties();
2403  QMap<QString, QString>::const_iterator it = properties.constBegin();
2404  for ( ; it != properties.constEnd(); ++it )
2405  {
2406  if ( !it.value().isEmpty() )
2407  {
2408  mLayer->setDataDefinedProperty( it.key(), it.value() );
2409  }
2410  }
2411  emit changed();
2412  }
2413 }
2414 
2416 
2418  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2419 {
2420  setupUi( this );
2421  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2422  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2423 }
2424 
2426 {
2427  if ( layer->layerType() != "LinePatternFill" )
2428  {
2429  return;
2430  }
2431 
2432  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2433  if ( patternLayer )
2434  {
2435  mLayer = patternLayer;
2436  mAngleSpinBox->blockSignals( true );
2437  mAngleSpinBox->setValue( mLayer->lineAngle() );
2438  mAngleSpinBox->blockSignals( false );
2439  mDistanceSpinBox->blockSignals( true );
2440  mDistanceSpinBox->setValue( mLayer->distance() );
2441  mDistanceSpinBox->blockSignals( false );
2442  mOffsetSpinBox->blockSignals( true );
2443  mOffsetSpinBox->setValue( mLayer->offset() );
2444  mOffsetSpinBox->blockSignals( false );
2445 
2446  //units
2447  mDistanceUnitWidget->blockSignals( true );
2448  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2449  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2450  mDistanceUnitWidget->blockSignals( false );
2451  mOffsetUnitWidget->blockSignals( true );
2452  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2453  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2454  mOffsetUnitWidget->blockSignals( false );
2455  }
2456 }
2457 
2459 {
2460  return mLayer;
2461 }
2462 
2464 {
2465  if ( mLayer )
2466  {
2467  mLayer->setLineAngle( d );
2468  emit changed();
2469  }
2470 }
2471 
2473 {
2474  if ( mLayer )
2475  {
2476  mLayer->setDistance( d );
2477  emit changed();
2478  }
2479 }
2480 
2482 {
2483  if ( mLayer )
2484  {
2485  mLayer->setOffset( d );
2486  emit changed();
2487  }
2488 }
2489 
2491 {
2492  if ( mLayer )
2493  {
2494  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
2495  mLayer->setDistanceUnit( unit );
2496  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2497  emit changed();
2498  }
2499 }
2500 
2502 {
2503  if ( mLayer )
2504  {
2505  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2506  mLayer->setOffsetUnit( unit );
2507  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2508  emit changed();
2509  }
2510 }
2511 
2513 {
2514  if ( !mLayer )
2515  {
2516  return;
2517  }
2518 
2519  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2520  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "lineangle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "lineangle" ),
2522  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance", tr( "Distance" ), mLayer->dataDefinedPropertyString( "distance" ),
2524  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "linewidth", tr( "Line width" ), mLayer->dataDefinedPropertyString( "linewidth" ),
2526  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ),
2528  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2529  if ( d.exec() == QDialog::Accepted )
2530  {
2531  //empty all existing properties first
2533 
2534  QMap<QString, QString> properties = d.dataDefinedProperties();
2535  QMap<QString, QString>::const_iterator it = properties.constBegin();
2536  for ( ; it != properties.constEnd(); ++it )
2537  {
2538  if ( !it.value().isEmpty() )
2539  {
2540  mLayer->setDataDefinedProperty( it.key(), it.value() );
2541  }
2542  }
2543  emit changed();
2544  }
2545 }
2546 
2547 
2549 
2551  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2552 {
2553  setupUi( this );
2554  mHorizontalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2555  mVerticalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2556  mHorizontalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2557  mVerticalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2558 }
2559 
2560 
2562 {
2563  if ( !layer || layer->layerType() != "PointPatternFill" )
2564  {
2565  return;
2566  }
2567 
2568  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2569  mHorizontalDistanceSpinBox->blockSignals( true );
2570  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2571  mHorizontalDistanceSpinBox->blockSignals( false );
2572  mVerticalDistanceSpinBox->blockSignals( true );
2573  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2574  mVerticalDistanceSpinBox->blockSignals( false );
2575  mHorizontalDisplacementSpinBox->blockSignals( true );
2576  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2577  mHorizontalDisplacementSpinBox->blockSignals( false );
2578  mVerticalDisplacementSpinBox->blockSignals( true );
2579  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2580  mVerticalDisplacementSpinBox->blockSignals( false );
2581 
2582  mHorizontalDistanceUnitWidget->blockSignals( true );
2583  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2584  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2585  mHorizontalDistanceUnitWidget->blockSignals( false );
2586  mVerticalDistanceUnitWidget->blockSignals( true ) ;
2587  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2588  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2589  mVerticalDistanceUnitWidget->blockSignals( false );
2590  mHorizontalDisplacementUnitWidget->blockSignals( true );
2591  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2592  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2593  mHorizontalDisplacementUnitWidget->blockSignals( false );
2594  mVerticalDisplacementUnitWidget->blockSignals( true );
2595  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2596  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2597  mVerticalDisplacementUnitWidget->blockSignals( false );
2598 }
2599 
2601 {
2602  return mLayer;
2603 }
2604 
2606 {
2607  if ( mLayer )
2608  {
2609  mLayer->setDistanceX( d );
2610  emit changed();
2611  }
2612 }
2613 
2615 {
2616  if ( mLayer )
2617  {
2618  mLayer->setDistanceY( d );
2619  emit changed();
2620  }
2621 }
2622 
2624 {
2625  if ( mLayer )
2626  {
2627  mLayer->setDisplacementX( d );
2628  emit changed();
2629  }
2630 }
2631 
2633 {
2634  if ( mLayer )
2635  {
2636  mLayer->setDisplacementY( d );
2637  emit changed();
2638  }
2639 }
2640 
2642 {
2643  if ( mLayer )
2644  {
2645  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDistanceUnitWidget->getUnit() );
2646  mLayer->setDistanceXUnit( unit );
2647  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2648  emit changed();
2649  }
2650 }
2651 
2653 {
2654  if ( mLayer )
2655  {
2656  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDistanceUnitWidget->getUnit() );
2657  mLayer->setDistanceYUnit( unit );
2658  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2659  emit changed();
2660  }
2661 }
2662 
2664 {
2665  if ( mLayer )
2666  {
2667  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDisplacementUnitWidget->getUnit() );
2668  mLayer->setDisplacementXUnit( unit );
2669  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2670  emit changed();
2671  }
2672 }
2673 
2675 {
2676  if ( mLayer )
2677  {
2678  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDisplacementUnitWidget->getUnit() );
2679  mLayer->setDisplacementYUnit( unit );
2680  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2681  emit changed();
2682  }
2683 }
2684 
2686 {
2687  if ( !mLayer )
2688  {
2689  return;
2690  }
2691 
2692  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2693  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance_x", tr( "Horizontal distance" ), mLayer->dataDefinedPropertyString( "distance_x" ),
2695  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance_y", tr( "Vertical distance" ), mLayer->dataDefinedPropertyString( "distance_y" ),
2697  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "displacement_x", tr( "Horizontal displacement" ), mLayer->dataDefinedPropertyString( "displacement_x" ),
2699  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "displacement_y", tr( "Vertical displacement" ), mLayer->dataDefinedPropertyString( "displacement_y" ),
2701  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2702  if ( d.exec() == QDialog::Accepted )
2703  {
2704  //empty all existing properties first
2706 
2707  QMap<QString, QString> properties = d.dataDefinedProperties();
2708  QMap<QString, QString>::const_iterator it = properties.constBegin();
2709  for ( ; it != properties.constEnd(); ++it )
2710  {
2711  if ( !it.value().isEmpty() )
2712  {
2713  mLayer->setDataDefinedProperty( it.key(), it.value() );
2714  }
2715  }
2716  emit changed();
2717  }
2718 }
2719 
2721 
2723  : QgsSymbolLayerV2Widget( parent, vl )
2724 {
2725  mLayer = NULL;
2726 
2727  setupUi( this );
2728  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2729  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2731  scrollArea->setWidget( widgetChar );
2732 
2733  btnColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
2734  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2735  btnColor->setContext( "symbology" );
2736 
2737  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2738  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2739  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2740  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2741  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2742  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2743  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2744 }
2745 
2746 
2748 {
2749  if ( layer->layerType() != "FontMarker" )
2750  return;
2751 
2752  // layer type is correct, we can do the cast
2753  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2754 
2755  // set values
2756  cboFont->blockSignals( true );
2757  cboFont->setCurrentFont( QFont( mLayer->fontFamily() ) );
2758  cboFont->blockSignals( false );
2759  spinSize->blockSignals( true );
2760  spinSize->setValue( mLayer->size() );
2761  spinSize->blockSignals( false );
2762  btnColor->blockSignals( true );
2763  btnColor->setColor( mLayer->color() );
2764  btnColor->blockSignals( false );
2765  spinAngle->blockSignals( true );
2766  spinAngle->setValue( mLayer->angle() );
2767  spinAngle->blockSignals( false );
2768 
2769  //block
2770  spinOffsetX->blockSignals( true );
2771  spinOffsetX->setValue( mLayer->offset().x() );
2772  spinOffsetX->blockSignals( false );
2773  spinOffsetY->blockSignals( true );
2774  spinOffsetY->setValue( mLayer->offset().y() );
2775  spinOffsetY->blockSignals( false );
2776 
2777  mSizeUnitWidget->blockSignals( true );
2778  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2779  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2780  mSizeUnitWidget->blockSignals( false );
2781 
2782  mOffsetUnitWidget->blockSignals( true );
2783  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2784  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2785  mOffsetUnitWidget->blockSignals( false );
2786 
2787  //anchor points
2788  mHorizontalAnchorComboBox->blockSignals( true );
2789  mVerticalAnchorComboBox->blockSignals( true );
2790  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2791  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2792  mHorizontalAnchorComboBox->blockSignals( false );
2793  mVerticalAnchorComboBox->blockSignals( false );
2794 }
2795 
2797 {
2798  return mLayer;
2799 }
2800 
2802 {
2803  mLayer->setFontFamily( font.family() );
2804  widgetChar->updateFont( font );
2805  emit changed();
2806 }
2807 
2809 {
2810  mLayer->setColor( color );
2811  emit changed();
2812 }
2813 
2815 {
2816  mLayer->setSize( size );
2817  //widgetChar->updateSize(size);
2818  emit changed();
2819 }
2820 
2822 {
2823  mLayer->setAngle( angle );
2824  emit changed();
2825 }
2826 
2828 {
2829  mLayer->setCharacter( chr );
2830  emit changed();
2831 }
2832 
2834 {
2835  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2836  emit changed();
2837 }
2838 
2840 {
2841  if ( mLayer )
2842  {
2843  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
2844  mLayer->setSizeUnit( unit );
2845  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2846  emit changed();
2847  }
2848 }
2849 
2851 {
2852  if ( mLayer )
2853  {
2854  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2855  mLayer->setOffsetUnit( unit );
2856  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2857  emit changed();
2858  }
2859 }
2860 
2862 {
2863  if ( mLayer )
2864  {
2866  emit changed();
2867  }
2868 }
2869 
2871 {
2872  if ( mLayer )
2873  {
2875  emit changed();
2876  }
2877 }
2878 
2879 
2881 
2882 
2884  : QgsSymbolLayerV2Widget( parent, vl )
2885 {
2886  mLayer = NULL;
2887 
2888  setupUi( this );
2889 }
2890 
2892 {
2893  if ( layer->layerType() != "CentroidFill" )
2894  return;
2895 
2896  // layer type is correct, we can do the cast
2897  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2898 
2899  // set values
2900  mDrawInsideCheckBox->blockSignals( true );
2901  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2902  mDrawInsideCheckBox->blockSignals( false );
2903 }
2904 
2906 {
2907  return mLayer;
2908 }
2909 
2911 {
2912  mLayer->setPointOnSurface( state == Qt::Checked );
2913  emit changed();
2914 }
void setIntervalUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit customDashPatternUnit() const
void setBorderWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsVectorColorRampV2 * colorRamp()
Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp...
VerticalAnchorPoint verticalAnchorPoint() const
QgsSymbolV2::OutputUnit intervalUnit() const
QgsSymbolV2::OutputUnit patternWidthUnit() const
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
void setOutlineStyle(Qt::PenStyle outlineStyle)
QgsSymbolV2::OutputUnit outlineWidthUnit() const
static const QString pkgDataPath()
Returns the common root path of all application data directories.
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon's boundary.
virtual QgsSymbolLayerV2 * symbolLayer()
const QgsMapUnitScale & patternWidthMapUnitScale() const
QgsVectorColorRampV2 * colorRamp()
Returns the color ramp used for the shapeburst fill.
void setGuiForSvg(const QgsSvgMarkerSymbolLayerV2 *layer)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
static unsigned index
virtual QgsSymbolLayerV2 * symbolLayer()
QgsSymbolV2::OutputUnit distanceYUnit() const
virtual void removeDataDefinedProperties()
double outlineWidth
Definition: qgssvgcache.cpp:78
void on_mChangeBorderColorButton_colorChanged(const QColor &color)
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
QgsSymbolV2::OutputUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for markers.
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
void setSvgOutlineWidth(double w)
void setAngle(double angle)
Rotation angle for gradient fill.
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
double ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
QgsSVGFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
const QgsMapUnitScale & offsetMapUnitScale() const
virtual QString type() const =0
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
void setCoordinateMode(GradientCoordinateMode coordinateMode)
virtual double width() const
QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
QgsGradientFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit distanceXUnit() const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsSimpleLineSymbolLayerV2 * mLayer
HorizontalAnchorPoint horizontalAnchorPoint() const
static const QStringList svgPaths()
Returns the pathes to svg directories.
QgsSymbolV2::OutputUnit offsetUnit() const
QgsSimpleMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
QString svgFilePath() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & customDashPatternMapUnitScale() const
QgsLinePatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
QColor outline
Definition: qgssvgcache.cpp:82
#define QgsDebugMsg(str)
Definition: qgslogger.h:36
void setCustomDashPatternUnit(QgsSymbolV2::OutputUnit unit)
double svgOutlineWidth() const
void updateFont(const QFont &font)
[0]
virtual QgsSymbolLayerV2 * symbolLayer()
QgsLinePatternFillSymbolLayer * mLayer
void setFillColor(const QColor &c)
Set fill color.
QgsGradientFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void setPointOnSurface(bool pointOnSurface)
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const
void setOffset(QPointF offset)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
void setMapUnitScale(const QgsMapUnitScale &scale)
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsFontMarkerSymbolLayerV2 * mLayer
void setColor2(QColor color2)
Sets the color for the endpoint of the shapeburst fill.
QVector< qreal > customDashVector() const
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
const QgsMapUnitScale & intervalMapUnitScale() const
void setPenJoinStyle(Qt::PenJoinStyle style)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
int rowCount(const QModelIndex &parent=QModelIndex()) const
void setVerticalAnchorPoint(VerticalAnchorPoint v)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolLayerV2 * clone() const
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
QgsSymbolV2::OutputUnit sizeUnit() const
void on_mChangeColorButton_colorChanged(const QColor &color)
double useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
void setFile(const QModelIndex &item)
void setBorderColor(QColor borderColor)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void on_mVerticalAnchorComboBox_currentIndexChanged(int index)
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & borderWidthMapUnitScale() const
static QIcon icon(QString icon)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsFontMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
static const QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
QgsCentroidFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void setColorRamp(QgsVectorColorRampV2 *ramp)
const QgsVectorLayer * mVectorLayer
Qt::PenStyle penStyle() const
void setWidthUnit(QgsSymbolV2::OutputUnit unit)
void setPatternWidth(double width)
void on_mChangeBorderColorButton_colorChanged(const QColor &color)
void setFontFamily(QString family)
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
virtual QString dataDefinedPropertyString(const QString &property) const
void populateIcons(const QModelIndex &item)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setSvgOutlineColor(const QColor &c)
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the marker placement.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setInterval(double interval)
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasOutlineParam, QColor &defaultOutlineColor, bool &hasOutlineWidthParam, double &defaultOutlineWidth) const
Tests if an svg file contains parameters for fill, outline color, outline width.
static QgsSvgCache * instance()
Definition: qgssvgcache.cpp:84
void on_mSVGLineEdit_textEdited(const QString &text)
void setDrawInsidePolygon(bool drawInsidePolygon)
void setGradientType(GradientType gradientType)
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
const QImage & svgAsImage(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool &fitsInCache)
Get SVG as QImage.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
QgsSymbolV2::OutputUnit offsetUnit() const
QgsShapeburstFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
double offsetAlongLine() const
Returns the offset along the line for the marker placement.
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit u)
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
Qt::PenStyle borderStyle() const
QColor fill
Definition: qgssvgcache.cpp:81
A dialog to enter a custom dash space pattern for lines.
void on_mChangeColorButton_colorChanged(const QColor &color)
void setBorderColor(const QColor &color)
void setPenJoinStyle(Qt::PenJoinStyle style)
void setBrushStyle(Qt::BrushStyle style)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
QgsSimpleLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
const QgsMapUnitScale & offsetMapUnitScale() const
QColor fillColor() const
Get fill color.
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void setMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsVectorColorRampV2 * clone() const =0
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
static QStringList listSvgFiles()
Return a list of all available svg files.
QgsSvgListModel(QObject *parent, QString path)
const QgsMapUnitScale & offsetMapUnitScale() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
virtual void setWidth(double width)
static QgsStyleV2 * defaultStyle()
return default application-wide style
Definition: qgsstylev2.cpp:51
QPointF offset() const
Returns the offset for the shapeburst fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void on_mVerticalAnchorComboBox_currentIndexChanged(int index)
const QgsMapUnitScale & distanceXMapUnitScale() const
void setAngle(double angle)
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & sizeMapUnitScale() const
QgsSymbolV2::OutputUnit distanceUnit() const
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
QgsSymbolV2::OutputUnit borderWidthUnit() const
QGis::GeometryType geometryType() const
Returns point, line or polygon.
virtual QColor color() const
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for markers...
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
void setDisplacementXUnit(QgsSymbolV2::OutputUnit unit)
QgsPointPatternFillSymbolLayer * mLayer
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
void setOffsetAlongLineUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit used for calculating the offset along line for markers.
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
static QStringList listSvgFilesAt(QString directory)
Return a list of svg files at the specified directory.
void setBorderWidthUnit(QgsSymbolV2::OutputUnit unit)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
void setPenCapStyle(Qt::PenCapStyle style)
QgsMarkerLineSymbolLayerV2 * mLayer
void setCustomDashVector(const QVector< qreal > &vector)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsSimpleFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
QgsSymbolV2::ScaleMethod scaleMethod() const
void setMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsSymbolLayerV2 * symbolLayer()
QgsSymbolV2::OutputUnit offsetUnit() const
const QgsMapUnitScale & displacementYMapUnitScale() const
QgsSvgMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void populateIcons(const QModelIndex &idx)
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
void setDistanceXUnit(QgsSymbolV2::OutputUnit unit)
QgsCentroidFillSymbolLayerV2 * mLayer
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QColor svgOutlineColor() const
GradientSpread gradientSpread() const
Gradient spread mode.
const QgsMapUnitScale & distanceMapUnitScale() const
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setOffset(QPointF offset)
Offset for gradient fill.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
virtual QString layerType() const =0
void on_mFileLineEdit_textEdited(const QString &text)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
Definition: qgis.h:410
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units used for the offset for the shapeburst fill.
QColor outlineColor() const
Get outline color.
QgsSimpleMarkerSymbolLayerV2 * mLayer
QString file
Definition: qgssvgcache.cpp:76
void setOffset(QPointF offset)
const QgsMapUnitScale & offsetMapUnitScale() const
virtual QgsSymbolLayerV2 * symbolLayer()
QgsSymbolV2::OutputUnit outlineWidthUnit() const
QgsSvgListModel(QObject *parent)
A class for svg fill patterns.
const QgsMapUnitScale & distanceMapUnitScale() const
void setGradientColorType(GradientColorType gradientColorType)
const QgsMapUnitScale & offsetMapUnitScale() const
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setPenStyle(Qt::PenStyle style)
const QgsMapUnitScale & outlineWidthMapUnitScale() const
void updateParamGui(bool resetValues=true)
Enables or disables svg fill color, border color and border width based on whether the svg file suppo...
Qt::PenStyle outlineStyle() const
const QgsMapUnitScale & widthMapUnitScale() const
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & distanceYMapUnitScale() const
QgsSymbolV2::OutputUnit displacementYUnit() const
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
void setSvgFilePath(const QString &svgPath)
virtual QgsSymbolLayerV2 * symbolLayer()
Qt::PenJoinStyle penJoinStyle() const
QgsSvgMarkerSymbolLayerV2 * mLayer
QgsPointPatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void setColorRamp(QgsVectorColorRampV2 *ramp)
Sets the color ramp used to draw the shapeburst fill.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
const QgsMapUnitScale & offsetMapUnitScale() const
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsSymbolLayerV2 * symbolLayer()
virtual void setColor(const QColor &color)
virtual QgsSymbolLayerV2 * symbolLayer()=0
GradientType gradientType() const
Type of gradient, eg linear or radial.
QgsSvgGroupsModel(QObject *parent)
void setUseWholeShape(double useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setOutlineColor(const QColor &c)
Set outline color.
QgsShapeburstFillSymbolLayerV2 * mLayer
void setMapUnitScale(const QgsMapUnitScale &scale)
void createTree(QStandardItem *&parentGroup)
virtual QString dataDefinedPropertyLabel(const QString &entryName)
Get label for data defined entry.
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit displacementXUnit() const
void setGradientSpread(GradientSpread gradientSpread)
QgsSymbolV2::OutputUnit offsetUnit() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setSize(double size)
void setAngle(double angle)
Represents a vector layer which manages a vector based data sets.
double size
Definition: qgssvgcache.cpp:77
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
const QgsMapUnitScale & offsetMapUnitScale() const
void setBorderWidth(double borderWidth)
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for markers...
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
double angle() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & outlineWidthMapUnitScale() const
Qt::BrushStyle brushStyle() const
QgsSymbolV2::OutputUnit widthUnit() const
QgsSVGFillSymbolLayer * mLayer
QgsSymbolV2::OutputUnit offsetUnit() const
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenJoinStyle penJoinStyle() const
virtual QgsSymbolLayerV2 * symbolLayer()
QgsSimpleFillSymbolLayerV2 * mLayer
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Units for gradient fill offset.
QgsSymbolV2::OutputUnit offsetUnit() const
void setName(const QModelIndex &idx)
Qt::PenCapStyle penCapStyle() const
void setIgnoreRings(double ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
void setSvgOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setDataDefinedProperty(const QString &property, const QString &expressionString)
virtual QgsSymbolLayerV2 * symbolLayer()
#define tr(sourceText)
void setBorderStyle(Qt::PenStyle borderStyle)