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 #include "qgsdatadefined.h"
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 
1938 {
1939  mLayer = 0;
1940  setupUi( this );
1941  mTextureWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1942  mSvgOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1943  mSvgTreeView->setHeaderHidden( true );
1944  insertIcons();
1945 
1946  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1947  mChangeColorButton->setContext( "symbology" );
1948  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1949  mChangeBorderColorButton->setContext( "symbology" );
1950 
1951  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
1952  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1953 }
1954 
1956 {
1957  if ( !layer )
1958  {
1959  return;
1960  }
1961 
1962  if ( layer->layerType() != "SVGFill" )
1963  {
1964  return;
1965  }
1966 
1967  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
1968  if ( mLayer )
1969  {
1970  double width = mLayer->patternWidth();
1971  mTextureWidthSpinBox->blockSignals( true );
1972  mTextureWidthSpinBox->setValue( width );
1973  mTextureWidthSpinBox->blockSignals( false );
1974  mSVGLineEdit->setText( mLayer->svgFilePath() );
1975  mRotationSpinBox->blockSignals( true );
1976  mRotationSpinBox->setValue( mLayer->angle() );
1977  mRotationSpinBox->blockSignals( false );
1978  mTextureWidthUnitWidget->blockSignals( true );
1979  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
1980  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
1981  mTextureWidthUnitWidget->blockSignals( false );
1982  mSvgOutlineWidthUnitWidget->blockSignals( true );
1983  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
1984  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
1985  mSvgOutlineWidthUnitWidget->blockSignals( false );
1986  mChangeColorButton->blockSignals( true );
1987  mChangeColorButton->setColor( mLayer->svgFillColor() );
1988  mChangeColorButton->blockSignals( false );
1989  mChangeBorderColorButton->blockSignals( true );
1990  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
1991  mChangeBorderColorButton->blockSignals( false );
1992  mBorderWidthSpinBox->blockSignals( true );
1993  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
1994  mBorderWidthSpinBox->blockSignals( false );
1995  }
1996  updateParamGui( false );
1997 
2004 }
2005 
2007 {
2008  return mLayer;
2009 }
2010 
2011 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2012 {
2013  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2014  if ( !filePath.isNull() )
2015  {
2016  mSVGLineEdit->setText( filePath );
2017  emit changed();
2018  }
2019 }
2020 
2021 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2022 {
2023  if ( mLayer )
2024  {
2025  mLayer->setPatternWidth( d );
2026  emit changed();
2027  }
2028 }
2029 
2030 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2031 {
2032  if ( !mLayer )
2033  {
2034  return;
2035  }
2036 
2037  QFileInfo fi( text );
2038  if ( !fi.exists() )
2039  {
2040  return;
2041  }
2042  mLayer->setSvgFilePath( text );
2043  updateParamGui();
2044  emit changed();
2045 }
2046 
2047 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2048 {
2049  if ( !mLayer )
2050  {
2051  return;
2052  }
2053 
2054  QFileInfo fi( mSVGLineEdit->text() );
2055  if ( !fi.exists() )
2056  {
2057  QUrl url( mSVGLineEdit->text() );
2058  if ( !url.isValid() )
2059  {
2060  return;
2061  }
2062  }
2063 
2064  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2065  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2066  QApplication::restoreOverrideCursor();
2067 
2068  updateParamGui();
2069  emit changed();
2070 }
2071 
2072 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2073 {
2074  QString file = item.data( Qt::UserRole ).toString();
2075  mLayer->setSvgFilePath( file );
2076  mSVGLineEdit->setText( file );
2077 
2078  updateParamGui();
2079  emit changed();
2080 }
2081 
2083 {
2084  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2085  mSvgTreeView->setModel( g );
2086  // Set the tree expanded at the first level
2087  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2088  for ( int i = 0; i < rows; i++ )
2089  {
2090  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2091  }
2092 
2093  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2094  mSvgListView->setModel( m );
2095 }
2096 
2097 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2098 {
2099  QString path = idx.data( Qt::UserRole + 1 ).toString();
2100 
2101  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2102  mSvgListView->setModel( m );
2103 
2104  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2105  emit changed();
2106 }
2107 
2108 
2109 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2110 {
2111  if ( mLayer )
2112  {
2113  mLayer->setAngle( d );
2114  emit changed();
2115  }
2116 }
2117 
2119 {
2120  //activate gui for svg parameters only if supported by the svg file
2121  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2122  QColor defaultFill, defaultOutline;
2123  double defaultOutlineWidth;
2124  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2125  if ( hasFillParam && resetValues )
2126  {
2127  mChangeColorButton->setColor( defaultFill );
2128  }
2129  mChangeColorButton->setEnabled( hasFillParam );
2130  if ( hasOutlineParam && resetValues )
2131  {
2132  mChangeBorderColorButton->setColor( defaultOutline );
2133  }
2134  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2135  if ( hasOutlineWidthParam && resetValues )
2136  {
2137  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2138  }
2139  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2140 }
2141 
2142 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2143 {
2144  if ( !mLayer )
2145  {
2146  return;
2147  }
2148 
2149  mLayer->setSvgFillColor( color );
2150  emit changed();
2151 }
2152 
2153 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2154 {
2155  if ( !mLayer )
2156  {
2157  return;
2158  }
2159 
2160  mLayer->setSvgOutlineColor( color );
2161  emit changed();
2162 }
2163 
2164 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2165 {
2166  if ( mLayer )
2167  {
2168  mLayer->setSvgOutlineWidth( d );
2169  emit changed();
2170  }
2171 }
2172 
2173 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2174 {
2175  if ( mLayer )
2176  {
2177  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2178  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2179  emit changed();
2180  }
2181 }
2182 
2183 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2184 {
2185  if ( mLayer )
2186  {
2187  mLayer->setSvgOutlineWidthUnit( mSvgOutlineWidthUnitWidget->unit() );
2188  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2189  emit changed();
2190  }
2191 }
2192 
2194 
2196  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2197 {
2198  setupUi( this );
2199  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2200  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2201 }
2202 
2204 {
2205  if ( layer->layerType() != "LinePatternFill" )
2206  {
2207  return;
2208  }
2209 
2210  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2211  if ( patternLayer )
2212  {
2213  mLayer = patternLayer;
2214  mAngleSpinBox->blockSignals( true );
2215  mAngleSpinBox->setValue( mLayer->lineAngle() );
2216  mAngleSpinBox->blockSignals( false );
2217  mDistanceSpinBox->blockSignals( true );
2218  mDistanceSpinBox->setValue( mLayer->distance() );
2219  mDistanceSpinBox->blockSignals( false );
2220  mOffsetSpinBox->blockSignals( true );
2221  mOffsetSpinBox->setValue( mLayer->offset() );
2222  mOffsetSpinBox->blockSignals( false );
2223 
2224  //units
2225  mDistanceUnitWidget->blockSignals( true );
2226  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2227  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2228  mDistanceUnitWidget->blockSignals( false );
2229  mOffsetUnitWidget->blockSignals( true );
2230  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2231  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2232  mOffsetUnitWidget->blockSignals( false );
2233  }
2234 
2237 }
2238 
2240 {
2241  return mLayer;
2242 }
2243 
2244 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2245 {
2246  if ( mLayer )
2247  {
2248  mLayer->setLineAngle( d );
2249  emit changed();
2250  }
2251 }
2252 
2253 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2254 {
2255  if ( mLayer )
2256  {
2257  mLayer->setDistance( d );
2258  emit changed();
2259  }
2260 }
2261 
2262 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2263 {
2264  if ( mLayer )
2265  {
2266  mLayer->setOffset( d );
2267  emit changed();
2268  }
2269 }
2270 
2271 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2272 {
2273  if ( mLayer )
2274  {
2275  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2276  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2277  emit changed();
2278  }
2279 }
2280 
2281 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2282 {
2283  if ( mLayer )
2284  {
2285  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2286  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2287  emit changed();
2288  }
2289 }
2290 
2292 
2294  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2295 {
2296  setupUi( this );
2297  mHorizontalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2298  mVerticalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2299  mHorizontalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2300  mVerticalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2301 }
2302 
2303 
2305 {
2306  if ( !layer || layer->layerType() != "PointPatternFill" )
2307  {
2308  return;
2309  }
2310 
2311  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2312  mHorizontalDistanceSpinBox->blockSignals( true );
2313  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2314  mHorizontalDistanceSpinBox->blockSignals( false );
2315  mVerticalDistanceSpinBox->blockSignals( true );
2316  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2317  mVerticalDistanceSpinBox->blockSignals( false );
2318  mHorizontalDisplacementSpinBox->blockSignals( true );
2319  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2320  mHorizontalDisplacementSpinBox->blockSignals( false );
2321  mVerticalDisplacementSpinBox->blockSignals( true );
2322  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2323  mVerticalDisplacementSpinBox->blockSignals( false );
2324 
2325  mHorizontalDistanceUnitWidget->blockSignals( true );
2326  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2327  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2328  mHorizontalDistanceUnitWidget->blockSignals( false );
2329  mVerticalDistanceUnitWidget->blockSignals( true );
2330  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2331  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2332  mVerticalDistanceUnitWidget->blockSignals( false );
2333  mHorizontalDisplacementUnitWidget->blockSignals( true );
2334  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2335  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2336  mHorizontalDisplacementUnitWidget->blockSignals( false );
2337  mVerticalDisplacementUnitWidget->blockSignals( true );
2338  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2339  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2340  mVerticalDisplacementUnitWidget->blockSignals( false );
2341 
2342  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2344  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2345  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2346 }
2347 
2349 {
2350  return mLayer;
2351 }
2352 
2353 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2354 {
2355  if ( mLayer )
2356  {
2357  mLayer->setDistanceX( d );
2358  emit changed();
2359  }
2360 }
2361 
2362 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2363 {
2364  if ( mLayer )
2365  {
2366  mLayer->setDistanceY( d );
2367  emit changed();
2368  }
2369 }
2370 
2371 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2372 {
2373  if ( mLayer )
2374  {
2375  mLayer->setDisplacementX( d );
2376  emit changed();
2377  }
2378 }
2379 
2380 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2381 {
2382  if ( mLayer )
2383  {
2384  mLayer->setDisplacementY( d );
2385  emit changed();
2386  }
2387 }
2388 
2389 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2390 {
2391  if ( mLayer )
2392  {
2393  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2394  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2395  emit changed();
2396  }
2397 }
2398 
2399 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2400 {
2401  if ( mLayer )
2402  {
2403  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2404  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2405  emit changed();
2406  }
2407 }
2408 
2409 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2410 {
2411  if ( mLayer )
2412  {
2413  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2414  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2415  emit changed();
2416  }
2417 }
2418 
2419 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2420 {
2421  if ( mLayer )
2422  {
2423  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2424  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2425  emit changed();
2426  }
2427 }
2428 
2430 
2432  : QgsSymbolLayerV2Widget( parent, vl )
2433 {
2434  mLayer = NULL;
2435 
2436  setupUi( this );
2437  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2438  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2440  scrollArea->setWidget( widgetChar );
2441 
2442  btnColor->setAllowAlpha( true );
2443  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2444  btnColor->setContext( "symbology" );
2445 
2446  spinOffsetX->setClearValue( 0.0 );
2447  spinOffsetY->setClearValue( 0.0 );
2448 
2449  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2450  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2451  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2452  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2453  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2454  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2455  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2456 }
2457 
2458 
2460 {
2461  if ( layer->layerType() != "FontMarker" )
2462  return;
2463 
2464  // layer type is correct, we can do the cast
2465  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2466 
2467  // set values
2468  cboFont->blockSignals( true );
2469  cboFont->setCurrentFont( QFont( mLayer->fontFamily() ) );
2470  cboFont->blockSignals( false );
2471  spinSize->blockSignals( true );
2472  spinSize->setValue( mLayer->size() );
2473  spinSize->blockSignals( false );
2474  btnColor->blockSignals( true );
2475  btnColor->setColor( mLayer->color() );
2476  btnColor->blockSignals( false );
2477  spinAngle->blockSignals( true );
2478  spinAngle->setValue( mLayer->angle() );
2479  spinAngle->blockSignals( false );
2480 
2481  //block
2482  spinOffsetX->blockSignals( true );
2483  spinOffsetX->setValue( mLayer->offset().x() );
2484  spinOffsetX->blockSignals( false );
2485  spinOffsetY->blockSignals( true );
2486  spinOffsetY->setValue( mLayer->offset().y() );
2487  spinOffsetY->blockSignals( false );
2488 
2489  mSizeUnitWidget->blockSignals( true );
2490  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2491  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2492  mSizeUnitWidget->blockSignals( false );
2493 
2494  mOffsetUnitWidget->blockSignals( true );
2495  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2496  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2497  mOffsetUnitWidget->blockSignals( false );
2498 
2499  //anchor points
2500  mHorizontalAnchorComboBox->blockSignals( true );
2501  mVerticalAnchorComboBox->blockSignals( true );
2502  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2503  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2504  mHorizontalAnchorComboBox->blockSignals( false );
2505  mVerticalAnchorComboBox->blockSignals( false );
2506 }
2507 
2509 {
2510  return mLayer;
2511 }
2512 
2514 {
2515  mLayer->setFontFamily( font.family() );
2516  widgetChar->updateFont( font );
2517  emit changed();
2518 }
2519 
2521 {
2522  mLayer->setColor( color );
2523  emit changed();
2524 }
2525 
2527 {
2528  mLayer->setSize( size );
2529  //widgetChar->updateSize(size);
2530  emit changed();
2531 }
2532 
2534 {
2535  mLayer->setAngle( angle );
2536  emit changed();
2537 }
2538 
2540 {
2541  mLayer->setCharacter( chr );
2542  emit changed();
2543 }
2544 
2546 {
2547  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2548  emit changed();
2549 }
2550 
2552 {
2553  if ( mLayer )
2554  {
2555  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2556  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2557  emit changed();
2558  }
2559 }
2560 
2562 {
2563  if ( mLayer )
2564  {
2565  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2566  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2567  emit changed();
2568  }
2569 }
2570 
2572 {
2573  if ( mLayer )
2574  {
2576  emit changed();
2577  }
2578 }
2579 
2581 {
2582  if ( mLayer )
2583  {
2585  emit changed();
2586  }
2587 }
2588 
2589 
2591 
2592 
2594  : QgsSymbolLayerV2Widget( parent, vl )
2595 {
2596  mLayer = NULL;
2597 
2598  setupUi( this );
2599 }
2600 
2602 {
2603  if ( layer->layerType() != "CentroidFill" )
2604  return;
2605 
2606  // layer type is correct, we can do the cast
2607  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2608 
2609  // set values
2610  mDrawInsideCheckBox->blockSignals( true );
2611  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2612  mDrawInsideCheckBox->blockSignals( false );
2613 }
2614 
2616 {
2617  return mLayer;
2618 }
2619 
2621 {
2622  mLayer->setPointOnSurface( state == Qt::Checked );
2623  emit changed();
2624 }
2625 
2627 
2629  : QgsSymbolLayerV2Widget( parent, vl )
2630 {
2631  mLayer = 0;
2632  setupUi( this );
2633 
2635  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2636 
2637  mSpinOffsetX->setClearValue( 0.0 );
2638  mSpinOffsetY->setClearValue( 0.0 );
2639 
2640  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2641  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2642  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2643 }
2644 
2646 {
2647  if ( !layer )
2648  {
2649  return;
2650  }
2651 
2652  if ( layer->layerType() != "RasterFill" )
2653  {
2654  return;
2655  }
2656 
2657  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2658  if ( !mLayer )
2659  {
2660  return;
2661  }
2662 
2663  mImageLineEdit->blockSignals( true );
2664  mImageLineEdit->setText( mLayer->imageFilePath() );
2665  mImageLineEdit->blockSignals( false );
2666 
2667  cboCoordinateMode->blockSignals( true );
2668  switch ( mLayer->coordinateMode() )
2669  {
2671  cboCoordinateMode->setCurrentIndex( 1 );
2672  break;
2674  default:
2675  cboCoordinateMode->setCurrentIndex( 0 );
2676  break;
2677  }
2678  cboCoordinateMode->blockSignals( false );
2679  mSpinTransparency->blockSignals( true );
2680  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2681  mSpinTransparency->blockSignals( false );
2682  mSliderTransparency->blockSignals( true );
2683  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2684  mSliderTransparency->blockSignals( false );
2685  mRotationSpinBox->blockSignals( true );
2686  mRotationSpinBox->setValue( mLayer->angle() );
2687  mRotationSpinBox->blockSignals( false );
2688 
2689  mSpinOffsetX->blockSignals( true );
2690  mSpinOffsetX->setValue( mLayer->offset().x() );
2691  mSpinOffsetX->blockSignals( false );
2692  mSpinOffsetY->blockSignals( true );
2693  mSpinOffsetY->setValue( mLayer->offset().y() );
2694  mSpinOffsetY->blockSignals( false );
2695  mOffsetUnitWidget->blockSignals( true );
2696  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2697  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2698  mOffsetUnitWidget->blockSignals( false );
2699 
2700  mWidthSpinBox->blockSignals( true );
2701  mWidthSpinBox->setValue( mLayer->width() );
2702  mWidthSpinBox->blockSignals( false );
2703  mWidthUnitWidget->blockSignals( true );
2704  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
2705  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2706  mWidthUnitWidget->blockSignals( false );
2707  updatePreviewImage();
2708 
2713 }
2714 
2716 {
2717  return mLayer;
2718 }
2719 
2720 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2721 {
2722  QSettings s;
2723  QString openDir;
2724  QString lineEditText = mImageLineEdit->text();
2725  if ( !lineEditText.isEmpty() )
2726  {
2727  QFileInfo openDirFileInfo( lineEditText );
2728  openDir = openDirFileInfo.path();
2729  }
2730 
2731  if ( openDir.isEmpty() )
2732  {
2733  openDir = s.value( "/UI/lastRasterFillImageDir", "" ).toString();
2734  }
2735 
2736  //show file dialog
2737  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select image file" ), openDir );
2738  if ( !filePath.isNull() )
2739  {
2740  //check if file exists
2741  QFileInfo fileInfo( filePath );
2742  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2743  {
2744  QMessageBox::critical( 0, "Invalid file", "Error, file does not exist or is not readable" );
2745  return;
2746  }
2747 
2748  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2749  mImageLineEdit->setText( filePath );
2750  on_mImageLineEdit_editingFinished();
2751  }
2752 }
2753 
2754 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2755 {
2756  if ( !mLayer )
2757  {
2758  return;
2759  }
2760 
2761  QFileInfo fi( mImageLineEdit->text() );
2762  if ( !fi.exists() )
2763  {
2764  QUrl url( mImageLineEdit->text() );
2765  if ( !url.isValid() )
2766  {
2767  return;
2768  }
2769  }
2770 
2771  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2772  mLayer->setImageFilePath( mImageLineEdit->text() );
2773  updatePreviewImage();
2774  QApplication::restoreOverrideCursor();
2775 
2776  emit changed();
2777 }
2778 
2779 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2780 {
2781  switch ( index )
2782  {
2783  case 0:
2784  //feature coordinate mode
2786  break;
2787  case 1:
2788  //viewport coordinate mode
2790  break;
2791  }
2792 
2793  emit changed();
2794 }
2795 
2796 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2797 {
2798  if ( !mLayer )
2799  {
2800  return;
2801  }
2802 
2803  mLayer->setAlpha( value / 100.0 );
2804  emit changed();
2805  updatePreviewImage();
2806 }
2807 
2808 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2809 {
2810  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2811  emit changed();
2812 }
2813 
2814 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2815 {
2816  if ( !mLayer )
2817  {
2818  return;
2819  }
2820  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2821  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2822  emit changed();
2823 }
2824 
2825 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2826 {
2827  if ( mLayer )
2828  {
2829  mLayer->setAngle( d );
2830  emit changed();
2831  }
2832 }
2833 
2834 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2835 {
2836  if ( !mLayer )
2837  {
2838  return;
2839  }
2840  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
2841  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2842  emit changed();
2843 }
2844 
2845 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2846 {
2847  if ( !mLayer )
2848  {
2849  return;
2850  }
2851  mLayer->setWidth( d );
2852  emit changed();
2853 }
2854 
2855 
2856 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2857 {
2858  if ( !mLayer )
2859  {
2860  return;
2861  }
2862 
2863  QImage image( mLayer->imageFilePath() );
2864  if ( image.isNull() )
2865  {
2866  mLabelImagePreview->setPixmap( QPixmap() );
2867  return;
2868  }
2869 
2870  if ( image.height() > 150 || image.width() > 150 )
2871  {
2872  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
2873  }
2874 
2875  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
2876  previewImage.fill( Qt::transparent );
2877  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
2878  QPainter p;
2879  p.begin( &previewImage );
2880  //draw a checkerboard background
2881  uchar pixDataRGB[] = { 150, 150, 150, 150,
2882  100, 100, 100, 150,
2883  100, 100, 100, 150,
2884  150, 150, 150, 150
2885  };
2886  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
2887  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
2888  QBrush checkerBrush;
2889  checkerBrush.setTexture( pix );
2890  p.fillRect( imageRect, checkerBrush );
2891 
2892  if ( mLayer->alpha() < 1.0 )
2893  {
2894  p.setOpacity( mLayer->alpha() );
2895  }
2896 
2897  p.drawImage( imageRect.left(), imageRect.top(), image );
2898  p.end();
2899  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
2900 }
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)