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 #include <QTextDocument>
49 
50 void QgsSymbolLayerV2Widget::registerDataDefinedButton( QgsDataDefinedButton * button, const QString & propertyName, QgsDataDefinedButton::DataType type, const QString & description )
51 {
52  QgsDataDefined dd( symbolLayer()->dataDefinedProperty( propertyName ) );
53  button->init( mVectorLayer, &dd, type, Qt::escape( description ) );
54  button->setProperty( "propertyName", propertyName );
55  connect( button, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
56  connect( button, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
57 }
58 
60 {
61  QgsDataDefinedButton* button = qobject_cast<QgsDataDefinedButton*>( sender() );
62  const QString propertyName( button->property( "propertyName" ).toString() );
63  if ( button->isActive() )
64  symbolLayer()->setDataDefinedProperty( propertyName, button->currentDefinition() );
65  else
66  symbolLayer()->removeDataDefinedProperty( propertyName );
67  emit changed();
68 }
69 
70 QString QgsSymbolLayerV2Widget::dataDefinedPropertyLabel( const QString &entryName )
71 {
72  QString label = entryName;
73  if ( entryName == "size" )
74  {
75  label = tr( "Size" );
76  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
77  if ( layer )
78  {
79  switch ( layer->scaleMethod() )
80  {
82  label += " (" + tr( "area" ) + ")";
83  break;
85  label += " (" + tr( "diameter" ) + ")";
86  break;
87  }
88  }
89  }
90  return label;
91 }
92 
94  : QgsSymbolLayerV2Widget( parent, vl )
95 {
96  mLayer = NULL;
97 
98  setupUi( this );
99  mPenWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
100  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
101  mDashPatternUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
102 
103  btnChangeColor->setAllowAlpha( true );
104  btnChangeColor->setColorDialogTitle( tr( "Select line color" ) );
105  btnChangeColor->setContext( "symbology" );
106 
107  spinOffset->setClearValue( 0.0 );
108 
109  if ( vl && vl->geometryType() != QGis::Polygon )
110  {
111  //draw inside polygon checkbox only makes sense for polygon layers
112  mDrawInsideCheckBox->hide();
113  }
114 
115  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
116  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
117  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
118  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
119  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
120  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
122 
123 }
124 
126 {
127  if ( !layer || layer->layerType() != "SimpleLine" )
128  return;
129 
130  // layer type is correct, we can do the cast
131  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
132 
133  // set units
134  mPenWidthUnitWidget->blockSignals( true );
135  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
136  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
137  mPenWidthUnitWidget->blockSignals( false );
138  mOffsetUnitWidget->blockSignals( true );
139  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
140  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
141  mOffsetUnitWidget->blockSignals( false );
142  mDashPatternUnitWidget->blockSignals( true );
143  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
144  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
145  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
146  mDashPatternUnitWidget->blockSignals( false );
147 
148  // set values
149  spinWidth->blockSignals( true );
150  spinWidth->setValue( mLayer->width() );
151  spinWidth->blockSignals( false );
152  btnChangeColor->blockSignals( true );
153  btnChangeColor->setColor( mLayer->color() );
154  btnChangeColor->blockSignals( false );
155  spinOffset->blockSignals( true );
156  spinOffset->setValue( mLayer->offset() );
157  spinOffset->blockSignals( false );
158  cboPenStyle->blockSignals( true );
159  cboJoinStyle->blockSignals( true );
160  cboCapStyle->blockSignals( true );
161  cboPenStyle->setPenStyle( mLayer->penStyle() );
162  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
163  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
164  cboPenStyle->blockSignals( false );
165  cboJoinStyle->blockSignals( false );
166  cboCapStyle->blockSignals( false );
167 
168  //use a custom dash pattern?
169  bool useCustomDashPattern = mLayer->useCustomDashPattern();
170  mChangePatternButton->setEnabled( useCustomDashPattern );
171  label_3->setEnabled( !useCustomDashPattern );
172  cboPenStyle->setEnabled( !useCustomDashPattern );
173  mCustomCheckBox->blockSignals( true );
174  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
175  mCustomCheckBox->blockSignals( false );
176 
177  //draw inside polygon?
178  bool drawInsidePolygon = mLayer->drawInsidePolygon();
179  mDrawInsideCheckBox->blockSignals( true );
180  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
181  mDrawInsideCheckBox->blockSignals( false );
182 
184 
192 }
193 
195 {
196  return mLayer;
197 }
198 
200 {
201  mLayer->setWidth( spinWidth->value() );
203  emit changed();
204 }
205 
207 {
208  mLayer->setColor( color );
210  emit changed();
211 }
212 
214 {
215  mLayer->setPenStyle( cboPenStyle->penStyle() );
216  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
217  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
218  emit changed();
219 }
220 
222 {
223  mLayer->setOffset( spinOffset->value() );
225  emit changed();
226 }
227 
229 {
230  bool checked = ( state == Qt::Checked );
231  mChangePatternButton->setEnabled( checked );
232  label_3->setEnabled( !checked );
233  cboPenStyle->setEnabled( !checked );
234 
235  mLayer->setUseCustomDashPattern( checked );
236  emit changed();
237 }
238 
240 {
242  if ( d.exec() == QDialog::Accepted )
243  {
244  mLayer->setCustomDashVector( d.dashDotVector() );
246  emit changed();
247  }
248 }
249 
251 {
252  if ( mLayer )
253  {
254  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mPenWidthUnitWidget->getUnit() );
255  mLayer->setWidthUnit( unit );
256  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
257  emit changed();
258  }
259 }
260 
262 {
263  if ( mLayer )
264  {
265  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
266  mLayer->setOffsetUnit( unit );
267  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
268  emit changed();
269  }
270 }
271 
273 {
274  if ( mLayer )
275  {
276  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDashPatternUnitWidget->getUnit() );
278  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
279  emit changed();
280  }
281 }
282 
284 {
285  bool checked = ( state == Qt::Checked );
286  mLayer->setDrawInsidePolygon( checked );
287  emit changed();
288 }
289 
290 
292 {
293  if ( !mLayer )
294  {
295  return;
296  }
297  QgsSimpleLineSymbolLayerV2* layerCopy = dynamic_cast<QgsSimpleLineSymbolLayerV2*>( mLayer->clone() );
298  if ( !layerCopy )
299  {
300  return;
301  }
302  layerCopy->setUseCustomDashPattern( true );
303  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
304  mChangePatternButton->setIcon( buttonIcon );
305  delete layerCopy;
306 }
307 
308 
310 
311 
313  : QgsSymbolLayerV2Widget( parent, vl )
314 {
315  mLayer = NULL;
316 
317  setupUi( this );
318  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
319  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
320  mOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
321 
322  btnChangeColorFill->setAllowAlpha( true );
323  btnChangeColorFill->setColorDialogTitle( tr( "Select fill color" ) );
324  btnChangeColorFill->setContext( "symbology" );
325  btnChangeColorFill->setShowNoColor( true );
326  btnChangeColorFill->setNoColorString( tr( "Transparent fill" ) );
327  btnChangeColorBorder->setAllowAlpha( true );
328  btnChangeColorBorder->setColorDialogTitle( tr( "Select border color" ) );
329  btnChangeColorBorder->setContext( "symbology" );
330  btnChangeColorBorder->setShowNoColor( true );
331  btnChangeColorBorder->setNoColorString( tr( "Transparent border" ) );
332 
333  spinOffsetX->setClearValue( 0.0 );
334  spinOffsetY->setClearValue( 0.0 );
335 
336  QSize size = lstNames->iconSize();
337  QStringList names;
338  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
339  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
340  double markerSize = DEFAULT_POINT_SIZE * 2;
341  for ( int i = 0; i < names.count(); ++i )
342  {
343  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
345  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
346  item->setData( Qt::UserRole, names[i] );
347  delete lyr;
348  }
349 
350  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
351  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
352  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
353  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
354  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
355  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
356  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
357 }
358 
360 {
361  if ( layer->layerType() != "SimpleMarker" )
362  return;
363 
364  // layer type is correct, we can do the cast
365  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
366 
367  // set values
368  QString name = mLayer->name();
369  for ( int i = 0; i < lstNames->count(); ++i )
370  {
371  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
372  {
373  lstNames->setCurrentRow( i );
374  break;
375  }
376  }
377  btnChangeColorBorder->blockSignals( true );
378  btnChangeColorBorder->setColor( mLayer->borderColor() );
379  btnChangeColorBorder->blockSignals( false );
380  btnChangeColorFill->blockSignals( true );
381  btnChangeColorFill->setColor( mLayer->color() );
382  btnChangeColorFill->blockSignals( false );
383  spinSize->blockSignals( true );
384  spinSize->setValue( mLayer->size() );
385  spinSize->blockSignals( false );
386  spinAngle->blockSignals( true );
387  spinAngle->setValue( mLayer->angle() );
388  spinAngle->blockSignals( false );
389  mOutlineStyleComboBox->blockSignals( true );
390  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
391  mOutlineStyleComboBox->blockSignals( false );
392  mOutlineWidthSpinBox->blockSignals( true );
393  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
394  mOutlineWidthSpinBox->blockSignals( false );
395 
396  // without blocking signals the value gets changed because of slot setOffset()
397  spinOffsetX->blockSignals( true );
398  spinOffsetX->setValue( mLayer->offset().x() );
399  spinOffsetX->blockSignals( false );
400  spinOffsetY->blockSignals( true );
401  spinOffsetY->setValue( mLayer->offset().y() );
402  spinOffsetY->blockSignals( false );
403 
404  mSizeUnitWidget->blockSignals( true );
405  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
406  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
407  mSizeUnitWidget->blockSignals( false );
408  mOffsetUnitWidget->blockSignals( true );
409  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
410  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
411  mOffsetUnitWidget->blockSignals( false );
412  mOutlineWidthUnitWidget->blockSignals( true );
413  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
414  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
415  mOutlineWidthUnitWidget->blockSignals( false );
416 
417  //anchor points
418  mHorizontalAnchorComboBox->blockSignals( true );
419  mVerticalAnchorComboBox->blockSignals( true );
420  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
421  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
422  mHorizontalAnchorComboBox->blockSignals( false );
423  mVerticalAnchorComboBox->blockSignals( false );
424 
425  registerDataDefinedButton( mNameDDBtn, "name", QgsDataDefinedButton::String, "'square'|'rectangle'|'diamond'|'pentagon'|'triangle'|'equilateral_triangle'|'star'|'regular_star'|'arrow'|'filled_arrowhead'|'circle'|'cross'|'x'|'cross2'|'line'|'arrowhead'" );
433  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
434  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
435 }
436 
438 {
439  return mLayer;
440 }
441 
443 {
444  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
445  emit changed();
446 }
447 
449 {
450  mLayer->setBorderColor( color );
451  emit changed();
452 }
453 
455 {
456  mLayer->setColor( color );
457  emit changed();
458 }
459 
461 {
462  mLayer->setSize( spinSize->value() );
463  emit changed();
464 }
465 
467 {
468  mLayer->setAngle( spinAngle->value() );
469  emit changed();
470 }
471 
473 {
474  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
475  emit changed();
476 }
477 
479 {
480  Q_UNUSED( index );
481 
482  if ( mLayer )
483  {
484  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
485  emit changed();
486  }
487 }
488 
490 {
491  if ( mLayer )
492  {
493  mLayer->setOutlineWidth( d );
494  emit changed();
495  }
496 }
497 
499 {
500  if ( mLayer )
501  {
502  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
503  mLayer->setSizeUnit( unit );
504  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
505  emit changed();
506  }
507 }
508 
510 {
511  if ( mLayer )
512  {
513  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
514  mLayer->setOffsetUnit( unit );
515  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
516  emit changed();
517  }
518 }
519 
521 {
522  if ( mLayer )
523  {
524  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOutlineWidthUnitWidget->getUnit() );
525  mLayer->setOutlineWidthUnit( unit );
526  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
527  emit changed();
528  }
529 }
530 
532 {
533  if ( mLayer )
534  {
536  emit changed();
537  }
538 }
539 
541 {
542  if ( mLayer )
543  {
545  emit changed();
546  }
547 }
548 
549 
551 
553  : QgsSymbolLayerV2Widget( parent, vl )
554 {
555  mLayer = NULL;
556 
557  setupUi( this );
558  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
559  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
560 
561  btnChangeColor->setAllowAlpha( true );
562  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
563  btnChangeColor->setContext( "symbology" );
564  btnChangeColor->setShowNoColor( true );
565  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
566  btnChangeBorderColor->setAllowAlpha( true );
567  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
568  btnChangeBorderColor->setContext( "symbology" );
569  btnChangeBorderColor->setShowNoColor( true );
570  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
571 
572  spinOffsetX->setClearValue( 0.0 );
573  spinOffsetY->setClearValue( 0.0 );
574 
575  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
576  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
577  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
578  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
579  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
580  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
581  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
582  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
583 }
584 
586 {
587  if ( layer->layerType() != "SimpleFill" )
588  return;
589 
590  // layer type is correct, we can do the cast
591  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
592 
593  // set values
594  btnChangeColor->blockSignals( true );
595  btnChangeColor->setColor( mLayer->color() );
596  btnChangeColor->blockSignals( false );
597  cboFillStyle->blockSignals( true );
598  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
599  cboFillStyle->blockSignals( false );
600  btnChangeBorderColor->blockSignals( true );
601  btnChangeBorderColor->setColor( mLayer->borderColor() );
602  btnChangeBorderColor->blockSignals( false );
603  cboBorderStyle->blockSignals( true );
604  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
605  cboBorderStyle->blockSignals( false );
606  spinBorderWidth->blockSignals( true );
607  spinBorderWidth->setValue( mLayer->borderWidth() );
608  spinBorderWidth->blockSignals( false );
609  cboJoinStyle->blockSignals( true );
610  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
611  cboJoinStyle->blockSignals( false );
612  spinOffsetX->blockSignals( true );
613  spinOffsetX->setValue( mLayer->offset().x() );
614  spinOffsetX->blockSignals( false );
615  spinOffsetY->blockSignals( true );
616  spinOffsetY->setValue( mLayer->offset().y() );
617  spinOffsetY->blockSignals( false );
618 
619  mBorderWidthUnitWidget->blockSignals( true );
620  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
621  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
622  mBorderWidthUnitWidget->blockSignals( false );
623  mOffsetUnitWidget->blockSignals( true );
624  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
625  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
626  mOffsetUnitWidget->blockSignals( false );
627 
634 
635 }
636 
638 {
639  return mLayer;
640 }
641 
643 {
644  mLayer->setColor( color );
645  emit changed();
646 }
647 
649 {
650  mLayer->setBorderColor( color );
651  emit changed();
652 }
653 
655 {
656  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
657  emit changed();
658 }
659 
661 {
662  mLayer->setBorderWidth( spinBorderWidth->value() );
663  emit changed();
664 }
665 
667 {
668  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
669  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
670  emit changed();
671 }
672 
674 {
675  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
676  emit changed();
677 }
678 
680 {
681  if ( mLayer )
682  {
683  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
684  mLayer->setBorderWidthUnit( unit );
685  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
686  emit changed();
687  }
688 }
689 
691 {
692  if ( mLayer )
693  {
694  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
695  mLayer->setOffsetUnit( unit );
696  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
697  emit changed();
698  }
699 }
700 
702 
704  : QgsSymbolLayerV2Widget( parent, vl )
705 {
706  mLayer = NULL;
707 
708  setupUi( this );
709  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
710 
711  cboGradientColorRamp->setShowGradientOnly( true );
712  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
713 
714  btnChangeColor->setAllowAlpha( true );
715  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
716  btnChangeColor->setContext( "symbology" );
717  btnChangeColor->setShowNoColor( true );
718  btnChangeColor->setNoColorString( tr( "Transparent" ) );
719  btnChangeColor2->setAllowAlpha( true );
720  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
721  btnChangeColor2->setContext( "symbology" );
722  btnChangeColor2->setShowNoColor( true );
723  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
724 
725  spinOffsetX->setClearValue( 0.0 );
726  spinOffsetY->setClearValue( 0.0 );
727 
728  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
729  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
730  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
731  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
732  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
733  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
734  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
735  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
736  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
737  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
738  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
739  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
740  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
741  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
742  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
743 }
744 
746 {
747  if ( layer->layerType() != "GradientFill" )
748  return;
749 
750  // layer type is correct, we can do the cast
751  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
752 
753  // set values
754  btnChangeColor->blockSignals( true );
755  btnChangeColor->setColor( mLayer->color() );
756  btnChangeColor->blockSignals( false );
757  btnChangeColor2->blockSignals( true );
758  btnChangeColor2->setColor( mLayer->color2() );
759  btnChangeColor2->blockSignals( false );
760 
762  {
763  radioTwoColor->setChecked( true );
764  cboGradientColorRamp->setEnabled( false );
765  }
766  else
767  {
768  radioColorRamp->setChecked( true );
769  btnChangeColor->setEnabled( false );
770  btnChangeColor2->setEnabled( false );
771  }
772 
773  // set source color ramp
774  if ( mLayer->colorRamp() )
775  {
776  cboGradientColorRamp->blockSignals( true );
777  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
778  cboGradientColorRamp->blockSignals( false );
779  }
780 
781  cboGradientType->blockSignals( true );
782  switch ( mLayer->gradientType() )
783  {
785  cboGradientType->setCurrentIndex( 0 );
786  break;
788  cboGradientType->setCurrentIndex( 1 );
789  break;
791  cboGradientType->setCurrentIndex( 2 );
792  break;
793  }
794  cboGradientType->blockSignals( false );
795 
796  cboCoordinateMode->blockSignals( true );
797  switch ( mLayer->coordinateMode() )
798  {
800  cboCoordinateMode->setCurrentIndex( 1 );
801  checkRefPoint1Centroid->setEnabled( false );
802  checkRefPoint2Centroid->setEnabled( false );
803  break;
805  default:
806  cboCoordinateMode->setCurrentIndex( 0 );
807  break;
808  }
809  cboCoordinateMode->blockSignals( false );
810 
811  cboGradientSpread->blockSignals( true );
812  switch ( mLayer->gradientSpread() )
813  {
815  cboGradientSpread->setCurrentIndex( 0 );
816  break;
818  cboGradientSpread->setCurrentIndex( 1 );
819  break;
821  cboGradientSpread->setCurrentIndex( 2 );
822  break;
823  }
824  cboGradientSpread->blockSignals( false );
825 
826  spinRefPoint1X->blockSignals( true );
827  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
828  spinRefPoint1X->blockSignals( false );
829  spinRefPoint1Y->blockSignals( true );
830  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
831  spinRefPoint1Y->blockSignals( false );
832  checkRefPoint1Centroid->blockSignals( true );
833  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
835  {
836  spinRefPoint1X->setEnabled( false );
837  spinRefPoint1Y->setEnabled( false );
838  }
839  checkRefPoint1Centroid->blockSignals( false );
840  spinRefPoint2X->blockSignals( true );
841  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
842  spinRefPoint2X->blockSignals( false );
843  spinRefPoint2Y->blockSignals( true );
844  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
845  spinRefPoint2Y->blockSignals( false );
846  checkRefPoint2Centroid->blockSignals( true );
847  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
849  {
850  spinRefPoint2X->setEnabled( false );
851  spinRefPoint2Y->setEnabled( false );
852  }
853  checkRefPoint2Centroid->blockSignals( false );
854 
855  spinOffsetX->blockSignals( true );
856  spinOffsetX->setValue( mLayer->offset().x() );
857  spinOffsetX->blockSignals( false );
858  spinOffsetY->blockSignals( true );
859  spinOffsetY->setValue( mLayer->offset().y() );
860  spinOffsetY->blockSignals( false );
861  mSpinAngle->blockSignals( true );
862  mSpinAngle->setValue( mLayer->angle() );
863  mSpinAngle->blockSignals( false );
864 
865  mOffsetUnitWidget->blockSignals( true );
866  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
867  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
868  mOffsetUnitWidget->blockSignals( false );
869 
878  registerDataDefinedButton( mRefPoint1CentroidDDBtn, "reference1_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
881  registerDataDefinedButton( mRefPoint2CentroidDDBtn, "reference2_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
882 }
883 
885 {
886  return mLayer;
887 }
888 
890 {
891  mLayer->setColor( color );
892  emit changed();
893 }
894 
896 {
897  mLayer->setColor2( color );
898  emit changed();
899 }
900 
902 {
903  if ( radioTwoColor->isChecked() )
904  {
906  }
907  else
908  {
910  }
911  emit changed();
912 }
913 
915 {
916  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
917  if ( ramp == NULL )
918  return;
919 
920  mLayer->setColorRamp( ramp );
921  emit changed();
922 }
923 
925 {
926  if ( mLayer->colorRamp()->type() == "gradient" )
927  {
929  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
930  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
931 
932  if ( dlg.exec() && gradRamp )
933  {
934  mLayer->setColorRamp( gradRamp );
935  cboGradientColorRamp->blockSignals( true );
936  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
937  cboGradientColorRamp->blockSignals( false );
938  emit changed();
939  }
940  else
941  {
942  delete ramp;
943  }
944  }
945 }
946 
948 {
949  switch ( index )
950  {
951  case 0:
953  //set sensible default reference points
954  spinRefPoint1X->setValue( 0.5 );
955  spinRefPoint1Y->setValue( 0 );
956  spinRefPoint2X->setValue( 0.5 );
957  spinRefPoint2Y->setValue( 1 );
958  break;
959  case 1:
961  //set sensible default reference points
962  spinRefPoint1X->setValue( 0 );
963  spinRefPoint1Y->setValue( 0 );
964  spinRefPoint2X->setValue( 1 );
965  spinRefPoint2Y->setValue( 1 );
966  break;
967  case 2:
969  spinRefPoint1X->setValue( 0.5 );
970  spinRefPoint1Y->setValue( 0.5 );
971  spinRefPoint2X->setValue( 1 );
972  spinRefPoint2Y->setValue( 1 );
973  break;
974  }
975  emit changed();
976 }
977 
979 {
980 
981  switch ( index )
982  {
983  case 0:
984  //feature coordinate mode
986  //allow choice of centroid reference positions
987  checkRefPoint1Centroid->setEnabled( true );
988  checkRefPoint2Centroid->setEnabled( true );
989  break;
990  case 1:
991  //viewport coordinate mode
993  //disable choice of centroid reference positions
994  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
995  checkRefPoint1Centroid->setEnabled( false );
996  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
997  checkRefPoint2Centroid->setEnabled( false );
998  break;
999  }
1000 
1001  emit changed();
1002 }
1003 
1005 {
1006  switch ( index )
1007  {
1008  case 0:
1010  break;
1011  case 1:
1013  break;
1014  case 2:
1016  break;
1017  }
1018 
1019  emit changed();
1020 }
1021 
1023 {
1024  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1025  emit changed();
1026 }
1027 
1029 {
1030  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1031  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1032  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1033  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1034  emit changed();
1035 }
1036 
1038 {
1039  mLayer->setAngle( value );
1040  emit changed();
1041 }
1042 
1044 {
1045  if ( mLayer )
1046  {
1047  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1048  mLayer->setOffsetUnit( unit );
1049  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1050  emit changed();
1051  }
1052 }
1053 
1055 
1057  : QgsSymbolLayerV2Widget( parent, vl )
1058 {
1059  mLayer = NULL;
1060 
1061  setupUi( this );
1062  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1063  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1064 
1065  btnChangeColor->setAllowAlpha( true );
1066  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1067  btnChangeColor->setContext( "symbology" );
1068  btnChangeColor->setShowNoColor( true );
1069  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1070  btnChangeColor2->setAllowAlpha( true );
1071  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1072  btnChangeColor2->setContext( "symbology" );
1073  btnChangeColor2->setShowNoColor( true );
1074  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1075 
1076  spinOffsetX->setClearValue( 0.0 );
1077  spinOffsetY->setClearValue( 0.0 );
1078 
1079  cboGradientColorRamp->setShowGradientOnly( true );
1080  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1081 
1082  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1083  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1084  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1085  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1086  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1087  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1088 
1089  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1090  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1091 }
1092 
1094 {
1095  if ( layer->layerType() != "ShapeburstFill" )
1096  return;
1097 
1098  // layer type is correct, we can do the cast
1099  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1100 
1101  // set values
1102  btnChangeColor->blockSignals( true );
1103  btnChangeColor->setColor( mLayer->color() );
1104  btnChangeColor->blockSignals( false );
1105  btnChangeColor2->blockSignals( true );
1106  btnChangeColor2->setColor( mLayer->color2() );
1107  btnChangeColor2->blockSignals( false );
1108 
1110  {
1111  radioTwoColor->setChecked( true );
1112  cboGradientColorRamp->setEnabled( false );
1113  }
1114  else
1115  {
1116  radioColorRamp->setChecked( true );
1117  btnChangeColor->setEnabled( false );
1118  btnChangeColor2->setEnabled( false );
1119  }
1120 
1121  mSpinBlurRadius->blockSignals( true );
1122  mBlurSlider->blockSignals( true );
1123  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1124  mBlurSlider->setValue( mLayer->blurRadius() );
1125  mSpinBlurRadius->blockSignals( false );
1126  mBlurSlider->blockSignals( false );
1127 
1128  mSpinMaxDistance->blockSignals( true );
1129  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1130  mSpinMaxDistance->blockSignals( false );
1131 
1132  mRadioUseWholeShape->blockSignals( true );
1133  mRadioUseMaxDistance->blockSignals( true );
1134  if ( mLayer->useWholeShape() )
1135  {
1136  mRadioUseWholeShape->setChecked( true );
1137  mSpinMaxDistance->setEnabled( false );
1138  mDistanceUnitWidget->setEnabled( false );
1139  }
1140  else
1141  {
1142  mRadioUseMaxDistance->setChecked( true );
1143  mSpinMaxDistance->setEnabled( true );
1144  mDistanceUnitWidget->setEnabled( true );
1145  }
1146  mRadioUseWholeShape->blockSignals( false );
1147  mRadioUseMaxDistance->blockSignals( false );
1148 
1149  mDistanceUnitWidget->blockSignals( true );
1150  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1151  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1152  mDistanceUnitWidget->blockSignals( false );
1153 
1154  mIgnoreRingsCheckBox->blockSignals( true );
1155  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1156  mIgnoreRingsCheckBox->blockSignals( false );
1157 
1158  // set source color ramp
1159  if ( mLayer->colorRamp() )
1160  {
1161  cboGradientColorRamp->blockSignals( true );
1162  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1163  cboGradientColorRamp->blockSignals( false );
1164  }
1165 
1166  spinOffsetX->blockSignals( true );
1167  spinOffsetX->setValue( mLayer->offset().x() );
1168  spinOffsetX->blockSignals( false );
1169  spinOffsetY->blockSignals( true );
1170  spinOffsetY->setValue( mLayer->offset().y() );
1171  spinOffsetY->blockSignals( false );
1172  mOffsetUnitWidget->blockSignals( true );
1173  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1174  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1175  mOffsetUnitWidget->blockSignals( false );
1176 
1179  registerDataDefinedButton( mBlurRadiusDDBtn, "blur_radius", QgsDataDefinedButton::Int, tr( "Integer between 0 and 18" ) );
1180  registerDataDefinedButton( mShadeWholeShapeDDBtn, "use_whole_shape", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1183 }
1184 
1186 {
1187  return mLayer;
1188 }
1189 
1191 {
1192  if ( mLayer )
1193  {
1194  mLayer->setColor( color );
1195  emit changed();
1196  }
1197 }
1198 
1200 {
1201  if ( mLayer )
1202  {
1203  mLayer->setColor2( color );
1204  emit changed();
1205  }
1206 }
1207 
1209 {
1210  if ( !mLayer )
1211  {
1212  return;
1213  }
1214 
1215  if ( radioTwoColor->isChecked() )
1216  {
1218  }
1219  else
1220  {
1222  }
1223  emit changed();
1224 }
1225 
1227 {
1228  if ( mLayer )
1229  {
1230  mLayer->setBlurRadius( value );
1231  emit changed();
1232  }
1233 }
1234 
1236 {
1237  if ( mLayer )
1238  {
1239  mLayer->setMaxDistance( value );
1240  emit changed();
1241  }
1242 }
1243 
1245 {
1246  if ( mLayer )
1247  {
1248  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
1249  mLayer->setDistanceUnit( unit );
1250  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1251  emit changed();
1252  }
1253 }
1254 
1256 {
1257  if ( mLayer )
1258  {
1259  mLayer->setUseWholeShape( value );
1260  mDistanceUnitWidget->setEnabled( !value );
1261  emit changed();
1262  }
1263 }
1264 
1266 {
1267  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1268  if ( ramp == NULL )
1269  return;
1270 
1271  mLayer->setColorRamp( ramp );
1272  emit changed();
1273 }
1274 
1276 {
1277  if ( mLayer->colorRamp()->type() == "gradient" )
1278  {
1280  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
1281  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
1282 
1283  if ( dlg.exec() && gradRamp )
1284  {
1285  mLayer->setColorRamp( gradRamp );
1286  cboGradientColorRamp->blockSignals( true );
1287  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1288  cboGradientColorRamp->blockSignals( false );
1289  emit changed();
1290  }
1291  else
1292  {
1293  delete ramp;
1294  }
1295  }
1296 }
1297 
1299 {
1300  if ( mLayer )
1301  {
1302  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1303  emit changed();
1304  }
1305 }
1306 
1308 {
1309  if ( mLayer )
1310  {
1311  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1312  mLayer->setOffsetUnit( unit );
1313  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1314  emit changed();
1315  }
1316 }
1317 
1318 
1320 {
1321  bool checked = ( state == Qt::Checked );
1322  mLayer->setIgnoreRings( checked );
1323  emit changed();
1324 }
1325 
1327 
1329  : QgsSymbolLayerV2Widget( parent, vl )
1330 {
1331  mLayer = NULL;
1332 
1333  setupUi( this );
1334  mIntervalUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1335  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1336  mOffsetAlongLineUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1337 
1338  spinOffset->setClearValue( 0.0 );
1339 
1340  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1341  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1342  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1343  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1344  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1345  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1346  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1347  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1348  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1349 }
1350 
1352 {
1353  if ( layer->layerType() != "MarkerLine" )
1354  return;
1355 
1356  // layer type is correct, we can do the cast
1357  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1358 
1359  // set values
1360  spinInterval->blockSignals( true );
1361  spinInterval->setValue( mLayer->interval() );
1362  spinInterval->blockSignals( false );
1363  mSpinOffsetAlongLine->blockSignals( true );
1364  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1365  mSpinOffsetAlongLine->blockSignals( false );
1366  chkRotateMarker->blockSignals( true );
1367  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1368  chkRotateMarker->blockSignals( false );
1369  spinOffset->blockSignals( true );
1370  spinOffset->setValue( mLayer->offset() );
1371  spinOffset->blockSignals( false );
1373  radInterval->setChecked( true );
1375  radVertex->setChecked( true );
1377  radVertexLast->setChecked( true );
1379  radCentralPoint->setChecked( true );
1380  else
1381  radVertexFirst->setChecked( true );
1382 
1383  // set units
1384  mIntervalUnitWidget->blockSignals( true );
1385  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1386  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1387  mIntervalUnitWidget->blockSignals( false );
1388  mOffsetUnitWidget->blockSignals( true );
1389  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1390  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1391  mOffsetUnitWidget->blockSignals( false );
1392  mOffsetAlongLineUnitWidget->blockSignals( true );
1393  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1394  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1395  mOffsetAlongLineUnitWidget->blockSignals( false );
1396 
1397  setPlacement(); // update gui
1398 
1401  registerDataDefinedButton( mPlacementDDBtn, "placement", QgsDataDefinedButton::String, "'vertex'|'lastvertex'|'firstvertex'|'centerpoint'" );
1402  registerDataDefinedButton( mOffsetAlongLineDDBtn, "offset_along_line", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
1403 }
1404 
1406 {
1407  return mLayer;
1408 }
1409 
1411 {
1412  mLayer->setInterval( val );
1413  emit changed();
1414 }
1415 
1417 {
1418  mLayer->setOffsetAlongLine( val );
1419  emit changed();
1420 }
1421 
1423 {
1424  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1425  emit changed();
1426 }
1427 
1429 {
1430  mLayer->setOffset( spinOffset->value() );
1431  emit changed();
1432 }
1433 
1435 {
1436  bool interval = radInterval->isChecked();
1437  spinInterval->setEnabled( interval );
1438  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1439  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1440  if ( radInterval->isChecked() )
1442  else if ( radVertex->isChecked() )
1444  else if ( radVertexLast->isChecked() )
1446  else if ( radVertexFirst->isChecked() )
1448  else
1450 
1451  emit changed();
1452 }
1453 
1455 {
1456  if ( mLayer )
1457  {
1458  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mIntervalUnitWidget->getUnit() );
1459  mLayer->setIntervalUnit( unit );
1460  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1461  emit changed();
1462  }
1463 }
1464 
1466 {
1467  if ( mLayer )
1468  {
1469  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1470  mLayer->setOffsetUnit( unit );
1471  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1472  emit changed();
1473  }
1474 }
1475 
1477 {
1478  if ( mLayer )
1479  {
1480  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetAlongLineUnitWidget->getUnit() );
1481  mLayer->setOffsetAlongLineUnit( unit );
1482  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1483  }
1484  emit changed();
1485 }
1486 
1488 
1489 
1491  : QgsSymbolLayerV2Widget( parent, vl )
1492 {
1493  mLayer = NULL;
1494 
1495  setupUi( this );
1496  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1497  mBorderWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1498  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1499  viewGroups->setHeaderHidden( true );
1500 
1501  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1502  mChangeColorButton->setContext( "symbology" );
1503  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1504  mChangeColorButton->setContext( "symbology" );
1505 
1506  spinOffsetX->setClearValue( 0.0 );
1507  spinOffsetY->setClearValue( 0.0 );
1508 
1509  populateList();
1510 
1511  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1512  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1513  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1514  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1515  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1516  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1517 }
1518 
1519 #include <QTime>
1520 #include <QAbstractListModel>
1521 #include <QPixmapCache>
1522 #include <QStyle>
1523 
1524 class QgsSvgListModel : public QAbstractListModel
1525 {
1526  public:
1527  QgsSvgListModel( QObject* parent ) : QAbstractListModel( parent )
1528  {
1530  }
1531 
1532  // Constructor to create model for icons in a specific path
1533  QgsSvgListModel( QObject* parent, QString path ) : QAbstractListModel( parent )
1534  {
1536  }
1537 
1538  int rowCount( const QModelIndex & parent = QModelIndex() ) const override
1539  {
1540  Q_UNUSED( parent );
1541  return mSvgFiles.count();
1542  }
1543 
1544  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override
1545  {
1546  QString entry = mSvgFiles.at( index.row() );
1547 
1548  if ( role == Qt::DecorationRole ) // icon
1549  {
1550  QPixmap pixmap;
1551  if ( !QPixmapCache::find( entry, pixmap ) )
1552  {
1553  // render SVG file
1554  QColor fill, outline;
1555  double outlineWidth;
1556  bool fillParam, outlineParam, outlineWidthParam;
1557  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1558 
1559  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1560  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1561  pixmap = QPixmap::fromImage( img );
1562  QPixmapCache::insert( entry, pixmap );
1563  }
1564 
1565  return pixmap;
1566  }
1567  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1568  {
1569  return entry;
1570  }
1571 
1572  return QVariant();
1573 }
1574 
1575 protected:
1576  QStringList mSvgFiles;
1577 };
1578 
1579 class QgsSvgGroupsModel : public QStandardItemModel
1580 {
1581 public:
1582  QgsSvgGroupsModel( QObject* parent ) : QStandardItemModel( parent )
1583  {
1584  QStringList svgPaths = QgsApplication::svgPaths();
1585  QStandardItem *parentItem = invisibleRootItem();
1586 
1587  for ( int i = 0; i < svgPaths.size(); i++ )
1588  {
1589  QDir dir( svgPaths[i] );
1590  QStandardItem *baseGroup;
1591 
1592  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1593  {
1594  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1595  }
1596  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1597  {
1598  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1599  }
1600  else
1601  {
1602  baseGroup = new QStandardItem( dir.dirName() );
1603  }
1604  baseGroup->setData( QVariant( svgPaths[i] ) );
1605  baseGroup->setEditable( false );
1606  baseGroup->setCheckable( false );
1607  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1608  baseGroup->setToolTip( dir.path() );
1609  parentItem->appendRow( baseGroup );
1610  createTree( baseGroup );
1611  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1612  }
1613  }
1614  private:
1615  void createTree( QStandardItem* &parentGroup )
1616  {
1617  QDir parentDir( parentGroup->data().toString() );
1618  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1619  {
1620  QStandardItem* group = new QStandardItem( item );
1621  group->setData( QVariant( parentDir.path() + "/" + item ) );
1622  group->setEditable( false );
1623  group->setCheckable( false );
1624  group->setToolTip( parentDir.path() + "/" + item );
1625  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1626  parentGroup->appendRow( group );
1627  createTree( group );
1628  }
1629  }
1630 };
1631 
1633 {
1634  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1635  viewGroups->setModel( g );
1636  // Set the tree expanded at the first level
1637  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1638  for ( int i = 0; i < rows; i++ )
1639  {
1640  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1641  }
1642 
1643  // Initally load the icons in the List view without any grouping
1644  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1645  viewImages->setModel( m );
1646 }
1647 
1649 {
1650  QString path = idx.data( Qt::UserRole + 1 ).toString();
1651 
1652  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1653  viewImages->setModel( m );
1654 
1655  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1656  emit changed();
1657 }
1658 
1660 {
1661  if ( !layer )
1662  {
1663  return;
1664  }
1665 
1666  //activate gui for svg parameters only if supported by the svg file
1667  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1668  QColor defaultFill, defaultOutline;
1669  double defaultOutlineWidth;
1670  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1671  mChangeColorButton->setEnabled( hasFillParam );
1672  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1673  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1674 
1675  if ( hasFillParam )
1676  {
1677  if ( layer->fillColor().isValid() )
1678  {
1679  mChangeColorButton->setColor( layer->fillColor() );
1680  }
1681  else
1682  {
1683  mChangeColorButton->setColor( defaultFill );
1684  }
1685  }
1686  if ( hasOutlineParam )
1687  {
1688  if ( layer->outlineColor().isValid() )
1689  {
1690  mChangeBorderColorButton->setColor( layer->outlineColor() );
1691  }
1692  else
1693  {
1694  mChangeBorderColorButton->setColor( defaultOutline );
1695  }
1696  }
1697 
1698  mFileLineEdit->blockSignals( true );
1699  mFileLineEdit->setText( layer->path() );
1700  mFileLineEdit->blockSignals( false );
1701 
1702  mBorderWidthSpinBox->blockSignals( true );
1703  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1704  mBorderWidthSpinBox->blockSignals( false );
1705 }
1706 
1707 
1709 {
1710  if ( !layer )
1711  {
1712  return;
1713  }
1714 
1715  if ( layer->layerType() != "SvgMarker" )
1716  return;
1717 
1718  // layer type is correct, we can do the cast
1719  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1720 
1721  // set values
1722 
1723  QAbstractItemModel* m = viewImages->model();
1724  QItemSelectionModel* selModel = viewImages->selectionModel();
1725  for ( int i = 0; i < m->rowCount(); i++ )
1726  {
1727  QModelIndex idx( m->index( i, 0 ) );
1728  if ( m->data( idx ).toString() == mLayer->path() )
1729  {
1730  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1731  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1732  setName( idx );
1733  break;
1734  }
1735  }
1736 
1737  spinSize->blockSignals( true );
1738  spinSize->setValue( mLayer->size() );
1739  spinSize->blockSignals( false );
1740  spinAngle->blockSignals( true );
1741  spinAngle->setValue( mLayer->angle() );
1742  spinAngle->blockSignals( false );
1743 
1744  // without blocking signals the value gets changed because of slot setOffset()
1745  spinOffsetX->blockSignals( true );
1746  spinOffsetX->setValue( mLayer->offset().x() );
1747  spinOffsetX->blockSignals( false );
1748  spinOffsetY->blockSignals( true );
1749  spinOffsetY->setValue( mLayer->offset().y() );
1750  spinOffsetY->blockSignals( false );
1751 
1752  mSizeUnitWidget->blockSignals( true );
1753  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1754  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1755  mSizeUnitWidget->blockSignals( false );
1756  mBorderWidthUnitWidget->blockSignals( true );
1757  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1758  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1759  mBorderWidthUnitWidget->blockSignals( false );
1760  mOffsetUnitWidget->blockSignals( true );
1761  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1762  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1763  mOffsetUnitWidget->blockSignals( false );
1764 
1765  //anchor points
1766  mHorizontalAnchorComboBox->blockSignals( true );
1767  mVerticalAnchorComboBox->blockSignals( true );
1768  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1769  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1770  mHorizontalAnchorComboBox->blockSignals( false );
1771  mVerticalAnchorComboBox->blockSignals( false );
1772 
1773  setGuiForSvg( mLayer );
1774 
1782  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
1783  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
1784 }
1785 
1787 {
1788  return mLayer;
1789 }
1790 
1791 void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
1792 {
1793  QString name = idx.data( Qt::UserRole ).toString();
1794  mLayer->setPath( name );
1795  mFileLineEdit->setText( name );
1796 
1797  setGuiForSvg( mLayer );
1798  emit changed();
1799 }
1800 
1802 {
1803  mLayer->setSize( spinSize->value() );
1804  emit changed();
1805 }
1806 
1808 {
1809  mLayer->setAngle( spinAngle->value() );
1810  emit changed();
1811 }
1812 
1814 {
1815  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1816  emit changed();
1817 }
1818 
1820 {
1821  QSettings s;
1822  QString file = QFileDialog::getOpenFileName( 0,
1823  tr( "Select SVG file" ),
1824  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1825  tr( "SVG files" ) + " (*.svg)" );
1826  QFileInfo fi( file );
1827  if ( file.isEmpty() || !fi.exists() )
1828  {
1829  return;
1830  }
1831  mFileLineEdit->setText( file );
1832  mLayer->setPath( file );
1833  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1834  emit changed();
1835 }
1836 
1838 {
1839  if ( !QFileInfo( text ).exists() )
1840  {
1841  return;
1842  }
1843  mLayer->setPath( text );
1844  setGuiForSvg( mLayer );
1845  emit changed();
1846 }
1847 
1849 {
1850  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1851  {
1852  QUrl url( mFileLineEdit->text() );
1853  if ( !url.isValid() )
1854  {
1855  return;
1856  }
1857  }
1858 
1859  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1860  mLayer->setPath( mFileLineEdit->text() );
1861  QApplication::restoreOverrideCursor();
1862 
1863  setGuiForSvg( mLayer );
1864  emit changed();
1865 }
1866 
1868 {
1869  if ( !mLayer )
1870  {
1871  return;
1872  }
1873 
1874  mLayer->setFillColor( color );
1875  emit changed();
1876 }
1877 
1879 {
1880  if ( !mLayer )
1881  {
1882  return;
1883  }
1884 
1885  mLayer->setOutlineColor( color );
1886  emit changed();
1887 }
1888 
1890 {
1891  if ( mLayer )
1892  {
1893  mLayer->setOutlineWidth( d );
1894  emit changed();
1895  }
1896 }
1897 
1899 {
1900  if ( mLayer )
1901  {
1902  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
1903  mLayer->setSizeUnit( unit );
1904  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1905  emit changed();
1906  }
1907 }
1908 
1910 {
1911  if ( mLayer )
1912  {
1913  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mBorderWidthUnitWidget->getUnit() );
1914  mLayer->setOutlineWidthUnit( unit );
1915  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1916  emit changed();
1917  }
1918 }
1919 
1921 {
1922  if ( mLayer )
1923  {
1924  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
1925  mLayer->setOffsetUnit( unit );
1926  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1927  emit changed();
1928  }
1929 }
1930 
1932 {
1933  if ( mLayer )
1934  {
1936  emit changed();
1937  }
1938 }
1939 
1941 {
1942  if ( mLayer )
1943  {
1945  emit changed();
1946  }
1947 }
1948 
1950 
1951 #include <QFileDialog>
1952 
1954 {
1955  mLayer = 0;
1956  setupUi( this );
1957  mTextureWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1958  mSvgOutlineWidthUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
1959  mSvgTreeView->setHeaderHidden( true );
1960  insertIcons();
1961 
1962  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1963  mChangeColorButton->setContext( "symbology" );
1964  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1965  mChangeBorderColorButton->setContext( "symbology" );
1966 
1967  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
1968  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1969 }
1970 
1972 {
1973  if ( !layer )
1974  {
1975  return;
1976  }
1977 
1978  if ( layer->layerType() != "SVGFill" )
1979  {
1980  return;
1981  }
1982 
1983  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
1984  if ( mLayer )
1985  {
1986  double width = mLayer->patternWidth();
1987  mTextureWidthSpinBox->blockSignals( true );
1988  mTextureWidthSpinBox->setValue( width );
1989  mTextureWidthSpinBox->blockSignals( false );
1990  mSVGLineEdit->setText( mLayer->svgFilePath() );
1991  mRotationSpinBox->blockSignals( true );
1992  mRotationSpinBox->setValue( mLayer->angle() );
1993  mRotationSpinBox->blockSignals( false );
1994  mTextureWidthUnitWidget->blockSignals( true );
1995  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
1996  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
1997  mTextureWidthUnitWidget->blockSignals( false );
1998  mSvgOutlineWidthUnitWidget->blockSignals( true );
1999  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2000  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2001  mSvgOutlineWidthUnitWidget->blockSignals( false );
2002  mChangeColorButton->blockSignals( true );
2003  mChangeColorButton->setColor( mLayer->svgFillColor() );
2004  mChangeColorButton->blockSignals( false );
2005  mChangeBorderColorButton->blockSignals( true );
2006  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2007  mChangeBorderColorButton->blockSignals( false );
2008  mBorderWidthSpinBox->blockSignals( true );
2009  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2010  mBorderWidthSpinBox->blockSignals( false );
2011  }
2012  updateParamGui( false );
2013 
2020 }
2021 
2023 {
2024  return mLayer;
2025 }
2026 
2027 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2028 {
2029  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2030  if ( !filePath.isNull() )
2031  {
2032  mSVGLineEdit->setText( filePath );
2033  emit changed();
2034  }
2035 }
2036 
2037 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2038 {
2039  if ( mLayer )
2040  {
2041  mLayer->setPatternWidth( d );
2042  emit changed();
2043  }
2044 }
2045 
2046 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2047 {
2048  if ( !mLayer )
2049  {
2050  return;
2051  }
2052 
2053  QFileInfo fi( text );
2054  if ( !fi.exists() )
2055  {
2056  return;
2057  }
2058  mLayer->setSvgFilePath( text );
2059  updateParamGui();
2060  emit changed();
2061 }
2062 
2063 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2064 {
2065  if ( !mLayer )
2066  {
2067  return;
2068  }
2069 
2070  QFileInfo fi( mSVGLineEdit->text() );
2071  if ( !fi.exists() )
2072  {
2073  QUrl url( mSVGLineEdit->text() );
2074  if ( !url.isValid() )
2075  {
2076  return;
2077  }
2078  }
2079 
2080  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2081  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2082  QApplication::restoreOverrideCursor();
2083 
2084  updateParamGui();
2085  emit changed();
2086 }
2087 
2088 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2089 {
2090  QString file = item.data( Qt::UserRole ).toString();
2091  mLayer->setSvgFilePath( file );
2092  mSVGLineEdit->setText( file );
2093 
2094  updateParamGui();
2095  emit changed();
2096 }
2097 
2099 {
2100  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2101  mSvgTreeView->setModel( g );
2102  // Set the tree expanded at the first level
2103  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2104  for ( int i = 0; i < rows; i++ )
2105  {
2106  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2107  }
2108 
2109  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2110  mSvgListView->setModel( m );
2111 }
2112 
2113 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2114 {
2115  QString path = idx.data( Qt::UserRole + 1 ).toString();
2116 
2117  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2118  mSvgListView->setModel( m );
2119 
2120  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2121  emit changed();
2122 }
2123 
2124 
2125 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2126 {
2127  if ( mLayer )
2128  {
2129  mLayer->setAngle( d );
2130  emit changed();
2131  }
2132 }
2133 
2135 {
2136  //activate gui for svg parameters only if supported by the svg file
2137  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2138  QColor defaultFill, defaultOutline;
2139  double defaultOutlineWidth;
2140  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2141  if ( hasFillParam && resetValues )
2142  {
2143  mChangeColorButton->setColor( defaultFill );
2144  }
2145  mChangeColorButton->setEnabled( hasFillParam );
2146  if ( hasOutlineParam && resetValues )
2147  {
2148  mChangeBorderColorButton->setColor( defaultOutline );
2149  }
2150  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2151  if ( hasOutlineWidthParam && resetValues )
2152  {
2153  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2154  }
2155  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2156 }
2157 
2158 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2159 {
2160  if ( !mLayer )
2161  {
2162  return;
2163  }
2164 
2165  mLayer->setSvgFillColor( color );
2166  emit changed();
2167 }
2168 
2169 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2170 {
2171  if ( !mLayer )
2172  {
2173  return;
2174  }
2175 
2176  mLayer->setSvgOutlineColor( color );
2177  emit changed();
2178 }
2179 
2180 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2181 {
2182  if ( mLayer )
2183  {
2184  mLayer->setSvgOutlineWidth( d );
2185  emit changed();
2186  }
2187 }
2188 
2189 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2190 {
2191  if ( mLayer )
2192  {
2193  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mTextureWidthUnitWidget->getUnit() );
2194  mLayer->setPatternWidthUnit( unit );
2195  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2196  emit changed();
2197  }
2198 }
2199 
2200 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2201 {
2202  if ( mLayer )
2203  {
2204  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSvgOutlineWidthUnitWidget->getUnit() );
2205  mLayer->setSvgOutlineWidthUnit( unit );
2206  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2207  emit changed();
2208  }
2209 }
2210 
2212 
2214  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2215 {
2216  setupUi( this );
2217  mDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2218  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2219 }
2220 
2222 {
2223  if ( layer->layerType() != "LinePatternFill" )
2224  {
2225  return;
2226  }
2227 
2228  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2229  if ( patternLayer )
2230  {
2231  mLayer = patternLayer;
2232  mAngleSpinBox->blockSignals( true );
2233  mAngleSpinBox->setValue( mLayer->lineAngle() );
2234  mAngleSpinBox->blockSignals( false );
2235  mDistanceSpinBox->blockSignals( true );
2236  mDistanceSpinBox->setValue( mLayer->distance() );
2237  mDistanceSpinBox->blockSignals( false );
2238  mOffsetSpinBox->blockSignals( true );
2239  mOffsetSpinBox->setValue( mLayer->offset() );
2240  mOffsetSpinBox->blockSignals( false );
2241 
2242  //units
2243  mDistanceUnitWidget->blockSignals( true );
2244  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2245  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2246  mDistanceUnitWidget->blockSignals( false );
2247  mOffsetUnitWidget->blockSignals( true );
2248  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2249  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2250  mOffsetUnitWidget->blockSignals( false );
2251  }
2252 
2255 }
2256 
2258 {
2259  return mLayer;
2260 }
2261 
2262 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2263 {
2264  if ( mLayer )
2265  {
2266  mLayer->setLineAngle( d );
2267  emit changed();
2268  }
2269 }
2270 
2271 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2272 {
2273  if ( mLayer )
2274  {
2275  mLayer->setDistance( d );
2276  emit changed();
2277  }
2278 }
2279 
2280 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2281 {
2282  if ( mLayer )
2283  {
2284  mLayer->setOffset( d );
2285  emit changed();
2286  }
2287 }
2288 
2289 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2290 {
2291  if ( mLayer )
2292  {
2293  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mDistanceUnitWidget->getUnit() );
2294  mLayer->setDistanceUnit( unit );
2295  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2296  emit changed();
2297  }
2298 }
2299 
2300 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2301 {
2302  if ( mLayer )
2303  {
2304  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2305  mLayer->setOffsetUnit( unit );
2306  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2307  emit changed();
2308  }
2309 }
2310 
2312 
2314  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2315 {
2316  setupUi( this );
2317  mHorizontalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2318  mVerticalDistanceUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2319  mHorizontalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2320  mVerticalDisplacementUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2321 }
2322 
2323 
2325 {
2326  if ( !layer || layer->layerType() != "PointPatternFill" )
2327  {
2328  return;
2329  }
2330 
2331  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2332  mHorizontalDistanceSpinBox->blockSignals( true );
2333  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2334  mHorizontalDistanceSpinBox->blockSignals( false );
2335  mVerticalDistanceSpinBox->blockSignals( true );
2336  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2337  mVerticalDistanceSpinBox->blockSignals( false );
2338  mHorizontalDisplacementSpinBox->blockSignals( true );
2339  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2340  mHorizontalDisplacementSpinBox->blockSignals( false );
2341  mVerticalDisplacementSpinBox->blockSignals( true );
2342  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2343  mVerticalDisplacementSpinBox->blockSignals( false );
2344 
2345  mHorizontalDistanceUnitWidget->blockSignals( true );
2346  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2347  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2348  mHorizontalDistanceUnitWidget->blockSignals( false );
2349  mVerticalDistanceUnitWidget->blockSignals( true );
2350  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2351  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2352  mVerticalDistanceUnitWidget->blockSignals( false );
2353  mHorizontalDisplacementUnitWidget->blockSignals( true );
2354  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2355  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2356  mHorizontalDisplacementUnitWidget->blockSignals( false );
2357  mVerticalDisplacementUnitWidget->blockSignals( true );
2358  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2359  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2360  mVerticalDisplacementUnitWidget->blockSignals( false );
2361 
2362  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2364  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2365  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2366 }
2367 
2369 {
2370  return mLayer;
2371 }
2372 
2373 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2374 {
2375  if ( mLayer )
2376  {
2377  mLayer->setDistanceX( d );
2378  emit changed();
2379  }
2380 }
2381 
2382 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2383 {
2384  if ( mLayer )
2385  {
2386  mLayer->setDistanceY( d );
2387  emit changed();
2388  }
2389 }
2390 
2391 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2392 {
2393  if ( mLayer )
2394  {
2395  mLayer->setDisplacementX( d );
2396  emit changed();
2397  }
2398 }
2399 
2400 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2401 {
2402  if ( mLayer )
2403  {
2404  mLayer->setDisplacementY( d );
2405  emit changed();
2406  }
2407 }
2408 
2409 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2410 {
2411  if ( mLayer )
2412  {
2413  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDistanceUnitWidget->getUnit() );
2414  mLayer->setDistanceXUnit( unit );
2415  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2416  emit changed();
2417  }
2418 }
2419 
2420 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2421 {
2422  if ( mLayer )
2423  {
2424  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDistanceUnitWidget->getUnit() );
2425  mLayer->setDistanceYUnit( unit );
2426  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2427  emit changed();
2428  }
2429 }
2430 
2431 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2432 {
2433  if ( mLayer )
2434  {
2435  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mHorizontalDisplacementUnitWidget->getUnit() );
2436  mLayer->setDisplacementXUnit( unit );
2437  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2438  emit changed();
2439  }
2440 }
2441 
2442 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2443 {
2444  if ( mLayer )
2445  {
2446  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mVerticalDisplacementUnitWidget->getUnit() );
2447  mLayer->setDisplacementYUnit( unit );
2448  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2449  emit changed();
2450  }
2451 }
2452 
2454 
2456  : QgsSymbolLayerV2Widget( parent, vl )
2457 {
2458  mLayer = NULL;
2459 
2460  setupUi( this );
2461  mSizeUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2462  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2464  scrollArea->setWidget( widgetChar );
2465 
2466  btnColor->setAllowAlpha( true );
2467  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2468  btnColor->setContext( "symbology" );
2469 
2470  spinOffsetX->setClearValue( 0.0 );
2471  spinOffsetY->setClearValue( 0.0 );
2472 
2473  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2474  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2475  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2476  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2477  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2478  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2479  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2480 }
2481 
2482 
2484 {
2485  if ( layer->layerType() != "FontMarker" )
2486  return;
2487 
2488  // layer type is correct, we can do the cast
2489  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2490 
2491  // set values
2492  cboFont->blockSignals( true );
2493  cboFont->setCurrentFont( QFont( mLayer->fontFamily() ) );
2494  cboFont->blockSignals( false );
2495  spinSize->blockSignals( true );
2496  spinSize->setValue( mLayer->size() );
2497  spinSize->blockSignals( false );
2498  btnColor->blockSignals( true );
2499  btnColor->setColor( mLayer->color() );
2500  btnColor->blockSignals( false );
2501  spinAngle->blockSignals( true );
2502  spinAngle->setValue( mLayer->angle() );
2503  spinAngle->blockSignals( false );
2504 
2505  //block
2506  spinOffsetX->blockSignals( true );
2507  spinOffsetX->setValue( mLayer->offset().x() );
2508  spinOffsetX->blockSignals( false );
2509  spinOffsetY->blockSignals( true );
2510  spinOffsetY->setValue( mLayer->offset().y() );
2511  spinOffsetY->blockSignals( false );
2512 
2513  mSizeUnitWidget->blockSignals( true );
2514  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2515  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2516  mSizeUnitWidget->blockSignals( false );
2517 
2518  mOffsetUnitWidget->blockSignals( true );
2519  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2520  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2521  mOffsetUnitWidget->blockSignals( false );
2522 
2523  //anchor points
2524  mHorizontalAnchorComboBox->blockSignals( true );
2525  mVerticalAnchorComboBox->blockSignals( true );
2526  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2527  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2528  mHorizontalAnchorComboBox->blockSignals( false );
2529  mVerticalAnchorComboBox->blockSignals( false );
2530 }
2531 
2533 {
2534  return mLayer;
2535 }
2536 
2538 {
2539  mLayer->setFontFamily( font.family() );
2540  widgetChar->updateFont( font );
2541  emit changed();
2542 }
2543 
2545 {
2546  mLayer->setColor( color );
2547  emit changed();
2548 }
2549 
2551 {
2552  mLayer->setSize( size );
2553  //widgetChar->updateSize(size);
2554  emit changed();
2555 }
2556 
2558 {
2559  mLayer->setAngle( angle );
2560  emit changed();
2561 }
2562 
2564 {
2565  mLayer->setCharacter( chr );
2566  emit changed();
2567 }
2568 
2570 {
2571  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2572  emit changed();
2573 }
2574 
2576 {
2577  if ( mLayer )
2578  {
2579  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mSizeUnitWidget->getUnit() );
2580  mLayer->setSizeUnit( unit );
2581  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2582  emit changed();
2583  }
2584 }
2585 
2587 {
2588  if ( mLayer )
2589  {
2590  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2591  mLayer->setOffsetUnit( unit );
2592  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2593  emit changed();
2594  }
2595 }
2596 
2598 {
2599  if ( mLayer )
2600  {
2602  emit changed();
2603  }
2604 }
2605 
2607 {
2608  if ( mLayer )
2609  {
2611  emit changed();
2612  }
2613 }
2614 
2615 
2617 
2618 
2620  : QgsSymbolLayerV2Widget( parent, vl )
2621 {
2622  mLayer = NULL;
2623 
2624  setupUi( this );
2625 }
2626 
2628 {
2629  if ( layer->layerType() != "CentroidFill" )
2630  return;
2631 
2632  // layer type is correct, we can do the cast
2633  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2634 
2635  // set values
2636  mDrawInsideCheckBox->blockSignals( true );
2637  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2638  mDrawInsideCheckBox->blockSignals( false );
2639 }
2640 
2642 {
2643  return mLayer;
2644 }
2645 
2647 {
2648  mLayer->setPointOnSurface( state == Qt::Checked );
2649  emit changed();
2650 }
2651 
2653 
2655  : QgsSymbolLayerV2Widget( parent, vl )
2656 {
2657  mLayer = 0;
2658  setupUi( this );
2659 
2660  mWidthUnitWidget->setUnits( QStringList() << tr( "Pixels" ) << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2661  mOffsetUnitWidget->setUnits( QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), 1 );
2662 
2663  mSpinOffsetX->setClearValue( 0.0 );
2664  mSpinOffsetY->setClearValue( 0.0 );
2665 
2666  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2667  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2668  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2669 }
2670 
2672 {
2673  if ( !layer )
2674  {
2675  return;
2676  }
2677 
2678  if ( layer->layerType() != "RasterFill" )
2679  {
2680  return;
2681  }
2682 
2683  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2684  if ( !mLayer )
2685  {
2686  return;
2687  }
2688 
2689  mImageLineEdit->blockSignals( true );
2690  mImageLineEdit->setText( mLayer->imageFilePath() );
2691  mImageLineEdit->blockSignals( false );
2692 
2693  cboCoordinateMode->blockSignals( true );
2694  switch ( mLayer->coordinateMode() )
2695  {
2697  cboCoordinateMode->setCurrentIndex( 1 );
2698  break;
2700  default:
2701  cboCoordinateMode->setCurrentIndex( 0 );
2702  break;
2703  }
2704  cboCoordinateMode->blockSignals( false );
2705  mSpinTransparency->blockSignals( true );
2706  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2707  mSpinTransparency->blockSignals( false );
2708  mSliderTransparency->blockSignals( true );
2709  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2710  mSliderTransparency->blockSignals( false );
2711  mRotationSpinBox->blockSignals( true );
2712  mRotationSpinBox->setValue( mLayer->angle() );
2713  mRotationSpinBox->blockSignals( false );
2714 
2715  mSpinOffsetX->blockSignals( true );
2716  mSpinOffsetX->setValue( mLayer->offset().x() );
2717  mSpinOffsetX->blockSignals( false );
2718  mSpinOffsetY->blockSignals( true );
2719  mSpinOffsetY->setValue( mLayer->offset().y() );
2720  mSpinOffsetY->blockSignals( false );
2721  mOffsetUnitWidget->blockSignals( true );
2722  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2723  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2724  mOffsetUnitWidget->blockSignals( false );
2725 
2726  mWidthSpinBox->blockSignals( true );
2727  mWidthSpinBox->setValue( mLayer->width() );
2728  mWidthSpinBox->blockSignals( false );
2729  mWidthUnitWidget->blockSignals( true );
2730  switch ( mLayer->widthUnit() )
2731  {
2732  case QgsSymbolV2::MM:
2733  mWidthUnitWidget->setUnit( 1 );
2734  break;
2735  case QgsSymbolV2::MapUnit:
2736  mWidthUnitWidget->setUnit( 2 );
2737  break;
2738  case QgsSymbolV2::Pixel:
2739  default:
2740  mWidthUnitWidget->setUnit( 0 );
2741  break;
2742  }
2743  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2744  mWidthUnitWidget->blockSignals( false );
2745  updatePreviewImage();
2746 
2751 }
2752 
2754 {
2755  return mLayer;
2756 }
2757 
2758 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2759 {
2760  QSettings s;
2761  QString openDir;
2762  QString lineEditText = mImageLineEdit->text();
2763  if ( !lineEditText.isEmpty() )
2764  {
2765  QFileInfo openDirFileInfo( lineEditText );
2766  openDir = openDirFileInfo.path();
2767  }
2768 
2769  if ( openDir.isEmpty() )
2770  {
2771  openDir = s.value( "/UI/lastRasterFillImageDir", "" ).toString();
2772  }
2773 
2774  //show file dialog
2775  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select image file" ), openDir );
2776  if ( !filePath.isNull() )
2777  {
2778  //check if file exists
2779  QFileInfo fileInfo( filePath );
2780  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2781  {
2782  QMessageBox::critical( 0, "Invalid file", "Error, file does not exist or is not readable" );
2783  return;
2784  }
2785 
2786  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2787  mImageLineEdit->setText( filePath );
2788  on_mImageLineEdit_editingFinished();
2789  }
2790 }
2791 
2792 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2793 {
2794  if ( !mLayer )
2795  {
2796  return;
2797  }
2798 
2799  QFileInfo fi( mImageLineEdit->text() );
2800  if ( !fi.exists() )
2801  {
2802  QUrl url( mImageLineEdit->text() );
2803  if ( !url.isValid() )
2804  {
2805  return;
2806  }
2807  }
2808 
2809  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2810  mLayer->setImageFilePath( mImageLineEdit->text() );
2811  updatePreviewImage();
2812  QApplication::restoreOverrideCursor();
2813 
2814  emit changed();
2815 }
2816 
2817 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2818 {
2819  switch ( index )
2820  {
2821  case 0:
2822  //feature coordinate mode
2824  break;
2825  case 1:
2826  //viewport coordinate mode
2828  break;
2829  }
2830 
2831  emit changed();
2832 }
2833 
2834 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2835 {
2836  if ( !mLayer )
2837  {
2838  return;
2839  }
2840 
2841  mLayer->setAlpha( value / 100.0 );
2842  emit changed();
2843  updatePreviewImage();
2844 }
2845 
2846 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2847 {
2848  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2849  emit changed();
2850 }
2851 
2852 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2853 {
2854  if ( !mLayer )
2855  {
2856  return;
2857  }
2858  QgsSymbolV2::OutputUnit unit = static_cast<QgsSymbolV2::OutputUnit>( mOffsetUnitWidget->getUnit() );
2859  mLayer->setOffsetUnit( unit );
2860  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2861  emit changed();
2862 }
2863 
2864 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2865 {
2866  if ( mLayer )
2867  {
2868  mLayer->setAngle( d );
2869  emit changed();
2870  }
2871 }
2872 
2873 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2874 {
2875  if ( !mLayer )
2876  {
2877  return;
2878  }
2880  switch ( mWidthUnitWidget->getUnit() )
2881  {
2882  case 0:
2883  unit = QgsSymbolV2::Pixel;
2884  break;
2885  case 2:
2886  unit = QgsSymbolV2::MapUnit;
2887  break;
2888  case 1:
2889  default:
2890  unit = QgsSymbolV2::MM;
2891  break;
2892  }
2893 
2894  mLayer->setWidthUnit( unit );
2895  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2896  emit changed();
2897 }
2898 
2899 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2900 {
2901  if ( !mLayer )
2902  {
2903  return;
2904  }
2905  mLayer->setWidth( d );
2906  emit changed();
2907 }
2908 
2909 
2910 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2911 {
2912  if ( !mLayer )
2913  {
2914  return;
2915  }
2916 
2917  QImage image( mLayer->imageFilePath() );
2918  if ( image.isNull() )
2919  {
2920  mLabelImagePreview->setPixmap( QPixmap() );
2921  return;
2922  }
2923 
2924  if ( image.height() > 150 || image.width() > 150 )
2925  {
2926  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
2927  }
2928 
2929  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
2930  previewImage.fill( Qt::transparent );
2931  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
2932  QPainter p;
2933  p.begin( &previewImage );
2934  //draw a checkerboard background
2935  uchar pixDataRGB[] = { 150, 150, 150, 150,
2936  100, 100, 100, 150,
2937  100, 100, 100, 150,
2938  150, 150, 150, 150
2939  };
2940  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
2941  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
2942  QBrush checkerBrush;
2943  checkerBrush.setTexture( pix );
2944  p.fillRect( imageRect, checkerBrush );
2945 
2946  if ( mLayer->alpha() < 1.0 )
2947  {
2948  p.setOpacity( mLayer->alpha() );
2949  }
2950 
2951  p.drawImage( imageRect.left(), imageRect.top(), image );
2952  p.end();
2953  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
2954 }
void setIntervalUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit customDashPatternUnit() const
void setBorderWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
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 void setSymbolLayer(QgsSymbolLayerV2 *layer) override
const QgsMapUnitScale & patternWidthMapUnitScale() const
QgsVectorColorRampV2 * colorRamp()
Returns the color ramp used for the shapeburst fill.
void setGuiForSvg(const QgsSvgMarkerSymbolLayerV2 *layer)
static QString gradientSpreadDesc()
static unsigned index
QgsSymbolV2::OutputUnit distanceYUnit() const
double outlineWidth
Definition: qgssvgcache.cpp:78
virtual QgsSymbolLayerV2 * symbolLayer() override
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)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
const QgsMapUnitScale & displacementXMapUnitScale() const
bool isActive()
Whether the current data definition or expression is to be used.
QgsSVGFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
virtual QgsSymbolLayerV2 * symbolLayer() override
const QgsMapUnitScale & offsetMapUnitScale() const
virtual QgsSymbolLayerV2 * symbolLayer() override
A container class for data source field mapping or expression.
virtual QString type() const =0
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
virtual QgsSymbolLayerV2 * symbolLayer() override
void setCoordinateMode(GradientCoordinateMode coordinateMode)
virtual double width() const
QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QgsGradientFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit distanceXUnit() const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
virtual QgsSymbolLayerV2 * symbolLayer() override
static QString doublePosDesc()
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
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
static QString colorNoAlphaDesc()
virtual QgsSymbolLayerV2 * symbolLayer() override
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & customDashPatternMapUnitScale() const
QgsLinePatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
QColor outline
Definition: qgssvgcache.cpp:82
void setOutlineColor(const QColor &c) override
Set outline color.
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
void setCustomDashPatternUnit(QgsSymbolV2::OutputUnit unit)
double svgOutlineWidth() const
void updateFont(const QFont &font)
[0]
QgsLinePatternFillSymbolLayer * mLayer
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)
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
virtual QgsSymbolLayerV2 * symbolLayer() override
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsFontMarkerSymbolLayerV2 * mLayer
void setColor2(QColor color2)
Sets the color for the endpoint of the shapeburst fill.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
QVector< qreal > customDashVector() const
const QgsMapUnitScale & intervalMapUnitScale() const
void setPenJoinStyle(Qt::PenJoinStyle style)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
static QString lineStyleDesc()
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
QgsSymbolV2::OutputUnit sizeUnit() const
QColor fillColor() const override
Get fill color.
void setBorderColor(QColor borderColor)
void init(const QgsVectorLayer *vl, const QgsDataDefined *datadefined=0, DataTypes datatypes=AnyType, QString description=QString(""))
Initialize a newly constructed data defined button (useful if button already included from form layou...
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
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
static QString horizontalAnchorDesc()
QgsFontMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void setMapUnitScale(const QgsMapUnitScale &scale) override
static const QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
virtual void removeDataDefinedProperty(const QString &property)
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.
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.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
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.
QgsSymbolV2::OutputUnit offsetUnit() const
QgsSymbolLayerV2 * clone() const override
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)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual QgsSymbolLayerV2 * symbolLayer() override
static QString penJoinStyleDesc()
virtual QgsSymbolLayerV2 * symbolLayer() override
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)
static QString double180RotDesc()
const QgsMapUnitScale & offsetMapUnitScale() const
static QString gradientTypeDesc()
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void registerDataDefinedButton(QgsDataDefinedButton *button, const QString &propertyName, QgsDataDefinedButton::DataType type, const QString &description)
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)
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) override
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
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)
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsSimpleFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
QgsSymbolV2::ScaleMethod scaleMethod() const
A button for defining data source field mappings or expressions.
QgsSymbolV2::OutputUnit offsetUnit() const
const QgsMapUnitScale & displacementYMapUnitScale() const
virtual QgsSymbolLayerV2 * symbolLayer() override
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
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setOffset(QPointF offset)
Offset for gradient fill.
virtual QString layerType() const =0
void on_mFileLineEdit_textEdited(const QString &text)
virtual QgsSymbolLayerV2 * symbolLayer() override
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
Definition: qgis.h:410
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units used for the offset for the shapeburst fill.
QgsSimpleMarkerSymbolLayerV2 * mLayer
QString file
Definition: qgssvgcache.cpp:76
void setOffset(QPointF offset)
static QString gradientCoordModeDesc()
const QgsMapUnitScale & offsetMapUnitScale() const
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 setMapUnitScale(const QgsMapUnitScale &scale) override
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.
static QString verticalAnchorDesc()
Qt::PenJoinStyle penJoinStyle() const
QgsSvgMarkerSymbolLayerV2 * mLayer
QgsPointPatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=NULL)
static QString fillStyleDesc()
void setColorRamp(QgsVectorColorRampV2 *ramp)
Sets the color ramp used to draw the shapeburst fill.
void setOffset(const QPointF &offset)
Sets the offset for the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
virtual QgsSymbolLayerV2 * symbolLayer() override
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
void setAlpha(const double alpha)
Sets the opacity for the raster image used in the fill.
virtual void setColor(const QColor &color)
virtual QgsSymbolLayerV2 * symbolLayer()=0
GradientType gradientType() const
Type of gradient, eg linear or radial.
QgsSvgGroupsModel(QObject *parent)
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsShapeburstFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image's width.
QString currentDefinition() const
The current definition.
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)
static QString customDashDesc()
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...
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
QColor outlineColor() const override
Get outline color.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
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.
static QString double0to1Desc()
QgsSVGFillSymbolLayer * mLayer
QgsSymbolV2::OutputUnit offsetUnit() const
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenJoinStyle penJoinStyle() const
QgsSimpleFillSymbolLayerV2 * mLayer
static QString colorAlphaDesc()
void setFillColor(const QColor &c) override
Set fill color.
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)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
double alpha() const
The opacity for the raster image used in the fill.
virtual QgsSymbolLayerV2 * symbolLayer() override
virtual void setDataDefinedProperty(const QString &property, const QString &expressionString)
#define tr(sourceText)
void setBorderStyle(Qt::PenStyle borderStyle)