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 
30 #include "qgsstylev2.h" //for symbol selector dialog
31 
32 #include "qgsapplication.h"
33 
34 #include "qgslogger.h"
35 
36 #include <QAbstractButton>
37 #include <QColorDialog>
38 #include <QCursor>
39 #include <QDir>
40 #include <QFileDialog>
41 #include <QPainter>
42 #include <QSettings>
43 #include <QStandardItemModel>
44 #include <QSvgRenderer>
45 
46 QString QgsSymbolLayerV2Widget::dataDefinedPropertyLabel( const QString &entryName )
47 {
48  QString label = entryName;
49  if ( entryName == "size" )
50  {
51  label = tr( "Size" );
52  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
53  if ( layer )
54  {
55  switch ( layer->scaleMethod() )
56  {
58  label += " (" + tr( "area" ) + ")";
59  break;
61  label += " (" + tr( "diameter" ) + ")";
62  break;
63  }
64  }
65  }
66  return label;
67 }
68 
70  : QgsSymbolLayerV2Widget( parent, vl )
71 {
72  mLayer = NULL;
73 
74  setupUi( this );
75  mPenWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
76  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
77  mDashPatternUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
78 
79  if ( vl && vl->geometryType() != QGis::Polygon )
80  {
81  //draw inside polygon checkbox only makes sense for polygon layers
82  mDrawInsideCheckBox->hide();
83  }
84 
85  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
86  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
87  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
88  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
89  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
90  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
92 
93 }
94 
96 {
97  if ( !layer || layer->layerType() != "SimpleLine" )
98  return;
99 
100  // layer type is correct, we can do the cast
101  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
102 
103  // set units
104  mPenWidthUnitWidget->blockSignals( true );
105  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
106  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
107  mPenWidthUnitWidget->blockSignals( false );
108  mOffsetUnitWidget->blockSignals( true );
109  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
110  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
111  mOffsetUnitWidget->blockSignals( false );
112  mDashPatternUnitWidget->blockSignals( true );
113  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
114  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
115  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
116  mDashPatternUnitWidget->blockSignals( false );
117 
118  // set values
119  spinWidth->blockSignals( true );
120  spinWidth->setValue( mLayer->width() );
121  spinWidth->blockSignals( false );
122  btnChangeColor->blockSignals( true );
123  btnChangeColor->setColor( mLayer->color() );
124  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
125  btnChangeColor->blockSignals( false );
126  spinOffset->blockSignals( true );
127  spinOffset->setValue( mLayer->offset() );
128  spinOffset->blockSignals( false );
129  cboPenStyle->blockSignals( true );
130  cboJoinStyle->blockSignals( true );
131  cboCapStyle->blockSignals( true );
132  cboPenStyle->setPenStyle( mLayer->penStyle() );
133  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
134  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
135  cboPenStyle->blockSignals( false );
136  cboJoinStyle->blockSignals( false );
137  cboCapStyle->blockSignals( false );
138 
139  //use a custom dash pattern?
140  bool useCustomDashPattern = mLayer->useCustomDashPattern();
141  mChangePatternButton->setEnabled( useCustomDashPattern );
142  label_3->setEnabled( !useCustomDashPattern );
143  cboPenStyle->setEnabled( !useCustomDashPattern );
144  mCustomCheckBox->blockSignals( true );
145  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
146  mCustomCheckBox->blockSignals( false );
147 
148  //draw inside polygon?
149  bool drawInsidePolygon = mLayer->drawInsidePolygon();
150  mDrawInsideCheckBox->blockSignals( true );
151  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
152  mDrawInsideCheckBox->blockSignals( false );
153 
155 }
156 
158 {
159  return mLayer;
160 }
161 
163 {
164  mLayer->setWidth( spinWidth->value() );
166  emit changed();
167 }
168 
170 {
171  mLayer->setColor( color );
173  emit changed();
174 }
175 
177 {
178  mLayer->setPenStyle( cboPenStyle->penStyle() );
179  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
180  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
181  emit changed();
182 }
183 
185 {
186  mLayer->setOffset( spinOffset->value() );
188  emit changed();
189 }
190 
192 {
193  bool checked = ( state == Qt::Checked );
194  mChangePatternButton->setEnabled( checked );
195  label_3->setEnabled( !checked );
196  cboPenStyle->setEnabled( !checked );
197 
198  mLayer->setUseCustomDashPattern( checked );
199  emit changed();
200 }
201 
203 {
205  if ( d.exec() == QDialog::Accepted )
206  {
207  mLayer->setCustomDashVector( d.dashDotVector() );
209  emit changed();
210  }
211 }
212 
214 {
215  if ( mLayer )
216  {
217  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mPenWidthUnitWidget->getUnit() );
218  mLayer->setWidthUnit( unit );
219  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
220  emit changed();
221  }
222 }
223 
225 {
226  if ( mLayer )
227  {
228  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
229  mLayer->setOffsetUnit( unit );
230  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
231  emit changed();
232  }
233 }
234 
236 {
237  if ( mLayer )
238  {
239  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDashPatternUnitWidget->getUnit() );
241  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
242  emit changed();
243  }
244 }
245 
247 {
248  bool checked = ( state == Qt::Checked );
249  mLayer->setDrawInsidePolygon( checked );
250  emit changed();
251 }
252 
254 {
255  if ( !mLayer )
256  {
257  return;
258  }
259 
260  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
261  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ),
263  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Pen width" ), mLayer->dataDefinedPropertyString( "width" ),
265  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
267  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "customdash", tr( "Dash pattern" ), mLayer->dataDefinedPropertyString( "customdash" ), "<dash>;<space>" );
268  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "joinstyle", tr( "Join style" ), mLayer->dataDefinedPropertyString( "joinstyle" ), "'bevel'|'miter'|'round'" );
269  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "capstyle", tr( "Cap style" ), mLayer->dataDefinedPropertyString( "capstyle" ), "'square'|'flat'|'round'" );
270  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
271 
272  if ( d.exec() == QDialog::Accepted )
273  {
274  //empty all existing properties first
276 
277  QMap<QString, QString> properties = d.dataDefinedProperties();
278  QMap<QString, QString>::const_iterator it = properties.constBegin();
279  for ( ; it != properties.constEnd(); ++it )
280  {
281  if ( !it.value().isEmpty() )
282  {
283  mLayer->setDataDefinedProperty( it.key(), it.value() );
284  }
285  }
286  emit changed();
287  }
288 }
289 
291 {
292  if ( !mLayer )
293  {
294  return;
295  }
296  QgsSimpleLineSymbolLayerV2* layerCopy = dynamic_cast<QgsSimpleLineSymbolLayerV2*>( mLayer->clone() );
297  if ( !layerCopy )
298  {
299  return;
300  }
301  layerCopy->setUseCustomDashPattern( true );
302  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
303  mChangePatternButton->setIcon( buttonIcon );
304  delete layerCopy;
305 }
306 
307 
309 
310 
312  : QgsSymbolLayerV2Widget( parent, vl )
313 {
314  mLayer = NULL;
315 
316  setupUi( this );
317  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
318  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
319  mOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
320 
321  QSize size = lstNames->iconSize();
322  QStringList names;
323  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
324  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
325  double markerSize = DEFAULT_POINT_SIZE * 2;
326  for ( int i = 0; i < names.count(); ++i )
327  {
328  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
330  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
331  item->setData( Qt::UserRole, names[i] );
332  delete lyr;
333  }
334 
335  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
336  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
337  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
338  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
339  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
340  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
341  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
342 }
343 
345 {
346  if ( layer->layerType() != "SimpleMarker" )
347  return;
348 
349  // layer type is correct, we can do the cast
350  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
351 
352  // set values
353  QString name = mLayer->name();
354  for ( int i = 0; i < lstNames->count(); ++i )
355  {
356  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
357  {
358  lstNames->setCurrentRow( i );
359  break;
360  }
361  }
362  btnChangeColorBorder->blockSignals( true );
363  btnChangeColorBorder->setColor( mLayer->borderColor() );
364  btnChangeColorBorder->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
365  btnChangeColorBorder->blockSignals( false );
366  btnChangeColorFill->blockSignals( true );
367  btnChangeColorFill->setColor( mLayer->color() );
368  btnChangeColorFill->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
369  btnChangeColorFill->blockSignals( false );
370  spinSize->blockSignals( true );
371  spinSize->setValue( mLayer->size() );
372  spinSize->blockSignals( false );
373  spinAngle->blockSignals( true );
374  spinAngle->setValue( mLayer->angle() );
375  spinAngle->blockSignals( false );
376  mOutlineStyleComboBox->blockSignals( true );
377  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
378  mOutlineStyleComboBox->blockSignals( false );
379  mOutlineWidthSpinBox->blockSignals( true );
380  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
381  mOutlineWidthSpinBox->blockSignals( false );
382 
383  // without blocking signals the value gets changed because of slot setOffset()
384  spinOffsetX->blockSignals( true );
385  spinOffsetX->setValue( mLayer->offset().x() );
386  spinOffsetX->blockSignals( false );
387  spinOffsetY->blockSignals( true );
388  spinOffsetY->setValue( mLayer->offset().y() );
389  spinOffsetY->blockSignals( false );
390 
391  mSizeUnitWidget->blockSignals( true );
392  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
393  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
394  mSizeUnitWidget->blockSignals( false );
395  mOffsetUnitWidget->blockSignals( true );
396  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
397  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
398  mOffsetUnitWidget->blockSignals( false );
399  mOutlineWidthUnitWidget->blockSignals( true );
400  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
401  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
402  mOutlineWidthUnitWidget->blockSignals( false );
403 
404  //anchor points
405  mHorizontalAnchorComboBox->blockSignals( true );
406  mVerticalAnchorComboBox->blockSignals( true );
407  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
408  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
409  mHorizontalAnchorComboBox->blockSignals( false );
410  mVerticalAnchorComboBox->blockSignals( false );
411 }
412 
414 {
415  return mLayer;
416 }
417 
419 {
420  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
421  emit changed();
422 }
423 
425 {
426  mLayer->setBorderColor( color );
427  emit changed();
428 }
429 
431 {
432  mLayer->setColor( color );
433  emit changed();
434 }
435 
437 {
438  mLayer->setSize( spinSize->value() );
439  emit changed();
440 }
441 
443 {
444  mLayer->setAngle( spinAngle->value() );
445  emit changed();
446 }
447 
449 {
450  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
451  emit changed();
452 }
453 
455 {
456  Q_UNUSED( index );
457 
458  if ( mLayer )
459  {
460  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
461  emit changed();
462  }
463 }
464 
466 {
467  if ( mLayer )
468  {
469  mLayer->setOutlineWidth( d );
470  emit changed();
471  }
472 }
473 
475 {
476  if ( mLayer )
477  {
478  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
479  mLayer->setSizeUnit( unit );
480  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
481  emit changed();
482  }
483 }
484 
486 {
487  if ( mLayer )
488  {
489  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
490  mLayer->setOffsetUnit( unit );
491  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
492  emit changed();
493  }
494 }
495 
497 {
498  if ( mLayer )
499  {
500  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOutlineWidthUnitWidget->getUnit() );
501  mLayer->setOutlineWidthUnit( unit );
502  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
503  emit changed();
504  }
505 }
506 
508 {
509  if ( !mLayer )
510  {
511  return;
512  }
513 
514  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
515  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "name", tr( "Name" ), mLayer->dataDefinedPropertyString( "name" ),
516  "'square'|'rectangle'|'diamond'|'pentagon'|'triangle'|'equilateral_triangle'|'star'|'regular_star'|'arrow'|'filled_arrowhead'|'circle'|'cross'|'x'|'cross2'|'line'|'arrowhead'" );
517  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Fill color" ), mLayer->dataDefinedPropertyString( "color" ),
519  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color_border", tr( "Border color" ), mLayer->dataDefinedPropertyString( "color_border" ),
521  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline_width", tr( "Outline width" ), mLayer->dataDefinedPropertyString( "outline_width" ),
525  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
527  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
529  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "horizontal_anchor_point", tr( "Horizontal anchor point" ), mLayer->dataDefinedPropertyString( "horizontal_anchor_point" ),
531  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "vertical_anchor_point", tr( "Vertical anchor point" ), mLayer->dataDefinedPropertyString( "vertical_anchor_point" ),
533  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
534  if ( d.exec() == QDialog::Accepted )
535  {
536  //empty all existing properties first
538 
539  QMap<QString, QString> properties = d.dataDefinedProperties();
540  QMap<QString, QString>::const_iterator it = properties.constBegin();
541  for ( ; it != properties.constEnd(); ++it )
542  {
543  if ( !it.value().isEmpty() )
544  {
545  mLayer->setDataDefinedProperty( it.key(), it.value() );
546  }
547  }
548  emit changed();
549  }
550 }
551 
553 {
554  if ( mLayer )
555  {
557  emit changed();
558  }
559 }
560 
562 {
563  if ( mLayer )
564  {
566  emit changed();
567  }
568 }
569 
570 
572 
574  : QgsSymbolLayerV2Widget( parent, vl )
575 {
576  mLayer = NULL;
577 
578  setupUi( this );
579  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
580  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
581 
582  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
583  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
584  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
585  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
586  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
587  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
588  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
589  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
590 }
591 
593 {
594  if ( layer->layerType() != "SimpleFill" )
595  return;
596 
597  // layer type is correct, we can do the cast
598  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
599 
600  // set values
601  btnChangeColor->blockSignals( true );
602  btnChangeColor->setColor( mLayer->color() );
603  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
604  btnChangeColor->blockSignals( false );
605  cboFillStyle->blockSignals( true );
606  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
607  cboFillStyle->blockSignals( false );
608  btnChangeBorderColor->blockSignals( true );
609  btnChangeBorderColor->setColor( mLayer->borderColor() );
610  btnChangeBorderColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
611  btnChangeBorderColor->blockSignals( false );
612  cboBorderStyle->blockSignals( true );
613  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
614  cboBorderStyle->blockSignals( false );
615  spinBorderWidth->blockSignals( true );
616  spinBorderWidth->setValue( mLayer->borderWidth() );
617  spinBorderWidth->blockSignals( false );
618  cboJoinStyle->blockSignals( true );
619  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
620  cboJoinStyle->blockSignals( false );
621  spinOffsetX->blockSignals( true );
622  spinOffsetX->setValue( mLayer->offset().x() );
623  spinOffsetX->blockSignals( false );
624  spinOffsetY->blockSignals( true );
625  spinOffsetY->setValue( mLayer->offset().y() );
626  spinOffsetY->blockSignals( false );
627 
628  mBorderWidthUnitWidget->blockSignals( true );
629  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
630  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
631  mBorderWidthUnitWidget->blockSignals( false );
632  mOffsetUnitWidget->blockSignals( true );
633  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
634  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
635  mOffsetUnitWidget->blockSignals( false );
636 }
637 
639 {
640  return mLayer;
641 }
642 
644 {
645  mLayer->setColor( color );
646  emit changed();
647 }
648 
650 {
651  mLayer->setBorderColor( color );
652  emit changed();
653 }
654 
656 {
657  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
658  emit changed();
659 }
660 
662 {
663  mLayer->setBorderWidth( spinBorderWidth->value() );
664  emit changed();
665 }
666 
668 {
669  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
670  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
671  emit changed();
672 }
673 
675 {
676  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
677  emit changed();
678 }
679 
681 {
682  if ( mLayer )
683  {
684  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
685  mLayer->setBorderWidthUnit( unit );
686  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
687  emit changed();
688  }
689 }
690 
692 {
693  if ( mLayer )
694  {
695  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
696  mLayer->setOffsetUnit( unit );
697  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
698  emit changed();
699  }
700 }
701 
703 {
704  if ( !mLayer )
705  {
706  return;
707  }
708 
709  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
711  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color_border", tr( "Border color" ), mLayer->dataDefinedPropertyString( "color_border" ),
713  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width_border", tr( "Border width" ), mLayer->dataDefinedPropertyString( "width_border" ),
715  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
716  if ( d.exec() == QDialog::Accepted )
717  {
718  //empty all existing properties first
720 
721  QMap<QString, QString> properties = d.dataDefinedProperties();
722  QMap<QString, QString>::const_iterator it = properties.constBegin();
723  for ( ; it != properties.constEnd(); ++it )
724  {
725  if ( !it.value().isEmpty() )
726  {
727  mLayer->setDataDefinedProperty( it.key(), it.value() );
728  }
729  }
730  emit changed();
731  }
732 }
733 
735 
737  : QgsSymbolLayerV2Widget( parent, vl )
738 {
739  mLayer = NULL;
740 
741  setupUi( this );
742  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
743 
744  cboGradientColorRamp->setShowGradientOnly( true );
745  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
746 
747  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
748  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
749  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ) , this, SLOT( applyColorRamp() ) );
750  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
751  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
752  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
753  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
754  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
755  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
756  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
757  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
758  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
759  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
760  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
761  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
762 }
763 
765 {
766  if ( layer->layerType() != "GradientFill" )
767  return;
768 
769  // layer type is correct, we can do the cast
770  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
771 
772  // set values
773  btnChangeColor->blockSignals( true );
774  btnChangeColor->setColor( mLayer->color() );
775  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
776  btnChangeColor->blockSignals( false );
777  btnChangeColor2->blockSignals( true );
778  btnChangeColor2->setColor( mLayer->color2() );
779  btnChangeColor2->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
780  btnChangeColor2->blockSignals( false );
781 
783  {
784  radioTwoColor->setChecked( true );
785  cboGradientColorRamp->setEnabled( false );
786  }
787  else
788  {
789  radioColorRamp->setChecked( true );
790  btnChangeColor->setEnabled( false );
791  btnChangeColor2->setEnabled( false );
792  }
793 
794  // set source color ramp
795  if ( mLayer->colorRamp() )
796  {
797  cboGradientColorRamp->blockSignals( true );
798  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
799  cboGradientColorRamp->blockSignals( false );
800  }
801 
802  cboGradientType->blockSignals( true );
803  switch ( mLayer->gradientType() )
804  {
806  cboGradientType->setCurrentIndex( 0 );
807  break;
809  cboGradientType->setCurrentIndex( 1 );
810  break;
812  cboGradientType->setCurrentIndex( 2 );
813  break;
814  }
815  cboGradientType->blockSignals( false );
816 
817  cboCoordinateMode->blockSignals( true );
818  switch ( mLayer->coordinateMode() )
819  {
821  cboCoordinateMode->setCurrentIndex( 1 );
822  checkRefPoint1Centroid->setEnabled( false );
823  checkRefPoint2Centroid->setEnabled( false );
824  break;
826  default:
827  cboCoordinateMode->setCurrentIndex( 0 );
828  break;
829  }
830  cboCoordinateMode->blockSignals( false );
831 
832  cboGradientSpread->blockSignals( true );
833  switch ( mLayer->gradientSpread() )
834  {
836  cboGradientSpread->setCurrentIndex( 0 );
837  break;
839  cboGradientSpread->setCurrentIndex( 1 );
840  break;
842  cboGradientSpread->setCurrentIndex( 2 );
843  break;
844  }
845  cboGradientSpread->blockSignals( false );
846 
847  spinRefPoint1X->blockSignals( true );
848  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
849  spinRefPoint1X->blockSignals( false );
850  spinRefPoint1Y->blockSignals( true );
851  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
852  spinRefPoint1Y->blockSignals( false );
853  checkRefPoint1Centroid->blockSignals( true );
854  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
856  {
857  spinRefPoint1X->setEnabled( false );
858  spinRefPoint1Y->setEnabled( false );
859  }
860  checkRefPoint1Centroid->blockSignals( false );
861  spinRefPoint2X->blockSignals( true );
862  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
863  spinRefPoint2X->blockSignals( false );
864  spinRefPoint2Y->blockSignals( true );
865  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
866  spinRefPoint2Y->blockSignals( false );
867  checkRefPoint2Centroid->blockSignals( true );
868  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
870  {
871  spinRefPoint2X->setEnabled( false );
872  spinRefPoint2Y->setEnabled( false );
873  }
874  checkRefPoint2Centroid->blockSignals( false );
875 
876  spinOffsetX->blockSignals( true );
877  spinOffsetX->setValue( mLayer->offset().x() );
878  spinOffsetX->blockSignals( false );
879  spinOffsetY->blockSignals( true );
880  spinOffsetY->setValue( mLayer->offset().y() );
881  spinOffsetY->blockSignals( false );
882  mSpinAngle->blockSignals( true );
883  mSpinAngle->setValue( mLayer->angle() );
884  mSpinAngle->blockSignals( false );
885 
886  mOffsetUnitWidget->blockSignals( true );
887  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
888  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
889  mOffsetUnitWidget->blockSignals( false );
890 }
891 
893 {
894  return mLayer;
895 }
896 
898 {
899  mLayer->setColor( color );
900  emit changed();
901 }
902 
904 {
905  mLayer->setColor2( color );
906  emit changed();
907 }
908 
910 {
911  if ( radioTwoColor->isChecked() )
912  {
914  }
915  else
916  {
918  }
919  emit changed();
920 }
921 
923 {
924  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
925  if ( ramp == NULL )
926  return;
927 
928  mLayer->setColorRamp( ramp );
929  emit changed();
930 }
931 
933 {
934  switch ( index )
935  {
936  case 0:
938  //set sensible default reference points
939  spinRefPoint1X->setValue( 0.5 );
940  spinRefPoint1Y->setValue( 0 );
941  spinRefPoint2X->setValue( 0.5 );
942  spinRefPoint2Y->setValue( 1 );
943  break;
944  case 1:
946  //set sensible default reference points
947  spinRefPoint1X->setValue( 0 );
948  spinRefPoint1Y->setValue( 0 );
949  spinRefPoint2X->setValue( 1 );
950  spinRefPoint2Y->setValue( 1 );
951  break;
952  case 2:
954  spinRefPoint1X->setValue( 0.5 );
955  spinRefPoint1Y->setValue( 0.5 );
956  spinRefPoint2X->setValue( 1 );
957  spinRefPoint2Y->setValue( 1 );
958  break;
959  }
960  emit changed();
961 }
962 
964 {
965 
966  switch ( index )
967  {
968  case 0:
969  //feature coordinate mode
971  //allow choice of centroid reference positions
972  checkRefPoint1Centroid->setEnabled( true );
973  checkRefPoint2Centroid->setEnabled( true );
974  break;
975  case 1:
976  //viewport coordinate mode
978  //disable choice of centroid reference positions
979  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
980  checkRefPoint1Centroid->setEnabled( false );
981  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
982  checkRefPoint2Centroid->setEnabled( false );
983  break;
984  }
985 
986  emit changed();
987 }
988 
990 {
991  switch ( index )
992  {
993  case 0:
995  break;
996  case 1:
998  break;
999  case 2:
1001  break;
1002  }
1003 
1004  emit changed();
1005 }
1006 
1008 {
1009  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1010  emit changed();
1011 }
1012 
1014 {
1015  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1016  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1017  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1018  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1019  emit changed();
1020 }
1021 
1023 {
1024  mLayer->setAngle( value );
1025  emit changed();
1026 }
1027 
1029 {
1030  if ( mLayer )
1031  {
1032  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1033  mLayer->setOffsetUnit( unit );
1034  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1035  emit changed();
1036  }
1037 }
1038 
1040 {
1041  if ( !mLayer )
1042  {
1043  return;
1044  }
1045 
1046  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1047  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color (start)" ), mLayer->dataDefinedPropertyString( "color" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1048  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color2", tr( "Color (end)" ), mLayer->dataDefinedPropertyString( "color2" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1049  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
1051  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "gradient_type", tr( "Gradient type" ), mLayer->dataDefinedPropertyString( "gradient_type" ), QgsDataDefinedSymbolDialog::gradientTypeHelpText() );
1052  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "coordinate_mode", tr( "Coordinate mode" ), mLayer->dataDefinedPropertyString( "coordinate_mode" ), QgsDataDefinedSymbolDialog::gradientCoordModeHelpText() );
1053  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "spread", tr( "Spread" ), mLayer->dataDefinedPropertyString( "spread" ),
1055  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_x", tr( "Reference Point 1 (x)" ), mLayer->dataDefinedPropertyString( "reference1_x" ),
1057  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_y", tr( "Reference Point 1 (y)" ), mLayer->dataDefinedPropertyString( "reference1_y" ),
1059  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_iscentroid", tr( "Reference Point 1 (is centroid)" ), mLayer->dataDefinedPropertyString( "reference1_iscentroid" ),
1061  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_x", tr( "Reference Point 2 (x)" ), mLayer->dataDefinedPropertyString( "reference2_x" ),
1063  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_y", tr( "Reference Point 2 (y)" ), mLayer->dataDefinedPropertyString( "reference2_y" ),
1065  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_iscentroid", tr( "Reference Point 2 (is centroid)" ), mLayer->dataDefinedPropertyString( "reference2_iscentroid" ),
1067 
1068  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1069  if ( d.exec() == QDialog::Accepted )
1070  {
1071  //empty all existing properties first
1073 
1074  QMap<QString, QString> properties = d.dataDefinedProperties();
1075  QMap<QString, QString>::const_iterator it = properties.constBegin();
1076  for ( ; it != properties.constEnd(); ++it )
1077  {
1078  if ( !it.value().isEmpty() )
1079  {
1080  mLayer->setDataDefinedProperty( it.key(), it.value() );
1081  }
1082  }
1083  emit changed();
1084  }
1085 }
1086 
1088 
1090  : QgsSymbolLayerV2Widget( parent, vl )
1091 {
1092  mLayer = NULL;
1093 
1094  setupUi( this );
1095  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1096  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1097 
1098  cboGradientColorRamp->setShowGradientOnly( true );
1099  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1100 
1101  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ) , this, SLOT( applyColorRamp() ) );
1102  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1103  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1104  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1105  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1106  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1107 
1108  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1109  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1110 }
1111 
1113 {
1114  if ( layer->layerType() != "ShapeburstFill" )
1115  return;
1116 
1117  // layer type is correct, we can do the cast
1118  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1119 
1120  // set values
1121  btnChangeColor->blockSignals( true );
1122  btnChangeColor->setColor( mLayer->color() );
1123  btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
1124  btnChangeColor->blockSignals( false );
1125  btnChangeColor2->blockSignals( true );
1126  btnChangeColor2->setColor( mLayer->color2() );
1127  btnChangeColor2->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
1128  btnChangeColor2->blockSignals( false );
1129 
1131  {
1132  radioTwoColor->setChecked( true );
1133  cboGradientColorRamp->setEnabled( false );
1134  }
1135  else
1136  {
1137  radioColorRamp->setChecked( true );
1138  btnChangeColor->setEnabled( false );
1139  btnChangeColor2->setEnabled( false );
1140  }
1141 
1142  mSpinBlurRadius->blockSignals( true );
1143  mBlurSlider->blockSignals( true );
1144  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1145  mBlurSlider->setValue( mLayer->blurRadius() );
1146  mSpinBlurRadius->blockSignals( false );
1147  mBlurSlider->blockSignals( false );
1148 
1149  mSpinMaxDistance->blockSignals( true );
1150  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1151  mSpinMaxDistance->blockSignals( false );
1152 
1153  mRadioUseWholeShape->blockSignals( true );
1154  mRadioUseMaxDistance->blockSignals( true );
1155  if ( mLayer->useWholeShape() )
1156  {
1157  mRadioUseWholeShape->setChecked( true );
1158  mSpinMaxDistance->setEnabled( false );
1159  mDistanceUnitWidget->setEnabled( false );
1160  }
1161  else
1162  {
1163  mRadioUseMaxDistance->setChecked( true );
1164  mSpinMaxDistance->setEnabled( true );
1165  mDistanceUnitWidget->setEnabled( true );
1166  }
1167  mRadioUseWholeShape->blockSignals( false );
1168  mRadioUseMaxDistance->blockSignals( false );
1169 
1170  mDistanceUnitWidget->blockSignals( true );
1171  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1172  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1173  mDistanceUnitWidget->blockSignals( false );
1174 
1175  mIgnoreRingsCheckBox->blockSignals( true );
1176  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1177  mIgnoreRingsCheckBox->blockSignals( false );
1178 
1179  // set source color ramp
1180  if ( mLayer->colorRamp() )
1181  {
1182  cboGradientColorRamp->blockSignals( true );
1183  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1184  cboGradientColorRamp->blockSignals( false );
1185  }
1186 
1187  spinOffsetX->blockSignals( true );
1188  spinOffsetX->setValue( mLayer->offset().x() );
1189  spinOffsetX->blockSignals( false );
1190  spinOffsetY->blockSignals( true );
1191  spinOffsetY->setValue( mLayer->offset().y() );
1192  spinOffsetY->blockSignals( false );
1193  mOffsetUnitWidget->blockSignals( true );
1194  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1195  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1196  mOffsetUnitWidget->blockSignals( false );
1197 }
1198 
1200 {
1201  return mLayer;
1202 }
1203 
1205 {
1206  if ( mLayer )
1207  {
1208  mLayer->setColor( color );
1209  emit changed();
1210  }
1211 }
1212 
1214 {
1215  if ( mLayer )
1216  {
1217  mLayer->setColor2( color );
1218  emit changed();
1219  }
1220 }
1221 
1223 {
1224  if ( !mLayer )
1225  {
1226  return;
1227  }
1228 
1229  if ( radioTwoColor->isChecked() )
1230  {
1232  }
1233  else
1234  {
1236  }
1237  emit changed();
1238 }
1239 
1241 {
1242  if ( mLayer )
1243  {
1244  mLayer->setBlurRadius( value );
1245  emit changed();
1246  }
1247 }
1248 
1250 {
1251  if ( mLayer )
1252  {
1253  mLayer->setMaxDistance( value );
1254  emit changed();
1255  }
1256 }
1257 
1259 {
1260  if ( mLayer )
1261  {
1262  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
1263  mLayer->setDistanceUnit( unit );
1264  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1265  emit changed();
1266  }
1267 }
1268 
1270 {
1271  if ( mLayer )
1272  {
1273  mLayer->setUseWholeShape( value );
1274  emit changed();
1275  }
1276 }
1277 
1279 {
1280  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1281  if ( ramp == NULL )
1282  return;
1283 
1284  mLayer->setColorRamp( ramp );
1285  emit changed();
1286 }
1287 
1289 {
1290  if ( mLayer )
1291  {
1292  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1293  emit changed();
1294  }
1295 }
1296 
1298 {
1299  if ( mLayer )
1300  {
1301  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1302  mLayer->setOffsetUnit( unit );
1303  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1304  emit changed();
1305  }
1306 }
1307 
1309 {
1310  if ( !mLayer )
1311  {
1312  return;
1313  }
1314 
1315  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1316  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color (start)" ), mLayer->dataDefinedPropertyString( "color" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1317  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color2", tr( "Color (end)" ), mLayer->dataDefinedPropertyString( "color2" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1318  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "blur_radius", tr( "Blur radius" ), mLayer->dataDefinedPropertyString( "blur_radius" ),
1319  tr( "Integer between 0 and 18" ) );
1320  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "use_whole_shape", tr( "Use whole shape" ), mLayer->dataDefinedPropertyString( "use_whole_shape" ), QgsDataDefinedSymbolDialog::boolHelpText() );
1321  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "max_distance", tr( "Maximum distance" ), mLayer->dataDefinedPropertyString( "max_distance" ), QgsDataDefinedSymbolDialog::doubleHelpText() );
1322  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "ignore_rings", tr( "Ignore rings" ), mLayer->dataDefinedPropertyString( "ignore_rings" ), QgsDataDefinedSymbolDialog::boolHelpText() );
1323 
1324  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1325  if ( d.exec() == QDialog::Accepted )
1326  {
1327  //empty all existing properties first
1329 
1330  QMap<QString, QString> properties = d.dataDefinedProperties();
1331  QMap<QString, QString>::const_iterator it = properties.constBegin();
1332  for ( ; it != properties.constEnd(); ++it )
1333  {
1334  if ( !it.value().isEmpty() )
1335  {
1336  mLayer->setDataDefinedProperty( it.key(), it.value() );
1337  }
1338  }
1339  emit changed();
1340  }
1341 }
1342 
1344 {
1345  bool checked = ( state == Qt::Checked );
1346  mLayer->setIgnoreRings( checked );
1347  emit changed();
1348 }
1349 
1351 
1353  : QgsSymbolLayerV2Widget( parent, vl )
1354 {
1355  mLayer = NULL;
1356 
1357  setupUi( this );
1358  mIntervalUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1359  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1360  mOffsetAlongLineUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1361 
1362  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1363  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1364  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1365  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1366  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1367  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1368  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1369  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1370  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1371 }
1372 
1374 {
1375  if ( layer->layerType() != "MarkerLine" )
1376  return;
1377 
1378  // layer type is correct, we can do the cast
1379  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1380 
1381  // set values
1382  spinInterval->blockSignals( true );
1383  spinInterval->setValue( mLayer->interval() );
1384  spinInterval->blockSignals( false );
1385  mSpinOffsetAlongLine->blockSignals( true );
1386  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1387  mSpinOffsetAlongLine->blockSignals( false );
1388  chkRotateMarker->blockSignals( true );
1389  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1390  chkRotateMarker->blockSignals( false );
1391  spinOffset->blockSignals( true );
1392  spinOffset->setValue( mLayer->offset() );
1393  spinOffset->blockSignals( false );
1395  radInterval->setChecked( true );
1397  radVertex->setChecked( true );
1399  radVertexLast->setChecked( true );
1401  radCentralPoint->setChecked( true );
1402  else
1403  radVertexFirst->setChecked( true );
1404 
1405  // set units
1406  mIntervalUnitWidget->blockSignals( true );
1407  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1408  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1409  mIntervalUnitWidget->blockSignals( false );
1410  mOffsetUnitWidget->blockSignals( true );
1411  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1412  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1413  mOffsetUnitWidget->blockSignals( false );
1414  mOffsetAlongLineUnitWidget->blockSignals( true );
1415  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1416  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1417  mOffsetAlongLineUnitWidget->blockSignals( false );
1418 
1419  setPlacement(); // update gui
1420 }
1421 
1423 {
1424  return mLayer;
1425 }
1426 
1428 {
1429  mLayer->setInterval( val );
1430  emit changed();
1431 }
1432 
1434 {
1435  mLayer->setOffsetAlongLine( val );
1436  emit changed();
1437 }
1438 
1440 {
1441  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1442  emit changed();
1443 }
1444 
1446 {
1447  mLayer->setOffset( spinOffset->value() );
1448  emit changed();
1449 }
1450 
1452 {
1453  bool interval = radInterval->isChecked();
1454  spinInterval->setEnabled( interval );
1455  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1456  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1457  if ( radInterval->isChecked() )
1459  else if ( radVertex->isChecked() )
1461  else if ( radVertexLast->isChecked() )
1463  else if ( radVertexFirst->isChecked() )
1465  else
1467 
1468  emit changed();
1469 }
1470 
1472 {
1473  if ( mLayer )
1474  {
1475  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mIntervalUnitWidget->getUnit() );
1476  mLayer->setIntervalUnit( unit );
1477  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1478  emit changed();
1479  }
1480 }
1481 
1483 {
1484  if ( mLayer )
1485  {
1486  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1487  mLayer->setOffsetUnit( unit );
1488  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1489  emit changed();
1490  }
1491 }
1492 
1494 {
1495  if ( mLayer )
1496  {
1497  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetAlongLineUnitWidget->getUnit() );
1498  mLayer->setOffsetAlongLineUnit( unit );
1499  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1500  }
1501  emit changed();
1502 }
1503 
1505 {
1506  if ( !mLayer )
1507  {
1508  return;
1509  }
1510 
1511  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1512  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "interval", tr( "Interval" ), mLayer->dataDefinedPropertyString( "interval" ),
1514  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Line offset" ), mLayer->dataDefinedPropertyString( "offset" ),
1516  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "placement", tr( "Placement" ), mLayer->dataDefinedPropertyString( "placement" ),
1517  tr( "'vertex'|'lastvertex'|'firstvertex'|'centerpoint'" ) );
1518  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset_along_line", tr( "Offset along line" ), mLayer->dataDefinedPropertyString( "offset_along_line" ),
1520  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1521  if ( d.exec() == QDialog::Accepted )
1522  {
1523  //empty all existing properties first
1525 
1526  QMap<QString, QString> properties = d.dataDefinedProperties();
1527  QMap<QString, QString>::const_iterator it = properties.constBegin();
1528  for ( ; it != properties.constEnd(); ++it )
1529  {
1530  if ( !it.value().isEmpty() )
1531  {
1532  mLayer->setDataDefinedProperty( it.key(), it.value() );
1533  }
1534  }
1535  emit changed();
1536  }
1537 }
1538 
1540 
1541 
1543  : QgsSymbolLayerV2Widget( parent, vl )
1544 {
1545  mLayer = NULL;
1546 
1547  setupUi( this );
1548  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1549  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1550  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1551  viewGroups->setHeaderHidden( true );
1552 
1553  populateList();
1554 
1555  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1556  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1557  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1558  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1559  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1560  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1561 }
1562 
1563 #include <QTime>
1564 #include <QAbstractListModel>
1565 #include <QPixmapCache>
1566 #include <QStyle>
1567 
1568 class QgsSvgListModel : public QAbstractListModel
1569 {
1570  public:
1571  QgsSvgListModel( QObject* parent ) : QAbstractListModel( parent )
1572  {
1574  }
1575 
1576  // Constructor to create model for icons in a specific path
1577  QgsSvgListModel( QObject* parent, QString path ) : QAbstractListModel( parent )
1578  {
1580  }
1581 
1582  int rowCount( const QModelIndex & parent = QModelIndex() ) const
1583  {
1584  Q_UNUSED( parent );
1585  return mSvgFiles.count();
1586  }
1587 
1588  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const
1589  {
1590  QString entry = mSvgFiles.at( index.row() );
1591 
1592  if ( role == Qt::DecorationRole ) // icon
1593  {
1594  QPixmap pixmap;
1595  if ( !QPixmapCache::find( entry, pixmap ) )
1596  {
1597  // render SVG file
1598  QColor fill, outline;
1599  double outlineWidth;
1600  bool fillParam, outlineParam, outlineWidthParam;
1601  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1602 
1603  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1604  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1605  pixmap = QPixmap::fromImage( img );
1606  QPixmapCache::insert( entry, pixmap );
1607  }
1608 
1609  return pixmap;
1610  }
1611  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1612  {
1613  return entry;
1614  }
1615 
1616  return QVariant();
1617  }
1618 
1619  protected:
1620  QStringList mSvgFiles;
1621 };
1622 
1623 class QgsSvgGroupsModel : public QStandardItemModel
1624 {
1625  public:
1626  QgsSvgGroupsModel( QObject* parent ) : QStandardItemModel( parent )
1627  {
1628  QStringList svgPaths = QgsApplication::svgPaths();
1629  QStandardItem *parentItem = invisibleRootItem();
1630 
1631  for ( int i = 0; i < svgPaths.size(); i++ )
1632  {
1633  QDir dir( svgPaths[i] );
1634  QStandardItem *baseGroup;
1635 
1636  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1637  {
1638  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1639  }
1640  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1641  {
1642  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1643  }
1644  else
1645  {
1646  baseGroup = new QStandardItem( dir.dirName() );
1647  }
1648  baseGroup->setData( QVariant( svgPaths[i] ) );
1649  baseGroup->setEditable( false );
1650  baseGroup->setCheckable( false );
1651  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1652  baseGroup->setToolTip( dir.path() );
1653  parentItem->appendRow( baseGroup );
1654  createTree( baseGroup );
1655  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1656  }
1657  }
1658  private:
1659  void createTree( QStandardItem* &parentGroup )
1660  {
1661  QDir parentDir( parentGroup->data().toString() );
1662  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1663  {
1664  QStandardItem* group = new QStandardItem( item );
1665  group->setData( QVariant( parentDir.path() + "/" + item ) );
1666  group->setEditable( false );
1667  group->setCheckable( false );
1668  group->setToolTip( parentDir.path() + "/" + item );
1669  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1670  parentGroup->appendRow( group );
1671  createTree( group );
1672  }
1673  }
1674 };
1675 
1677 {
1678  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1679  viewGroups->setModel( g );
1680  // Set the tree expanded at the first level
1681  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1682  for ( int i = 0; i < rows; i++ )
1683  {
1684  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1685  }
1686 
1687  // Initally load the icons in the List view without any grouping
1688  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1689  viewImages->setModel( m );
1690 }
1691 
1693 {
1694  QString path = idx.data( Qt::UserRole + 1 ).toString();
1695 
1696  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1697  viewImages->setModel( m );
1698 
1699  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1700  emit changed();
1701 }
1702 
1704 {
1705  if ( !layer )
1706  {
1707  return;
1708  }
1709 
1710  //activate gui for svg parameters only if supported by the svg file
1711  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1712  QColor defaultFill, defaultOutline;
1713  double defaultOutlineWidth;
1714  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1715  mChangeColorButton->setEnabled( hasFillParam );
1716  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1717  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1718 
1719  if ( hasFillParam )
1720  {
1721  if ( layer->fillColor().isValid() )
1722  {
1723  mChangeColorButton->setColor( layer->fillColor() );
1724  }
1725  else
1726  {
1727  mChangeColorButton->setColor( defaultFill );
1728  }
1729  }
1730  if ( hasOutlineParam )
1731  {
1732  if ( layer->outlineColor().isValid() )
1733  {
1734  mChangeBorderColorButton->setColor( layer->outlineColor() );
1735  }
1736  else
1737  {
1738  mChangeBorderColorButton->setColor( defaultOutline );
1739  }
1740  }
1741 
1742  mFileLineEdit->blockSignals( true );
1743  mFileLineEdit->setText( layer->path() );
1744  mFileLineEdit->blockSignals( false );
1745 
1746  mBorderWidthSpinBox->blockSignals( true );
1747  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1748  mBorderWidthSpinBox->blockSignals( false );
1749 }
1750 
1751 
1753 {
1754  if ( !layer )
1755  {
1756  return;
1757  }
1758 
1759  if ( layer->layerType() != "SvgMarker" )
1760  return;
1761 
1762  // layer type is correct, we can do the cast
1763  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1764 
1765  // set values
1766 
1767  QAbstractItemModel* m = viewImages->model();
1768  QItemSelectionModel* selModel = viewImages->selectionModel();
1769  for ( int i = 0; i < m->rowCount(); i++ )
1770  {
1771  QModelIndex idx( m->index( i, 0 ) );
1772  if ( m->data( idx ).toString() == mLayer->path() )
1773  {
1774  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1775  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1776  setName( idx );
1777  break;
1778  }
1779  }
1780 
1781  spinSize->blockSignals( true );
1782  spinSize->setValue( mLayer->size() );
1783  spinSize->blockSignals( false );
1784  spinAngle->blockSignals( true );
1785  spinAngle->setValue( mLayer->angle() );
1786  spinAngle->blockSignals( false );
1787 
1788  // without blocking signals the value gets changed because of slot setOffset()
1789  spinOffsetX->blockSignals( true );
1790  spinOffsetX->setValue( mLayer->offset().x() );
1791  spinOffsetX->blockSignals( false );
1792  spinOffsetY->blockSignals( true );
1793  spinOffsetY->setValue( mLayer->offset().y() );
1794  spinOffsetY->blockSignals( false );
1795 
1796  mSizeUnitWidget->blockSignals( true );
1797  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1798  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1799  mSizeUnitWidget->blockSignals( false );
1800  mBorderWidthUnitWidget->blockSignals( true );
1801  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1802  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1803  mBorderWidthUnitWidget->blockSignals( false );
1804  mOffsetUnitWidget->blockSignals( true );
1805  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1806  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1807  mOffsetUnitWidget->blockSignals( false );
1808 
1809  //anchor points
1810  mHorizontalAnchorComboBox->blockSignals( true );
1811  mVerticalAnchorComboBox->blockSignals( true );
1812  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1813  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1814  mHorizontalAnchorComboBox->blockSignals( false );
1815  mVerticalAnchorComboBox->blockSignals( false );
1816 
1817  setGuiForSvg( mLayer );
1818 }
1819 
1821 {
1822  return mLayer;
1823 }
1824 
1825 void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
1826 {
1827  QString name = idx.data( Qt::UserRole ).toString();
1828  mLayer->setPath( name );
1829  mFileLineEdit->setText( name );
1830 
1831  setGuiForSvg( mLayer );
1832  emit changed();
1833 }
1834 
1836 {
1837  mLayer->setSize( spinSize->value() );
1838  emit changed();
1839 }
1840 
1842 {
1843  mLayer->setAngle( spinAngle->value() );
1844  emit changed();
1845 }
1846 
1848 {
1849  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1850  emit changed();
1851 }
1852 
1854 {
1855  QSettings s;
1856  QString file = QFileDialog::getOpenFileName( 0,
1857  tr( "Select SVG file" ),
1858  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1859  tr( "SVG files" ) + " (*.svg)" );
1860  QFileInfo fi( file );
1861  if ( file.isEmpty() || !fi.exists() )
1862  {
1863  return;
1864  }
1865  mFileLineEdit->setText( file );
1866  mLayer->setPath( file );
1867  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1868  emit changed();
1869 }
1870 
1872 {
1873  if ( !QFileInfo( text ).exists() )
1874  {
1875  return;
1876  }
1877  mLayer->setPath( text );
1878  setGuiForSvg( mLayer );
1879  emit changed();
1880 }
1881 
1883 {
1884  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1885  {
1886  QUrl url( mFileLineEdit->text() );
1887  if ( !url.isValid() )
1888  {
1889  return;
1890  }
1891  }
1892 
1893  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1894  mLayer->setPath( mFileLineEdit->text() );
1895  QApplication::restoreOverrideCursor();
1896 
1897  setGuiForSvg( mLayer );
1898  emit changed();
1899 }
1900 
1902 {
1903  if ( !mLayer )
1904  {
1905  return;
1906  }
1907 
1908  mLayer->setFillColor( color );
1909  emit changed();
1910 }
1911 
1913 {
1914  if ( !mLayer )
1915  {
1916  return;
1917  }
1918 
1919  mLayer->setOutlineColor( color );
1920  emit changed();
1921 }
1922 
1924 {
1925  if ( mLayer )
1926  {
1927  mLayer->setOutlineWidth( d );
1928  emit changed();
1929  }
1930 }
1931 
1933 {
1934  if ( mLayer )
1935  {
1936  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
1937  mLayer->setSizeUnit( unit );
1938  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1939  emit changed();
1940  }
1941 }
1942 
1944 {
1945  if ( mLayer )
1946  {
1947  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
1948  mLayer->setOutlineWidthUnit( unit );
1949  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1950  emit changed();
1951  }
1952 }
1953 
1955 {
1956  if ( mLayer )
1957  {
1958  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1959  mLayer->setOffsetUnit( unit );
1960  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1961  emit changed();
1962  }
1963 }
1964 
1966 {
1967  if ( !mLayer )
1968  {
1969  return;
1970  }
1971 
1972  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1975  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline-width", tr( "Border width" ), mLayer->dataDefinedPropertyString( "outline-width" ),
1977  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
1979  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
1981  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "name", tr( "SVG file" ), mLayer->dataDefinedPropertyString( "name" ),
1983  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "fill", tr( "Color" ), mLayer->dataDefinedPropertyString( "fill" ),
1985  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline", tr( "Border color" ), mLayer->dataDefinedPropertyString( "outline" ),
1987  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "horizontal_anchor_point", tr( "Horizontal anchor point" ), mLayer->dataDefinedPropertyString( "horizontal_anchor_point" ),
1989  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "vertical_anchor_point", tr( "Vertical anchor point" ), mLayer->dataDefinedPropertyString( "vertical_anchor_point" ),
1991  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1992  if ( d.exec() == QDialog::Accepted )
1993  {
1994  //empty all existing properties first
1996 
1997  QMap<QString, QString> properties = d.dataDefinedProperties();
1998  QMap<QString, QString>::const_iterator it = properties.constBegin();
1999  for ( ; it != properties.constEnd(); ++it )
2000  {
2001  if ( !it.value().isEmpty() )
2002  {
2003  mLayer->setDataDefinedProperty( it.key(), it.value() );
2004  }
2005  }
2006  emit changed();
2007  }
2008 }
2009 
2011 {
2012  if ( mLayer )
2013  {
2015  emit changed();
2016  }
2017 }
2018 
2020 {
2021  if ( mLayer )
2022  {
2024  emit changed();
2025  }
2026 }
2027 
2029 
2030 #include <QFileDialog>
2031 
2033 {
2034  mLayer = 0;
2035  setupUi( this );
2036  mTextureWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2037  mSvgOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2038  mSvgTreeView->setHeaderHidden( true );
2039  insertIcons();
2040 
2041  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2042  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
2043 }
2044 
2046 {
2047  if ( !layer )
2048  {
2049  return;
2050  }
2051 
2052  if ( layer->layerType() != "SVGFill" )
2053  {
2054  return;
2055  }
2056 
2057  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
2058  if ( mLayer )
2059  {
2060  double width = mLayer->patternWidth();
2061  mTextureWidthSpinBox->blockSignals( true );
2062  mTextureWidthSpinBox->setValue( width );
2063  mTextureWidthSpinBox->blockSignals( false );
2064  mSVGLineEdit->setText( mLayer->svgFilePath() );
2065  mRotationSpinBox->blockSignals( true );
2066  mRotationSpinBox->setValue( mLayer->angle() );
2067  mRotationSpinBox->blockSignals( false );
2068  mTextureWidthUnitWidget->blockSignals( true );
2069  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2070  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2071  mTextureWidthUnitWidget->blockSignals( false );
2072  mSvgOutlineWidthUnitWidget->blockSignals( true );
2073  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2074  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2075  mSvgOutlineWidthUnitWidget->blockSignals( false );
2076  mChangeColorButton->blockSignals( true );
2077  mChangeColorButton->setColor( mLayer->svgFillColor() );
2078  mChangeColorButton->blockSignals( false );
2079  mChangeBorderColorButton->blockSignals( true );
2080  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2081  mChangeBorderColorButton->blockSignals( false );
2082  mBorderWidthSpinBox->blockSignals( true );
2083  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2084  mBorderWidthSpinBox->blockSignals( false );
2085  }
2086  updateParamGui( false );
2087 }
2088 
2090 {
2091  return mLayer;
2092 }
2093 
2095 {
2096  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2097  if ( !filePath.isNull() )
2098  {
2099  mSVGLineEdit->setText( filePath );
2100  emit changed();
2101  }
2102 }
2103 
2105 {
2106  if ( mLayer )
2107  {
2108  mLayer->setPatternWidth( d );
2109  emit changed();
2110  }
2111 }
2112 
2114 {
2115  if ( !mLayer )
2116  {
2117  return;
2118  }
2119 
2120  QFileInfo fi( text );
2121  if ( !fi.exists() )
2122  {
2123  return;
2124  }
2125  mLayer->setSvgFilePath( text );
2126  updateParamGui();
2127  emit changed();
2128 }
2129 
2131 {
2132  if ( !mLayer )
2133  {
2134  return;
2135  }
2136 
2137  QFileInfo fi( mSVGLineEdit->text() );
2138  if ( !fi.exists() )
2139  {
2140  QUrl url( mSVGLineEdit->text() );
2141  if ( !url.isValid() )
2142  {
2143  return;
2144  }
2145  }
2146 
2147  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2148  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2149  QApplication::restoreOverrideCursor();
2150 
2151  updateParamGui();
2152  emit changed();
2153 }
2154 
2155 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2156 {
2157  QString file = item.data( Qt::UserRole ).toString();
2158  mLayer->setSvgFilePath( file );
2159  mSVGLineEdit->setText( file );
2160 
2161  updateParamGui();
2162  emit changed();
2163 }
2164 
2166 {
2167  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2168  mSvgTreeView->setModel( g );
2169  // Set the tree expanded at the first level
2170  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2171  for ( int i = 0; i < rows; i++ )
2172  {
2173  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2174  }
2175 
2176  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2177  mSvgListView->setModel( m );
2178 }
2179 
2180 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2181 {
2182  QString path = idx.data( Qt::UserRole + 1 ).toString();
2183 
2184  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2185  mSvgListView->setModel( m );
2186 
2187  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2188  emit changed();
2189 }
2190 
2191 
2193 {
2194  if ( mLayer )
2195  {
2196  mLayer->setAngle( d );
2197  emit changed();
2198  }
2199 }
2200 
2202 {
2203  //activate gui for svg parameters only if supported by the svg file
2204  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2205  QColor defaultFill, defaultOutline;
2206  double defaultOutlineWidth;
2207  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2208  if ( hasFillParam && resetValues )
2209  {
2210  mChangeColorButton->setColor( defaultFill );
2211  }
2212  mChangeColorButton->setEnabled( hasFillParam );
2213  if ( hasOutlineParam && resetValues )
2214  {
2215  mChangeBorderColorButton->setColor( defaultOutline );
2216  }
2217  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2218  if ( hasOutlineWidthParam && resetValues )
2219  {
2220  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2221  }
2222  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2223 }
2224 
2226 {
2227  if ( !mLayer )
2228  {
2229  return;
2230  }
2231 
2232  mLayer->setSvgFillColor( color );
2233  emit changed();
2234 }
2235 
2237 {
2238  if ( !mLayer )
2239  {
2240  return;
2241  }
2242 
2243  mLayer->setSvgOutlineColor( color );
2244  emit changed();
2245 }
2246 
2248 {
2249  if ( mLayer )
2250  {
2251  mLayer->setSvgOutlineWidth( d );
2252  emit changed();
2253  }
2254 }
2255 
2257 {
2258  if ( mLayer )
2259  {
2260  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mTextureWidthUnitWidget->getUnit() );
2261  mLayer->setPatternWidthUnit( unit );
2262  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2263  emit changed();
2264  }
2265 }
2266 
2268 {
2269  if ( mLayer )
2270  {
2271  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSvgOutlineWidthUnitWidget->getUnit() );
2272  mLayer->setSvgOutlineWidthUnit( unit );
2273  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2274  emit changed();
2275  }
2276 }
2277 
2279 {
2280  if ( !mLayer )
2281  {
2282  return;
2283  }
2284 
2285  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2286  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Texture width" ), mLayer->dataDefinedPropertyString( "width" ),
2288  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgFile", tr( "SVG file" ), mLayer->dataDefinedPropertyString( "svgFile" ),
2290  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Rotation" ), mLayer->dataDefinedPropertyString( "angle" ),
2292  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgFillColor", tr( "Color" ), mLayer->dataDefinedPropertyString( "svgFillColor" ),
2294  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgOutlineColor", tr( "Border color" ), mLayer->dataDefinedPropertyString( "svgOutlineColor" ),
2296  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgOutlineWidth", tr( "Border width" ), mLayer->dataDefinedPropertyString( "svgOutlineWidth" ),
2298  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2299  if ( d.exec() == QDialog::Accepted )
2300  {
2301  //empty all existing properties first
2303 
2304  QMap<QString, QString> properties = d.dataDefinedProperties();
2305  QMap<QString, QString>::const_iterator it = properties.constBegin();
2306  for ( ; it != properties.constEnd(); ++it )
2307  {
2308  if ( !it.value().isEmpty() )
2309  {
2310  mLayer->setDataDefinedProperty( it.key(), it.value() );
2311  }
2312  }
2313  emit changed();
2314  }
2315 }
2316 
2318 
2320  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2321 {
2322  setupUi( this );
2323  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2324  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2325 }
2326 
2328 {
2329  if ( layer->layerType() != "LinePatternFill" )
2330  {
2331  return;
2332  }
2333 
2334  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2335  if ( patternLayer )
2336  {
2337  mLayer = patternLayer;
2338  mAngleSpinBox->blockSignals( true );
2339  mAngleSpinBox->setValue( mLayer->lineAngle() );
2340  mAngleSpinBox->blockSignals( false );
2341  mDistanceSpinBox->blockSignals( true );
2342  mDistanceSpinBox->setValue( mLayer->distance() );
2343  mDistanceSpinBox->blockSignals( false );
2344  mOffsetSpinBox->blockSignals( true );
2345  mOffsetSpinBox->setValue( mLayer->offset() );
2346  mOffsetSpinBox->blockSignals( false );
2347 
2348  //units
2349  mDistanceUnitWidget->blockSignals( true );
2350  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2351  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2352  mDistanceUnitWidget->blockSignals( false );
2353  mOffsetUnitWidget->blockSignals( true );
2354  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2355  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2356  mOffsetUnitWidget->blockSignals( false );
2357  }
2358 }
2359 
2361 {
2362  return mLayer;
2363 }
2364 
2366 {
2367  if ( mLayer )
2368  {
2369  mLayer->setLineAngle( d );
2370  emit changed();
2371  }
2372 }
2373 
2375 {
2376  if ( mLayer )
2377  {
2378  mLayer->setDistance( d );
2379  emit changed();
2380  }
2381 }
2382 
2384 {
2385  if ( mLayer )
2386  {
2387  mLayer->setOffset( d );
2388  emit changed();
2389  }
2390 }
2391 
2393 {
2394  if ( mLayer )
2395  {
2396  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
2397  mLayer->setDistanceUnit( unit );
2398  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2399  emit changed();
2400  }
2401 }
2402 
2404 {
2405  if ( mLayer )
2406  {
2407  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2408  mLayer->setOffsetUnit( unit );
2409  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2410  emit changed();
2411  }
2412 }
2413 
2415 {
2416  if ( !mLayer )
2417  {
2418  return;
2419  }
2420 
2421  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2422  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "lineangle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "lineangle" ),
2424  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance", tr( "Distance" ), mLayer->dataDefinedPropertyString( "distance" ),
2426  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "linewidth", tr( "Line width" ), mLayer->dataDefinedPropertyString( "linewidth" ),
2428  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ),
2430  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2431  if ( d.exec() == QDialog::Accepted )
2432  {
2433  //empty all existing properties first
2435 
2436  QMap<QString, QString> properties = d.dataDefinedProperties();
2437  QMap<QString, QString>::const_iterator it = properties.constBegin();
2438  for ( ; it != properties.constEnd(); ++it )
2439  {
2440  if ( !it.value().isEmpty() )
2441  {
2442  mLayer->setDataDefinedProperty( it.key(), it.value() );
2443  }
2444  }
2445  emit changed();
2446  }
2447 }
2448 
2449 
2451 
2453  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2454 {
2455  setupUi( this );
2456  mHorizontalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2457  mVerticalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2458  mHorizontalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2459  mVerticalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2460 }
2461 
2462 
2464 {
2465  if ( !layer || layer->layerType() != "PointPatternFill" )
2466  {
2467  return;
2468  }
2469 
2470  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2471  mHorizontalDistanceSpinBox->blockSignals( true );
2472  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2473  mHorizontalDistanceSpinBox->blockSignals( false );
2474  mVerticalDistanceSpinBox->blockSignals( true );
2475  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2476  mVerticalDistanceSpinBox->blockSignals( false );
2477  mHorizontalDisplacementSpinBox->blockSignals( true );
2478  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2479  mHorizontalDisplacementSpinBox->blockSignals( false );
2480  mVerticalDisplacementSpinBox->blockSignals( true );
2481  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2482  mVerticalDisplacementSpinBox->blockSignals( false );
2483 
2484  mHorizontalDistanceUnitWidget->blockSignals( true );
2485  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2486  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2487  mHorizontalDistanceUnitWidget->blockSignals( false );
2488  mVerticalDistanceUnitWidget->blockSignals( true ) ;
2489  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2490  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2491  mVerticalDistanceUnitWidget->blockSignals( false );
2492  mHorizontalDisplacementUnitWidget->blockSignals( true );
2493  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2494  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2495  mHorizontalDisplacementUnitWidget->blockSignals( false );
2496  mVerticalDisplacementUnitWidget->blockSignals( true );
2497  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2498  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2499  mVerticalDisplacementUnitWidget->blockSignals( false );
2500 }
2501 
2503 {
2504  return mLayer;
2505 }
2506 
2508 {
2509  if ( mLayer )
2510  {
2511  mLayer->setDistanceX( d );
2512  emit changed();
2513  }
2514 }
2515 
2517 {
2518  if ( mLayer )
2519  {
2520  mLayer->setDistanceY( d );
2521  emit changed();
2522  }
2523 }
2524 
2526 {
2527  if ( mLayer )
2528  {
2529  mLayer->setDisplacementX( d );
2530  emit changed();
2531  }
2532 }
2533 
2535 {
2536  if ( mLayer )
2537  {
2538  mLayer->setDisplacementY( d );
2539  emit changed();
2540  }
2541 }
2542 
2544 {
2545  if ( mLayer )
2546  {
2547  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDistanceUnitWidget->getUnit() );
2548  mLayer->setDistanceXUnit( unit );
2549  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2550  emit changed();
2551  }
2552 }
2553 
2555 {
2556  if ( mLayer )
2557  {
2558  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDistanceUnitWidget->getUnit() );
2559  mLayer->setDistanceYUnit( unit );
2560  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2561  emit changed();
2562  }
2563 }
2564 
2566 {
2567  if ( mLayer )
2568  {
2569  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDisplacementUnitWidget->getUnit() );
2570  mLayer->setDisplacementXUnit( unit );
2571  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2572  emit changed();
2573  }
2574 }
2575 
2577 {
2578  if ( mLayer )
2579  {
2580  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDisplacementUnitWidget->getUnit() );
2581  mLayer->setDisplacementYUnit( unit );
2582  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2583  emit changed();
2584  }
2585 }
2586 
2588 {
2589  if ( !mLayer )
2590  {
2591  return;
2592  }
2593 
2594  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2595  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance_x", tr( "Horizontal distance" ), mLayer->dataDefinedPropertyString( "distance_x" ),
2597  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance_y", tr( "Vertical distance" ), mLayer->dataDefinedPropertyString( "distance_y" ),
2599  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "displacement_x", tr( "Horizontal displacement" ), mLayer->dataDefinedPropertyString( "displacement_x" ),
2601  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "displacement_y", tr( "Vertical displacement" ), mLayer->dataDefinedPropertyString( "displacement_y" ),
2603  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2604  if ( d.exec() == QDialog::Accepted )
2605  {
2606  //empty all existing properties first
2608 
2609  QMap<QString, QString> properties = d.dataDefinedProperties();
2610  QMap<QString, QString>::const_iterator it = properties.constBegin();
2611  for ( ; it != properties.constEnd(); ++it )
2612  {
2613  if ( !it.value().isEmpty() )
2614  {
2615  mLayer->setDataDefinedProperty( it.key(), it.value() );
2616  }
2617  }
2618  emit changed();
2619  }
2620 }
2621 
2623 
2625  : QgsSymbolLayerV2Widget( parent, vl )
2626 {
2627  mLayer = NULL;
2628 
2629  setupUi( this );
2630  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2631  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2633  scrollArea->setWidget( widgetChar );
2634 
2635  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2636  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2637  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2638  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2639  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2640  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2641  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2642 }
2643 
2644 
2646 {
2647  if ( layer->layerType() != "FontMarker" )
2648  return;
2649 
2650  // layer type is correct, we can do the cast
2651  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2652 
2653  // set values
2654  cboFont->blockSignals( true );
2655  cboFont->setCurrentFont( QFont( mLayer->fontFamily() ) );
2656  cboFont->blockSignals( false );
2657  spinSize->blockSignals( true );
2658  spinSize->setValue( mLayer->size() );
2659  spinSize->blockSignals( false );
2660  btnColor->blockSignals( true );
2661  btnColor->setColor( mLayer->color() );
2662  btnColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
2663  btnColor->blockSignals( false );
2664  spinAngle->blockSignals( true );
2665  spinAngle->setValue( mLayer->angle() );
2666  spinAngle->blockSignals( false );
2667 
2668  //block
2669  spinOffsetX->blockSignals( true );
2670  spinOffsetX->setValue( mLayer->offset().x() );
2671  spinOffsetX->blockSignals( false );
2672  spinOffsetY->blockSignals( true );
2673  spinOffsetY->setValue( mLayer->offset().y() );
2674  spinOffsetY->blockSignals( false );
2675 
2676  mSizeUnitWidget->blockSignals( true );
2677  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2678  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2679  mSizeUnitWidget->blockSignals( false );
2680 
2681  mOffsetUnitWidget->blockSignals( true );
2682  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2683  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2684  mOffsetUnitWidget->blockSignals( false );
2685 
2686  //anchor points
2687  mHorizontalAnchorComboBox->blockSignals( true );
2688  mVerticalAnchorComboBox->blockSignals( true );
2689  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2690  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2691  mHorizontalAnchorComboBox->blockSignals( false );
2692  mVerticalAnchorComboBox->blockSignals( false );
2693 }
2694 
2696 {
2697  return mLayer;
2698 }
2699 
2701 {
2702  mLayer->setFontFamily( font.family() );
2703  widgetChar->updateFont( font );
2704  emit changed();
2705 }
2706 
2708 {
2709  mLayer->setColor( color );
2710  emit changed();
2711 }
2712 
2714 {
2715  mLayer->setSize( size );
2716  //widgetChar->updateSize(size);
2717  emit changed();
2718 }
2719 
2721 {
2722  mLayer->setAngle( angle );
2723  emit changed();
2724 }
2725 
2727 {
2728  mLayer->setCharacter( chr );
2729  emit changed();
2730 }
2731 
2733 {
2734  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2735  emit changed();
2736 }
2737 
2739 {
2740  if ( mLayer )
2741  {
2742  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
2743  mLayer->setSizeUnit( unit );
2744  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2745  emit changed();
2746  }
2747 }
2748 
2750 {
2751  if ( mLayer )
2752  {
2753  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2754  mLayer->setOffsetUnit( unit );
2755  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2756  emit changed();
2757  }
2758 }
2759 
2761 {
2762  if ( mLayer )
2763  {
2765  emit changed();
2766  }
2767 }
2768 
2770 {
2771  if ( mLayer )
2772  {
2774  emit changed();
2775  }
2776 }
2777 
2778 
2780 
2781 
2783  : QgsSymbolLayerV2Widget( parent, vl )
2784 {
2785  mLayer = NULL;
2786 
2787  setupUi( this );
2788 }
2789 
2791 {
2792  if ( layer->layerType() != "CentroidFill" )
2793  return;
2794 
2795  // layer type is correct, we can do the cast
2796  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2797 
2798  // set values
2799  mDrawInsideCheckBox->blockSignals( true );
2800  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2801  mDrawInsideCheckBox->blockSignals( false );
2802 }
2803 
2805 {
2806  return mLayer;
2807 }
2808 
2810 {
2811  mLayer->setPointOnSurface( state == Qt::Checked );
2812  emit changed();
2813 }
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
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)
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)