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