QGIS API Documentation  2.13.0-Master
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"
23 #include "qgssymbolslistwidget.h"
24 
25 #include "characterwidget.h"
26 #include "qgsdashspacedialog.h"
29 #include "qgssvgcache.h"
30 #include "qgssymbollayerv2utils.h"
31 #include "qgsvectorcolorrampv2.h"
33 #include "qgsdatadefined.h"
34 #include "qgsstylev2.h" //for symbol selector dialog
35 #include "qgsmapcanvas.h"
36 #include "qgsapplication.h"
37 
38 #include "qgslogger.h"
39 #include "qgssizescalewidget.h"
40 
41 #include <QAbstractButton>
42 #include <QColorDialog>
43 #include <QCursor>
44 #include <QDir>
45 #include <QFileDialog>
46 #include <QPainter>
47 #include <QSettings>
48 #include <QStandardItemModel>
49 #include <QSvgRenderer>
50 #include <QMessageBox>
51 
52 static QgsExpressionContext _getExpressionContext( const void* context )
53 {
54  const QgsSymbolLayerV2Widget* widget = ( const QgsSymbolLayerV2Widget* ) context;
55 
56  if ( widget->expressionContext() )
57  return QgsExpressionContext( *widget->expressionContext() );
58 
59  QgsExpressionContext expContext;
63 
64  if ( widget->mapCanvas() )
65  {
68  }
69  else
70  {
72  }
73 
74  const QgsVectorLayer* layer = widget->vectorLayer();
75  if ( layer )
76  expContext << QgsExpressionContextUtils::layerScope( layer );
77 
79  if ( const QgsSymbolLayerV2* symbolLayer = const_cast< QgsSymbolLayerV2Widget* >( widget )->symbolLayer() )
80  {
81  //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
82  //color, but that's not accessible here). 99% of the time these will be the same anyway
83  symbolScope->setVariable( QgsExpressionContext::EXPR_SYMBOL_COLOR, symbolLayer->color() );
84  }
85  expContext << symbolScope;
88 
89  //TODO - show actual value
90  expContext.setOriginalValueVariable( QVariant() );
93 
94  return expContext;
95 }
96 
98 {
99  mMapCanvas = canvas;
100  Q_FOREACH ( QgsUnitSelectionWidget* unitWidget, findChildren<QgsUnitSelectionWidget*>() )
101  {
102  unitWidget->setMapCanvas( mMapCanvas );
103  }
104  Q_FOREACH ( QgsDataDefinedButton* ddButton, findChildren<QgsDataDefinedButton*>() )
105  {
106  if ( ddButton->assistant() )
107  ddButton->assistant()->setMapCanvas( mMapCanvas );
108  }
109 }
110 
112 {
113  return mMapCanvas;
114 }
115 
117 {
118  const QgsDataDefined* dd = symbolLayer()->getDataDefinedProperty( propertyName );
119  button->init( mVectorLayer, dd, type, description );
120  button->setProperty( "propertyName", propertyName );
121  connect( button, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
122  connect( button, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
123 
125 }
126 
128 {
129  QgsDataDefinedButton* button = qobject_cast<QgsDataDefinedButton*>( sender() );
130  const QString propertyName( button->property( "propertyName" ).toString() );
131 
132  QgsDataDefined* dd = symbolLayer()->getDataDefinedProperty( propertyName );
133  if ( !dd )
134  {
135  dd = new QgsDataDefined();
136  symbolLayer()->setDataDefinedProperty( propertyName, dd );
137  }
138  button->updateDataDefined( dd );
139 
140  emit changed();
141 }
142 
144 {
145  QString label = entryName;
146  if ( entryName == "size" )
147  {
148  label = tr( "Size" );
149  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
150  if ( layer )
151  {
152  switch ( layer->scaleMethod() )
153  {
155  label += " (" + tr( "area" ) + ')';
156  break;
158  label += " (" + tr( "diameter" ) + ')';
159  break;
160  }
161  }
162  }
163  return label;
164 }
165 
167  : QgsSymbolLayerV2Widget( parent, vl )
168 {
169  mLayer = nullptr;
170 
171  setupUi( this );
172  mPenWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
174  mDashPatternUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
175 
176  btnChangeColor->setAllowAlpha( true );
177  btnChangeColor->setColorDialogTitle( tr( "Select line color" ) );
178  btnChangeColor->setContext( "symbology" );
179 
180  spinOffset->setClearValue( 0.0 );
181 
182  if ( vl && vl->geometryType() != QGis::Polygon )
183  {
184  //draw inside polygon checkbox only makes sense for polygon layers
185  mDrawInsideCheckBox->hide();
186  }
187 
188  //make a temporary symbol for the size assistant preview
189  mAssistantPreviewSymbol = new QgsLineSymbolV2();
190 
191  if ( mVectorLayer )
192  mPenWidthDDBtn->setAssistant( tr( "Width Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
193 
194 
195  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
196  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
197  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
198  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
199  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
200  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
201 
203 
204  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
205 }
206 
208 {
209  delete mAssistantPreviewSymbol;
210 }
211 
212 void QgsSimpleLineSymbolLayerV2Widget::updateAssistantSymbol()
213 {
214  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
215  {
216  mAssistantPreviewSymbol->deleteSymbolLayer( i );
217  }
218  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
219  QgsDataDefined* ddWidth = mLayer->getDataDefinedProperty( "width" );
220  if ( ddWidth )
221  mAssistantPreviewSymbol->setDataDefinedWidth( *ddWidth );
222 }
223 
224 
226 {
227  if ( !layer || layer->layerType() != "SimpleLine" )
228  return;
229 
230  // layer type is correct, we can do the cast
231  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
232 
233  // set units
234  mPenWidthUnitWidget->blockSignals( true );
235  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
236  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
237  mPenWidthUnitWidget->blockSignals( false );
238  mOffsetUnitWidget->blockSignals( true );
239  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
240  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
241  mOffsetUnitWidget->blockSignals( false );
242  mDashPatternUnitWidget->blockSignals( true );
243  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
244  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
245  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
246  mDashPatternUnitWidget->blockSignals( false );
247 
248  // set values
249  spinWidth->blockSignals( true );
250  spinWidth->setValue( mLayer->width() );
251  spinWidth->blockSignals( false );
252  btnChangeColor->blockSignals( true );
253  btnChangeColor->setColor( mLayer->color() );
254  btnChangeColor->blockSignals( false );
255  spinOffset->blockSignals( true );
256  spinOffset->setValue( mLayer->offset() );
257  spinOffset->blockSignals( false );
258  cboPenStyle->blockSignals( true );
259  cboJoinStyle->blockSignals( true );
260  cboCapStyle->blockSignals( true );
261  cboPenStyle->setPenStyle( mLayer->penStyle() );
262  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
263  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
264  cboPenStyle->blockSignals( false );
265  cboJoinStyle->blockSignals( false );
266  cboCapStyle->blockSignals( false );
267 
268  //use a custom dash pattern?
269  bool useCustomDashPattern = mLayer->useCustomDashPattern();
270  mChangePatternButton->setEnabled( useCustomDashPattern );
271  label_3->setEnabled( !useCustomDashPattern );
272  cboPenStyle->setEnabled( !useCustomDashPattern );
273  mCustomCheckBox->blockSignals( true );
274  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
275  mCustomCheckBox->blockSignals( false );
276 
277  //draw inside polygon?
278  bool drawInsidePolygon = mLayer->drawInsidePolygon();
279  mDrawInsideCheckBox->blockSignals( true );
280  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
281  mDrawInsideCheckBox->blockSignals( false );
282 
284 
292 
293  updateAssistantSymbol();
294 }
295 
297 {
298  return mLayer;
299 }
300 
302 {
303  mLayer->setWidth( spinWidth->value() );
305  emit changed();
306 }
307 
309 {
310  mLayer->setColor( color );
312  emit changed();
313 }
314 
316 {
317  mLayer->setPenStyle( cboPenStyle->penStyle() );
318  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
319  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
320  emit changed();
321 }
322 
324 {
325  mLayer->setOffset( spinOffset->value() );
327  emit changed();
328 }
329 
331 {
332  bool checked = ( state == Qt::Checked );
333  mChangePatternButton->setEnabled( checked );
334  label_3->setEnabled( !checked );
335  cboPenStyle->setEnabled( !checked );
336 
337  mLayer->setUseCustomDashPattern( checked );
338  emit changed();
339 }
340 
342 {
344  if ( d.exec() == QDialog::Accepted )
345  {
346  mLayer->setCustomDashVector( d.dashDotVector() );
348  emit changed();
349  }
350 }
351 
353 {
354  if ( mLayer )
355  {
356  mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
357  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
358  emit changed();
359  }
360 }
361 
363 {
364  if ( mLayer )
365  {
366  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
367  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
368  emit changed();
369  }
370 }
371 
373 {
374  if ( mLayer )
375  {
376  mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
377  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
378  emit changed();
379  }
380 }
381 
383 {
384  bool checked = ( state == Qt::Checked );
385  mLayer->setDrawInsidePolygon( checked );
386  emit changed();
387 }
388 
389 
391 {
392  if ( !mLayer )
393  {
394  return;
395  }
396  QgsSimpleLineSymbolLayerV2* layerCopy = mLayer->clone();
397  if ( !layerCopy )
398  {
399  return;
400  }
401  layerCopy->setUseCustomDashPattern( true );
402  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
403  mChangePatternButton->setIcon( buttonIcon );
404  delete layerCopy;
405 }
406 
407 
409 
410 
412  : QgsSymbolLayerV2Widget( parent, vl )
413 {
414  mLayer = nullptr;
415 
416  setupUi( this );
419  mOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
420 
421  btnChangeColorFill->setAllowAlpha( true );
422  btnChangeColorFill->setColorDialogTitle( tr( "Select fill color" ) );
423  btnChangeColorFill->setContext( "symbology" );
424  btnChangeColorFill->setShowNoColor( true );
425  btnChangeColorFill->setNoColorString( tr( "Transparent fill" ) );
426  btnChangeColorBorder->setAllowAlpha( true );
427  btnChangeColorBorder->setColorDialogTitle( tr( "Select border color" ) );
428  btnChangeColorBorder->setContext( "symbology" );
429  btnChangeColorBorder->setShowNoColor( true );
430  btnChangeColorBorder->setNoColorString( tr( "Transparent border" ) );
431 
432  spinOffsetX->setClearValue( 0.0 );
433  spinOffsetY->setClearValue( 0.0 );
434 
435  //make a temporary symbol for the size assistant preview
436  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
437 
438  if ( mVectorLayer )
439  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
440 
441  QSize size = lstNames->iconSize();
442  QStringList names;
443  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
444  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
445  double markerSize = DEFAULT_POINT_SIZE * 2;
446  for ( int i = 0; i < names.count(); ++i )
447  {
448  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
450  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
451  item->setData( Qt::UserRole, names[i] );
452  delete lyr;
453  }
454 
455  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
456  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
457  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
458  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
459  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
460  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
461  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
462  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
463 }
464 
466 {
467  delete mAssistantPreviewSymbol;
468 }
469 
471 {
472  if ( layer->layerType() != "SimpleMarker" )
473  return;
474 
475  // layer type is correct, we can do the cast
476  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
477 
478  // set values
479  QString name = mLayer->name();
480  for ( int i = 0; i < lstNames->count(); ++i )
481  {
482  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
483  {
484  lstNames->setCurrentRow( i );
485  break;
486  }
487  }
488  btnChangeColorBorder->blockSignals( true );
489  btnChangeColorBorder->setColor( mLayer->borderColor() );
490  btnChangeColorBorder->blockSignals( false );
491  btnChangeColorFill->blockSignals( true );
492  btnChangeColorFill->setColor( mLayer->color() );
493  btnChangeColorFill->blockSignals( false );
494  spinSize->blockSignals( true );
495  spinSize->setValue( mLayer->size() );
496  spinSize->blockSignals( false );
497  spinAngle->blockSignals( true );
498  spinAngle->setValue( mLayer->angle() );
499  spinAngle->blockSignals( false );
500  mOutlineStyleComboBox->blockSignals( true );
501  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
502  mOutlineStyleComboBox->blockSignals( false );
503  mOutlineWidthSpinBox->blockSignals( true );
504  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
505  mOutlineWidthSpinBox->blockSignals( false );
506 
507  // without blocking signals the value gets changed because of slot setOffset()
508  spinOffsetX->blockSignals( true );
509  spinOffsetX->setValue( mLayer->offset().x() );
510  spinOffsetX->blockSignals( false );
511  spinOffsetY->blockSignals( true );
512  spinOffsetY->setValue( mLayer->offset().y() );
513  spinOffsetY->blockSignals( false );
514 
515  mSizeUnitWidget->blockSignals( true );
516  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
517  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
518  mSizeUnitWidget->blockSignals( false );
519  mOffsetUnitWidget->blockSignals( true );
520  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
521  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
522  mOffsetUnitWidget->blockSignals( false );
523  mOutlineWidthUnitWidget->blockSignals( true );
524  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
525  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
526  mOutlineWidthUnitWidget->blockSignals( false );
527 
528  //anchor points
529  mHorizontalAnchorComboBox->blockSignals( true );
530  mVerticalAnchorComboBox->blockSignals( true );
531  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
532  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
533  mHorizontalAnchorComboBox->blockSignals( false );
534  mVerticalAnchorComboBox->blockSignals( false );
535 
536  registerDataDefinedButton( mNameDDBtn, "name", QgsDataDefinedButton::String, tr( "string " ) + QLatin1String( "[<b>square</b>|<b>rectangle</b>|<b>diamond</b>|"
537  "<b>pentagon</b>|<b>triangle</b>|<b>equilateral_triangle</b>|"
538  "<b>star</b>|<b>regular_star</b>|<b>arrow</b>|<b>filled_arrowhead</b>|"
539  "<b>circle</b>|<b>cross</b>|<b>x</b>|"
540  "<b>cross2</b>|<b>line</b>|<b>arrowhead</b>]" ) );
548  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
549  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
550 
551  updateAssistantSymbol();
552 }
553 
555 {
556  return mLayer;
557 }
558 
560 {
561  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
562  emit changed();
563 }
564 
566 {
567  mLayer->setBorderColor( color );
568  emit changed();
569 }
570 
572 {
573  mLayer->setColor( color );
574  emit changed();
575 }
576 
578 {
579  mLayer->setSize( spinSize->value() );
580  emit changed();
581 }
582 
584 {
585  mLayer->setAngle( spinAngle->value() );
586  emit changed();
587 }
588 
590 {
591  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
592  emit changed();
593 }
594 
596 {
597  Q_UNUSED( index );
598 
599  if ( mLayer )
600  {
601  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
602  emit changed();
603  }
604 }
605 
607 {
608  if ( mLayer )
609  {
610  mLayer->setOutlineWidth( d );
611  emit changed();
612  }
613 }
614 
616 {
617  if ( mLayer )
618  {
619  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
620  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
621  emit changed();
622  }
623 }
624 
626 {
627  if ( mLayer )
628  {
629  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
630  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
631  emit changed();
632  }
633 }
634 
636 {
637  if ( mLayer )
638  {
639  mLayer->setOutlineWidthUnit( mOutlineWidthUnitWidget->unit() );
640  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
641  emit changed();
642  }
643 }
644 
646 {
647  if ( mLayer )
648  {
650  emit changed();
651  }
652 }
653 
655 {
656  if ( mLayer )
657  {
659  emit changed();
660  }
661 }
662 
663 void QgsSimpleMarkerSymbolLayerV2Widget::updateAssistantSymbol()
664 {
665  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
666  {
667  mAssistantPreviewSymbol->deleteSymbolLayer( i );
668  }
669  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
670  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
671  if ( ddSize )
672  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
673 }
674 
675 
677 
679  : QgsSymbolLayerV2Widget( parent, vl )
680 {
681  mLayer = nullptr;
682 
683  setupUi( this );
684  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
686 
687  btnChangeColor->setAllowAlpha( true );
688  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
689  btnChangeColor->setContext( "symbology" );
690  btnChangeColor->setShowNoColor( true );
691  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
692  btnChangeBorderColor->setAllowAlpha( true );
693  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
694  btnChangeBorderColor->setContext( "symbology" );
695  btnChangeBorderColor->setShowNoColor( true );
696  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
697 
698  spinOffsetX->setClearValue( 0.0 );
699  spinOffsetY->setClearValue( 0.0 );
700 
701  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
702  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
703  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
704  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
705  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
706  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
707  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
708  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
709 }
710 
712 {
713  if ( layer->layerType() != "SimpleFill" )
714  return;
715 
716  // layer type is correct, we can do the cast
717  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
718 
719  // set values
720  btnChangeColor->blockSignals( true );
721  btnChangeColor->setColor( mLayer->color() );
722  btnChangeColor->blockSignals( false );
723  cboFillStyle->blockSignals( true );
724  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
725  cboFillStyle->blockSignals( false );
726  btnChangeBorderColor->blockSignals( true );
727  btnChangeBorderColor->setColor( mLayer->borderColor() );
728  btnChangeBorderColor->blockSignals( false );
729  cboBorderStyle->blockSignals( true );
730  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
731  cboBorderStyle->blockSignals( false );
732  spinBorderWidth->blockSignals( true );
733  spinBorderWidth->setValue( mLayer->borderWidth() );
734  spinBorderWidth->blockSignals( false );
735  cboJoinStyle->blockSignals( true );
736  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
737  cboJoinStyle->blockSignals( false );
738  spinOffsetX->blockSignals( true );
739  spinOffsetX->setValue( mLayer->offset().x() );
740  spinOffsetX->blockSignals( false );
741  spinOffsetY->blockSignals( true );
742  spinOffsetY->setValue( mLayer->offset().y() );
743  spinOffsetY->blockSignals( false );
744 
745  mBorderWidthUnitWidget->blockSignals( true );
746  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
747  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
748  mBorderWidthUnitWidget->blockSignals( false );
749  mOffsetUnitWidget->blockSignals( true );
750  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
751  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
752  mOffsetUnitWidget->blockSignals( false );
753 
760 
761 }
762 
764 {
765  return mLayer;
766 }
767 
769 {
770  mLayer->setColor( color );
771  emit changed();
772 }
773 
775 {
776  mLayer->setBorderColor( color );
777  emit changed();
778 }
779 
781 {
782  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
783  emit changed();
784 }
785 
787 {
788  mLayer->setBorderWidth( spinBorderWidth->value() );
789  emit changed();
790 }
791 
793 {
794  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
795  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
796  emit changed();
797 }
798 
800 {
801  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
802  emit changed();
803 }
804 
806 {
807  if ( mLayer )
808  {
809  mLayer->setBorderWidthUnit( mBorderWidthUnitWidget->unit() );
810  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
811  emit changed();
812  }
813 }
814 
816 {
817  if ( mLayer )
818  {
819  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
820  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
821  emit changed();
822  }
823 }
824 
826 
828  : QgsSymbolLayerV2Widget( parent, vl )
829 {
830  mLayer = nullptr;
831 
832  setupUi( this );
834 
835  cboGradientColorRamp->setShowGradientOnly( true );
836  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
837 
838  btnChangeColor->setAllowAlpha( true );
839  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
840  btnChangeColor->setContext( "symbology" );
841  btnChangeColor->setShowNoColor( true );
842  btnChangeColor->setNoColorString( tr( "Transparent" ) );
843  btnChangeColor2->setAllowAlpha( true );
844  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
845  btnChangeColor2->setContext( "symbology" );
846  btnChangeColor2->setShowNoColor( true );
847  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
848 
849  spinOffsetX->setClearValue( 0.0 );
850  spinOffsetY->setClearValue( 0.0 );
851 
852  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
853  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
854  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
855  connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
856  connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
857  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
858  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
859  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
860  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
861  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
862  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
863  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
864  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
865  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
866  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
867  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
868  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
869 }
870 
872 {
873  if ( layer->layerType() != "GradientFill" )
874  return;
875 
876  // layer type is correct, we can do the cast
877  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
878 
879  // set values
880  btnChangeColor->blockSignals( true );
881  btnChangeColor->setColor( mLayer->color() );
882  btnChangeColor->blockSignals( false );
883  btnChangeColor2->blockSignals( true );
884  btnChangeColor2->setColor( mLayer->color2() );
885  btnChangeColor2->blockSignals( false );
886 
888  {
889  radioTwoColor->setChecked( true );
890  cboGradientColorRamp->setEnabled( false );
891  }
892  else
893  {
894  radioColorRamp->setChecked( true );
895  btnChangeColor->setEnabled( false );
896  btnChangeColor2->setEnabled( false );
897  }
898 
899  // set source color ramp
900  if ( mLayer->colorRamp() )
901  {
902  cboGradientColorRamp->blockSignals( true );
903  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
904  cboGradientColorRamp->blockSignals( false );
905  }
906 
907  cboGradientType->blockSignals( true );
908  switch ( mLayer->gradientType() )
909  {
911  cboGradientType->setCurrentIndex( 0 );
912  break;
914  cboGradientType->setCurrentIndex( 1 );
915  break;
917  cboGradientType->setCurrentIndex( 2 );
918  break;
919  }
920  cboGradientType->blockSignals( false );
921 
922  cboCoordinateMode->blockSignals( true );
923  switch ( mLayer->coordinateMode() )
924  {
926  cboCoordinateMode->setCurrentIndex( 1 );
927  checkRefPoint1Centroid->setEnabled( false );
928  checkRefPoint2Centroid->setEnabled( false );
929  break;
931  default:
932  cboCoordinateMode->setCurrentIndex( 0 );
933  break;
934  }
935  cboCoordinateMode->blockSignals( false );
936 
937  cboGradientSpread->blockSignals( true );
938  switch ( mLayer->gradientSpread() )
939  {
941  cboGradientSpread->setCurrentIndex( 0 );
942  break;
944  cboGradientSpread->setCurrentIndex( 1 );
945  break;
947  cboGradientSpread->setCurrentIndex( 2 );
948  break;
949  }
950  cboGradientSpread->blockSignals( false );
951 
952  spinRefPoint1X->blockSignals( true );
953  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
954  spinRefPoint1X->blockSignals( false );
955  spinRefPoint1Y->blockSignals( true );
956  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
957  spinRefPoint1Y->blockSignals( false );
958  checkRefPoint1Centroid->blockSignals( true );
959  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
961  {
962  spinRefPoint1X->setEnabled( false );
963  spinRefPoint1Y->setEnabled( false );
964  }
965  checkRefPoint1Centroid->blockSignals( false );
966  spinRefPoint2X->blockSignals( true );
967  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
968  spinRefPoint2X->blockSignals( false );
969  spinRefPoint2Y->blockSignals( true );
970  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
971  spinRefPoint2Y->blockSignals( false );
972  checkRefPoint2Centroid->blockSignals( true );
973  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
975  {
976  spinRefPoint2X->setEnabled( false );
977  spinRefPoint2Y->setEnabled( false );
978  }
979  checkRefPoint2Centroid->blockSignals( false );
980 
981  spinOffsetX->blockSignals( true );
982  spinOffsetX->setValue( mLayer->offset().x() );
983  spinOffsetX->blockSignals( false );
984  spinOffsetY->blockSignals( true );
985  spinOffsetY->setValue( mLayer->offset().y() );
986  spinOffsetY->blockSignals( false );
987  mSpinAngle->blockSignals( true );
988  mSpinAngle->setValue( mLayer->angle() );
989  mSpinAngle->blockSignals( false );
990 
991  mOffsetUnitWidget->blockSignals( true );
992  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
993  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
994  mOffsetUnitWidget->blockSignals( false );
995 
1004  registerDataDefinedButton( mRefPoint1CentroidDDBtn, "reference1_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1007  registerDataDefinedButton( mRefPoint2CentroidDDBtn, "reference2_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1008 }
1009 
1011 {
1012  return mLayer;
1013 }
1014 
1016 {
1017  mLayer->setColor( color );
1018  emit changed();
1019 }
1020 
1022 {
1023  mLayer->setColor2( color );
1024  emit changed();
1025 }
1026 
1028 {
1029  if ( radioTwoColor->isChecked() )
1030  {
1032  }
1033  else
1034  {
1036  }
1037  emit changed();
1038 }
1039 
1041 {
1042  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1043  if ( !ramp )
1044  return;
1045 
1046  mLayer->setColorRamp( ramp );
1047  emit changed();
1048 }
1049 
1051 {
1052  switch ( index )
1053  {
1054  case 0:
1056  //set sensible default reference points
1057  spinRefPoint1X->setValue( 0.5 );
1058  spinRefPoint1Y->setValue( 0 );
1059  spinRefPoint2X->setValue( 0.5 );
1060  spinRefPoint2Y->setValue( 1 );
1061  break;
1062  case 1:
1064  //set sensible default reference points
1065  spinRefPoint1X->setValue( 0 );
1066  spinRefPoint1Y->setValue( 0 );
1067  spinRefPoint2X->setValue( 1 );
1068  spinRefPoint2Y->setValue( 1 );
1069  break;
1070  case 2:
1072  spinRefPoint1X->setValue( 0.5 );
1073  spinRefPoint1Y->setValue( 0.5 );
1074  spinRefPoint2X->setValue( 1 );
1075  spinRefPoint2Y->setValue( 1 );
1076  break;
1077  }
1078  emit changed();
1079 }
1080 
1082 {
1083 
1084  switch ( index )
1085  {
1086  case 0:
1087  //feature coordinate mode
1089  //allow choice of centroid reference positions
1090  checkRefPoint1Centroid->setEnabled( true );
1091  checkRefPoint2Centroid->setEnabled( true );
1092  break;
1093  case 1:
1094  //viewport coordinate mode
1096  //disable choice of centroid reference positions
1097  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1098  checkRefPoint1Centroid->setEnabled( false );
1099  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1100  checkRefPoint2Centroid->setEnabled( false );
1101  break;
1102  }
1103 
1104  emit changed();
1105 }
1106 
1108 {
1109  switch ( index )
1110  {
1111  case 0:
1113  break;
1114  case 1:
1116  break;
1117  case 2:
1119  break;
1120  }
1121 
1122  emit changed();
1123 }
1124 
1126 {
1127  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1128  emit changed();
1129 }
1130 
1132 {
1133  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1134  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1135  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1136  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1137  emit changed();
1138 }
1139 
1141 {
1142  mLayer->setAngle( value );
1143  emit changed();
1144 }
1145 
1147 {
1148  if ( mLayer )
1149  {
1150  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1151  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1152  emit changed();
1153  }
1154 }
1155 
1157 
1159  : QgsSymbolLayerV2Widget( parent, vl )
1160 {
1161  mLayer = nullptr;
1162 
1163  setupUi( this );
1164  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1165  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1166 
1167  btnChangeColor->setAllowAlpha( true );
1168  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1169  btnChangeColor->setContext( "symbology" );
1170  btnChangeColor->setShowNoColor( true );
1171  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1172  btnChangeColor2->setAllowAlpha( true );
1173  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1174  btnChangeColor2->setContext( "symbology" );
1175  btnChangeColor2->setShowNoColor( true );
1176  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1177 
1178  spinOffsetX->setClearValue( 0.0 );
1179  spinOffsetY->setClearValue( 0.0 );
1180 
1181  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1182 
1183  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1184  connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
1185  connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
1186 
1187  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1188  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1189  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1190  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1191  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1192 
1193  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1194  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1195 }
1196 
1198 {
1199  if ( layer->layerType() != "ShapeburstFill" )
1200  return;
1201 
1202  // layer type is correct, we can do the cast
1203  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1204 
1205  // set values
1206  btnChangeColor->blockSignals( true );
1207  btnChangeColor->setColor( mLayer->color() );
1208  btnChangeColor->blockSignals( false );
1209  btnChangeColor2->blockSignals( true );
1210  btnChangeColor2->setColor( mLayer->color2() );
1211  btnChangeColor2->blockSignals( false );
1212 
1214  {
1215  radioTwoColor->setChecked( true );
1216  cboGradientColorRamp->setEnabled( false );
1217  }
1218  else
1219  {
1220  radioColorRamp->setChecked( true );
1221  btnChangeColor->setEnabled( false );
1222  btnChangeColor2->setEnabled( false );
1223  }
1224 
1225  mSpinBlurRadius->blockSignals( true );
1226  mBlurSlider->blockSignals( true );
1227  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1228  mBlurSlider->setValue( mLayer->blurRadius() );
1229  mSpinBlurRadius->blockSignals( false );
1230  mBlurSlider->blockSignals( false );
1231 
1232  mSpinMaxDistance->blockSignals( true );
1233  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1234  mSpinMaxDistance->blockSignals( false );
1235 
1236  mRadioUseWholeShape->blockSignals( true );
1237  mRadioUseMaxDistance->blockSignals( true );
1238  if ( mLayer->useWholeShape() )
1239  {
1240  mRadioUseWholeShape->setChecked( true );
1241  mSpinMaxDistance->setEnabled( false );
1242  mDistanceUnitWidget->setEnabled( false );
1243  }
1244  else
1245  {
1246  mRadioUseMaxDistance->setChecked( true );
1247  mSpinMaxDistance->setEnabled( true );
1248  mDistanceUnitWidget->setEnabled( true );
1249  }
1250  mRadioUseWholeShape->blockSignals( false );
1251  mRadioUseMaxDistance->blockSignals( false );
1252 
1253  mDistanceUnitWidget->blockSignals( true );
1254  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1255  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1256  mDistanceUnitWidget->blockSignals( false );
1257 
1258  mIgnoreRingsCheckBox->blockSignals( true );
1259  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1260  mIgnoreRingsCheckBox->blockSignals( false );
1261 
1262  // set source color ramp
1263  if ( mLayer->colorRamp() )
1264  {
1265  cboGradientColorRamp->blockSignals( true );
1266  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1267  cboGradientColorRamp->blockSignals( false );
1268  }
1269 
1270  spinOffsetX->blockSignals( true );
1271  spinOffsetX->setValue( mLayer->offset().x() );
1272  spinOffsetX->blockSignals( false );
1273  spinOffsetY->blockSignals( true );
1274  spinOffsetY->setValue( mLayer->offset().y() );
1275  spinOffsetY->blockSignals( false );
1276  mOffsetUnitWidget->blockSignals( true );
1277  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1278  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1279  mOffsetUnitWidget->blockSignals( false );
1280 
1283  registerDataDefinedButton( mBlurRadiusDDBtn, "blur_radius", QgsDataDefinedButton::Int, tr( "Integer between 0 and 18" ) );
1284  registerDataDefinedButton( mShadeWholeShapeDDBtn, "use_whole_shape", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1287 }
1288 
1290 {
1291  return mLayer;
1292 }
1293 
1295 {
1296  if ( mLayer )
1297  {
1298  mLayer->setColor( color );
1299  emit changed();
1300  }
1301 }
1302 
1304 {
1305  if ( mLayer )
1306  {
1307  mLayer->setColor2( color );
1308  emit changed();
1309  }
1310 }
1311 
1313 {
1314  if ( !mLayer )
1315  {
1316  return;
1317  }
1318 
1319  if ( radioTwoColor->isChecked() )
1320  {
1322  }
1323  else
1324  {
1326  }
1327  emit changed();
1328 }
1329 
1331 {
1332  if ( mLayer )
1333  {
1334  mLayer->setBlurRadius( value );
1335  emit changed();
1336  }
1337 }
1338 
1340 {
1341  if ( mLayer )
1342  {
1343  mLayer->setMaxDistance( value );
1344  emit changed();
1345  }
1346 }
1347 
1349 {
1350  if ( mLayer )
1351  {
1352  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1353  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1354  emit changed();
1355  }
1356 }
1357 
1359 {
1360  if ( mLayer )
1361  {
1362  mLayer->setUseWholeShape( value );
1363  mDistanceUnitWidget->setEnabled( !value );
1364  emit changed();
1365  }
1366 }
1367 
1369 {
1370  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1371  if ( !ramp )
1372  return;
1373 
1374  mLayer->setColorRamp( ramp );
1375  emit changed();
1376 }
1377 
1379 {
1380  if ( mLayer )
1381  {
1382  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1383  emit changed();
1384  }
1385 }
1386 
1388 {
1389  if ( mLayer )
1390  {
1391  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1392  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1393  emit changed();
1394  }
1395 }
1396 
1397 
1399 {
1400  bool checked = ( state == Qt::Checked );
1401  mLayer->setIgnoreRings( checked );
1402  emit changed();
1403 }
1404 
1406 
1408  : QgsSymbolLayerV2Widget( parent, vl )
1409 {
1410  mLayer = nullptr;
1411 
1412  setupUi( this );
1413  mIntervalUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1414  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1415  mOffsetAlongLineUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1416 
1417  spinOffset->setClearValue( 0.0 );
1418 
1419  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1420  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1421  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1422  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1423  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1424  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1425  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1426  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1427  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1428  connect( radCurvePoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1429 }
1430 
1432 {
1433  if ( layer->layerType() != "MarkerLine" )
1434  return;
1435 
1436  // layer type is correct, we can do the cast
1437  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1438 
1439  // set values
1440  spinInterval->blockSignals( true );
1441  spinInterval->setValue( mLayer->interval() );
1442  spinInterval->blockSignals( false );
1443  mSpinOffsetAlongLine->blockSignals( true );
1444  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1445  mSpinOffsetAlongLine->blockSignals( false );
1446  chkRotateMarker->blockSignals( true );
1447  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1448  chkRotateMarker->blockSignals( false );
1449  spinOffset->blockSignals( true );
1450  spinOffset->setValue( mLayer->offset() );
1451  spinOffset->blockSignals( false );
1453  radInterval->setChecked( true );
1455  radVertex->setChecked( true );
1457  radVertexLast->setChecked( true );
1459  radCentralPoint->setChecked( true );
1461  radCurvePoint->setChecked( true );
1462  else
1463  radVertexFirst->setChecked( true );
1464 
1465  // set units
1466  mIntervalUnitWidget->blockSignals( true );
1467  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1468  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1469  mIntervalUnitWidget->blockSignals( false );
1470  mOffsetUnitWidget->blockSignals( true );
1471  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1472  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1473  mOffsetUnitWidget->blockSignals( false );
1474  mOffsetAlongLineUnitWidget->blockSignals( true );
1475  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1476  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1477  mOffsetAlongLineUnitWidget->blockSignals( false );
1478 
1479  setPlacement(); // update gui
1480 
1483  registerDataDefinedButton( mPlacementDDBtn, "placement", QgsDataDefinedButton::String, tr( "string " ) + QLatin1String( "[<b>vertex</b>|<b>lastvertex</b>|<b>firstvertex</b>|<b>centerpoint</b>]" ) );
1484  registerDataDefinedButton( mOffsetAlongLineDDBtn, "offset_along_line", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
1485 }
1486 
1488 {
1489  return mLayer;
1490 }
1491 
1493 {
1494  mLayer->setInterval( val );
1495  emit changed();
1496 }
1497 
1499 {
1500  mLayer->setOffsetAlongLine( val );
1501  emit changed();
1502 }
1503 
1505 {
1506  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1507  emit changed();
1508 }
1509 
1511 {
1512  mLayer->setOffset( spinOffset->value() );
1513  emit changed();
1514 }
1515 
1517 {
1518  bool interval = radInterval->isChecked();
1519  spinInterval->setEnabled( interval );
1520  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1521  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1522  if ( radInterval->isChecked() )
1524  else if ( radVertex->isChecked() )
1526  else if ( radVertexLast->isChecked() )
1528  else if ( radVertexFirst->isChecked() )
1530  else if ( radCurvePoint->isChecked() )
1532  else
1534 
1535  emit changed();
1536 }
1537 
1539 {
1540  if ( mLayer )
1541  {
1542  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1543  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1544  emit changed();
1545  }
1546 }
1547 
1549 {
1550  if ( mLayer )
1551  {
1552  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1553  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1554  emit changed();
1555  }
1556 }
1557 
1559 {
1560  if ( mLayer )
1561  {
1562  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1563  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1564  }
1565  emit changed();
1566 }
1567 
1569 
1570 
1572  : QgsSymbolLayerV2Widget( parent, vl )
1573 {
1574  mLayer = nullptr;
1575 
1576  setupUi( this );
1578  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1579  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1580  viewGroups->setHeaderHidden( true );
1581  mChangeColorButton->setAllowAlpha( true );
1582  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1583  mChangeColorButton->setContext( "symbology" );
1584  mChangeBorderColorButton->setAllowAlpha( true );
1585  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1586  mChangeBorderColorButton->setContext( "symbology" );
1587 
1588  spinOffsetX->setClearValue( 0.0 );
1589  spinOffsetY->setClearValue( 0.0 );
1590 
1591  populateList();
1592 
1593  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1594  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1595  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1596  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1597  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1598  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1599  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
1600 
1601  //make a temporary symbol for the size assistant preview
1602  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
1603  if ( mVectorLayer )
1604  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
1605 }
1606 
1608 {
1609  delete mAssistantPreviewSymbol;
1610 }
1611 
1612 #include <QTime>
1613 #include <QAbstractListModel>
1614 #include <QPixmapCache>
1615 #include <QStyle>
1616 
1617 
1619 {
1620  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1621  viewGroups->setModel( g );
1622  // Set the tree expanded at the first level
1623  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1624  for ( int i = 0; i < rows; i++ )
1625  {
1626  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1627  }
1628 
1629  // Initally load the icons in the List view without any grouping
1630  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1631  viewImages->setModel( m );
1632 }
1633 
1635 {
1636  QString path = idx.data( Qt::UserRole + 1 ).toString();
1637 
1638  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1639  viewImages->setModel( m );
1640 
1641  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1642  emit changed();
1643 }
1644 
1646 {
1647  if ( !layer )
1648  {
1649  return;
1650  }
1651 
1652  //activate gui for svg parameters only if supported by the svg file
1653  bool hasFillParam, hasFillOpacityParam, hasOutlineParam, hasOutlineWidthParam, hasOutlineOpacityParam;
1654  QColor defaultFill, defaultOutline;
1655  double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity;
1656  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity;
1657  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
1658  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
1659  hasOutlineParam, hasDefaultOutlineColor, defaultOutline,
1660  hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth,
1661  hasOutlineOpacityParam, hasDefaultOutlineOpacity, defaultOutlineOpacity );
1662  mChangeColorButton->setEnabled( hasFillParam );
1663  mChangeColorButton->setAllowAlpha( hasFillOpacityParam );
1664  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1665  mChangeBorderColorButton->setAllowAlpha( hasOutlineOpacityParam );
1666  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1667 
1668  if ( hasFillParam )
1669  {
1670  QColor fill = layer->fillColor();
1671  double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
1672  if ( hasDefaultFillColor )
1673  {
1674  fill = defaultFill;
1675  }
1676  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
1677  mChangeColorButton->setColor( fill );
1678  }
1679  if ( hasOutlineParam )
1680  {
1681  QColor outline = layer->outlineColor();
1682  double existingOpacity = hasOutlineOpacityParam ? outline.alphaF() : 1.0;
1683  if ( hasDefaultOutlineColor )
1684  {
1685  outline = defaultOutline;
1686  }
1687  outline.setAlphaF( hasDefaultOutlineOpacity ? defaultOutlineOpacity : existingOpacity );
1688  mChangeBorderColorButton->setColor( outline );
1689  }
1690 
1691  mFileLineEdit->blockSignals( true );
1692  mFileLineEdit->setText( layer->path() );
1693  mFileLineEdit->blockSignals( false );
1694 
1695  mBorderWidthSpinBox->blockSignals( true );
1696  mBorderWidthSpinBox->setValue( hasDefaultOutlineWidth ? defaultOutlineWidth : layer->outlineWidth() );
1697  mBorderWidthSpinBox->blockSignals( false );
1698 }
1699 
1700 void QgsSvgMarkerSymbolLayerV2Widget::updateAssistantSymbol()
1701 {
1702  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1703  {
1704  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1705  }
1706  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1707  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
1708  if ( ddSize )
1709  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
1710 }
1711 
1712 
1714 {
1715  if ( !layer )
1716  {
1717  return;
1718  }
1719 
1720  if ( layer->layerType() != "SvgMarker" )
1721  return;
1722 
1723  // layer type is correct, we can do the cast
1724  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1725 
1726  // set values
1727 
1728  QAbstractItemModel* m = viewImages->model();
1729  QItemSelectionModel* selModel = viewImages->selectionModel();
1730  for ( int i = 0; i < m->rowCount(); i++ )
1731  {
1732  QModelIndex idx( m->index( i, 0 ) );
1733  if ( m->data( idx ).toString() == mLayer->path() )
1734  {
1735  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1736  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1737  setName( idx );
1738  break;
1739  }
1740  }
1741 
1742  spinSize->blockSignals( true );
1743  spinSize->setValue( mLayer->size() );
1744  spinSize->blockSignals( false );
1745  spinAngle->blockSignals( true );
1746  spinAngle->setValue( mLayer->angle() );
1747  spinAngle->blockSignals( false );
1748 
1749  // without blocking signals the value gets changed because of slot setOffset()
1750  spinOffsetX->blockSignals( true );
1751  spinOffsetX->setValue( mLayer->offset().x() );
1752  spinOffsetX->blockSignals( false );
1753  spinOffsetY->blockSignals( true );
1754  spinOffsetY->setValue( mLayer->offset().y() );
1755  spinOffsetY->blockSignals( false );
1756 
1757  mSizeUnitWidget->blockSignals( true );
1758  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1759  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1760  mSizeUnitWidget->blockSignals( false );
1761  mBorderWidthUnitWidget->blockSignals( true );
1762  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1763  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1764  mBorderWidthUnitWidget->blockSignals( false );
1765  mOffsetUnitWidget->blockSignals( true );
1766  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1767  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1768  mOffsetUnitWidget->blockSignals( false );
1769 
1770  //anchor points
1771  mHorizontalAnchorComboBox->blockSignals( true );
1772  mVerticalAnchorComboBox->blockSignals( true );
1773  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1774  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1775  mHorizontalAnchorComboBox->blockSignals( false );
1776  mVerticalAnchorComboBox->blockSignals( false );
1777 
1778  setGuiForSvg( mLayer );
1779 
1787  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
1788  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
1789 
1790  updateAssistantSymbol();
1791 }
1792 
1794 {
1795  return mLayer;
1796 }
1797 
1799 {
1800  QString name = idx.data( Qt::UserRole ).toString();
1801  mLayer->setPath( name );
1802  mFileLineEdit->setText( name );
1803 
1804  setGuiForSvg( mLayer );
1805  emit changed();
1806 }
1807 
1809 {
1810  mLayer->setSize( spinSize->value() );
1811  emit changed();
1812 }
1813 
1815 {
1816  mLayer->setAngle( spinAngle->value() );
1817  emit changed();
1818 }
1819 
1821 {
1822  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1823  emit changed();
1824 }
1825 
1827 {
1828  QSettings s;
1829  QString file = QFileDialog::getOpenFileName( nullptr,
1830  tr( "Select SVG file" ),
1831  s.value( "/UI/lastSVGMarkerDir", QDir::homePath() ).toString(),
1832  tr( "SVG files" ) + " (*.svg)" );
1833  QFileInfo fi( file );
1834  if ( file.isEmpty() || !fi.exists() )
1835  {
1836  return;
1837  }
1838  mFileLineEdit->setText( file );
1839  mLayer->setPath( file );
1840  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1841  setGuiForSvg( mLayer );
1842  emit changed();
1843 }
1844 
1846 {
1847  if ( !QFileInfo( text ).exists() )
1848  {
1849  return;
1850  }
1851  mLayer->setPath( text );
1852  setGuiForSvg( mLayer );
1853  emit changed();
1854 }
1855 
1857 {
1858  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1859  {
1860  QUrl url( mFileLineEdit->text() );
1861  if ( !url.isValid() )
1862  {
1863  return;
1864  }
1865  }
1866 
1867  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1868  mLayer->setPath( mFileLineEdit->text() );
1870 
1871  setGuiForSvg( mLayer );
1872  emit changed();
1873 }
1874 
1876 {
1877  if ( !mLayer )
1878  {
1879  return;
1880  }
1881 
1882  mLayer->setFillColor( color );
1883  emit changed();
1884 }
1885 
1887 {
1888  if ( !mLayer )
1889  {
1890  return;
1891  }
1892 
1893  mLayer->setOutlineColor( color );
1894  emit changed();
1895 }
1896 
1898 {
1899  if ( mLayer )
1900  {
1901  mLayer->setOutlineWidth( d );
1902  emit changed();
1903  }
1904 }
1905 
1907 {
1908  if ( mLayer )
1909  {
1910  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1911  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1912  emit changed();
1913  }
1914 }
1915 
1917 {
1918  if ( mLayer )
1919  {
1920  mLayer->setOutlineWidthUnit( mBorderWidthUnitWidget->unit() );
1921  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1922  emit changed();
1923  }
1924 }
1925 
1927 {
1928  if ( mLayer )
1929  {
1930  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1931  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1932  emit changed();
1933  }
1934 }
1935 
1937 {
1938  if ( mLayer )
1939  {
1941  emit changed();
1942  }
1943 }
1944 
1946 {
1947  if ( mLayer )
1948  {
1950  emit changed();
1951  }
1952 }
1953 
1955 
1957 {
1958  mLayer = nullptr;
1959  setupUi( this );
1960  mTextureWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1961  mSvgOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1962  mSvgTreeView->setHeaderHidden( true );
1963  insertIcons();
1964 
1965  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1966  mChangeColorButton->setContext( "symbology" );
1967  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1968  mChangeBorderColorButton->setContext( "symbology" );
1969 
1970  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
1971  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1972 }
1973 
1975 {
1976  if ( !layer )
1977  {
1978  return;
1979  }
1980 
1981  if ( layer->layerType() != "SVGFill" )
1982  {
1983  return;
1984  }
1985 
1986  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
1987  if ( mLayer )
1988  {
1989  double width = mLayer->patternWidth();
1990  mTextureWidthSpinBox->blockSignals( true );
1991  mTextureWidthSpinBox->setValue( width );
1992  mTextureWidthSpinBox->blockSignals( false );
1993  mSVGLineEdit->setText( mLayer->svgFilePath() );
1994  mRotationSpinBox->blockSignals( true );
1995  mRotationSpinBox->setValue( mLayer->angle() );
1996  mRotationSpinBox->blockSignals( false );
1997  mTextureWidthUnitWidget->blockSignals( true );
1998  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
1999  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2000  mTextureWidthUnitWidget->blockSignals( false );
2001  mSvgOutlineWidthUnitWidget->blockSignals( true );
2002  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2003  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2004  mSvgOutlineWidthUnitWidget->blockSignals( false );
2005  mChangeColorButton->blockSignals( true );
2006  mChangeColorButton->setColor( mLayer->svgFillColor() );
2007  mChangeColorButton->blockSignals( false );
2008  mChangeBorderColorButton->blockSignals( true );
2009  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2010  mChangeBorderColorButton->blockSignals( false );
2011  mBorderWidthSpinBox->blockSignals( true );
2012  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2013  mBorderWidthSpinBox->blockSignals( false );
2014  }
2015  updateParamGui( false );
2016 
2023 }
2024 
2026 {
2027  return mLayer;
2028 }
2029 
2030 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2031 {
2032  QString filePath = QFileDialog::getOpenFileName( nullptr, tr( "Select SVG texture file" ), QDir::homePath(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2033  if ( !filePath.isNull() )
2034  {
2035  mSVGLineEdit->setText( filePath );
2036  emit changed();
2037  }
2038 }
2039 
2040 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2041 {
2042  if ( mLayer )
2043  {
2044  mLayer->setPatternWidth( d );
2045  emit changed();
2046  }
2047 }
2048 
2049 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2050 {
2051  if ( !mLayer )
2052  {
2053  return;
2054  }
2055 
2056  QFileInfo fi( text );
2057  if ( !fi.exists() )
2058  {
2059  return;
2060  }
2061  mLayer->setSvgFilePath( text );
2062  updateParamGui();
2063  emit changed();
2064 }
2065 
2066 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2067 {
2068  if ( !mLayer )
2069  {
2070  return;
2071  }
2072 
2073  QFileInfo fi( mSVGLineEdit->text() );
2074  if ( !fi.exists() )
2075  {
2076  QUrl url( mSVGLineEdit->text() );
2077  if ( !url.isValid() )
2078  {
2079  return;
2080  }
2081  }
2082 
2083  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2084  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2086 
2087  updateParamGui();
2088  emit changed();
2089 }
2090 
2091 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2092 {
2093  QString file = item.data( Qt::UserRole ).toString();
2094  mLayer->setSvgFilePath( file );
2095  mSVGLineEdit->setText( file );
2096 
2097  updateParamGui();
2098  emit changed();
2099 }
2100 
2102 {
2103  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2104  mSvgTreeView->setModel( g );
2105  // Set the tree expanded at the first level
2106  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2107  for ( int i = 0; i < rows; i++ )
2108  {
2109  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2110  }
2111 
2112  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2113  mSvgListView->setModel( m );
2114 }
2115 
2116 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2117 {
2118  QString path = idx.data( Qt::UserRole + 1 ).toString();
2119 
2120  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2121  mSvgListView->setModel( m );
2122 
2123  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2124  emit changed();
2125 }
2126 
2127 
2128 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2129 {
2130  if ( mLayer )
2131  {
2132  mLayer->setAngle( d );
2133  emit changed();
2134  }
2135 }
2136 
2138 {
2139  //activate gui for svg parameters only if supported by the svg file
2140  bool hasFillParam, hasFillOpacityParam, hasOutlineParam, hasOutlineWidthParam, hasOutlineOpacityParam;
2141  QColor defaultFill, defaultOutline;
2142  double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity;
2143  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity;
2144  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, hasDefaultFillColor, defaultFill,
2145  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2146  hasOutlineParam, hasDefaultOutlineColor, defaultOutline,
2147  hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth,
2148  hasOutlineOpacityParam, hasDefaultOutlineOpacity, defaultOutlineOpacity );
2149  if ( resetValues )
2150  {
2151  QColor fill = mChangeColorButton->color();
2152  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2153  if ( hasDefaultFillColor )
2154  {
2155  fill = defaultFill;
2156  }
2157  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2158  mChangeColorButton->setColor( fill );
2159  }
2160  mChangeColorButton->setEnabled( hasFillParam );
2161  mChangeColorButton->setAllowAlpha( hasFillOpacityParam );
2162  if ( resetValues )
2163  {
2164  QColor outline = mChangeBorderColorButton->color();
2165  double newOpacity = hasOutlineOpacityParam ? outline.alphaF() : 1.0;
2166  if ( hasDefaultOutlineColor )
2167  {
2168  outline = defaultOutline;
2169  }
2170  outline.setAlphaF( hasDefaultOutlineOpacity ? defaultOutlineOpacity : newOpacity );
2171  mChangeBorderColorButton->setColor( outline );
2172  }
2173  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2174  mChangeBorderColorButton->setAllowAlpha( hasOutlineOpacityParam );
2175  if ( hasDefaultOutlineWidth && resetValues )
2176  {
2177  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2178  }
2179  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2180 }
2181 
2182 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2183 {
2184  if ( !mLayer )
2185  {
2186  return;
2187  }
2188 
2189  mLayer->setSvgFillColor( color );
2190  emit changed();
2191 }
2192 
2193 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2194 {
2195  if ( !mLayer )
2196  {
2197  return;
2198  }
2199 
2200  mLayer->setSvgOutlineColor( color );
2201  emit changed();
2202 }
2203 
2204 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2205 {
2206  if ( mLayer )
2207  {
2208  mLayer->setSvgOutlineWidth( d );
2209  emit changed();
2210  }
2211 }
2212 
2213 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2214 {
2215  if ( mLayer )
2216  {
2217  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2218  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2219  emit changed();
2220  }
2221 }
2222 
2223 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2224 {
2225  if ( mLayer )
2226  {
2227  mLayer->setSvgOutlineWidthUnit( mSvgOutlineWidthUnitWidget->unit() );
2228  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2229  emit changed();
2230  }
2231 }
2232 
2234 
2236  QgsSymbolLayerV2Widget( parent, vl ), mLayer( nullptr )
2237 {
2238  setupUi( this );
2239  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2240  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2241  mOffsetSpinBox->setClearValue( 0 );
2242 }
2243 
2245 {
2246  if ( layer->layerType() != "LinePatternFill" )
2247  {
2248  return;
2249  }
2250 
2251  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2252  if ( patternLayer )
2253  {
2254  mLayer = patternLayer;
2255  mAngleSpinBox->blockSignals( true );
2256  mAngleSpinBox->setValue( mLayer->lineAngle() );
2257  mAngleSpinBox->blockSignals( false );
2258  mDistanceSpinBox->blockSignals( true );
2259  mDistanceSpinBox->setValue( mLayer->distance() );
2260  mDistanceSpinBox->blockSignals( false );
2261  mOffsetSpinBox->blockSignals( true );
2262  mOffsetSpinBox->setValue( mLayer->offset() );
2263  mOffsetSpinBox->blockSignals( false );
2264 
2265  //units
2266  mDistanceUnitWidget->blockSignals( true );
2267  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2268  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2269  mDistanceUnitWidget->blockSignals( false );
2270  mOffsetUnitWidget->blockSignals( true );
2271  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2272  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2273  mOffsetUnitWidget->blockSignals( false );
2274  }
2275 
2278 }
2279 
2281 {
2282  return mLayer;
2283 }
2284 
2285 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2286 {
2287  if ( mLayer )
2288  {
2289  mLayer->setLineAngle( d );
2290  emit changed();
2291  }
2292 }
2293 
2294 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2295 {
2296  if ( mLayer )
2297  {
2298  mLayer->setDistance( d );
2299  emit changed();
2300  }
2301 }
2302 
2303 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2304 {
2305  if ( mLayer )
2306  {
2307  mLayer->setOffset( d );
2308  emit changed();
2309  }
2310 }
2311 
2312 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2313 {
2314  if ( mLayer )
2315  {
2316  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2317  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2318  emit changed();
2319  }
2320 }
2321 
2322 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2323 {
2324  if ( mLayer )
2325  {
2326  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2327  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2328  emit changed();
2329  }
2330 }
2331 
2333 
2335  QgsSymbolLayerV2Widget( parent, vl ), mLayer( nullptr )
2336 {
2337  setupUi( this );
2338  mHorizontalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2339  mVerticalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2340  mHorizontalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2341  mVerticalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2342 }
2343 
2344 
2346 {
2347  if ( !layer || layer->layerType() != "PointPatternFill" )
2348  {
2349  return;
2350  }
2351 
2352  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2353  mHorizontalDistanceSpinBox->blockSignals( true );
2354  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2355  mHorizontalDistanceSpinBox->blockSignals( false );
2356  mVerticalDistanceSpinBox->blockSignals( true );
2357  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2358  mVerticalDistanceSpinBox->blockSignals( false );
2359  mHorizontalDisplacementSpinBox->blockSignals( true );
2360  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2361  mHorizontalDisplacementSpinBox->blockSignals( false );
2362  mVerticalDisplacementSpinBox->blockSignals( true );
2363  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2364  mVerticalDisplacementSpinBox->blockSignals( false );
2365 
2366  mHorizontalDistanceUnitWidget->blockSignals( true );
2367  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2368  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2369  mHorizontalDistanceUnitWidget->blockSignals( false );
2370  mVerticalDistanceUnitWidget->blockSignals( true );
2371  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2372  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2373  mVerticalDistanceUnitWidget->blockSignals( false );
2374  mHorizontalDisplacementUnitWidget->blockSignals( true );
2375  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2376  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2377  mHorizontalDisplacementUnitWidget->blockSignals( false );
2378  mVerticalDisplacementUnitWidget->blockSignals( true );
2379  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2380  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2381  mVerticalDisplacementUnitWidget->blockSignals( false );
2382 
2383  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2385  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2386  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2387 }
2388 
2390 {
2391  return mLayer;
2392 }
2393 
2394 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2395 {
2396  if ( mLayer )
2397  {
2398  mLayer->setDistanceX( d );
2399  emit changed();
2400  }
2401 }
2402 
2403 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2404 {
2405  if ( mLayer )
2406  {
2407  mLayer->setDistanceY( d );
2408  emit changed();
2409  }
2410 }
2411 
2412 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2413 {
2414  if ( mLayer )
2415  {
2416  mLayer->setDisplacementX( d );
2417  emit changed();
2418  }
2419 }
2420 
2421 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2422 {
2423  if ( mLayer )
2424  {
2425  mLayer->setDisplacementY( d );
2426  emit changed();
2427  }
2428 }
2429 
2430 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2431 {
2432  if ( mLayer )
2433  {
2434  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2435  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2436  emit changed();
2437  }
2438 }
2439 
2440 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2441 {
2442  if ( mLayer )
2443  {
2444  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2445  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2446  emit changed();
2447  }
2448 }
2449 
2450 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2451 {
2452  if ( mLayer )
2453  {
2454  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2455  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2456  emit changed();
2457  }
2458 }
2459 
2460 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2461 {
2462  if ( mLayer )
2463  {
2464  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2465  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2466  emit changed();
2467  }
2468 }
2469 
2471 
2473  : QgsSymbolLayerV2Widget( parent, vl )
2474 {
2475  mLayer = nullptr;
2476 
2477  setupUi( this );
2479  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2481  scrollArea->setWidget( widgetChar );
2482 
2483  btnColor->setAllowAlpha( true );
2484  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2485  btnColor->setContext( "symbology" );
2486 
2487  spinOffsetX->setClearValue( 0.0 );
2488  spinOffsetY->setClearValue( 0.0 );
2489 
2490  //make a temporary symbol for the size assistant preview
2491  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
2492 
2493  if ( mVectorLayer )
2494  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
2495 
2496  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2497  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2498  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2499  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2500  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2501  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2502  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2503  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
2504 }
2505 
2507 {
2508  delete mAssistantPreviewSymbol;
2509 }
2510 
2512 {
2513  if ( layer->layerType() != "FontMarker" )
2514  return;
2515 
2516  // layer type is correct, we can do the cast
2517  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2518 
2519  QFont layerFont( mLayer->fontFamily() );
2520  // set values
2521  cboFont->blockSignals( true );
2522  cboFont->setCurrentFont( layerFont );
2523  cboFont->blockSignals( false );
2524  spinSize->blockSignals( true );
2525  spinSize->setValue( mLayer->size() );
2526  spinSize->blockSignals( false );
2527  btnColor->blockSignals( true );
2528  btnColor->setColor( mLayer->color() );
2529  btnColor->blockSignals( false );
2530  spinAngle->blockSignals( true );
2531  spinAngle->setValue( mLayer->angle() );
2532  spinAngle->blockSignals( false );
2533 
2534  widgetChar->blockSignals( true );
2535  widgetChar->updateFont( layerFont );
2537  widgetChar->blockSignals( false );
2538 
2539  //block
2540  spinOffsetX->blockSignals( true );
2541  spinOffsetX->setValue( mLayer->offset().x() );
2542  spinOffsetX->blockSignals( false );
2543  spinOffsetY->blockSignals( true );
2544  spinOffsetY->setValue( mLayer->offset().y() );
2545  spinOffsetY->blockSignals( false );
2546 
2547  mSizeUnitWidget->blockSignals( true );
2548  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2549  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2550  mSizeUnitWidget->blockSignals( false );
2551 
2552  mOffsetUnitWidget->blockSignals( true );
2553  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2554  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2555  mOffsetUnitWidget->blockSignals( false );
2556 
2557  //anchor points
2558  mHorizontalAnchorComboBox->blockSignals( true );
2559  mVerticalAnchorComboBox->blockSignals( true );
2560  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2561  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2562  mHorizontalAnchorComboBox->blockSignals( false );
2563  mVerticalAnchorComboBox->blockSignals( false );
2564 
2569  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
2570  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
2572 
2573  updateAssistantSymbol();
2574 }
2575 
2577 {
2578  return mLayer;
2579 }
2580 
2582 {
2583  mLayer->setFontFamily( font.family() );
2584  widgetChar->updateFont( font );
2585  emit changed();
2586 }
2587 
2589 {
2590  mLayer->setColor( color );
2591  emit changed();
2592 }
2593 
2595 {
2596  mLayer->setSize( size );
2597  //widgetChar->updateSize(size);
2598  emit changed();
2599 }
2600 
2602 {
2603  mLayer->setAngle( angle );
2604  emit changed();
2605 }
2606 
2608 {
2609  mLayer->setCharacter( chr );
2610  emit changed();
2611 }
2612 
2614 {
2615  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2616  emit changed();
2617 }
2618 
2620 {
2621  if ( mLayer )
2622  {
2623  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2624  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2625  emit changed();
2626  }
2627 }
2628 
2630 {
2631  if ( mLayer )
2632  {
2633  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2634  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2635  emit changed();
2636  }
2637 }
2638 
2640 {
2641  if ( mLayer )
2642  {
2644  emit changed();
2645  }
2646 }
2647 
2649 {
2650  if ( mLayer )
2651  {
2653  emit changed();
2654  }
2655 }
2656 
2657 void QgsFontMarkerSymbolLayerV2Widget::updateAssistantSymbol()
2658 {
2659  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2660  {
2661  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2662  }
2663  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2664  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
2665  if ( ddSize )
2666  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
2667 }
2668 
2670 
2671 
2673  : QgsSymbolLayerV2Widget( parent, vl )
2674 {
2675  mLayer = nullptr;
2676 
2677  setupUi( this );
2678 }
2679 
2681 {
2682  if ( layer->layerType() != "CentroidFill" )
2683  return;
2684 
2685  // layer type is correct, we can do the cast
2686  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2687 
2688  // set values
2689  mDrawInsideCheckBox->blockSignals( true );
2690  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2691  mDrawInsideCheckBox->blockSignals( false );
2692 }
2693 
2695 {
2696  return mLayer;
2697 }
2698 
2699 void QgsCentroidFillSymbolLayerV2Widget::on_mDrawInsideCheckBox_stateChanged( int state )
2700 {
2701  mLayer->setPointOnSurface( state == Qt::Checked );
2702  emit changed();
2703 }
2704 
2706 
2708  : QgsSymbolLayerV2Widget( parent, vl )
2709 {
2710  mLayer = nullptr;
2711  setupUi( this );
2712 
2714  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2715 
2716  mSpinOffsetX->setClearValue( 0.0 );
2717  mSpinOffsetY->setClearValue( 0.0 );
2718 
2719  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2720  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2721  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2722 }
2723 
2725 {
2726  if ( !layer )
2727  {
2728  return;
2729  }
2730 
2731  if ( layer->layerType() != "RasterFill" )
2732  {
2733  return;
2734  }
2735 
2736  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2737  if ( !mLayer )
2738  {
2739  return;
2740  }
2741 
2742  mImageLineEdit->blockSignals( true );
2743  mImageLineEdit->setText( mLayer->imageFilePath() );
2744  mImageLineEdit->blockSignals( false );
2745 
2746  cboCoordinateMode->blockSignals( true );
2747  switch ( mLayer->coordinateMode() )
2748  {
2750  cboCoordinateMode->setCurrentIndex( 1 );
2751  break;
2753  default:
2754  cboCoordinateMode->setCurrentIndex( 0 );
2755  break;
2756  }
2757  cboCoordinateMode->blockSignals( false );
2758  mSpinTransparency->blockSignals( true );
2759  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2760  mSpinTransparency->blockSignals( false );
2761  mSliderTransparency->blockSignals( true );
2762  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2763  mSliderTransparency->blockSignals( false );
2764  mRotationSpinBox->blockSignals( true );
2765  mRotationSpinBox->setValue( mLayer->angle() );
2766  mRotationSpinBox->blockSignals( false );
2767 
2768  mSpinOffsetX->blockSignals( true );
2769  mSpinOffsetX->setValue( mLayer->offset().x() );
2770  mSpinOffsetX->blockSignals( false );
2771  mSpinOffsetY->blockSignals( true );
2772  mSpinOffsetY->setValue( mLayer->offset().y() );
2773  mSpinOffsetY->blockSignals( false );
2774  mOffsetUnitWidget->blockSignals( true );
2775  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2776  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2777  mOffsetUnitWidget->blockSignals( false );
2778 
2779  mWidthSpinBox->blockSignals( true );
2780  mWidthSpinBox->setValue( mLayer->width() );
2781  mWidthSpinBox->blockSignals( false );
2782  mWidthUnitWidget->blockSignals( true );
2783  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
2784  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2785  mWidthUnitWidget->blockSignals( false );
2786  updatePreviewImage();
2787 
2792 }
2793 
2795 {
2796  return mLayer;
2797 }
2798 
2799 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2800 {
2801  QSettings s;
2802  QString openDir;
2803  QString lineEditText = mImageLineEdit->text();
2804  if ( !lineEditText.isEmpty() )
2805  {
2806  QFileInfo openDirFileInfo( lineEditText );
2807  openDir = openDirFileInfo.path();
2808  }
2809 
2810  if ( openDir.isEmpty() )
2811  {
2812  openDir = s.value( "/UI/lastRasterFillImageDir", QDir::homePath() ).toString();
2813  }
2814 
2815  //show file dialog
2816  QString filePath = QFileDialog::getOpenFileName( nullptr, tr( "Select image file" ), openDir );
2817  if ( !filePath.isNull() )
2818  {
2819  //check if file exists
2820  QFileInfo fileInfo( filePath );
2821  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2822  {
2823  QMessageBox::critical( nullptr, "Invalid file", "Error, file does not exist or is not readable" );
2824  return;
2825  }
2826 
2827  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2828  mImageLineEdit->setText( filePath );
2829  on_mImageLineEdit_editingFinished();
2830  }
2831 }
2832 
2833 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2834 {
2835  if ( !mLayer )
2836  {
2837  return;
2838  }
2839 
2840  QFileInfo fi( mImageLineEdit->text() );
2841  if ( !fi.exists() )
2842  {
2843  QUrl url( mImageLineEdit->text() );
2844  if ( !url.isValid() )
2845  {
2846  return;
2847  }
2848  }
2849 
2850  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2851  mLayer->setImageFilePath( mImageLineEdit->text() );
2852  updatePreviewImage();
2854 
2855  emit changed();
2856 }
2857 
2858 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2859 {
2860  switch ( index )
2861  {
2862  case 0:
2863  //feature coordinate mode
2865  break;
2866  case 1:
2867  //viewport coordinate mode
2869  break;
2870  }
2871 
2872  emit changed();
2873 }
2874 
2875 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2876 {
2877  if ( !mLayer )
2878  {
2879  return;
2880  }
2881 
2882  mLayer->setAlpha( value / 100.0 );
2883  emit changed();
2884  updatePreviewImage();
2885 }
2886 
2887 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2888 {
2889  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2890  emit changed();
2891 }
2892 
2893 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2894 {
2895  if ( !mLayer )
2896  {
2897  return;
2898  }
2899  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2900  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2901  emit changed();
2902 }
2903 
2904 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2905 {
2906  if ( mLayer )
2907  {
2908  mLayer->setAngle( d );
2909  emit changed();
2910  }
2911 }
2912 
2913 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2914 {
2915  if ( !mLayer )
2916  {
2917  return;
2918  }
2919  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
2920  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2921  emit changed();
2922 }
2923 
2924 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2925 {
2926  if ( !mLayer )
2927  {
2928  return;
2929  }
2930  mLayer->setWidth( d );
2931  emit changed();
2932 }
2933 
2934 
2935 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2936 {
2937  if ( !mLayer )
2938  {
2939  return;
2940  }
2941 
2942  QImage image( mLayer->imageFilePath() );
2943  if ( image.isNull() )
2944  {
2945  mLabelImagePreview->setPixmap( QPixmap() );
2946  return;
2947  }
2948 
2949  if ( image.height() > 150 || image.width() > 150 )
2950  {
2951  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
2952  }
2953 
2954  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
2955  previewImage.fill( Qt::transparent );
2956  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
2957  QPainter p;
2958  p.begin( &previewImage );
2959  //draw a checkerboard background
2960  uchar pixDataRGB[] = { 150, 150, 150, 150,
2961  100, 100, 100, 150,
2962  100, 100, 100, 150,
2963  150, 150, 150, 150
2964  };
2965  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
2966  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
2967  QBrush checkerBrush;
2968  checkerBrush.setTexture( pix );
2969  p.fillRect( imageRect, checkerBrush );
2970 
2971  if ( mLayer->alpha() < 1.0 )
2972  {
2973  p.setOpacity( mLayer->alpha() );
2974  }
2975 
2976  p.drawImage( imageRect.left(), imageRect.top(), image );
2977  p.end();
2978  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
2979 }
2980 
2981 
2983 
2984 QgsSvgListModel::QgsSvgListModel( QObject* parent ) : QAbstractListModel( parent )
2985 {
2987 }
2988 
2989 QgsSvgListModel::QgsSvgListModel( QObject* parent, const QString& path ) : QAbstractListModel( parent )
2990 {
2991  mSvgFiles = QgsSymbolLayerV2Utils::listSvgFilesAt( path );
2992 }
2993 
2994 int QgsSvgListModel::rowCount( const QModelIndex& parent ) const
2995 {
2996  Q_UNUSED( parent );
2997  return mSvgFiles.count();
2998 }
2999 
3000 QVariant QgsSvgListModel::data( const QModelIndex& index, int role ) const
3001 {
3002  QString entry = mSvgFiles.at( index.row() );
3003 
3004  if ( role == Qt::DecorationRole ) // icon
3005  {
3006  QPixmap pixmap;
3007  if ( !QPixmapCache::find( entry, pixmap ) )
3008  {
3009  // render SVG file
3010  QColor fill, outline;
3011  double outlineWidth, fillOpacity, outlineOpacity;
3012  bool fillParam, fillOpacityParam, outlineParam, outlineWidthParam, outlineOpacityParam;
3013  bool hasDefaultFillColor = false, hasDefaultFillOpacity = false, hasDefaultOutlineColor = false,
3014  hasDefaultOutlineWidth = false, hasDefaultOutlineOpacity = false;
3015  QgsSvgCache::instance()->containsParams( entry, fillParam, hasDefaultFillColor, fill,
3016  fillOpacityParam, hasDefaultFillOpacity, fillOpacity,
3017  outlineParam, hasDefaultOutlineColor, outline,
3018  outlineWidthParam, hasDefaultOutlineWidth, outlineWidth,
3019  outlineOpacityParam, hasDefaultOutlineOpacity, outlineOpacity );
3020 
3021  //if defaults not set in symbol, use these values
3022  if ( !hasDefaultFillColor )
3023  fill = QColor( 200, 200, 200 );
3024  fill.setAlphaF( hasDefaultFillOpacity ? fillOpacity : 1.0 );
3025  if ( !hasDefaultOutlineColor )
3026  outline = Qt::black;
3027  outline.setAlphaF( hasDefaultOutlineOpacity ? outlineOpacity : 1.0 );
3028  if ( !hasDefaultOutlineWidth )
3029  outlineWidth = 0.6;
3030 
3031  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
3032  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
3033  pixmap = QPixmap::fromImage( img );
3034  QPixmapCache::insert( entry, pixmap );
3035  }
3036 
3037  return pixmap;
3038  }
3039  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
3040  {
3041  return entry;
3042  }
3043 
3044  return QVariant();
3045 }
3046 
3047 
3048 QgsSvgGroupsModel::QgsSvgGroupsModel( QObject* parent ) : QStandardItemModel( parent )
3049 {
3051  QStandardItem *parentItem = invisibleRootItem();
3052 
3053  for ( int i = 0; i < svgPaths.size(); i++ )
3054  {
3055  QDir dir( svgPaths[i] );
3056  QStandardItem *baseGroup;
3057 
3058  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
3059  {
3060  baseGroup = new QStandardItem( QString( "App Symbols" ) );
3061  }
3062  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
3063  {
3064  baseGroup = new QStandardItem( QString( "User Symbols" ) );
3065  }
3066  else
3067  {
3068  baseGroup = new QStandardItem( dir.dirName() );
3069  }
3070  baseGroup->setData( QVariant( svgPaths[i] ) );
3071  baseGroup->setEditable( false );
3072  baseGroup->setCheckable( false );
3073  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
3074  baseGroup->setToolTip( dir.path() );
3075  parentItem->appendRow( baseGroup );
3076  createTree( baseGroup );
3077  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
3078  }
3079 }
3080 
3081 void QgsSvgGroupsModel::createTree( QStandardItem*& parentGroup )
3082 {
3083  QDir parentDir( parentGroup->data().toString() );
3084  Q_FOREACH ( const QString& item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3085  {
3086  QStandardItem* group = new QStandardItem( item );
3087  group->setData( QVariant( parentDir.path() + '/' + item ) );
3088  group->setEditable( false );
3089  group->setCheckable( false );
3090  group->setToolTip( parentDir.path() + '/' + item );
3091  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
3092  parentGroup->appendRow( group );
3093  createTree( group );
3094  }
3095 }
3096 
3097 
3099 
3100 
3101 
3102 
3103 
3104 
3106  : QgsSymbolLayerV2Widget( parent, vl )
3107  , mLayer( nullptr )
3108 {
3109  setupUi( this );
3110  modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer*>( vl ) );
3111  cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPolygonLayer.svg" ), tr( "Polygon / MultiPolygon" ), QgsSymbolV2::Fill );
3112  cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconLineLayer.svg" ), tr( "LineString / MultiLineString" ), QgsSymbolV2::Line );
3113  cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPointLayer.svg" ), tr( "Point / MultiPoint" ), QgsSymbolV2::Marker );
3114  connect( modificationExpressionSelector, SIGNAL( expressionParsed( bool ) ), this, SLOT( updateExpression() ) );
3115  connect( cbxGeometryType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateSymbolType() ) );
3116 }
3117 
3119 {
3120  mLayer = static_cast<QgsGeometryGeneratorSymbolLayerV2*>( l );
3121 
3123  modificationExpressionSelector->setExpressionContext( *mPresetExpressionContext );
3124  modificationExpressionSelector->setExpressionText( mLayer->geometryExpression() );
3125  cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
3126 }
3127 
3129 {
3130  return mLayer;
3131 }
3132 
3133 void QgsGeometryGeneratorSymbolLayerWidget::updateExpression()
3134 {
3135  mLayer->setGeometryExpression( modificationExpressionSelector->expressionText() );
3136 
3137  emit changed();
3138 }
3139 
3140 void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
3141 {
3142  mLayer->setSymbolType( static_cast<QgsSymbolV2::SymbolType>( cbxGeometryType->itemData( cbxGeometryType->currentIndex() ).toInt() ) );
3143 
3144  emit symbolChanged();
3145 }
void setIntervalUnit(QgsSymbolV2::OutputUnit unit)
void symbolChanged()
Should be emitted whenever the sub symbol changed on this symbol layer configuration.
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...
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
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)
QgsShapeburstFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
QgsSymbolV2::OutputUnit outlineWidthUnit() const
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
void setToolTip(const QString &toolTip)
const QgsMapUnitScale & patternWidthMapUnitScale() const
QgsVectorColorRampV2 * colorRamp()
Returns the color ramp used for the shapeburst fill.
void setGuiForSvg(const QgsSvgMarkerSymbolLayerV2 *layer)
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
Single variable definition for use within a QgsExpressionContextScope.
static QString gradientSpreadDesc()
static unsigned index
QgsSymbolV2::OutputUnit distanceYUnit() const
virtual int rowCount(const QModelIndex &parent) const =0
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 setSymbolType(QgsSymbolV2::SymbolType symbolType)
Set the type of symbol which should be created.
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
void setupUi(QWidget *widget)
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
void setIcon(const QIcon &icon)
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.
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
QgsGradientFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit distanceXUnit() const
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
qreal alphaF() 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
QgsSymbolV2::OutputUnit offsetUnit() const
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
QString svgFilePath() const
QgsFontMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
static QString colorNoAlphaDesc()
virtual QgsSymbolLayerV2 * symbolLayer() override
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & customDashPatternMapUnitScale() const
static QgsExpressionContextScope * atlasScope(const QgsAtlasComposition *atlas)
Creates a new scope which contains variables and functions relating to a QgsAtlasComposition.
void setOutlineColor(const QColor &c) override
Set outline color.
QString geometryExpression() const
Get the expression to generate this geometry.
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
QgsSimpleFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
void setCustomDashPatternUnit(QgsSymbolV2::OutputUnit unit)
double svgOutlineWidth() const
void updateFont(const QFont &font)
[0]
QObject * sender() const
QgsLinePatternFillSymbolLayer * mLayer
QgsCentroidFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
void setPointOnSurface(bool pointOnSurface)
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
QgsSymbolV2::SymbolType symbolType() const
Access the symbol type.
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
The output shall be in pixels.
Definition: qgssymbolv2.h:64
Calculate scale by the diameter.
Definition: qgssymbolv2.h:87
void setOffset(QPointF offset)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
QgsGradientFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
virtual QgsSymbolLayerV2 * symbolLayer() override
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsFontMarkerSymbolLayerV2 * mLayer
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
QVector< qreal > customDashVector() const
void setCharacter(QChar character)
const QgsMapUnitScale & intervalMapUnitScale() const
void setPenJoinStyle(Qt::PenJoinStyle style)
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
Line symbol.
Definition: qgssymbolv2.h:76
static QString lineStyleDesc()
void updateDataDefined(QgsDataDefined *dd) const
Updates a QgsDataDefined with the current settings from the button.
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
const QPixmap * icon() const
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
QColor fillColor() const override
Get fill color.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void on_mVerticalAnchorComboBox_currentIndexChanged(int index)
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
static QStringList listSvgFilesAt(const QString &directory)
Return a list of svg files at the specified directory.
const QgsMapUnitScale & borderWidthMapUnitScale() const
static QString horizontalAnchorDesc()
void setMapUnitScale(const QgsMapUnitScale &scale) override
QString homePath()
QString tr(const char *sourceText, const char *disambiguation, int n)
void setColorRamp(QgsVectorColorRampV2 *ramp)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
void setVariable(const QString &name, const QVariant &value)
Convenience method for setting a variable in the context scope by name and value. ...
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
const QgsVectorLayer * mVectorLayer
Qt::PenStyle penStyle() const
void setWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsPointPatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
void setPatternWidth(double width)
Marker symbol.
Definition: qgssymbolv2.h:75
int size() const
virtual void setData(const QVariant &value, int role)
void on_mChangeBorderColorButton_colorChanged(const QColor &color)
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
bool isNull() const
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)
The interval between individual markers.
The QgsMapSettings class contains configuration for rendering of the map.
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.
virtual QgsSymbolLayerV2 * symbolLayer() override
int width() const
static QgsSvgCache * instance()
Definition: qgssvgcache.cpp:97
void setDrawInsidePolygon(bool drawInsidePolygon)
void setGradientType(GradientType gradientType)
void setValue(const QString &key, const QVariant &value)
QSize size() const
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void setRotateMarker(bool rotate)
Shall the marker be rotated.
QgsSymbolV2::OutputUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
const QImage & svgAsImage(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool &fitsInCache)
Get SVG as QImage.
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
const char * name() const
QgsSymbolV2::OutputUnit offsetUnit() const
QgsSimpleLineSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
The output shall be in millimeters.
Definition: qgssymbolv2.h:61
double offsetAlongLine() const
Returns the offset along the line for the marker placement.
int count(const T &value) const
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
qreal x() const
qreal y() const
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)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
Append symbol layer at the end of the list Ownership will be transferred.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
void setMapUnitScale(const QgsMapUnitScale &scale) override
QVariant property(const char *name) const
virtual QgsSymbolLayerV2 * symbolLayer() override
static QString penJoinStyleDesc()
virtual QgsSymbolLayerV2 * symbolLayer() override
QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
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)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
void setBrushStyle(Qt::BrushStyle style)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
static QString double180RotDesc()
void setFontFamily(const QString &family)
void setPath(const QString &path)
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)
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
void appendRow(const QList< QStandardItem * > &items)
static QStringList listSvgFiles()
Return a list of all available svg files.
const QgsMapUnitScale & offsetMapUnitScale() const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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.
void setFillColor(const QColor &color) override
Set fill color.
virtual void select(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
bool isEmpty() const
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)
int row() const
The output shall be in map unitx.
Definition: qgssymbolv2.h:62
QString imageFilePath() const
The path to the raster image used for the fill.
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
bool rotateMarker() const
Shall the marker be rotated.
void setOverrideCursor(const QCursor &cursor)
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
static QgsExpressionContext _getExpressionContext(const void *context)
const QgsMapUnitScale & sizeMapUnitScale() const
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:128
void restoreOverrideCursor()
QgsSymbolV2::OutputUnit distanceUnit() const
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
double interval() const
The interval between individual markers.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
QgsSymbolV2::OutputUnit borderWidthUnit() const
QGis::GeometryType geometryType() const
Returns point, line or polygon.
virtual QColor color() const
The fill color.
virtual QVariant data(const QModelIndex &index, int role) const =0
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
QgsSvgMarkerSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setOffsetAlongLineUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit used for calculating the offset along line for markers.
QgsDataDefinedAssistant * assistant()
Returns the assistant used to defined the data defined object properties, if set. ...
Single scope for storing variables and functions for use within a QgsExpressionContext.
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
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)
void setOffset(QPointF offset)
Sets the offset for the fill.
QgsSymbolV2::ScaleMethod scaleMethod() const
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
A button for defining data source field mappings or expressions.
const QgsMapUnitScale & displacementYMapUnitScale() const
virtual QgsSymbolLayerV2 * symbolLayer() override
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
bool blockSignals(bool block)
static QString pkgDataPath()
Returns the common root path of all application data directories.
GradientSpread gradientSpread() const
Gradient spread mode.
const QgsMapUnitScale & distanceMapUnitScale() const
virtual void setData(int role, const QVariant &value)
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setOffset(QPointF offset)
Offset for gradient fill.
void registerGetExpressionContextCallback(ExpressionContextCallback fnGetExpressionContext, const void *context)
Register callback function for retrieving the expression context for the button.
virtual QString layerType() const =0
Returns a string that represents this layer type.
void setBorderColor(const QColor &borderColor)
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:378
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units used for the offset for the shapeburst fill.
QgsSimpleMarkerSymbolLayerV2 * mLayer
void setOffset(QPointF offset)
void setTexture(const QPixmap &pixmap)
static QString gradientCoordModeDesc()
const QgsMapUnitScale & offsetMapUnitScale() const
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
QgsSymbolV2::OutputUnit outlineWidthUnit() const
A class for svg fill patterns.
QgsSimpleLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units for the fill's offset.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QVariant value(const QString &key, const QVariant &defaultValue) const
void setBorderColor(const QColor &color)
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
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
Definition: qgsmapcanvas.h:442
void setPenStyle(Qt::PenStyle style)
QPointF offset() const
Returns the offset for the fill.
QgsSymbolV2::OutputUnit offsetUnit() const
QVariant data(int role) const
void setPlacement(Placement p)
The placement of the markers.
const QgsMapUnitScale & outlineWidthMapUnitScale() const
QStyle * style()
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.
QgsExpressionContext * mPresetExpressionContext
Optional preset expression context.
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
QgsSvgMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
const QgsMapUnitScale & distanceYMapUnitScale() const
QgsSymbolV2::OutputUnit displacementYUnit() const
QString family() 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()
virtual QgsDataDefined * getDataDefinedProperty(const QString &property) const
Returns the data defined property corresponding to the specified property key.
const QChar at(int position) const
Qt::PenJoinStyle penJoinStyle() const
QgsSvgMarkerSymbolLayerV2 * mLayer
static QString fillStyleDesc()
QPixmap * find(const QString &key)
void setColorRamp(QgsVectorColorRampV2 *ramp)
Sets the color ramp used to draw the shapeburst fill.
Fill symbol.
Definition: qgssymbolv2.h:77
const QgsMapUnitScale & offsetMapUnitScale() const
StandardButton critical(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
void on_mHorizontalAnchorComboBox_currentIndexChanged(int index)
QgsSimpleMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
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.
static QStringList svgPaths()
Returns the pathes to svg directories.
void setAlphaF(qreal alpha)
virtual void setColor(const QColor &color)
The fill color.
virtual QgsSymbolLayerV2 * symbolLayer()=0
Placement placement() const
The placement of the markers.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
GradientType gradientType() const
Type of gradient, eg linear or radial.
void setCurrentIndex(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
bool setProperty(const char *name, const QVariant &value)
void setMapUnitScale(const QgsMapUnitScale &scale) override
Calculate scale by the area.
Definition: qgssymbolv2.h:86
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setColor2(const QColor &color2)
QgsSVGFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
QgsShapeburstFillSymbolLayerV2 * mLayer
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image's width.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
virtual Q_DECL_DEPRECATED 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.
bool insert(const QString &key, const QPixmap &pixmap)
QgsSymbolV2::OutputUnit offsetUnit() const
Widget displaying a combobox allowing the user to choose between millimeter and map units If the user...
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setSize(double size)
void init(const QgsVectorLayer *vl, const QgsDataDefined *datadefined=nullptr, const QgsDataDefinedButton::DataTypes &datatypes=AnyType, const QString &description=QString())
Initialize a newly constructed data defined button (useful if button already included from form layou...
static QString customDashDesc()
void setAngle(double angle)
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
QPointF offset() const
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
QgsGeometryGeneratorSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
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...
QgsFontMarkerSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbolV2 *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbolV2 to an expression context.
QString toString() const
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QColor outlineColor() const override
Get outline color.
void setCheckable(bool checkable)
QgsSimpleMarkerSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
double angle() const
const QgsMapUnitScale & outlineWidthMapUnitScale() const
virtual QVariant data(int role) const
Qt::BrushStyle brushStyle() const
void setEditable(bool editable)
QgsSymbolV2::OutputUnit widthUnit() const
void setOffsetUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the fill's offset.
static QString double0to1Desc()
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
QgsSVGFillSymbolLayer * mLayer
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenJoinStyle penJoinStyle() const
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
QgsSimpleFillSymbolLayerV2 * mLayer
static QString colorAlphaDesc()
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
void setName(const QString &name)
QgsRasterFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
double alpha() const
The opacity for the raster image used in the fill.
virtual QgsSymbolLayerV2 * symbolLayer() override
virtual Q_DECL_DEPRECATED void setDataDefinedProperty(const QString &property, const QString &expressionString)
Sets a data defined expression for a property.
void setBorderStyle(Qt::PenStyle borderStyle)
QgsLinePatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=nullptr)