QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgssymbollayerv2widget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerv2widget.cpp - symbol layer widgets
3 
4  ---------------------
5  begin : November 2009
6  copyright : (C) 2009 by Martin Dobias
7  email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgssymbollayerv2widget.h"
18 
19 #include "qgslinesymbollayerv2.h"
20 #include "qgsmarkersymbollayerv2.h"
21 #include "qgsfillsymbollayerv2.h"
22 
23 #include "characterwidget.h"
24 #include "qgsdashspacedialog.h"
27 #include "qgssvgcache.h"
28 #include "qgssymbollayerv2utils.h"
29 #include "qgsvectorcolorrampv2.h"
31 
32 #include "qgsstylev2.h" //for symbol selector dialog
33 
34 #include "qgsapplication.h"
35 
36 #include "qgslogger.h"
37 
38 #include <QAbstractButton>
39 #include <QColorDialog>
40 #include <QCursor>
41 #include <QDir>
42 #include <QFileDialog>
43 #include <QPainter>
44 #include <QSettings>
45 #include <QStandardItemModel>
46 #include <QSvgRenderer>
47 #include <QMessageBox>
48 
49 QString QgsSymbolLayerV2Widget::dataDefinedPropertyLabel( const QString &entryName )
50 {
51  QString label = entryName;
52  if ( entryName == "size" )
53  {
54  label = tr( "Size" );
55  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
56  if ( layer )
57  {
58  switch ( layer->scaleMethod() )
59  {
61  label += " (" + tr( "area" ) + ")";
62  break;
64  label += " (" + tr( "diameter" ) + ")";
65  break;
66  }
67  }
68  }
69  return label;
70 }
71 
73  : QgsSymbolLayerV2Widget( parent, vl )
74 {
75  mLayer = NULL;
76 
77  setupUi( this );
78  mPenWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
79  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
80  mDashPatternUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
81 
82  btnChangeColor->setAllowAlpha( true );
83  btnChangeColor->setColorDialogTitle( tr( "Select line color" ) );
84  btnChangeColor->setContext( "symbology" );
85 
86  spinOffset->setClearValue( 0.0 );
87 
88  if ( vl && vl->geometryType() != QGis::Polygon )
89  {
90  //draw inside polygon checkbox only makes sense for polygon layers
91  mDrawInsideCheckBox->hide();
92  }
93 
94  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
95  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
96  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
97  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
98  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
99  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
101 
102 }
103 
105 {
106  if ( !layer || layer->layerType() != "SimpleLine" )
107  return;
108 
109  // layer type is correct, we can do the cast
110  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
111 
112  // set units
113  mPenWidthUnitWidget->blockSignals( true );
114  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
115  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
116  mPenWidthUnitWidget->blockSignals( false );
117  mOffsetUnitWidget->blockSignals( true );
118  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
119  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
120  mOffsetUnitWidget->blockSignals( false );
121  mDashPatternUnitWidget->blockSignals( true );
122  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
123  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
124  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
125  mDashPatternUnitWidget->blockSignals( false );
126 
127  // set values
128  spinWidth->blockSignals( true );
129  spinWidth->setValue( mLayer->width() );
130  spinWidth->blockSignals( false );
131  btnChangeColor->blockSignals( true );
132  btnChangeColor->setColor( mLayer->color() );
133  btnChangeColor->blockSignals( false );
134  spinOffset->blockSignals( true );
135  spinOffset->setValue( mLayer->offset() );
136  spinOffset->blockSignals( false );
137  cboPenStyle->blockSignals( true );
138  cboJoinStyle->blockSignals( true );
139  cboCapStyle->blockSignals( true );
140  cboPenStyle->setPenStyle( mLayer->penStyle() );
141  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
142  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
143  cboPenStyle->blockSignals( false );
144  cboJoinStyle->blockSignals( false );
145  cboCapStyle->blockSignals( false );
146 
147  //use a custom dash pattern?
148  bool useCustomDashPattern = mLayer->useCustomDashPattern();
149  mChangePatternButton->setEnabled( useCustomDashPattern );
150  label_3->setEnabled( !useCustomDashPattern );
151  cboPenStyle->setEnabled( !useCustomDashPattern );
152  mCustomCheckBox->blockSignals( true );
153  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
154  mCustomCheckBox->blockSignals( false );
155 
156  //draw inside polygon?
157  bool drawInsidePolygon = mLayer->drawInsidePolygon();
158  mDrawInsideCheckBox->blockSignals( true );
159  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
160  mDrawInsideCheckBox->blockSignals( false );
161 
163 }
164 
166 {
167  return mLayer;
168 }
169 
171 {
172  mLayer->setWidth( spinWidth->value() );
174  emit changed();
175 }
176 
178 {
179  mLayer->setColor( color );
181  emit changed();
182 }
183 
185 {
186  mLayer->setPenStyle( cboPenStyle->penStyle() );
187  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
188  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
189  emit changed();
190 }
191 
193 {
194  mLayer->setOffset( spinOffset->value() );
196  emit changed();
197 }
198 
200 {
201  bool checked = ( state == Qt::Checked );
202  mChangePatternButton->setEnabled( checked );
203  label_3->setEnabled( !checked );
204  cboPenStyle->setEnabled( !checked );
205 
206  mLayer->setUseCustomDashPattern( checked );
207  emit changed();
208 }
209 
211 {
213  if ( d.exec() == QDialog::Accepted )
214  {
215  mLayer->setCustomDashVector( d.dashDotVector() );
217  emit changed();
218  }
219 }
220 
222 {
223  if ( mLayer )
224  {
225  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mPenWidthUnitWidget->getUnit() );
226  mLayer->setWidthUnit( unit );
227  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
228  emit changed();
229  }
230 }
231 
233 {
234  if ( mLayer )
235  {
236  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
237  mLayer->setOffsetUnit( unit );
238  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
239  emit changed();
240  }
241 }
242 
244 {
245  if ( mLayer )
246  {
247  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDashPatternUnitWidget->getUnit() );
249  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
250  emit changed();
251  }
252 }
253 
255 {
256  bool checked = ( state == Qt::Checked );
257  mLayer->setDrawInsidePolygon( checked );
258  emit changed();
259 }
260 
262 {
263  if ( !mLayer )
264  {
265  return;
266  }
267 
268  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
269  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ),
271  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Pen width" ), mLayer->dataDefinedPropertyString( "width" ),
273  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
275  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "customdash", tr( "Dash pattern" ), mLayer->dataDefinedPropertyString( "customdash" ), "<dash>;<space>" );
276  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "joinstyle", tr( "Join style" ), mLayer->dataDefinedPropertyString( "joinstyle" ), "'bevel'|'miter'|'round'" );
277  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "capstyle", tr( "Cap style" ), mLayer->dataDefinedPropertyString( "capstyle" ), "'square'|'flat'|'round'" );
278  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
279 
280  if ( d.exec() == QDialog::Accepted )
281  {
282  //empty all existing properties first
284 
285  QMap<QString, QString> properties = d.dataDefinedProperties();
286  QMap<QString, QString>::const_iterator it = properties.constBegin();
287  for ( ; it != properties.constEnd(); ++it )
288  {
289  if ( !it.value().isEmpty() )
290  {
291  mLayer->setDataDefinedProperty( it.key(), it.value() );
292  }
293  }
294  emit changed();
295  }
296 }
297 
299 {
300  if ( !mLayer )
301  {
302  return;
303  }
304  QgsSimpleLineSymbolLayerV2* layerCopy = dynamic_cast<QgsSimpleLineSymbolLayerV2*>( mLayer->clone() );
305  if ( !layerCopy )
306  {
307  return;
308  }
309  layerCopy->setUseCustomDashPattern( true );
310  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
311  mChangePatternButton->setIcon( buttonIcon );
312  delete layerCopy;
313 }
314 
315 
317 
318 
320  : QgsSymbolLayerV2Widget( parent, vl )
321 {
322  mLayer = NULL;
323 
324  setupUi( this );
325  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
326  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
327  mOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
328 
329  btnChangeColorFill->setAllowAlpha( true );
330  btnChangeColorFill->setColorDialogTitle( tr( "Select fill color" ) );
331  btnChangeColorFill->setContext( "symbology" );
332  btnChangeColorFill->setShowNoColor( true );
333  btnChangeColorFill->setNoColorString( tr( "Transparent fill" ) );
334  btnChangeColorBorder->setAllowAlpha( true );
335  btnChangeColorBorder->setColorDialogTitle( tr( "Select border color" ) );
336  btnChangeColorBorder->setContext( "symbology" );
337  btnChangeColorBorder->setShowNoColor( true );
338  btnChangeColorBorder->setNoColorString( tr( "Transparent border" ) );
339 
340  spinOffsetX->setClearValue( 0.0 );
341  spinOffsetY->setClearValue( 0.0 );
342 
343  QSize size = lstNames->iconSize();
344  QStringList names;
345  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
346  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
347  double markerSize = DEFAULT_POINT_SIZE * 2;
348  for ( int i = 0; i < names.count(); ++i )
349  {
350  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
352  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
353  item->setData( Qt::UserRole, names[i] );
354  delete lyr;
355  }
356 
357  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
358  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
359  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
360  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
361  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
362  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
363  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
364 }
365 
367 {
368  if ( layer->layerType() != "SimpleMarker" )
369  return;
370 
371  // layer type is correct, we can do the cast
372  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
373 
374  // set values
375  QString name = mLayer->name();
376  for ( int i = 0; i < lstNames->count(); ++i )
377  {
378  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
379  {
380  lstNames->setCurrentRow( i );
381  break;
382  }
383  }
384  btnChangeColorBorder->blockSignals( true );
385  btnChangeColorBorder->setColor( mLayer->borderColor() );
386  btnChangeColorBorder->blockSignals( false );
387  btnChangeColorFill->blockSignals( true );
388  btnChangeColorFill->setColor( mLayer->color() );
389  btnChangeColorFill->blockSignals( false );
390  spinSize->blockSignals( true );
391  spinSize->setValue( mLayer->size() );
392  spinSize->blockSignals( false );
393  spinAngle->blockSignals( true );
394  spinAngle->setValue( mLayer->angle() );
395  spinAngle->blockSignals( false );
396  mOutlineStyleComboBox->blockSignals( true );
397  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
398  mOutlineStyleComboBox->blockSignals( false );
399  mOutlineWidthSpinBox->blockSignals( true );
400  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
401  mOutlineWidthSpinBox->blockSignals( false );
402 
403  // without blocking signals the value gets changed because of slot setOffset()
404  spinOffsetX->blockSignals( true );
405  spinOffsetX->setValue( mLayer->offset().x() );
406  spinOffsetX->blockSignals( false );
407  spinOffsetY->blockSignals( true );
408  spinOffsetY->setValue( mLayer->offset().y() );
409  spinOffsetY->blockSignals( false );
410 
411  mSizeUnitWidget->blockSignals( true );
412  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
413  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
414  mSizeUnitWidget->blockSignals( false );
415  mOffsetUnitWidget->blockSignals( true );
416  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
417  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
418  mOffsetUnitWidget->blockSignals( false );
419  mOutlineWidthUnitWidget->blockSignals( true );
420  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
421  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
422  mOutlineWidthUnitWidget->blockSignals( false );
423 
424  //anchor points
425  mHorizontalAnchorComboBox->blockSignals( true );
426  mVerticalAnchorComboBox->blockSignals( true );
427  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
428  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
429  mHorizontalAnchorComboBox->blockSignals( false );
430  mVerticalAnchorComboBox->blockSignals( false );
431 }
432 
434 {
435  return mLayer;
436 }
437 
439 {
440  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
441  emit changed();
442 }
443 
445 {
446  mLayer->setBorderColor( color );
447  emit changed();
448 }
449 
451 {
452  mLayer->setColor( color );
453  emit changed();
454 }
455 
457 {
458  mLayer->setSize( spinSize->value() );
459  emit changed();
460 }
461 
463 {
464  mLayer->setAngle( spinAngle->value() );
465  emit changed();
466 }
467 
469 {
470  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
471  emit changed();
472 }
473 
475 {
476  Q_UNUSED( index );
477 
478  if ( mLayer )
479  {
480  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
481  emit changed();
482  }
483 }
484 
486 {
487  if ( mLayer )
488  {
489  mLayer->setOutlineWidth( d );
490  emit changed();
491  }
492 }
493 
495 {
496  if ( mLayer )
497  {
498  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
499  mLayer->setSizeUnit( unit );
500  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
501  emit changed();
502  }
503 }
504 
506 {
507  if ( mLayer )
508  {
509  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
510  mLayer->setOffsetUnit( unit );
511  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
512  emit changed();
513  }
514 }
515 
517 {
518  if ( mLayer )
519  {
520  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOutlineWidthUnitWidget->getUnit() );
521  mLayer->setOutlineWidthUnit( unit );
522  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
523  emit changed();
524  }
525 }
526 
528 {
529  if ( !mLayer )
530  {
531  return;
532  }
533 
534  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
535  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "name", tr( "Name" ), mLayer->dataDefinedPropertyString( "name" ),
536  "'square'|'rectangle'|'diamond'|'pentagon'|'triangle'|'equilateral_triangle'|'star'|'regular_star'|'arrow'|'filled_arrowhead'|'circle'|'cross'|'x'|'cross2'|'line'|'arrowhead'" );
537  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Fill color" ), mLayer->dataDefinedPropertyString( "color" ),
539  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color_border", tr( "Border color" ), mLayer->dataDefinedPropertyString( "color_border" ),
541  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline_width", tr( "Outline width" ), mLayer->dataDefinedPropertyString( "outline_width" ),
545  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
547  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
549  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "horizontal_anchor_point", tr( "Horizontal anchor point" ), mLayer->dataDefinedPropertyString( "horizontal_anchor_point" ),
551  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "vertical_anchor_point", tr( "Vertical anchor point" ), mLayer->dataDefinedPropertyString( "vertical_anchor_point" ),
553  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
554  if ( d.exec() == QDialog::Accepted )
555  {
556  //empty all existing properties first
558 
559  QMap<QString, QString> properties = d.dataDefinedProperties();
560  QMap<QString, QString>::const_iterator it = properties.constBegin();
561  for ( ; it != properties.constEnd(); ++it )
562  {
563  if ( !it.value().isEmpty() )
564  {
565  mLayer->setDataDefinedProperty( it.key(), it.value() );
566  }
567  }
568  emit changed();
569  }
570 }
571 
573 {
574  if ( mLayer )
575  {
577  emit changed();
578  }
579 }
580 
582 {
583  if ( mLayer )
584  {
586  emit changed();
587  }
588 }
589 
590 
592 
594  : QgsSymbolLayerV2Widget( parent, vl )
595 {
596  mLayer = NULL;
597 
598  setupUi( this );
599  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
600  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
601 
602  btnChangeColor->setAllowAlpha( true );
603  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
604  btnChangeColor->setContext( "symbology" );
605  btnChangeColor->setShowNoColor( true );
606  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
607  btnChangeBorderColor->setAllowAlpha( true );
608  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
609  btnChangeBorderColor->setContext( "symbology" );
610  btnChangeBorderColor->setShowNoColor( true );
611  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
612 
613  spinOffsetX->setClearValue( 0.0 );
614  spinOffsetY->setClearValue( 0.0 );
615 
616  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
617  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
618  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
619  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
620  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
621  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
622  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
623  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
624 }
625 
627 {
628  if ( layer->layerType() != "SimpleFill" )
629  return;
630 
631  // layer type is correct, we can do the cast
632  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
633 
634  // set values
635  btnChangeColor->blockSignals( true );
636  btnChangeColor->setColor( mLayer->color() );
637  btnChangeColor->blockSignals( false );
638  cboFillStyle->blockSignals( true );
639  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
640  cboFillStyle->blockSignals( false );
641  btnChangeBorderColor->blockSignals( true );
642  btnChangeBorderColor->setColor( mLayer->borderColor() );
643  btnChangeBorderColor->blockSignals( false );
644  cboBorderStyle->blockSignals( true );
645  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
646  cboBorderStyle->blockSignals( false );
647  spinBorderWidth->blockSignals( true );
648  spinBorderWidth->setValue( mLayer->borderWidth() );
649  spinBorderWidth->blockSignals( false );
650  cboJoinStyle->blockSignals( true );
651  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
652  cboJoinStyle->blockSignals( false );
653  spinOffsetX->blockSignals( true );
654  spinOffsetX->setValue( mLayer->offset().x() );
655  spinOffsetX->blockSignals( false );
656  spinOffsetY->blockSignals( true );
657  spinOffsetY->setValue( mLayer->offset().y() );
658  spinOffsetY->blockSignals( false );
659 
660  mBorderWidthUnitWidget->blockSignals( true );
661  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
662  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
663  mBorderWidthUnitWidget->blockSignals( false );
664  mOffsetUnitWidget->blockSignals( true );
665  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
666  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
667  mOffsetUnitWidget->blockSignals( false );
668 }
669 
671 {
672  return mLayer;
673 }
674 
676 {
677  mLayer->setColor( color );
678  emit changed();
679 }
680 
682 {
683  mLayer->setBorderColor( color );
684  emit changed();
685 }
686 
688 {
689  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
690  emit changed();
691 }
692 
694 {
695  mLayer->setBorderWidth( spinBorderWidth->value() );
696  emit changed();
697 }
698 
700 {
701  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
702  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
703  emit changed();
704 }
705 
707 {
708  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
709  emit changed();
710 }
711 
713 {
714  if ( mLayer )
715  {
716  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
717  mLayer->setBorderWidthUnit( unit );
718  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
719  emit changed();
720  }
721 }
722 
724 {
725  if ( mLayer )
726  {
727  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
728  mLayer->setOffsetUnit( unit );
729  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
730  emit changed();
731  }
732 }
733 
735 {
736  if ( !mLayer )
737  {
738  return;
739  }
740 
741  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
743  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color_border", tr( "Border color" ), mLayer->dataDefinedPropertyString( "color_border" ),
745  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width_border", tr( "Border width" ), mLayer->dataDefinedPropertyString( "width_border" ),
747  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
748  if ( d.exec() == QDialog::Accepted )
749  {
750  //empty all existing properties first
752 
753  QMap<QString, QString> properties = d.dataDefinedProperties();
754  QMap<QString, QString>::const_iterator it = properties.constBegin();
755  for ( ; it != properties.constEnd(); ++it )
756  {
757  if ( !it.value().isEmpty() )
758  {
759  mLayer->setDataDefinedProperty( it.key(), it.value() );
760  }
761  }
762  emit changed();
763  }
764 }
765 
767 
769  : QgsSymbolLayerV2Widget( parent, vl )
770 {
771  mLayer = NULL;
772 
773  setupUi( this );
774  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
775 
776  cboGradientColorRamp->setShowGradientOnly( true );
777  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
778 
779  btnChangeColor->setAllowAlpha( true );
780  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
781  btnChangeColor->setContext( "symbology" );
782  btnChangeColor->setShowNoColor( true );
783  btnChangeColor->setNoColorString( tr( "Transparent" ) );
784  btnChangeColor2->setAllowAlpha( true );
785  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
786  btnChangeColor2->setContext( "symbology" );
787  btnChangeColor2->setShowNoColor( true );
788  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
789 
790  spinOffsetX->setClearValue( 0.0 );
791  spinOffsetY->setClearValue( 0.0 );
792 
793  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
794  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
795  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
796  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
797  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
798  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
799  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
800  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
801  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
802  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
803  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
804  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
805  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
806  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
807  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
808 }
809 
811 {
812  if ( layer->layerType() != "GradientFill" )
813  return;
814 
815  // layer type is correct, we can do the cast
816  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
817 
818  // set values
819  btnChangeColor->blockSignals( true );
820  btnChangeColor->setColor( mLayer->color() );
821  btnChangeColor->blockSignals( false );
822  btnChangeColor2->blockSignals( true );
823  btnChangeColor2->setColor( mLayer->color2() );
824  btnChangeColor2->blockSignals( false );
825 
827  {
828  radioTwoColor->setChecked( true );
829  cboGradientColorRamp->setEnabled( false );
830  }
831  else
832  {
833  radioColorRamp->setChecked( true );
834  btnChangeColor->setEnabled( false );
835  btnChangeColor2->setEnabled( false );
836  }
837 
838  // set source color ramp
839  if ( mLayer->colorRamp() )
840  {
841  cboGradientColorRamp->blockSignals( true );
842  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
843  cboGradientColorRamp->blockSignals( false );
844  }
845 
846  cboGradientType->blockSignals( true );
847  switch ( mLayer->gradientType() )
848  {
850  cboGradientType->setCurrentIndex( 0 );
851  break;
853  cboGradientType->setCurrentIndex( 1 );
854  break;
856  cboGradientType->setCurrentIndex( 2 );
857  break;
858  }
859  cboGradientType->blockSignals( false );
860 
861  cboCoordinateMode->blockSignals( true );
862  switch ( mLayer->coordinateMode() )
863  {
865  cboCoordinateMode->setCurrentIndex( 1 );
866  checkRefPoint1Centroid->setEnabled( false );
867  checkRefPoint2Centroid->setEnabled( false );
868  break;
870  default:
871  cboCoordinateMode->setCurrentIndex( 0 );
872  break;
873  }
874  cboCoordinateMode->blockSignals( false );
875 
876  cboGradientSpread->blockSignals( true );
877  switch ( mLayer->gradientSpread() )
878  {
880  cboGradientSpread->setCurrentIndex( 0 );
881  break;
883  cboGradientSpread->setCurrentIndex( 1 );
884  break;
886  cboGradientSpread->setCurrentIndex( 2 );
887  break;
888  }
889  cboGradientSpread->blockSignals( false );
890 
891  spinRefPoint1X->blockSignals( true );
892  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
893  spinRefPoint1X->blockSignals( false );
894  spinRefPoint1Y->blockSignals( true );
895  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
896  spinRefPoint1Y->blockSignals( false );
897  checkRefPoint1Centroid->blockSignals( true );
898  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
900  {
901  spinRefPoint1X->setEnabled( false );
902  spinRefPoint1Y->setEnabled( false );
903  }
904  checkRefPoint1Centroid->blockSignals( false );
905  spinRefPoint2X->blockSignals( true );
906  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
907  spinRefPoint2X->blockSignals( false );
908  spinRefPoint2Y->blockSignals( true );
909  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
910  spinRefPoint2Y->blockSignals( false );
911  checkRefPoint2Centroid->blockSignals( true );
912  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
914  {
915  spinRefPoint2X->setEnabled( false );
916  spinRefPoint2Y->setEnabled( false );
917  }
918  checkRefPoint2Centroid->blockSignals( false );
919 
920  spinOffsetX->blockSignals( true );
921  spinOffsetX->setValue( mLayer->offset().x() );
922  spinOffsetX->blockSignals( false );
923  spinOffsetY->blockSignals( true );
924  spinOffsetY->setValue( mLayer->offset().y() );
925  spinOffsetY->blockSignals( false );
926  mSpinAngle->blockSignals( true );
927  mSpinAngle->setValue( mLayer->angle() );
928  mSpinAngle->blockSignals( false );
929 
930  mOffsetUnitWidget->blockSignals( true );
931  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
932  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
933  mOffsetUnitWidget->blockSignals( false );
934 }
935 
937 {
938  return mLayer;
939 }
940 
942 {
943  mLayer->setColor( color );
944  emit changed();
945 }
946 
948 {
949  mLayer->setColor2( color );
950  emit changed();
951 }
952 
954 {
955  if ( radioTwoColor->isChecked() )
956  {
958  }
959  else
960  {
962  }
963  emit changed();
964 }
965 
967 {
968  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
969  if ( ramp == NULL )
970  return;
971 
972  mLayer->setColorRamp( ramp );
973  emit changed();
974 }
975 
977 {
978  if ( mLayer->colorRamp()->type() == "gradient" )
979  {
981  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
982  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
983 
984  if ( dlg.exec() && gradRamp )
985  {
986  mLayer->setColorRamp( gradRamp );
987  cboGradientColorRamp->blockSignals( true );
988  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
989  cboGradientColorRamp->blockSignals( false );
990  emit changed();
991  }
992  else
993  {
994  delete ramp;
995  }
996  }
997 }
998 
1000 {
1001  switch ( index )
1002  {
1003  case 0:
1005  //set sensible default reference points
1006  spinRefPoint1X->setValue( 0.5 );
1007  spinRefPoint1Y->setValue( 0 );
1008  spinRefPoint2X->setValue( 0.5 );
1009  spinRefPoint2Y->setValue( 1 );
1010  break;
1011  case 1:
1013  //set sensible default reference points
1014  spinRefPoint1X->setValue( 0 );
1015  spinRefPoint1Y->setValue( 0 );
1016  spinRefPoint2X->setValue( 1 );
1017  spinRefPoint2Y->setValue( 1 );
1018  break;
1019  case 2:
1021  spinRefPoint1X->setValue( 0.5 );
1022  spinRefPoint1Y->setValue( 0.5 );
1023  spinRefPoint2X->setValue( 1 );
1024  spinRefPoint2Y->setValue( 1 );
1025  break;
1026  }
1027  emit changed();
1028 }
1029 
1031 {
1032 
1033  switch ( index )
1034  {
1035  case 0:
1036  //feature coordinate mode
1038  //allow choice of centroid reference positions
1039  checkRefPoint1Centroid->setEnabled( true );
1040  checkRefPoint2Centroid->setEnabled( true );
1041  break;
1042  case 1:
1043  //viewport coordinate mode
1045  //disable choice of centroid reference positions
1046  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1047  checkRefPoint1Centroid->setEnabled( false );
1048  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1049  checkRefPoint2Centroid->setEnabled( false );
1050  break;
1051  }
1052 
1053  emit changed();
1054 }
1055 
1057 {
1058  switch ( index )
1059  {
1060  case 0:
1062  break;
1063  case 1:
1065  break;
1066  case 2:
1068  break;
1069  }
1070 
1071  emit changed();
1072 }
1073 
1075 {
1076  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1077  emit changed();
1078 }
1079 
1081 {
1082  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1083  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1084  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1085  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1086  emit changed();
1087 }
1088 
1090 {
1091  mLayer->setAngle( value );
1092  emit changed();
1093 }
1094 
1096 {
1097  if ( mLayer )
1098  {
1099  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1100  mLayer->setOffsetUnit( unit );
1101  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1102  emit changed();
1103  }
1104 }
1105 
1107 {
1108  if ( !mLayer )
1109  {
1110  return;
1111  }
1112 
1113  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1114  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color (start)" ), mLayer->dataDefinedPropertyString( "color" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1115  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color2", tr( "Color (end)" ), mLayer->dataDefinedPropertyString( "color2" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1116  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
1118  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "gradient_type", tr( "Gradient type" ), mLayer->dataDefinedPropertyString( "gradient_type" ), QgsDataDefinedSymbolDialog::gradientTypeHelpText() );
1119  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "coordinate_mode", tr( "Coordinate mode" ), mLayer->dataDefinedPropertyString( "coordinate_mode" ), QgsDataDefinedSymbolDialog::gradientCoordModeHelpText() );
1120  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "spread", tr( "Spread" ), mLayer->dataDefinedPropertyString( "spread" ),
1122  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_x", tr( "Reference Point 1 (x)" ), mLayer->dataDefinedPropertyString( "reference1_x" ),
1124  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_y", tr( "Reference Point 1 (y)" ), mLayer->dataDefinedPropertyString( "reference1_y" ),
1126  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference1_iscentroid", tr( "Reference Point 1 (is centroid)" ), mLayer->dataDefinedPropertyString( "reference1_iscentroid" ),
1128  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_x", tr( "Reference Point 2 (x)" ), mLayer->dataDefinedPropertyString( "reference2_x" ),
1130  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_y", tr( "Reference Point 2 (y)" ), mLayer->dataDefinedPropertyString( "reference2_y" ),
1132  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "reference2_iscentroid", tr( "Reference Point 2 (is centroid)" ), mLayer->dataDefinedPropertyString( "reference2_iscentroid" ),
1134 
1135  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1136  if ( d.exec() == QDialog::Accepted )
1137  {
1138  //empty all existing properties first
1140 
1141  QMap<QString, QString> properties = d.dataDefinedProperties();
1142  QMap<QString, QString>::const_iterator it = properties.constBegin();
1143  for ( ; it != properties.constEnd(); ++it )
1144  {
1145  if ( !it.value().isEmpty() )
1146  {
1147  mLayer->setDataDefinedProperty( it.key(), it.value() );
1148  }
1149  }
1150  emit changed();
1151  }
1152 }
1153 
1155 
1157  : QgsSymbolLayerV2Widget( parent, vl )
1158 {
1159  mLayer = NULL;
1160 
1161  setupUi( this );
1162  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1163  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1164 
1165  btnChangeColor->setAllowAlpha( true );
1166  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1167  btnChangeColor->setContext( "symbology" );
1168  btnChangeColor->setShowNoColor( true );
1169  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1170  btnChangeColor2->setAllowAlpha( true );
1171  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1172  btnChangeColor2->setContext( "symbology" );
1173  btnChangeColor2->setShowNoColor( true );
1174  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1175 
1176  spinOffsetX->setClearValue( 0.0 );
1177  spinOffsetY->setClearValue( 0.0 );
1178 
1179  cboGradientColorRamp->setShowGradientOnly( true );
1180  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1181 
1182  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1183  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1184  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1185  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1186  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1187  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1188 
1189  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1190  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1191 }
1192 
1194 {
1195  if ( layer->layerType() != "ShapeburstFill" )
1196  return;
1197 
1198  // layer type is correct, we can do the cast
1199  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1200 
1201  // set values
1202  btnChangeColor->blockSignals( true );
1203  btnChangeColor->setColor( mLayer->color() );
1204  btnChangeColor->blockSignals( false );
1205  btnChangeColor2->blockSignals( true );
1206  btnChangeColor2->setColor( mLayer->color2() );
1207  btnChangeColor2->blockSignals( false );
1208 
1210  {
1211  radioTwoColor->setChecked( true );
1212  cboGradientColorRamp->setEnabled( false );
1213  }
1214  else
1215  {
1216  radioColorRamp->setChecked( true );
1217  btnChangeColor->setEnabled( false );
1218  btnChangeColor2->setEnabled( false );
1219  }
1220 
1221  mSpinBlurRadius->blockSignals( true );
1222  mBlurSlider->blockSignals( true );
1223  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1224  mBlurSlider->setValue( mLayer->blurRadius() );
1225  mSpinBlurRadius->blockSignals( false );
1226  mBlurSlider->blockSignals( false );
1227 
1228  mSpinMaxDistance->blockSignals( true );
1229  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1230  mSpinMaxDistance->blockSignals( false );
1231 
1232  mRadioUseWholeShape->blockSignals( true );
1233  mRadioUseMaxDistance->blockSignals( true );
1234  if ( mLayer->useWholeShape() )
1235  {
1236  mRadioUseWholeShape->setChecked( true );
1237  mSpinMaxDistance->setEnabled( false );
1238  mDistanceUnitWidget->setEnabled( false );
1239  }
1240  else
1241  {
1242  mRadioUseMaxDistance->setChecked( true );
1243  mSpinMaxDistance->setEnabled( true );
1244  mDistanceUnitWidget->setEnabled( true );
1245  }
1246  mRadioUseWholeShape->blockSignals( false );
1247  mRadioUseMaxDistance->blockSignals( false );
1248 
1249  mDistanceUnitWidget->blockSignals( true );
1250  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1251  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1252  mDistanceUnitWidget->blockSignals( false );
1253 
1254  mIgnoreRingsCheckBox->blockSignals( true );
1255  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1256  mIgnoreRingsCheckBox->blockSignals( false );
1257 
1258  // set source color ramp
1259  if ( mLayer->colorRamp() )
1260  {
1261  cboGradientColorRamp->blockSignals( true );
1262  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1263  cboGradientColorRamp->blockSignals( false );
1264  }
1265 
1266  spinOffsetX->blockSignals( true );
1267  spinOffsetX->setValue( mLayer->offset().x() );
1268  spinOffsetX->blockSignals( false );
1269  spinOffsetY->blockSignals( true );
1270  spinOffsetY->setValue( mLayer->offset().y() );
1271  spinOffsetY->blockSignals( false );
1272  mOffsetUnitWidget->blockSignals( true );
1273  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1274  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1275  mOffsetUnitWidget->blockSignals( false );
1276 }
1277 
1279 {
1280  return mLayer;
1281 }
1282 
1284 {
1285  if ( mLayer )
1286  {
1287  mLayer->setColor( color );
1288  emit changed();
1289  }
1290 }
1291 
1293 {
1294  if ( mLayer )
1295  {
1296  mLayer->setColor2( color );
1297  emit changed();
1298  }
1299 }
1300 
1302 {
1303  if ( !mLayer )
1304  {
1305  return;
1306  }
1307 
1308  if ( radioTwoColor->isChecked() )
1309  {
1311  }
1312  else
1313  {
1315  }
1316  emit changed();
1317 }
1318 
1320 {
1321  if ( mLayer )
1322  {
1323  mLayer->setBlurRadius( value );
1324  emit changed();
1325  }
1326 }
1327 
1329 {
1330  if ( mLayer )
1331  {
1332  mLayer->setMaxDistance( value );
1333  emit changed();
1334  }
1335 }
1336 
1338 {
1339  if ( mLayer )
1340  {
1341  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
1342  mLayer->setDistanceUnit( unit );
1343  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1344  emit changed();
1345  }
1346 }
1347 
1349 {
1350  if ( mLayer )
1351  {
1352  mLayer->setUseWholeShape( value );
1353  mDistanceUnitWidget->setEnabled( !value );
1354  emit changed();
1355  }
1356 }
1357 
1359 {
1360  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1361  if ( ramp == NULL )
1362  return;
1363 
1364  mLayer->setColorRamp( ramp );
1365  emit changed();
1366 }
1367 
1369 {
1370  if ( mLayer->colorRamp()->type() == "gradient" )
1371  {
1373  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
1374  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
1375 
1376  if ( dlg.exec() && gradRamp )
1377  {
1378  mLayer->setColorRamp( gradRamp );
1379  cboGradientColorRamp->blockSignals( true );
1380  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1381  cboGradientColorRamp->blockSignals( false );
1382  emit changed();
1383  }
1384  else
1385  {
1386  delete ramp;
1387  }
1388  }
1389 }
1390 
1392 {
1393  if ( mLayer )
1394  {
1395  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1396  emit changed();
1397  }
1398 }
1399 
1401 {
1402  if ( mLayer )
1403  {
1404  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1405  mLayer->setOffsetUnit( unit );
1406  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1407  emit changed();
1408  }
1409 }
1410 
1412 {
1413  if ( !mLayer )
1414  {
1415  return;
1416  }
1417 
1418  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1419  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color (start)" ), mLayer->dataDefinedPropertyString( "color" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1420  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color2", tr( "Color (end)" ), mLayer->dataDefinedPropertyString( "color2" ), QgsDataDefinedSymbolDialog::colorHelpText() );
1421  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "blur_radius", tr( "Blur radius" ), mLayer->dataDefinedPropertyString( "blur_radius" ),
1422  tr( "Integer between 0 and 18" ) );
1423  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "use_whole_shape", tr( "Use whole shape" ), mLayer->dataDefinedPropertyString( "use_whole_shape" ), QgsDataDefinedSymbolDialog::boolHelpText() );
1424  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "max_distance", tr( "Maximum distance" ), mLayer->dataDefinedPropertyString( "max_distance" ), QgsDataDefinedSymbolDialog::doubleHelpText() );
1425  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "ignore_rings", tr( "Ignore rings" ), mLayer->dataDefinedPropertyString( "ignore_rings" ), QgsDataDefinedSymbolDialog::boolHelpText() );
1426 
1427  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1428  if ( d.exec() == QDialog::Accepted )
1429  {
1430  //empty all existing properties first
1432 
1433  QMap<QString, QString> properties = d.dataDefinedProperties();
1434  QMap<QString, QString>::const_iterator it = properties.constBegin();
1435  for ( ; it != properties.constEnd(); ++it )
1436  {
1437  if ( !it.value().isEmpty() )
1438  {
1439  mLayer->setDataDefinedProperty( it.key(), it.value() );
1440  }
1441  }
1442  emit changed();
1443  }
1444 }
1445 
1447 {
1448  bool checked = ( state == Qt::Checked );
1449  mLayer->setIgnoreRings( checked );
1450  emit changed();
1451 }
1452 
1454 
1456  : QgsSymbolLayerV2Widget( parent, vl )
1457 {
1458  mLayer = NULL;
1459 
1460  setupUi( this );
1461  mIntervalUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1462  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1463  mOffsetAlongLineUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1464 
1465  spinOffset->setClearValue( 0.0 );
1466 
1467  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1468  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1469  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1470  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1471  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1472  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1473  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1474  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1475  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1476 }
1477 
1479 {
1480  if ( layer->layerType() != "MarkerLine" )
1481  return;
1482 
1483  // layer type is correct, we can do the cast
1484  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1485 
1486  // set values
1487  spinInterval->blockSignals( true );
1488  spinInterval->setValue( mLayer->interval() );
1489  spinInterval->blockSignals( false );
1490  mSpinOffsetAlongLine->blockSignals( true );
1491  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1492  mSpinOffsetAlongLine->blockSignals( false );
1493  chkRotateMarker->blockSignals( true );
1494  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1495  chkRotateMarker->blockSignals( false );
1496  spinOffset->blockSignals( true );
1497  spinOffset->setValue( mLayer->offset() );
1498  spinOffset->blockSignals( false );
1500  radInterval->setChecked( true );
1502  radVertex->setChecked( true );
1504  radVertexLast->setChecked( true );
1506  radCentralPoint->setChecked( true );
1507  else
1508  radVertexFirst->setChecked( true );
1509 
1510  // set units
1511  mIntervalUnitWidget->blockSignals( true );
1512  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1513  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1514  mIntervalUnitWidget->blockSignals( false );
1515  mOffsetUnitWidget->blockSignals( true );
1516  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1517  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1518  mOffsetUnitWidget->blockSignals( false );
1519  mOffsetAlongLineUnitWidget->blockSignals( true );
1520  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1521  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1522  mOffsetAlongLineUnitWidget->blockSignals( false );
1523 
1524  setPlacement(); // update gui
1525 }
1526 
1528 {
1529  return mLayer;
1530 }
1531 
1533 {
1534  mLayer->setInterval( val );
1535  emit changed();
1536 }
1537 
1539 {
1540  mLayer->setOffsetAlongLine( val );
1541  emit changed();
1542 }
1543 
1545 {
1546  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1547  emit changed();
1548 }
1549 
1551 {
1552  mLayer->setOffset( spinOffset->value() );
1553  emit changed();
1554 }
1555 
1557 {
1558  bool interval = radInterval->isChecked();
1559  spinInterval->setEnabled( interval );
1560  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1561  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1562  if ( radInterval->isChecked() )
1564  else if ( radVertex->isChecked() )
1566  else if ( radVertexLast->isChecked() )
1568  else if ( radVertexFirst->isChecked() )
1570  else
1572 
1573  emit changed();
1574 }
1575 
1577 {
1578  if ( mLayer )
1579  {
1580  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mIntervalUnitWidget->getUnit() );
1581  mLayer->setIntervalUnit( unit );
1582  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1583  emit changed();
1584  }
1585 }
1586 
1588 {
1589  if ( mLayer )
1590  {
1591  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1592  mLayer->setOffsetUnit( unit );
1593  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1594  emit changed();
1595  }
1596 }
1597 
1599 {
1600  if ( mLayer )
1601  {
1602  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetAlongLineUnitWidget->getUnit() );
1603  mLayer->setOffsetAlongLineUnit( unit );
1604  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1605  }
1606  emit changed();
1607 }
1608 
1610 {
1611  if ( !mLayer )
1612  {
1613  return;
1614  }
1615 
1616  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
1617  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "interval", tr( "Interval" ), mLayer->dataDefinedPropertyString( "interval" ),
1619  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Line offset" ), mLayer->dataDefinedPropertyString( "offset" ),
1621  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "placement", tr( "Placement" ), mLayer->dataDefinedPropertyString( "placement" ),
1622  tr( "'vertex'|'lastvertex'|'firstvertex'|'centerpoint'" ) );
1623  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset_along_line", tr( "Offset along line" ), mLayer->dataDefinedPropertyString( "offset_along_line" ),
1625  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
1626  if ( d.exec() == QDialog::Accepted )
1627  {
1628  //empty all existing properties first
1630 
1631  QMap<QString, QString> properties = d.dataDefinedProperties();
1632  QMap<QString, QString>::const_iterator it = properties.constBegin();
1633  for ( ; it != properties.constEnd(); ++it )
1634  {
1635  if ( !it.value().isEmpty() )
1636  {
1637  mLayer->setDataDefinedProperty( it.key(), it.value() );
1638  }
1639  }
1640  emit changed();
1641  }
1642 }
1643 
1645 
1646 
1648  : QgsSymbolLayerV2Widget( parent, vl )
1649 {
1650  mLayer = NULL;
1651 
1652  setupUi( this );
1653  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1654  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1655  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1656  viewGroups->setHeaderHidden( true );
1657 
1658  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1659  mChangeColorButton->setContext( "symbology" );
1660  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1661  mChangeColorButton->setContext( "symbology" );
1662 
1663  spinOffsetX->setClearValue( 0.0 );
1664  spinOffsetY->setClearValue( 0.0 );
1665 
1666  populateList();
1667 
1668  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1669  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1670  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1671  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1672  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1673  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1674 }
1675 
1676 #include <QTime>
1677 #include <QAbstractListModel>
1678 #include <QPixmapCache>
1679 #include <QStyle>
1680 
1681 class QgsSvgListModel : public QAbstractListModel
1682 {
1683  public:
1684  QgsSvgListModel( QObject* parent ) : QAbstractListModel( parent )
1685  {
1687  }
1688 
1689  // Constructor to create model for icons in a specific path
1690  QgsSvgListModel( QObject* parent, QString path ) : QAbstractListModel( parent )
1691  {
1693  }
1694 
1695  int rowCount( const QModelIndex & parent = QModelIndex() ) const
1696  {
1697  Q_UNUSED( parent );
1698  return mSvgFiles.count();
1699  }
1700 
1701  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const
1702  {
1703  QString entry = mSvgFiles.at( index.row() );
1704 
1705  if ( role == Qt::DecorationRole ) // icon
1706  {
1707  QPixmap pixmap;
1708  if ( !QPixmapCache::find( entry, pixmap ) )
1709  {
1710  // render SVG file
1711  QColor fill, outline;
1712  double outlineWidth;
1713  bool fillParam, outlineParam, outlineWidthParam;
1714  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1715 
1716  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1717  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1718  pixmap = QPixmap::fromImage( img );
1719  QPixmapCache::insert( entry, pixmap );
1720  }
1721 
1722  return pixmap;
1723  }
1724  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1725  {
1726  return entry;
1727  }
1728 
1729  return QVariant();
1730  }
1731 
1732  protected:
1733  QStringList mSvgFiles;
1734 };
1735 
1736 class QgsSvgGroupsModel : public QStandardItemModel
1737 {
1738  public:
1739  QgsSvgGroupsModel( QObject* parent ) : QStandardItemModel( parent )
1740  {
1741  QStringList svgPaths = QgsApplication::svgPaths();
1742  QStandardItem *parentItem = invisibleRootItem();
1743 
1744  for ( int i = 0; i < svgPaths.size(); i++ )
1745  {
1746  QDir dir( svgPaths[i] );
1747  QStandardItem *baseGroup;
1748 
1749  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1750  {
1751  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1752  }
1753  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1754  {
1755  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1756  }
1757  else
1758  {
1759  baseGroup = new QStandardItem( dir.dirName() );
1760  }
1761  baseGroup->setData( QVariant( svgPaths[i] ) );
1762  baseGroup->setEditable( false );
1763  baseGroup->setCheckable( false );
1764  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1765  baseGroup->setToolTip( dir.path() );
1766  parentItem->appendRow( baseGroup );
1767  createTree( baseGroup );
1768  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1769  }
1770  }
1771  private:
1772  void createTree( QStandardItem* &parentGroup )
1773  {
1774  QDir parentDir( parentGroup->data().toString() );
1775  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1776  {
1777  QStandardItem* group = new QStandardItem( item );
1778  group->setData( QVariant( parentDir.path() + "/" + item ) );
1779  group->setEditable( false );
1780  group->setCheckable( false );
1781  group->setToolTip( parentDir.path() + "/" + item );
1782  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1783  parentGroup->appendRow( group );
1784  createTree( group );
1785  }
1786  }
1787 };
1788 
1790 {
1791  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1792  viewGroups->setModel( g );
1793  // Set the tree expanded at the first level
1794  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1795  for ( int i = 0; i < rows; i++ )
1796  {
1797  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1798  }
1799 
1800  // Initally load the icons in the List view without any grouping
1801  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1802  viewImages->setModel( m );
1803 }
1804 
1806 {
1807  QString path = idx.data( Qt::UserRole + 1 ).toString();
1808 
1809  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1810  viewImages->setModel( m );
1811 
1812  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1813  emit changed();
1814 }
1815 
1817 {
1818  if ( !layer )
1819  {
1820  return;
1821  }
1822 
1823  //activate gui for svg parameters only if supported by the svg file
1824  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1825  QColor defaultFill, defaultOutline;
1826  double defaultOutlineWidth;
1827  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1828  mChangeColorButton->setEnabled( hasFillParam );
1829  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1830  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1831 
1832  if ( hasFillParam )
1833  {
1834  if ( layer->fillColor().isValid() )
1835  {
1836  mChangeColorButton->setColor( layer->fillColor() );
1837  }
1838  else
1839  {
1840  mChangeColorButton->setColor( defaultFill );
1841  }
1842  }
1843  if ( hasOutlineParam )
1844  {
1845  if ( layer->outlineColor().isValid() )
1846  {
1847  mChangeBorderColorButton->setColor( layer->outlineColor() );
1848  }
1849  else
1850  {
1851  mChangeBorderColorButton->setColor( defaultOutline );
1852  }
1853  }
1854 
1855  mFileLineEdit->blockSignals( true );
1856  mFileLineEdit->setText( layer->path() );
1857  mFileLineEdit->blockSignals( false );
1858 
1859  mBorderWidthSpinBox->blockSignals( true );
1860  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1861  mBorderWidthSpinBox->blockSignals( false );
1862 }
1863 
1864 
1866 {
1867  if ( !layer )
1868  {
1869  return;
1870  }
1871 
1872  if ( layer->layerType() != "SvgMarker" )
1873  return;
1874 
1875  // layer type is correct, we can do the cast
1876  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1877 
1878  // set values
1879 
1880  QAbstractItemModel* m = viewImages->model();
1881  QItemSelectionModel* selModel = viewImages->selectionModel();
1882  for ( int i = 0; i < m->rowCount(); i++ )
1883  {
1884  QModelIndex idx( m->index( i, 0 ) );
1885  if ( m->data( idx ).toString() == mLayer->path() )
1886  {
1887  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1888  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1889  setName( idx );
1890  break;
1891  }
1892  }
1893 
1894  spinSize->blockSignals( true );
1895  spinSize->setValue( mLayer->size() );
1896  spinSize->blockSignals( false );
1897  spinAngle->blockSignals( true );
1898  spinAngle->setValue( mLayer->angle() );
1899  spinAngle->blockSignals( false );
1900 
1901  // without blocking signals the value gets changed because of slot setOffset()
1902  spinOffsetX->blockSignals( true );
1903  spinOffsetX->setValue( mLayer->offset().x() );
1904  spinOffsetX->blockSignals( false );
1905  spinOffsetY->blockSignals( true );
1906  spinOffsetY->setValue( mLayer->offset().y() );
1907  spinOffsetY->blockSignals( false );
1908 
1909  mSizeUnitWidget->blockSignals( true );
1910  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1911  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1912  mSizeUnitWidget->blockSignals( false );
1913  mBorderWidthUnitWidget->blockSignals( true );
1914  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1915  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1916  mBorderWidthUnitWidget->blockSignals( false );
1917  mOffsetUnitWidget->blockSignals( true );
1918  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1919  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1920  mOffsetUnitWidget->blockSignals( false );
1921 
1922  //anchor points
1923  mHorizontalAnchorComboBox->blockSignals( true );
1924  mVerticalAnchorComboBox->blockSignals( true );
1925  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1926  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1927  mHorizontalAnchorComboBox->blockSignals( false );
1928  mVerticalAnchorComboBox->blockSignals( false );
1929 
1930  setGuiForSvg( mLayer );
1931 }
1932 
1934 {
1935  return mLayer;
1936 }
1937 
1938 void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
1939 {
1940  QString name = idx.data( Qt::UserRole ).toString();
1941  mLayer->setPath( name );
1942  mFileLineEdit->setText( name );
1943 
1944  setGuiForSvg( mLayer );
1945  emit changed();
1946 }
1947 
1949 {
1950  mLayer->setSize( spinSize->value() );
1951  emit changed();
1952 }
1953 
1955 {
1956  mLayer->setAngle( spinAngle->value() );
1957  emit changed();
1958 }
1959 
1961 {
1962  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1963  emit changed();
1964 }
1965 
1967 {
1968  QSettings s;
1969  QString file = QFileDialog::getOpenFileName( 0,
1970  tr( "Select SVG file" ),
1971  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1972  tr( "SVG files" ) + " (*.svg)" );
1973  QFileInfo fi( file );
1974  if ( file.isEmpty() || !fi.exists() )
1975  {
1976  return;
1977  }
1978  mFileLineEdit->setText( file );
1979  mLayer->setPath( file );
1980  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1981  emit changed();
1982 }
1983 
1985 {
1986  if ( !QFileInfo( text ).exists() )
1987  {
1988  return;
1989  }
1990  mLayer->setPath( text );
1991  setGuiForSvg( mLayer );
1992  emit changed();
1993 }
1994 
1996 {
1997  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1998  {
1999  QUrl url( mFileLineEdit->text() );
2000  if ( !url.isValid() )
2001  {
2002  return;
2003  }
2004  }
2005 
2006  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2007  mLayer->setPath( mFileLineEdit->text() );
2008  QApplication::restoreOverrideCursor();
2009 
2010  setGuiForSvg( mLayer );
2011  emit changed();
2012 }
2013 
2015 {
2016  if ( !mLayer )
2017  {
2018  return;
2019  }
2020 
2021  mLayer->setFillColor( color );
2022  emit changed();
2023 }
2024 
2026 {
2027  if ( !mLayer )
2028  {
2029  return;
2030  }
2031 
2032  mLayer->setOutlineColor( color );
2033  emit changed();
2034 }
2035 
2037 {
2038  if ( mLayer )
2039  {
2040  mLayer->setOutlineWidth( d );
2041  emit changed();
2042  }
2043 }
2044 
2046 {
2047  if ( mLayer )
2048  {
2049  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
2050  mLayer->setSizeUnit( unit );
2051  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2052  emit changed();
2053  }
2054 }
2055 
2057 {
2058  if ( mLayer )
2059  {
2060  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
2061  mLayer->setOutlineWidthUnit( unit );
2062  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
2063  emit changed();
2064  }
2065 }
2066 
2068 {
2069  if ( mLayer )
2070  {
2071  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2072  mLayer->setOffsetUnit( unit );
2073  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2074  emit changed();
2075  }
2076 }
2077 
2079 {
2080  if ( !mLayer )
2081  {
2082  return;
2083  }
2084 
2085  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2088  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline-width", tr( "Border width" ), mLayer->dataDefinedPropertyString( "outline-width" ),
2090  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
2092  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
2094  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "name", tr( "SVG file" ), mLayer->dataDefinedPropertyString( "name" ),
2096  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "fill", tr( "Color" ), mLayer->dataDefinedPropertyString( "fill" ),
2098  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline", tr( "Border color" ), mLayer->dataDefinedPropertyString( "outline" ),
2100  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "horizontal_anchor_point", tr( "Horizontal anchor point" ), mLayer->dataDefinedPropertyString( "horizontal_anchor_point" ),
2102  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "vertical_anchor_point", tr( "Vertical anchor point" ), mLayer->dataDefinedPropertyString( "vertical_anchor_point" ),
2104  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2105  if ( d.exec() == QDialog::Accepted )
2106  {
2107  //empty all existing properties first
2109 
2110  QMap<QString, QString> properties = d.dataDefinedProperties();
2111  QMap<QString, QString>::const_iterator it = properties.constBegin();
2112  for ( ; it != properties.constEnd(); ++it )
2113  {
2114  if ( !it.value().isEmpty() )
2115  {
2116  mLayer->setDataDefinedProperty( it.key(), it.value() );
2117  }
2118  }
2119  emit changed();
2120  }
2121 }
2122 
2124 {
2125  if ( mLayer )
2126  {
2128  emit changed();
2129  }
2130 }
2131 
2133 {
2134  if ( mLayer )
2135  {
2137  emit changed();
2138  }
2139 }
2140 
2142 
2143 #include <QFileDialog>
2144 
2146 {
2147  mLayer = 0;
2148  setupUi( this );
2149  mTextureWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2150  mSvgOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2151  mSvgTreeView->setHeaderHidden( true );
2152  insertIcons();
2153 
2154  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
2155  mChangeColorButton->setContext( "symbology" );
2156  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
2157  mChangeBorderColorButton->setContext( "symbology" );
2158 
2159  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2160  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
2161 }
2162 
2164 {
2165  if ( !layer )
2166  {
2167  return;
2168  }
2169 
2170  if ( layer->layerType() != "SVGFill" )
2171  {
2172  return;
2173  }
2174 
2175  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
2176  if ( mLayer )
2177  {
2178  double width = mLayer->patternWidth();
2179  mTextureWidthSpinBox->blockSignals( true );
2180  mTextureWidthSpinBox->setValue( width );
2181  mTextureWidthSpinBox->blockSignals( false );
2182  mSVGLineEdit->setText( mLayer->svgFilePath() );
2183  mRotationSpinBox->blockSignals( true );
2184  mRotationSpinBox->setValue( mLayer->angle() );
2185  mRotationSpinBox->blockSignals( false );
2186  mTextureWidthUnitWidget->blockSignals( true );
2187  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2188  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2189  mTextureWidthUnitWidget->blockSignals( false );
2190  mSvgOutlineWidthUnitWidget->blockSignals( true );
2191  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2192  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2193  mSvgOutlineWidthUnitWidget->blockSignals( false );
2194  mChangeColorButton->blockSignals( true );
2195  mChangeColorButton->setColor( mLayer->svgFillColor() );
2196  mChangeColorButton->blockSignals( false );
2197  mChangeBorderColorButton->blockSignals( true );
2198  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2199  mChangeBorderColorButton->blockSignals( false );
2200  mBorderWidthSpinBox->blockSignals( true );
2201  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2202  mBorderWidthSpinBox->blockSignals( false );
2203  }
2204  updateParamGui( false );
2205 }
2206 
2208 {
2209  return mLayer;
2210 }
2211 
2212 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2213 {
2214  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2215  if ( !filePath.isNull() )
2216  {
2217  mSVGLineEdit->setText( filePath );
2218  emit changed();
2219  }
2220 }
2221 
2222 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2223 {
2224  if ( mLayer )
2225  {
2226  mLayer->setPatternWidth( d );
2227  emit changed();
2228  }
2229 }
2230 
2231 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2232 {
2233  if ( !mLayer )
2234  {
2235  return;
2236  }
2237 
2238  QFileInfo fi( text );
2239  if ( !fi.exists() )
2240  {
2241  return;
2242  }
2243  mLayer->setSvgFilePath( text );
2244  updateParamGui();
2245  emit changed();
2246 }
2247 
2248 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2249 {
2250  if ( !mLayer )
2251  {
2252  return;
2253  }
2254 
2255  QFileInfo fi( mSVGLineEdit->text() );
2256  if ( !fi.exists() )
2257  {
2258  QUrl url( mSVGLineEdit->text() );
2259  if ( !url.isValid() )
2260  {
2261  return;
2262  }
2263  }
2264 
2265  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2266  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2267  QApplication::restoreOverrideCursor();
2268 
2269  updateParamGui();
2270  emit changed();
2271 }
2272 
2273 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2274 {
2275  QString file = item.data( Qt::UserRole ).toString();
2276  mLayer->setSvgFilePath( file );
2277  mSVGLineEdit->setText( file );
2278 
2279  updateParamGui();
2280  emit changed();
2281 }
2282 
2284 {
2285  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2286  mSvgTreeView->setModel( g );
2287  // Set the tree expanded at the first level
2288  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2289  for ( int i = 0; i < rows; i++ )
2290  {
2291  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2292  }
2293 
2294  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2295  mSvgListView->setModel( m );
2296 }
2297 
2298 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2299 {
2300  QString path = idx.data( Qt::UserRole + 1 ).toString();
2301 
2302  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2303  mSvgListView->setModel( m );
2304 
2305  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2306  emit changed();
2307 }
2308 
2309 
2310 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2311 {
2312  if ( mLayer )
2313  {
2314  mLayer->setAngle( d );
2315  emit changed();
2316  }
2317 }
2318 
2320 {
2321  //activate gui for svg parameters only if supported by the svg file
2322  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2323  QColor defaultFill, defaultOutline;
2324  double defaultOutlineWidth;
2325  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2326  if ( hasFillParam && resetValues )
2327  {
2328  mChangeColorButton->setColor( defaultFill );
2329  }
2330  mChangeColorButton->setEnabled( hasFillParam );
2331  if ( hasOutlineParam && resetValues )
2332  {
2333  mChangeBorderColorButton->setColor( defaultOutline );
2334  }
2335  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2336  if ( hasOutlineWidthParam && resetValues )
2337  {
2338  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2339  }
2340  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2341 }
2342 
2343 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2344 {
2345  if ( !mLayer )
2346  {
2347  return;
2348  }
2349 
2350  mLayer->setSvgFillColor( color );
2351  emit changed();
2352 }
2353 
2354 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2355 {
2356  if ( !mLayer )
2357  {
2358  return;
2359  }
2360 
2361  mLayer->setSvgOutlineColor( color );
2362  emit changed();
2363 }
2364 
2365 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2366 {
2367  if ( mLayer )
2368  {
2369  mLayer->setSvgOutlineWidth( d );
2370  emit changed();
2371  }
2372 }
2373 
2374 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2375 {
2376  if ( mLayer )
2377  {
2378  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mTextureWidthUnitWidget->getUnit() );
2379  mLayer->setPatternWidthUnit( unit );
2380  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2381  emit changed();
2382  }
2383 }
2384 
2385 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2386 {
2387  if ( mLayer )
2388  {
2389  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSvgOutlineWidthUnitWidget->getUnit() );
2390  mLayer->setSvgOutlineWidthUnit( unit );
2391  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2392  emit changed();
2393  }
2394 }
2395 
2396 void QgsSVGFillSymbolLayerWidget::on_mDataDefinedPropertiesButton_clicked()
2397 {
2398  if ( !mLayer )
2399  {
2400  return;
2401  }
2402 
2403  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2404  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Texture width" ), mLayer->dataDefinedPropertyString( "width" ),
2406  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgFile", tr( "SVG file" ), mLayer->dataDefinedPropertyString( "svgFile" ),
2408  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Rotation" ), mLayer->dataDefinedPropertyString( "angle" ),
2410  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgFillColor", tr( "Color" ), mLayer->dataDefinedPropertyString( "svgFillColor" ),
2412  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgOutlineColor", tr( "Border color" ), mLayer->dataDefinedPropertyString( "svgOutlineColor" ),
2414  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "svgOutlineWidth", tr( "Border width" ), mLayer->dataDefinedPropertyString( "svgOutlineWidth" ),
2416  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2417  if ( d.exec() == QDialog::Accepted )
2418  {
2419  //empty all existing properties first
2421 
2422  QMap<QString, QString> properties = d.dataDefinedProperties();
2423  QMap<QString, QString>::const_iterator it = properties.constBegin();
2424  for ( ; it != properties.constEnd(); ++it )
2425  {
2426  if ( !it.value().isEmpty() )
2427  {
2428  mLayer->setDataDefinedProperty( it.key(), it.value() );
2429  }
2430  }
2431  emit changed();
2432  }
2433 }
2434 
2436 
2438  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2439 {
2440  setupUi( this );
2441  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2442  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2443 }
2444 
2446 {
2447  if ( layer->layerType() != "LinePatternFill" )
2448  {
2449  return;
2450  }
2451 
2452  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2453  if ( patternLayer )
2454  {
2455  mLayer = patternLayer;
2456  mAngleSpinBox->blockSignals( true );
2457  mAngleSpinBox->setValue( mLayer->lineAngle() );
2458  mAngleSpinBox->blockSignals( false );
2459  mDistanceSpinBox->blockSignals( true );
2460  mDistanceSpinBox->setValue( mLayer->distance() );
2461  mDistanceSpinBox->blockSignals( false );
2462  mOffsetSpinBox->blockSignals( true );
2463  mOffsetSpinBox->setValue( mLayer->offset() );
2464  mOffsetSpinBox->blockSignals( false );
2465 
2466  //units
2467  mDistanceUnitWidget->blockSignals( true );
2468  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2469  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2470  mDistanceUnitWidget->blockSignals( false );
2471  mOffsetUnitWidget->blockSignals( true );
2472  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2473  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2474  mOffsetUnitWidget->blockSignals( false );
2475  }
2476 }
2477 
2479 {
2480  return mLayer;
2481 }
2482 
2483 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2484 {
2485  if ( mLayer )
2486  {
2487  mLayer->setLineAngle( d );
2488  emit changed();
2489  }
2490 }
2491 
2492 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2493 {
2494  if ( mLayer )
2495  {
2496  mLayer->setDistance( d );
2497  emit changed();
2498  }
2499 }
2500 
2501 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2502 {
2503  if ( mLayer )
2504  {
2505  mLayer->setOffset( d );
2506  emit changed();
2507  }
2508 }
2509 
2510 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2511 {
2512  if ( mLayer )
2513  {
2514  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
2515  mLayer->setDistanceUnit( unit );
2516  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2517  emit changed();
2518  }
2519 }
2520 
2521 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2522 {
2523  if ( mLayer )
2524  {
2525  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2526  mLayer->setOffsetUnit( unit );
2527  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2528  emit changed();
2529  }
2530 }
2531 
2532 void QgsLinePatternFillSymbolLayerWidget::on_mDataDefinedPropertiesButton_clicked()
2533 {
2534  if ( !mLayer )
2535  {
2536  return;
2537  }
2538 
2539  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2540  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "lineangle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "lineangle" ),
2542  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance", tr( "Distance" ), mLayer->dataDefinedPropertyString( "distance" ),
2544  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "linewidth", tr( "Line width" ), mLayer->dataDefinedPropertyString( "linewidth" ),
2546  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ),
2548  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2549  if ( d.exec() == QDialog::Accepted )
2550  {
2551  //empty all existing properties first
2553 
2554  QMap<QString, QString> properties = d.dataDefinedProperties();
2555  QMap<QString, QString>::const_iterator it = properties.constBegin();
2556  for ( ; it != properties.constEnd(); ++it )
2557  {
2558  if ( !it.value().isEmpty() )
2559  {
2560  mLayer->setDataDefinedProperty( it.key(), it.value() );
2561  }
2562  }
2563  emit changed();
2564  }
2565 }
2566 
2567 
2569 
2571  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2572 {
2573  setupUi( this );
2574  mHorizontalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2575  mVerticalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2576  mHorizontalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2577  mVerticalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2578 }
2579 
2580 
2582 {
2583  if ( !layer || layer->layerType() != "PointPatternFill" )
2584  {
2585  return;
2586  }
2587 
2588  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2589  mHorizontalDistanceSpinBox->blockSignals( true );
2590  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2591  mHorizontalDistanceSpinBox->blockSignals( false );
2592  mVerticalDistanceSpinBox->blockSignals( true );
2593  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2594  mVerticalDistanceSpinBox->blockSignals( false );
2595  mHorizontalDisplacementSpinBox->blockSignals( true );
2596  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2597  mHorizontalDisplacementSpinBox->blockSignals( false );
2598  mVerticalDisplacementSpinBox->blockSignals( true );
2599  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2600  mVerticalDisplacementSpinBox->blockSignals( false );
2601 
2602  mHorizontalDistanceUnitWidget->blockSignals( true );
2603  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2604  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2605  mHorizontalDistanceUnitWidget->blockSignals( false );
2606  mVerticalDistanceUnitWidget->blockSignals( true );
2607  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2608  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2609  mVerticalDistanceUnitWidget->blockSignals( false );
2610  mHorizontalDisplacementUnitWidget->blockSignals( true );
2611  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2612  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2613  mHorizontalDisplacementUnitWidget->blockSignals( false );
2614  mVerticalDisplacementUnitWidget->blockSignals( true );
2615  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2616  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2617  mVerticalDisplacementUnitWidget->blockSignals( false );
2618 }
2619 
2621 {
2622  return mLayer;
2623 }
2624 
2625 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2626 {
2627  if ( mLayer )
2628  {
2629  mLayer->setDistanceX( d );
2630  emit changed();
2631  }
2632 }
2633 
2634 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2635 {
2636  if ( mLayer )
2637  {
2638  mLayer->setDistanceY( d );
2639  emit changed();
2640  }
2641 }
2642 
2643 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2644 {
2645  if ( mLayer )
2646  {
2647  mLayer->setDisplacementX( d );
2648  emit changed();
2649  }
2650 }
2651 
2652 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2653 {
2654  if ( mLayer )
2655  {
2656  mLayer->setDisplacementY( d );
2657  emit changed();
2658  }
2659 }
2660 
2661 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2662 {
2663  if ( mLayer )
2664  {
2665  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDistanceUnitWidget->getUnit() );
2666  mLayer->setDistanceXUnit( unit );
2667  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2668  emit changed();
2669  }
2670 }
2671 
2672 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2673 {
2674  if ( mLayer )
2675  {
2676  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDistanceUnitWidget->getUnit() );
2677  mLayer->setDistanceYUnit( unit );
2678  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2679  emit changed();
2680  }
2681 }
2682 
2683 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2684 {
2685  if ( mLayer )
2686  {
2687  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDisplacementUnitWidget->getUnit() );
2688  mLayer->setDisplacementXUnit( unit );
2689  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2690  emit changed();
2691  }
2692 }
2693 
2694 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2695 {
2696  if ( mLayer )
2697  {
2698  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDisplacementUnitWidget->getUnit() );
2699  mLayer->setDisplacementYUnit( unit );
2700  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2701  emit changed();
2702  }
2703 }
2704 
2705 void QgsPointPatternFillSymbolLayerWidget::on_mDataDefinedPropertiesButton_clicked()
2706 {
2707  if ( !mLayer )
2708  {
2709  return;
2710  }
2711 
2712  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
2713  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance_x", tr( "Horizontal distance" ), mLayer->dataDefinedPropertyString( "distance_x" ),
2715  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "distance_y", tr( "Vertical distance" ), mLayer->dataDefinedPropertyString( "distance_y" ),
2717  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "displacement_x", tr( "Horizontal displacement" ), mLayer->dataDefinedPropertyString( "displacement_x" ),
2719  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "displacement_y", tr( "Vertical displacement" ), mLayer->dataDefinedPropertyString( "displacement_y" ),
2721  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
2722  if ( d.exec() == QDialog::Accepted )
2723  {
2724  //empty all existing properties first
2726 
2727  QMap<QString, QString> properties = d.dataDefinedProperties();
2728  QMap<QString, QString>::const_iterator it = properties.constBegin();
2729  for ( ; it != properties.constEnd(); ++it )
2730  {
2731  if ( !it.value().isEmpty() )
2732  {
2733  mLayer->setDataDefinedProperty( it.key(), it.value() );
2734  }
2735  }
2736  emit changed();
2737  }
2738 }
2739 
2741 
2743  : QgsSymbolLayerV2Widget( parent, vl )
2744 {
2745  mLayer = NULL;
2746 
2747  setupUi( this );
2748  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2749  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2751  scrollArea->setWidget( widgetChar );
2752 
2753  btnColor->setAllowAlpha( true );
2754  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2755  btnColor->setContext( "symbology" );
2756 
2757  spinOffsetX->setClearValue( 0.0 );
2758  spinOffsetY->setClearValue( 0.0 );
2759 
2760  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2761  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2762  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2763  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2764  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2765  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2766  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2767 }
2768 
2769 
2771 {
2772  if ( layer->layerType() != "FontMarker" )
2773  return;
2774 
2775  // layer type is correct, we can do the cast
2776  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2777 
2778  // set values
2779  cboFont->blockSignals( true );
2780  cboFont->setCurrentFont( QFont( mLayer->fontFamily() ) );
2781  cboFont->blockSignals( false );
2782  spinSize->blockSignals( true );
2783  spinSize->setValue( mLayer->size() );
2784  spinSize->blockSignals( false );
2785  btnColor->blockSignals( true );
2786  btnColor->setColor( mLayer->color() );
2787  btnColor->blockSignals( false );
2788  spinAngle->blockSignals( true );
2789  spinAngle->setValue( mLayer->angle() );
2790  spinAngle->blockSignals( false );
2791 
2792  //block
2793  spinOffsetX->blockSignals( true );
2794  spinOffsetX->setValue( mLayer->offset().x() );
2795  spinOffsetX->blockSignals( false );
2796  spinOffsetY->blockSignals( true );
2797  spinOffsetY->setValue( mLayer->offset().y() );
2798  spinOffsetY->blockSignals( false );
2799 
2800  mSizeUnitWidget->blockSignals( true );
2801  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2802  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2803  mSizeUnitWidget->blockSignals( false );
2804 
2805  mOffsetUnitWidget->blockSignals( true );
2806  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2807  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2808  mOffsetUnitWidget->blockSignals( false );
2809 
2810  //anchor points
2811  mHorizontalAnchorComboBox->blockSignals( true );
2812  mVerticalAnchorComboBox->blockSignals( true );
2813  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2814  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2815  mHorizontalAnchorComboBox->blockSignals( false );
2816  mVerticalAnchorComboBox->blockSignals( false );
2817 }
2818 
2820 {
2821  return mLayer;
2822 }
2823 
2825 {
2826  mLayer->setFontFamily( font.family() );
2827  widgetChar->updateFont( font );
2828  emit changed();
2829 }
2830 
2832 {
2833  mLayer->setColor( color );
2834  emit changed();
2835 }
2836 
2838 {
2839  mLayer->setSize( size );
2840  //widgetChar->updateSize(size);
2841  emit changed();
2842 }
2843 
2845 {
2846  mLayer->setAngle( angle );
2847  emit changed();
2848 }
2849 
2851 {
2852  mLayer->setCharacter( chr );
2853  emit changed();
2854 }
2855 
2857 {
2858  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2859  emit changed();
2860 }
2861 
2863 {
2864  if ( mLayer )
2865  {
2866  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
2867  mLayer->setSizeUnit( unit );
2868  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2869  emit changed();
2870  }
2871 }
2872 
2874 {
2875  if ( mLayer )
2876  {
2877  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2878  mLayer->setOffsetUnit( unit );
2879  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2880  emit changed();
2881  }
2882 }
2883 
2885 {
2886  if ( mLayer )
2887  {
2889  emit changed();
2890  }
2891 }
2892 
2894 {
2895  if ( mLayer )
2896  {
2898  emit changed();
2899  }
2900 }
2901 
2902 
2904 
2905 
2907  : QgsSymbolLayerV2Widget( parent, vl )
2908 {
2909  mLayer = NULL;
2910 
2911  setupUi( this );
2912 }
2913 
2915 {
2916  if ( layer->layerType() != "CentroidFill" )
2917  return;
2918 
2919  // layer type is correct, we can do the cast
2920  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2921 
2922  // set values
2923  mDrawInsideCheckBox->blockSignals( true );
2924  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2925  mDrawInsideCheckBox->blockSignals( false );
2926 }
2927 
2929 {
2930  return mLayer;
2931 }
2932 
2934 {
2935  mLayer->setPointOnSurface( state == Qt::Checked );
2936  emit changed();
2937 }
2938 
2940 
2942  : QgsSymbolLayerV2Widget( parent, vl )
2943 {
2944  mLayer = 0;
2945  setupUi( this );
2946 
2947  mWidthUnitWidget->setUnits( QStringList() << tr( "Pixels" ) << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2948  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2949 
2950  mSpinOffsetX->setClearValue( 0.0 );
2951  mSpinOffsetY->setClearValue( 0.0 );
2952 
2953  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2954  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2955  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2956 }
2957 
2959 {
2960  if ( !layer )
2961  {
2962  return;
2963  }
2964 
2965  if ( layer->layerType() != "RasterFill" )
2966  {
2967  return;
2968  }
2969 
2970  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2971  if ( !mLayer )
2972  {
2973  return;
2974  }
2975 
2976  mImageLineEdit->blockSignals( true );
2977  mImageLineEdit->setText( mLayer->imageFilePath() );
2978  mImageLineEdit->blockSignals( false );
2979 
2980  cboCoordinateMode->blockSignals( true );
2981  switch ( mLayer->coordinateMode() )
2982  {
2984  cboCoordinateMode->setCurrentIndex( 1 );
2985  break;
2987  default:
2988  cboCoordinateMode->setCurrentIndex( 0 );
2989  break;
2990  }
2991  cboCoordinateMode->blockSignals( false );
2992  mSpinTransparency->blockSignals( true );
2993  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2994  mSpinTransparency->blockSignals( false );
2995  mSliderTransparency->blockSignals( true );
2996  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2997  mSliderTransparency->blockSignals( false );
2998  mRotationSpinBox->blockSignals( true );
2999  mRotationSpinBox->setValue( mLayer->angle() );
3000  mRotationSpinBox->blockSignals( false );
3001 
3002  mSpinOffsetX->blockSignals( true );
3003  mSpinOffsetX->setValue( mLayer->offset().x() );
3004  mSpinOffsetX->blockSignals( false );
3005  mSpinOffsetY->blockSignals( true );
3006  mSpinOffsetY->setValue( mLayer->offset().y() );
3007  mSpinOffsetY->blockSignals( false );
3008  mOffsetUnitWidget->blockSignals( true );
3009  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3010  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3011  mOffsetUnitWidget->blockSignals( false );
3012 
3013  mWidthSpinBox->blockSignals( true );
3014  mWidthSpinBox->setValue( mLayer->width() );
3015  mWidthSpinBox->blockSignals( false );
3016  mWidthUnitWidget->blockSignals( true );
3017  switch ( mLayer->widthUnit() )
3018  {
3019  case QgsSymbolV2::MM:
3020  mWidthUnitWidget->setUnit( 1 );
3021  break;
3022  case QgsSymbolV2::MapUnit:
3023  mWidthUnitWidget->setUnit( 2 );
3024  break;
3025  case QgsSymbolV2::Pixel:
3026  default:
3027  mWidthUnitWidget->setUnit( 0 );
3028  break;
3029  }
3030  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
3031  mWidthUnitWidget->blockSignals( false );
3032  updatePreviewImage();
3033 }
3034 
3036 {
3037  return mLayer;
3038 }
3039 
3040 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
3041 {
3042  QSettings s;
3043  QString openDir;
3044  QString lineEditText = mImageLineEdit->text();
3045  if ( !lineEditText.isEmpty() )
3046  {
3047  QFileInfo openDirFileInfo( lineEditText );
3048  openDir = openDirFileInfo.path();
3049  }
3050 
3051  if ( openDir.isEmpty() )
3052  {
3053  openDir = s.value( "/UI/lastRasterFillImageDir", "" ).toString();
3054  }
3055 
3056  //show file dialog
3057  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select image file" ), openDir );
3058  if ( !filePath.isNull() )
3059  {
3060  //check if file exists
3061  QFileInfo fileInfo( filePath );
3062  if ( !fileInfo.exists() || !fileInfo.isReadable() )
3063  {
3064  QMessageBox::critical( 0, "Invalid file", "Error, file does not exist or is not readable" );
3065  return;
3066  }
3067 
3068  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
3069  mImageLineEdit->setText( filePath );
3070  on_mImageLineEdit_editingFinished();
3071  }
3072 }
3073 
3074 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
3075 {
3076  if ( !mLayer )
3077  {
3078  return;
3079  }
3080 
3081  QFileInfo fi( mImageLineEdit->text() );
3082  if ( !fi.exists() )
3083  {
3084  QUrl url( mImageLineEdit->text() );
3085  if ( !url.isValid() )
3086  {
3087  return;
3088  }
3089  }
3090 
3091  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3092  mLayer->setImageFilePath( mImageLineEdit->text() );
3093  updatePreviewImage();
3094  QApplication::restoreOverrideCursor();
3095 
3096  emit changed();
3097 }
3098 
3099 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
3100 {
3101  switch ( index )
3102  {
3103  case 0:
3104  //feature coordinate mode
3106  break;
3107  case 1:
3108  //viewport coordinate mode
3110  break;
3111  }
3112 
3113  emit changed();
3114 }
3115 
3116 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
3117 {
3118  if ( !mLayer )
3119  {
3120  return;
3121  }
3122 
3123  mLayer->setAlpha( value / 100.0 );
3124  emit changed();
3125  updatePreviewImage();
3126 }
3127 
3128 void QgsRasterFillSymbolLayerWidget::offsetChanged()
3129 {
3130  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
3131  emit changed();
3132 }
3133 
3134 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
3135 {
3136  if ( !mLayer )
3137  {
3138  return;
3139  }
3140  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
3141  mLayer->setOffsetUnit( unit );
3142  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3143  emit changed();
3144 }
3145 
3146 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
3147 {
3148  if ( mLayer )
3149  {
3150  mLayer->setAngle( d );
3151  emit changed();
3152  }
3153 }
3154 
3155 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
3156 {
3157  if ( !mLayer )
3158  {
3159  return;
3160  }
3162  switch ( mWidthUnitWidget->getUnit() )
3163  {
3164  case 0:
3165  unit = QgsSymbolV2::Pixel;
3166  break;
3167  case 1:
3168  unit = QgsSymbolV2::MM;
3169  break;
3170  case 2:
3171  unit = QgsSymbolV2::MapUnit;
3172  break;
3173  }
3174 
3175  mLayer->setWidthUnit( unit );
3176  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3177  emit changed();
3178 }
3179 
3180 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
3181 {
3182  if ( !mLayer )
3183  {
3184  return;
3185  }
3186  mLayer->setWidth( d );
3187  emit changed();
3188 }
3189 
3190 void QgsRasterFillSymbolLayerWidget::on_mDataDefinedPropertiesButton_clicked()
3191 {
3192  if ( !mLayer )
3193  {
3194  return;
3195  }
3196 
3197  QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
3198  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "file", tr( "File" ), mLayer->dataDefinedPropertyString( "file" ),
3200  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "alpha", tr( "Opacity" ), mLayer->dataDefinedPropertyString( "alpha" ),
3202  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
3204  dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Width" ), mLayer->dataDefinedPropertyString( "width" ),
3206  QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
3207  if ( d.exec() == QDialog::Accepted )
3208  {
3209  //empty all existing properties first
3211 
3212  QMap<QString, QString> properties = d.dataDefinedProperties();
3213  QMap<QString, QString>::const_iterator it = properties.constBegin();
3214  for ( ; it != properties.constEnd(); ++it )
3215  {
3216  if ( !it.value().isEmpty() )
3217  {
3218  mLayer->setDataDefinedProperty( it.key(), it.value() );
3219  }
3220  }
3221  emit changed();
3222  }
3223 }
3224 
3225 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
3226 {
3227  if ( !mLayer )
3228  {
3229  return;
3230  }
3231 
3232  QImage image( mLayer->imageFilePath() );
3233  if ( image.isNull() )
3234  {
3235  mLabelImagePreview->setPixmap( QPixmap() );
3236  return;
3237  }
3238 
3239  if ( image.height() > 150 || image.width() > 150 )
3240  {
3241  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
3242  }
3243 
3244  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3245  previewImage.fill( Qt::transparent );
3246  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3247  QPainter p;
3248  p.begin( &previewImage );
3249  //draw a checkerboard background
3250  uchar pixDataRGB[] = { 150, 150, 150, 150,
3251  100, 100, 100, 150,
3252  100, 100, 100, 150,
3253  150, 150, 150, 150
3254  };
3255  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3256  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3257  QBrush checkerBrush;
3258  checkerBrush.setTexture( pix );
3259  p.fillRect( imageRect, checkerBrush );
3260 
3261  if ( mLayer->alpha() < 1.0 )
3262  {
3263  p.setOpacity( mLayer->alpha() );
3264  }
3265 
3266  p.drawImage( imageRect.left(), imageRect.top(), image );
3267  p.end();
3268  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3269 }
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
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
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 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)
QgsSVGFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
const QgsMapUnitScale & offsetMapUnitScale() const
virtual QString type() const =0
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
void setCoordinateMode(GradientCoordinateMode coordinateMode)
virtual double width() const
QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
QgsGradientFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit distanceXUnit() const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)
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:33
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 setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
void setOffset(QPointF offset)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
void setMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
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 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)
QgsRasterFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
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 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 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
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
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)
A class for filling symbols with a repeated raster image.
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 setWidth(const double width)
Sets the width for scaling the image used in the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setPenJoinStyle(Qt::PenJoinStyle style)
void setBrushStyle(Qt::BrushStyle style)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
QgsSimpleLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
const QgsMapUnitScale & offsetMapUnitScale() const
QColor fillColor() const
Get fill color.
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void setMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsVectorColorRampV2 * clone() const =0
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
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
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
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)
QString imageFilePath() const
The path to the raster image used for the fill.
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)
void setCoordinateMode(const FillCoordinateMode mode)
Set the coordinate mode for fill.
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)
QgsRasterFillSymbolLayer * mLayer
QgsMarkerLineSymbolLayerV2 * mLayer
void setCustomDashVector(const QVector< qreal > &vector)
virtual QgsSymbolLayerV2 * symbolLayer()
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.
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units for the fill's offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
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)
QPointF offset() const
Returns the offset for the fill.
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
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & distanceYMapUnitScale() const
QgsSymbolV2::OutputUnit displacementYUnit() const
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
void setSvgFilePath(const QString &svgPath)
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
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
void setOffset(const QPointF &offset)
Sets the offset for the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
void setAlpha(const double alpha)
Sets the opacity for the raster image used in the fill.
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 setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setOutlineColor(const QColor &c)
Set outline color.
QgsShapeburstFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image's width.
void setMapUnitScale(const QgsMapUnitScale &scale)
virtual QString dataDefinedPropertyLabel(const QString &entryName)
Get label for data defined entry.
void setWidthUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the image's width.
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit displacementXUnit() const
void setGradientSpread(GradientSpread gradientSpread)
double width() const
Returns the width used for scaling the image used in the fill.
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
void setOffsetUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the fill's offset.
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
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
void setSvgOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
double alpha() const
The opacity for the raster image used in the fill.
virtual void setDataDefinedProperty(const QString &property, const QString &expressionString)
virtual QgsSymbolLayerV2 * symbolLayer()
#define tr(sourceText)
void setBorderStyle(Qt::PenStyle borderStyle)