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