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