QGIS API Documentation
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;
90 
91  //TODO - show actual value
92  expContext.setOriginalValueVariable( QVariant() );
96 
97  return expContext;
98 }
99 
101 {
102  mMapCanvas = canvas;
103  Q_FOREACH ( QgsUnitSelectionWidget* unitWidget, findChildren<QgsUnitSelectionWidget*>() )
104  {
105  unitWidget->setMapCanvas( mMapCanvas );
106  }
107  Q_FOREACH ( QgsDataDefinedButton* ddButton, findChildren<QgsDataDefinedButton*>() )
108  {
109  if ( ddButton->assistant() )
110  ddButton->assistant()->setMapCanvas( mMapCanvas );
111  }
112 }
113 
115 {
116  return mMapCanvas;
117 }
118 
120 {
121  const QgsDataDefined* dd = symbolLayer()->getDataDefinedProperty( propertyName );
122  button->init( mVectorLayer, dd, type, description );
123  button->setProperty( "propertyName", propertyName );
124  connect( button, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
125  connect( button, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
126 
128 }
129 
131 {
132  QgsDataDefinedButton* button = qobject_cast<QgsDataDefinedButton*>( sender() );
133  const QString propertyName( button->property( "propertyName" ).toString() );
134 
135  QgsDataDefined* dd = symbolLayer()->getDataDefinedProperty( propertyName );
136  if ( !dd )
137  {
138  dd = new QgsDataDefined();
139  symbolLayer()->setDataDefinedProperty( propertyName, dd );
140  }
141  button->updateDataDefined( dd );
142 
143  emit changed();
144 }
145 
147 {
148  QString label = entryName;
149  if ( entryName == "size" )
150  {
151  label = tr( "Size" );
152  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
153  if ( layer )
154  {
155  switch ( layer->scaleMethod() )
156  {
158  label += " (" + tr( "area" ) + ')';
159  break;
161  label += " (" + tr( "diameter" ) + ')';
162  break;
163  }
164  }
165  }
166  return label;
167 }
168 
170  : QgsSymbolLayerV2Widget( parent, vl )
171 {
172  mLayer = nullptr;
173 
174  setupUi( this );
175  mPenWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
177  mDashPatternUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
178 
179  btnChangeColor->setAllowAlpha( true );
180  btnChangeColor->setColorDialogTitle( tr( "Select line color" ) );
181  btnChangeColor->setContext( "symbology" );
182 
183  spinOffset->setClearValue( 0.0 );
184 
185  if ( vl && vl->geometryType() != QGis::Polygon )
186  {
187  //draw inside polygon checkbox only makes sense for polygon layers
188  mDrawInsideCheckBox->hide();
189  }
190 
191  //make a temporary symbol for the size assistant preview
192  mAssistantPreviewSymbol = new QgsLineSymbolV2();
193 
194  if ( mVectorLayer )
195  mPenWidthDDBtn->setAssistant( tr( "Width Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
196 
197 
198  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
199  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
200  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
201  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
202  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
203  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
204 
206 
207  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
208 }
209 
211 {
212  delete mAssistantPreviewSymbol;
213 }
214 
215 void QgsSimpleLineSymbolLayerV2Widget::updateAssistantSymbol()
216 {
217  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
218  {
219  mAssistantPreviewSymbol->deleteSymbolLayer( i );
220  }
221  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
222  QgsDataDefined* ddWidth = mLayer->getDataDefinedProperty( "width" );
223  if ( ddWidth )
224  mAssistantPreviewSymbol->setDataDefinedWidth( *ddWidth );
225 }
226 
227 
229 {
230  if ( !layer || layer->layerType() != "SimpleLine" )
231  return;
232 
233  // layer type is correct, we can do the cast
234  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
235 
236  // set units
237  mPenWidthUnitWidget->blockSignals( true );
238  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
239  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
240  mPenWidthUnitWidget->blockSignals( false );
241  mOffsetUnitWidget->blockSignals( true );
242  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
243  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
244  mOffsetUnitWidget->blockSignals( false );
245  mDashPatternUnitWidget->blockSignals( true );
246  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
247  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
248  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
249  mDashPatternUnitWidget->blockSignals( false );
250 
251  // set values
252  spinWidth->blockSignals( true );
253  spinWidth->setValue( mLayer->width() );
254  spinWidth->blockSignals( false );
255  btnChangeColor->blockSignals( true );
256  btnChangeColor->setColor( mLayer->color() );
257  btnChangeColor->blockSignals( false );
258  spinOffset->blockSignals( true );
259  spinOffset->setValue( mLayer->offset() );
260  spinOffset->blockSignals( false );
261  cboPenStyle->blockSignals( true );
262  cboJoinStyle->blockSignals( true );
263  cboCapStyle->blockSignals( true );
264  cboPenStyle->setPenStyle( mLayer->penStyle() );
265  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
266  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
267  cboPenStyle->blockSignals( false );
268  cboJoinStyle->blockSignals( false );
269  cboCapStyle->blockSignals( false );
270 
271  //use a custom dash pattern?
272  bool useCustomDashPattern = mLayer->useCustomDashPattern();
273  mChangePatternButton->setEnabled( useCustomDashPattern );
274  label_3->setEnabled( !useCustomDashPattern );
275  cboPenStyle->setEnabled( !useCustomDashPattern );
276  mCustomCheckBox->blockSignals( true );
277  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
278  mCustomCheckBox->blockSignals( false );
279 
280  //draw inside polygon?
281  bool drawInsidePolygon = mLayer->drawInsidePolygon();
282  mDrawInsideCheckBox->blockSignals( true );
283  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
284  mDrawInsideCheckBox->blockSignals( false );
285 
287 
295 
296  updateAssistantSymbol();
297 }
298 
300 {
301  return mLayer;
302 }
303 
305 {
306  mLayer->setWidth( spinWidth->value() );
308  emit changed();
309 }
310 
312 {
313  mLayer->setColor( color );
315  emit changed();
316 }
317 
319 {
320  mLayer->setPenStyle( cboPenStyle->penStyle() );
321  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
322  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
323  emit changed();
324 }
325 
327 {
328  mLayer->setOffset( spinOffset->value() );
330  emit changed();
331 }
332 
334 {
335  bool checked = ( state == Qt::Checked );
336  mChangePatternButton->setEnabled( checked );
337  label_3->setEnabled( !checked );
338  cboPenStyle->setEnabled( !checked );
339 
340  mLayer->setUseCustomDashPattern( checked );
341  emit changed();
342 }
343 
345 {
347  if ( d.exec() == QDialog::Accepted )
348  {
349  mLayer->setCustomDashVector( d.dashDotVector() );
351  emit changed();
352  }
353 }
354 
356 {
357  if ( mLayer )
358  {
359  mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
360  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
361  emit changed();
362  }
363 }
364 
366 {
367  if ( mLayer )
368  {
369  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
370  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
371  emit changed();
372  }
373 }
374 
376 {
377  if ( mLayer )
378  {
379  mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
380  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
381  emit changed();
382  }
383 }
384 
386 {
387  bool checked = ( state == Qt::Checked );
388  mLayer->setDrawInsidePolygon( checked );
389  emit changed();
390 }
391 
392 
394 {
395  if ( !mLayer )
396  {
397  return;
398  }
399  QgsSimpleLineSymbolLayerV2* layerCopy = mLayer->clone();
400  if ( !layerCopy )
401  {
402  return;
403  }
404  layerCopy->setUseCustomDashPattern( true );
405  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
406  mChangePatternButton->setIcon( buttonIcon );
407  delete layerCopy;
408 }
409 
410 
412 
413 
415  : QgsSymbolLayerV2Widget( parent, vl )
416 {
417  mLayer = nullptr;
418 
419  setupUi( this );
422  mOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
423 
424  btnChangeColorFill->setAllowAlpha( true );
425  btnChangeColorFill->setColorDialogTitle( tr( "Select fill color" ) );
426  btnChangeColorFill->setContext( "symbology" );
427  btnChangeColorFill->setShowNoColor( true );
428  btnChangeColorFill->setNoColorString( tr( "Transparent fill" ) );
429  btnChangeColorBorder->setAllowAlpha( true );
430  btnChangeColorBorder->setColorDialogTitle( tr( "Select border color" ) );
431  btnChangeColorBorder->setContext( "symbology" );
432  btnChangeColorBorder->setShowNoColor( true );
433  btnChangeColorBorder->setNoColorString( tr( "Transparent border" ) );
434 
435  spinOffsetX->setClearValue( 0.0 );
436  spinOffsetY->setClearValue( 0.0 );
437 
438  //make a temporary symbol for the size assistant preview
439  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
440 
441  if ( mVectorLayer )
442  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
443 
444  QSize size = lstNames->iconSize();
445  QStringList names;
446  names << "circle" << "rectangle" << "diamond" << "pentagon" << "hexagon" << "cross" << "cross_fill" << "triangle" << "equilateral_triangle"
447  << "star" << "arrow" << "line" << "arrowhead" << "cross2" << "filled_arrowhead" << "semi_circle" << "third_circle" << "quarter_circle"
448  << "quarter_square" << "half_square" << "diagonal_half_square" << "right_half_triangle" << "left_half_triangle";
449  double markerSize = DEFAULT_POINT_SIZE * 2;
450  Q_FOREACH ( const QString& name, names )
451  {
452  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( name, QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
454  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
455  item->setData( Qt::UserRole, name );
456  item->setToolTip( name );
457  delete lyr;
458  }
459 
460  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
461  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
462  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
463  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penJoinStyleChanged() ) );
464  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
465  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
466  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
467  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
468  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
469 }
470 
472 {
473  delete mAssistantPreviewSymbol;
474 }
475 
477 {
478  if ( layer->layerType() != "SimpleMarker" )
479  return;
480 
481  // layer type is correct, we can do the cast
482  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
483 
484  // set values
485  QString name = mLayer->name();
486  for ( int i = 0; i < lstNames->count(); ++i )
487  {
488  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
489  {
490  lstNames->setCurrentRow( i );
491  break;
492  }
493  }
494  btnChangeColorBorder->blockSignals( true );
495  btnChangeColorBorder->setColor( mLayer->borderColor() );
496  btnChangeColorBorder->blockSignals( false );
497  btnChangeColorFill->blockSignals( true );
498  btnChangeColorFill->setColor( mLayer->color() );
499  btnChangeColorFill->blockSignals( false );
500  spinSize->blockSignals( true );
501  spinSize->setValue( mLayer->size() );
502  spinSize->blockSignals( false );
503  spinAngle->blockSignals( true );
504  spinAngle->setValue( mLayer->angle() );
505  spinAngle->blockSignals( false );
506  mOutlineStyleComboBox->blockSignals( true );
507  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
508  mOutlineStyleComboBox->blockSignals( false );
509  mOutlineWidthSpinBox->blockSignals( true );
510  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
511  mOutlineWidthSpinBox->blockSignals( false );
512  cboJoinStyle->blockSignals( true );
513  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
514  cboJoinStyle->blockSignals( false );
515 
516  // without blocking signals the value gets changed because of slot setOffset()
517  spinOffsetX->blockSignals( true );
518  spinOffsetX->setValue( mLayer->offset().x() );
519  spinOffsetX->blockSignals( false );
520  spinOffsetY->blockSignals( true );
521  spinOffsetY->setValue( mLayer->offset().y() );
522  spinOffsetY->blockSignals( false );
523 
524  mSizeUnitWidget->blockSignals( true );
525  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
526  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
527  mSizeUnitWidget->blockSignals( false );
528  mOffsetUnitWidget->blockSignals( true );
529  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
530  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
531  mOffsetUnitWidget->blockSignals( false );
532  mOutlineWidthUnitWidget->blockSignals( true );
533  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
534  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
535  mOutlineWidthUnitWidget->blockSignals( false );
536 
537  //anchor points
538  mHorizontalAnchorComboBox->blockSignals( true );
539  mVerticalAnchorComboBox->blockSignals( true );
540  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
541  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
542  mHorizontalAnchorComboBox->blockSignals( false );
543  mVerticalAnchorComboBox->blockSignals( false );
544 
545  registerDataDefinedButton( mNameDDBtn, "name", QgsDataDefinedButton::String, tr( "string " ) + QLatin1String( "[<b>square</b>|<b>rectangle</b>|<b>diamond</b>|"
546  "<b>pentagon</b>|<b>hexagon</b>|<b>triangle</b>|<b>equilateral_triangle</b>|"
547  "<b>star</b>|<b>arrow</b>|<b>filled_arrowhead</b>|"
548  "<b>circle</b>|<b>cross</b>|<b>cross_fill</b>|<b>x</b>|"
549  "<b>line</b>|<b>arrowhead</b>|<b>cross2</b>|<b>semi_circle</b>|<b>third_circle</b>|<b>quarter_circle</b>|"
550  "<b>quarter_square</b>|<b>half_square</b>|<b>diagonal_half_square</b>|<b>right_half_triangle</b>|<b>left_half_triangle</b>]" ) );
559  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
560  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
561 
562  updateAssistantSymbol();
563 }
564 
566 {
567  return mLayer;
568 }
569 
571 {
572  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
573  emit changed();
574 }
575 
577 {
578  mLayer->setBorderColor( color );
579  emit changed();
580 }
581 
583 {
584  mLayer->setColor( color );
585  emit changed();
586 }
587 
588 void QgsSimpleMarkerSymbolLayerV2Widget::penJoinStyleChanged()
589 {
590  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
591  emit changed();
592 }
593 
595 {
596  mLayer->setSize( spinSize->value() );
597  emit changed();
598 }
599 
601 {
602  mLayer->setAngle( spinAngle->value() );
603  emit changed();
604 }
605 
607 {
608  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
609  emit changed();
610 }
611 
613 {
614  Q_UNUSED( index );
615 
616  if ( mLayer )
617  {
618  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
619  emit changed();
620  }
621 }
622 
624 {
625  if ( mLayer )
626  {
627  mLayer->setOutlineWidth( d );
628  emit changed();
629  }
630 }
631 
633 {
634  if ( mLayer )
635  {
636  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
637  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
638  emit changed();
639  }
640 }
641 
643 {
644  if ( mLayer )
645  {
646  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
647  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
648  emit changed();
649  }
650 }
651 
653 {
654  if ( mLayer )
655  {
656  mLayer->setOutlineWidthUnit( mOutlineWidthUnitWidget->unit() );
657  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
658  emit changed();
659  }
660 }
661 
663 {
664  if ( mLayer )
665  {
667  emit changed();
668  }
669 }
670 
672 {
673  if ( mLayer )
674  {
676  emit changed();
677  }
678 }
679 
680 void QgsSimpleMarkerSymbolLayerV2Widget::updateAssistantSymbol()
681 {
682  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
683  {
684  mAssistantPreviewSymbol->deleteSymbolLayer( i );
685  }
686  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
687  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
688  if ( ddSize )
689  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
690 }
691 
692 
694 
696  : QgsSymbolLayerV2Widget( parent, vl )
697 {
698  mLayer = nullptr;
699 
700  setupUi( this );
701  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
703 
704  btnChangeColor->setAllowAlpha( true );
705  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
706  btnChangeColor->setContext( "symbology" );
707  btnChangeColor->setShowNoColor( true );
708  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
709  btnChangeBorderColor->setAllowAlpha( true );
710  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
711  btnChangeBorderColor->setContext( "symbology" );
712  btnChangeBorderColor->setShowNoColor( true );
713  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
714 
715  spinOffsetX->setClearValue( 0.0 );
716  spinOffsetY->setClearValue( 0.0 );
717 
718  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
719  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
720  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
721  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
722  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
723  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
724  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
725  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
726 }
727 
729 {
730  if ( layer->layerType() != "SimpleFill" )
731  return;
732 
733  // layer type is correct, we can do the cast
734  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
735 
736  // set values
737  btnChangeColor->blockSignals( true );
738  btnChangeColor->setColor( mLayer->color() );
739  btnChangeColor->blockSignals( false );
740  cboFillStyle->blockSignals( true );
741  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
742  cboFillStyle->blockSignals( false );
743  btnChangeBorderColor->blockSignals( true );
744  btnChangeBorderColor->setColor( mLayer->borderColor() );
745  btnChangeBorderColor->blockSignals( false );
746  cboBorderStyle->blockSignals( true );
747  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
748  cboBorderStyle->blockSignals( false );
749  spinBorderWidth->blockSignals( true );
750  spinBorderWidth->setValue( mLayer->borderWidth() );
751  spinBorderWidth->blockSignals( false );
752  cboJoinStyle->blockSignals( true );
753  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
754  cboJoinStyle->blockSignals( false );
755  spinOffsetX->blockSignals( true );
756  spinOffsetX->setValue( mLayer->offset().x() );
757  spinOffsetX->blockSignals( false );
758  spinOffsetY->blockSignals( true );
759  spinOffsetY->setValue( mLayer->offset().y() );
760  spinOffsetY->blockSignals( false );
761 
762  mBorderWidthUnitWidget->blockSignals( true );
763  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
764  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
765  mBorderWidthUnitWidget->blockSignals( false );
766  mOffsetUnitWidget->blockSignals( true );
767  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
768  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
769  mOffsetUnitWidget->blockSignals( false );
770 
777 
778 }
779 
781 {
782  return mLayer;
783 }
784 
786 {
787  mLayer->setColor( color );
788  emit changed();
789 }
790 
792 {
793  mLayer->setBorderColor( color );
794  emit changed();
795 }
796 
798 {
799  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
800  emit changed();
801 }
802 
804 {
805  mLayer->setBorderWidth( spinBorderWidth->value() );
806  emit changed();
807 }
808 
810 {
811  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
812  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
813  emit changed();
814 }
815 
817 {
818  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
819  emit changed();
820 }
821 
823 {
824  if ( mLayer )
825  {
826  mLayer->setBorderWidthUnit( mBorderWidthUnitWidget->unit() );
827  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
828  emit changed();
829  }
830 }
831 
833 {
834  if ( mLayer )
835  {
836  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
837  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
838  emit changed();
839  }
840 }
841 
843 
845  : QgsSymbolLayerV2Widget( parent, vl )
846 {
847  mLayer = nullptr;
848 
849  setupUi( this );
851 
852  cboGradientColorRamp->setShowGradientOnly( true );
853  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
854 
855  btnChangeColor->setAllowAlpha( true );
856  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
857  btnChangeColor->setContext( "symbology" );
858  btnChangeColor->setShowNoColor( true );
859  btnChangeColor->setNoColorString( tr( "Transparent" ) );
860  btnChangeColor2->setAllowAlpha( true );
861  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
862  btnChangeColor2->setContext( "symbology" );
863  btnChangeColor2->setShowNoColor( true );
864  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
865 
866  spinOffsetX->setClearValue( 0.0 );
867  spinOffsetY->setClearValue( 0.0 );
868 
869  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
870  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
871  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
872  connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
873  connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
874  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
875  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
876  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
877  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
878  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
879  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
880  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
881  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
882  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
883  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
884  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
885  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
886 }
887 
889 {
890  if ( layer->layerType() != "GradientFill" )
891  return;
892 
893  // layer type is correct, we can do the cast
894  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
895 
896  // set values
897  btnChangeColor->blockSignals( true );
898  btnChangeColor->setColor( mLayer->color() );
899  btnChangeColor->blockSignals( false );
900  btnChangeColor2->blockSignals( true );
901  btnChangeColor2->setColor( mLayer->color2() );
902  btnChangeColor2->blockSignals( false );
903 
905  {
906  radioTwoColor->setChecked( true );
907  cboGradientColorRamp->setEnabled( false );
908  }
909  else
910  {
911  radioColorRamp->setChecked( true );
912  btnChangeColor->setEnabled( false );
913  btnChangeColor2->setEnabled( false );
914  }
915 
916  // set source color ramp
917  if ( mLayer->colorRamp() )
918  {
919  cboGradientColorRamp->blockSignals( true );
920  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
921  cboGradientColorRamp->blockSignals( false );
922  }
923 
924  cboGradientType->blockSignals( true );
925  switch ( mLayer->gradientType() )
926  {
928  cboGradientType->setCurrentIndex( 0 );
929  break;
931  cboGradientType->setCurrentIndex( 1 );
932  break;
934  cboGradientType->setCurrentIndex( 2 );
935  break;
936  }
937  cboGradientType->blockSignals( false );
938 
939  cboCoordinateMode->blockSignals( true );
940  switch ( mLayer->coordinateMode() )
941  {
943  cboCoordinateMode->setCurrentIndex( 1 );
944  checkRefPoint1Centroid->setEnabled( false );
945  checkRefPoint2Centroid->setEnabled( false );
946  break;
948  default:
949  cboCoordinateMode->setCurrentIndex( 0 );
950  break;
951  }
952  cboCoordinateMode->blockSignals( false );
953 
954  cboGradientSpread->blockSignals( true );
955  switch ( mLayer->gradientSpread() )
956  {
958  cboGradientSpread->setCurrentIndex( 0 );
959  break;
961  cboGradientSpread->setCurrentIndex( 1 );
962  break;
964  cboGradientSpread->setCurrentIndex( 2 );
965  break;
966  }
967  cboGradientSpread->blockSignals( false );
968 
969  spinRefPoint1X->blockSignals( true );
970  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
971  spinRefPoint1X->blockSignals( false );
972  spinRefPoint1Y->blockSignals( true );
973  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
974  spinRefPoint1Y->blockSignals( false );
975  checkRefPoint1Centroid->blockSignals( true );
976  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
978  {
979  spinRefPoint1X->setEnabled( false );
980  spinRefPoint1Y->setEnabled( false );
981  }
982  checkRefPoint1Centroid->blockSignals( false );
983  spinRefPoint2X->blockSignals( true );
984  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
985  spinRefPoint2X->blockSignals( false );
986  spinRefPoint2Y->blockSignals( true );
987  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
988  spinRefPoint2Y->blockSignals( false );
989  checkRefPoint2Centroid->blockSignals( true );
990  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
992  {
993  spinRefPoint2X->setEnabled( false );
994  spinRefPoint2Y->setEnabled( false );
995  }
996  checkRefPoint2Centroid->blockSignals( false );
997 
998  spinOffsetX->blockSignals( true );
999  spinOffsetX->setValue( mLayer->offset().x() );
1000  spinOffsetX->blockSignals( false );
1001  spinOffsetY->blockSignals( true );
1002  spinOffsetY->setValue( mLayer->offset().y() );
1003  spinOffsetY->blockSignals( false );
1004  mSpinAngle->blockSignals( true );
1005  mSpinAngle->setValue( mLayer->angle() );
1006  mSpinAngle->blockSignals( false );
1007 
1008  mOffsetUnitWidget->blockSignals( true );
1009  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1010  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1011  mOffsetUnitWidget->blockSignals( false );
1012 
1021  registerDataDefinedButton( mRefPoint1CentroidDDBtn, "reference1_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1024  registerDataDefinedButton( mRefPoint2CentroidDDBtn, "reference2_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1025 }
1026 
1028 {
1029  return mLayer;
1030 }
1031 
1033 {
1034  mLayer->setColor( color );
1035  emit changed();
1036 }
1037 
1039 {
1040  mLayer->setColor2( color );
1041  emit changed();
1042 }
1043 
1045 {
1046  if ( radioTwoColor->isChecked() )
1047  {
1049  }
1050  else
1051  {
1053  }
1054  emit changed();
1055 }
1056 
1058 {
1059  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1060  if ( !ramp )
1061  return;
1062 
1063  mLayer->setColorRamp( ramp );
1064  emit changed();
1065 }
1066 
1068 {
1069  switch ( index )
1070  {
1071  case 0:
1073  //set sensible default reference points
1074  spinRefPoint1X->setValue( 0.5 );
1075  spinRefPoint1Y->setValue( 0 );
1076  spinRefPoint2X->setValue( 0.5 );
1077  spinRefPoint2Y->setValue( 1 );
1078  break;
1079  case 1:
1081  //set sensible default reference points
1082  spinRefPoint1X->setValue( 0 );
1083  spinRefPoint1Y->setValue( 0 );
1084  spinRefPoint2X->setValue( 1 );
1085  spinRefPoint2Y->setValue( 1 );
1086  break;
1087  case 2:
1089  spinRefPoint1X->setValue( 0.5 );
1090  spinRefPoint1Y->setValue( 0.5 );
1091  spinRefPoint2X->setValue( 1 );
1092  spinRefPoint2Y->setValue( 1 );
1093  break;
1094  }
1095  emit changed();
1096 }
1097 
1099 {
1100 
1101  switch ( index )
1102  {
1103  case 0:
1104  //feature coordinate mode
1106  //allow choice of centroid reference positions
1107  checkRefPoint1Centroid->setEnabled( true );
1108  checkRefPoint2Centroid->setEnabled( true );
1109  break;
1110  case 1:
1111  //viewport coordinate mode
1113  //disable choice of centroid reference positions
1114  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1115  checkRefPoint1Centroid->setEnabled( false );
1116  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1117  checkRefPoint2Centroid->setEnabled( false );
1118  break;
1119  }
1120 
1121  emit changed();
1122 }
1123 
1125 {
1126  switch ( index )
1127  {
1128  case 0:
1130  break;
1131  case 1:
1133  break;
1134  case 2:
1136  break;
1137  }
1138 
1139  emit changed();
1140 }
1141 
1143 {
1144  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1145  emit changed();
1146 }
1147 
1149 {
1150  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1151  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1152  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1153  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1154  emit changed();
1155 }
1156 
1158 {
1159  mLayer->setAngle( value );
1160  emit changed();
1161 }
1162 
1164 {
1165  if ( mLayer )
1166  {
1167  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1168  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1169  emit changed();
1170  }
1171 }
1172 
1174 
1176  : QgsSymbolLayerV2Widget( parent, vl )
1177 {
1178  mLayer = nullptr;
1179 
1180  setupUi( this );
1181  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1182  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1183 
1184  btnChangeColor->setAllowAlpha( true );
1185  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1186  btnChangeColor->setContext( "symbology" );
1187  btnChangeColor->setShowNoColor( true );
1188  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1189  btnChangeColor2->setAllowAlpha( true );
1190  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1191  btnChangeColor2->setContext( "symbology" );
1192  btnChangeColor2->setShowNoColor( true );
1193  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1194 
1195  spinOffsetX->setClearValue( 0.0 );
1196  spinOffsetY->setClearValue( 0.0 );
1197 
1198  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1199 
1200  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1201  connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
1202  connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
1203 
1204  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1205  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1206  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1207  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1208  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1209 
1210  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1211  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1212 }
1213 
1215 {
1216  if ( layer->layerType() != "ShapeburstFill" )
1217  return;
1218 
1219  // layer type is correct, we can do the cast
1220  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1221 
1222  // set values
1223  btnChangeColor->blockSignals( true );
1224  btnChangeColor->setColor( mLayer->color() );
1225  btnChangeColor->blockSignals( false );
1226  btnChangeColor2->blockSignals( true );
1227  btnChangeColor2->setColor( mLayer->color2() );
1228  btnChangeColor2->blockSignals( false );
1229 
1231  {
1232  radioTwoColor->setChecked( true );
1233  cboGradientColorRamp->setEnabled( false );
1234  }
1235  else
1236  {
1237  radioColorRamp->setChecked( true );
1238  btnChangeColor->setEnabled( false );
1239  btnChangeColor2->setEnabled( false );
1240  }
1241 
1242  mSpinBlurRadius->blockSignals( true );
1243  mBlurSlider->blockSignals( true );
1244  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1245  mBlurSlider->setValue( mLayer->blurRadius() );
1246  mSpinBlurRadius->blockSignals( false );
1247  mBlurSlider->blockSignals( false );
1248 
1249  mSpinMaxDistance->blockSignals( true );
1250  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1251  mSpinMaxDistance->blockSignals( false );
1252 
1253  mRadioUseWholeShape->blockSignals( true );
1254  mRadioUseMaxDistance->blockSignals( true );
1255  if ( mLayer->useWholeShape() )
1256  {
1257  mRadioUseWholeShape->setChecked( true );
1258  mSpinMaxDistance->setEnabled( false );
1259  mDistanceUnitWidget->setEnabled( false );
1260  }
1261  else
1262  {
1263  mRadioUseMaxDistance->setChecked( true );
1264  mSpinMaxDistance->setEnabled( true );
1265  mDistanceUnitWidget->setEnabled( true );
1266  }
1267  mRadioUseWholeShape->blockSignals( false );
1268  mRadioUseMaxDistance->blockSignals( false );
1269 
1270  mDistanceUnitWidget->blockSignals( true );
1271  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1272  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1273  mDistanceUnitWidget->blockSignals( false );
1274 
1275  mIgnoreRingsCheckBox->blockSignals( true );
1276  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1277  mIgnoreRingsCheckBox->blockSignals( false );
1278 
1279  // set source color ramp
1280  if ( mLayer->colorRamp() )
1281  {
1282  cboGradientColorRamp->blockSignals( true );
1283  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1284  cboGradientColorRamp->blockSignals( false );
1285  }
1286 
1287  spinOffsetX->blockSignals( true );
1288  spinOffsetX->setValue( mLayer->offset().x() );
1289  spinOffsetX->blockSignals( false );
1290  spinOffsetY->blockSignals( true );
1291  spinOffsetY->setValue( mLayer->offset().y() );
1292  spinOffsetY->blockSignals( false );
1293  mOffsetUnitWidget->blockSignals( true );
1294  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1295  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1296  mOffsetUnitWidget->blockSignals( false );
1297 
1300  registerDataDefinedButton( mBlurRadiusDDBtn, "blur_radius", QgsDataDefinedButton::Int, tr( "Integer between 0 and 18" ) );
1301  registerDataDefinedButton( mShadeWholeShapeDDBtn, "use_whole_shape", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1304 }
1305 
1307 {
1308  return mLayer;
1309 }
1310 
1312 {
1313  if ( mLayer )
1314  {
1315  mLayer->setColor( color );
1316  emit changed();
1317  }
1318 }
1319 
1321 {
1322  if ( mLayer )
1323  {
1324  mLayer->setColor2( color );
1325  emit changed();
1326  }
1327 }
1328 
1330 {
1331  if ( !mLayer )
1332  {
1333  return;
1334  }
1335 
1336  if ( radioTwoColor->isChecked() )
1337  {
1339  }
1340  else
1341  {
1343  }
1344  emit changed();
1345 }
1346 
1348 {
1349  if ( mLayer )
1350  {
1351  mLayer->setBlurRadius( value );
1352  emit changed();
1353  }
1354 }
1355 
1357 {
1358  if ( mLayer )
1359  {
1360  mLayer->setMaxDistance( value );
1361  emit changed();
1362  }
1363 }
1364 
1366 {
1367  if ( mLayer )
1368  {
1369  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1370  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1371  emit changed();
1372  }
1373 }
1374 
1376 {
1377  if ( mLayer )
1378  {
1379  mLayer->setUseWholeShape( value );
1380  mDistanceUnitWidget->setEnabled( !value );
1381  emit changed();
1382  }
1383 }
1384 
1386 {
1387  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1388  if ( !ramp )
1389  return;
1390 
1391  mLayer->setColorRamp( ramp );
1392  emit changed();
1393 }
1394 
1396 {
1397  if ( mLayer )
1398  {
1399  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1400  emit changed();
1401  }
1402 }
1403 
1405 {
1406  if ( mLayer )
1407  {
1408  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1409  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1410  emit changed();
1411  }
1412 }
1413 
1414 
1416 {
1417  bool checked = ( state == Qt::Checked );
1418  mLayer->setIgnoreRings( checked );
1419  emit changed();
1420 }
1421 
1423 
1425  : QgsSymbolLayerV2Widget( parent, vl )
1426 {
1427  mLayer = nullptr;
1428 
1429  setupUi( this );
1430  mIntervalUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1431  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1432  mOffsetAlongLineUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1433 
1434  spinOffset->setClearValue( 0.0 );
1435 
1436  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1437  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1438  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1439  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1440  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1441  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1442  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1443  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1444  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1445  connect( radCurvePoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1446 }
1447 
1449 {
1450  if ( layer->layerType() != "MarkerLine" )
1451  return;
1452 
1453  // layer type is correct, we can do the cast
1454  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1455 
1456  // set values
1457  spinInterval->blockSignals( true );
1458  spinInterval->setValue( mLayer->interval() );
1459  spinInterval->blockSignals( false );
1460  mSpinOffsetAlongLine->blockSignals( true );
1461  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1462  mSpinOffsetAlongLine->blockSignals( false );
1463  chkRotateMarker->blockSignals( true );
1464  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1465  chkRotateMarker->blockSignals( false );
1466  spinOffset->blockSignals( true );
1467  spinOffset->setValue( mLayer->offset() );
1468  spinOffset->blockSignals( false );
1470  radInterval->setChecked( true );
1472  radVertex->setChecked( true );
1474  radVertexLast->setChecked( true );
1476  radCentralPoint->setChecked( true );
1478  radCurvePoint->setChecked( true );
1479  else
1480  radVertexFirst->setChecked( true );
1481 
1482  // set units
1483  mIntervalUnitWidget->blockSignals( true );
1484  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1485  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1486  mIntervalUnitWidget->blockSignals( false );
1487  mOffsetUnitWidget->blockSignals( true );
1488  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1489  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1490  mOffsetUnitWidget->blockSignals( false );
1491  mOffsetAlongLineUnitWidget->blockSignals( true );
1492  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1493  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1494  mOffsetAlongLineUnitWidget->blockSignals( false );
1495 
1496  setPlacement(); // update gui
1497 
1500  registerDataDefinedButton( mPlacementDDBtn, "placement", QgsDataDefinedButton::String, tr( "string " ) + QLatin1String( "[<b>vertex</b>|<b>lastvertex</b>|<b>firstvertex</b>|<b>centerpoint</b>]" ) );
1501  registerDataDefinedButton( mOffsetAlongLineDDBtn, "offset_along_line", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
1502 }
1503 
1505 {
1506  return mLayer;
1507 }
1508 
1510 {
1511  mLayer->setInterval( val );
1512  emit changed();
1513 }
1514 
1516 {
1517  mLayer->setOffsetAlongLine( val );
1518  emit changed();
1519 }
1520 
1522 {
1523  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1524  emit changed();
1525 }
1526 
1528 {
1529  mLayer->setOffset( spinOffset->value() );
1530  emit changed();
1531 }
1532 
1534 {
1535  bool interval = radInterval->isChecked();
1536  spinInterval->setEnabled( interval );
1537  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1538  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1539  if ( radInterval->isChecked() )
1541  else if ( radVertex->isChecked() )
1543  else if ( radVertexLast->isChecked() )
1545  else if ( radVertexFirst->isChecked() )
1547  else if ( radCurvePoint->isChecked() )
1549  else
1551 
1552  emit changed();
1553 }
1554 
1556 {
1557  if ( mLayer )
1558  {
1559  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1560  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1561  emit changed();
1562  }
1563 }
1564 
1566 {
1567  if ( mLayer )
1568  {
1569  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1570  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1571  emit changed();
1572  }
1573 }
1574 
1576 {
1577  if ( mLayer )
1578  {
1579  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1580  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1581  }
1582  emit changed();
1583 }
1584 
1586 
1587 
1589  : QgsSymbolLayerV2Widget( parent, vl )
1590 {
1591  mLayer = nullptr;
1592 
1593  setupUi( this );
1595  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1596  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1597  viewGroups->setHeaderHidden( true );
1598  mChangeColorButton->setAllowAlpha( true );
1599  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1600  mChangeColorButton->setContext( "symbology" );
1601  mChangeBorderColorButton->setAllowAlpha( true );
1602  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1603  mChangeBorderColorButton->setContext( "symbology" );
1604 
1605  spinOffsetX->setClearValue( 0.0 );
1606  spinOffsetY->setClearValue( 0.0 );
1607 
1608  populateList();
1609 
1610  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1611  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1612  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1613  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1614  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1615  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1616  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
1617 
1618  //make a temporary symbol for the size assistant preview
1619  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
1620  if ( mVectorLayer )
1621  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
1622 }
1623 
1625 {
1626  delete mAssistantPreviewSymbol;
1627 }
1628 
1629 #include <QTime>
1630 #include <QAbstractListModel>
1631 #include <QPixmapCache>
1632 #include <QStyle>
1633 
1634 
1636 {
1637  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1638  viewGroups->setModel( g );
1639  // Set the tree expanded at the first level
1640  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1641  for ( int i = 0; i < rows; i++ )
1642  {
1643  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1644  }
1645 
1646  // Initally load the icons in the List view without any grouping
1647  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1648  viewImages->setModel( m );
1649 }
1650 
1652 {
1653  QString path = idx.data( Qt::UserRole + 1 ).toString();
1654 
1655  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1656  viewImages->setModel( m );
1657 
1658  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1659  emit changed();
1660 }
1661 
1663 {
1664  if ( !layer )
1665  {
1666  return;
1667  }
1668 
1669  //activate gui for svg parameters only if supported by the svg file
1670  bool hasFillParam, hasFillOpacityParam, hasOutlineParam, hasOutlineWidthParam, hasOutlineOpacityParam;
1671  QColor defaultFill, defaultOutline;
1672  double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity;
1673  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity;
1674  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
1675  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
1676  hasOutlineParam, hasDefaultOutlineColor, defaultOutline,
1677  hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth,
1678  hasOutlineOpacityParam, hasDefaultOutlineOpacity, defaultOutlineOpacity );
1679  mChangeColorButton->setEnabled( hasFillParam );
1680  mChangeColorButton->setAllowAlpha( hasFillOpacityParam );
1681  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1682  mChangeBorderColorButton->setAllowAlpha( hasOutlineOpacityParam );
1683  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1684 
1685  if ( hasFillParam )
1686  {
1687  QColor fill = layer->fillColor();
1688  double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
1689  if ( hasDefaultFillColor )
1690  {
1691  fill = defaultFill;
1692  }
1693  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
1694  mChangeColorButton->setColor( fill );
1695  }
1696  if ( hasOutlineParam )
1697  {
1698  QColor outline = layer->outlineColor();
1699  double existingOpacity = hasOutlineOpacityParam ? outline.alphaF() : 1.0;
1700  if ( hasDefaultOutlineColor )
1701  {
1702  outline = defaultOutline;
1703  }
1704  outline.setAlphaF( hasDefaultOutlineOpacity ? defaultOutlineOpacity : existingOpacity );
1705  mChangeBorderColorButton->setColor( outline );
1706  }
1707 
1708  mFileLineEdit->blockSignals( true );
1709  mFileLineEdit->setText( layer->path() );
1710  mFileLineEdit->blockSignals( false );
1711 
1712  mBorderWidthSpinBox->blockSignals( true );
1713  mBorderWidthSpinBox->setValue( hasDefaultOutlineWidth ? defaultOutlineWidth : layer->outlineWidth() );
1714  mBorderWidthSpinBox->blockSignals( false );
1715 }
1716 
1717 void QgsSvgMarkerSymbolLayerV2Widget::updateAssistantSymbol()
1718 {
1719  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1720  {
1721  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1722  }
1723  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1724  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
1725  if ( ddSize )
1726  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
1727 }
1728 
1729 
1731 {
1732  if ( !layer )
1733  {
1734  return;
1735  }
1736 
1737  if ( layer->layerType() != "SvgMarker" )
1738  return;
1739 
1740  // layer type is correct, we can do the cast
1741  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1742 
1743  // set values
1744 
1745  QAbstractItemModel* m = viewImages->model();
1746  QItemSelectionModel* selModel = viewImages->selectionModel();
1747  for ( int i = 0; i < m->rowCount(); i++ )
1748  {
1749  QModelIndex idx( m->index( i, 0 ) );
1750  if ( m->data( idx ).toString() == mLayer->path() )
1751  {
1752  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1753  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1754  setName( idx );
1755  break;
1756  }
1757  }
1758 
1759  spinSize->blockSignals( true );
1760  spinSize->setValue( mLayer->size() );
1761  spinSize->blockSignals( false );
1762  spinAngle->blockSignals( true );
1763  spinAngle->setValue( mLayer->angle() );
1764  spinAngle->blockSignals( false );
1765 
1766  // without blocking signals the value gets changed because of slot setOffset()
1767  spinOffsetX->blockSignals( true );
1768  spinOffsetX->setValue( mLayer->offset().x() );
1769  spinOffsetX->blockSignals( false );
1770  spinOffsetY->blockSignals( true );
1771  spinOffsetY->setValue( mLayer->offset().y() );
1772  spinOffsetY->blockSignals( false );
1773 
1774  mSizeUnitWidget->blockSignals( true );
1775  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1776  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1777  mSizeUnitWidget->blockSignals( false );
1778  mBorderWidthUnitWidget->blockSignals( true );
1779  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1780  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1781  mBorderWidthUnitWidget->blockSignals( false );
1782  mOffsetUnitWidget->blockSignals( true );
1783  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1784  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1785  mOffsetUnitWidget->blockSignals( false );
1786 
1787  //anchor points
1788  mHorizontalAnchorComboBox->blockSignals( true );
1789  mVerticalAnchorComboBox->blockSignals( true );
1790  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1791  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1792  mHorizontalAnchorComboBox->blockSignals( false );
1793  mVerticalAnchorComboBox->blockSignals( false );
1794 
1795  setGuiForSvg( mLayer );
1796 
1804  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
1805  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
1806 
1807  updateAssistantSymbol();
1808 }
1809 
1811 {
1812  return mLayer;
1813 }
1814 
1816 {
1817  QString name = idx.data( Qt::UserRole ).toString();
1818  mLayer->setPath( name );
1819  mFileLineEdit->setText( name );
1820 
1821  setGuiForSvg( mLayer );
1822  emit changed();
1823 }
1824 
1826 {
1827  mLayer->setSize( spinSize->value() );
1828  emit changed();
1829 }
1830 
1832 {
1833  mLayer->setAngle( spinAngle->value() );
1834  emit changed();
1835 }
1836 
1838 {
1839  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1840  emit changed();
1841 }
1842 
1844 {
1845  QSettings s;
1846  QString file = QFileDialog::getOpenFileName( nullptr,
1847  tr( "Select SVG file" ),
1848  s.value( "/UI/lastSVGMarkerDir", QDir::homePath() ).toString(),
1849  tr( "SVG files" ) + " (*.svg)" );
1850  QFileInfo fi( file );
1851  if ( file.isEmpty() || !fi.exists() )
1852  {
1853  return;
1854  }
1855  mFileLineEdit->setText( file );
1856  mLayer->setPath( file );
1857  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1858  setGuiForSvg( mLayer );
1859  emit changed();
1860 }
1861 
1863 {
1864  if ( !QFileInfo( text ).exists() )
1865  {
1866  return;
1867  }
1868  mLayer->setPath( text );
1869  setGuiForSvg( mLayer );
1870  emit changed();
1871 }
1872 
1874 {
1875  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1876  {
1877  QUrl url( mFileLineEdit->text() );
1878  if ( !url.isValid() )
1879  {
1880  return;
1881  }
1882  }
1883 
1884  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1885  mLayer->setPath( mFileLineEdit->text() );
1887 
1888  setGuiForSvg( mLayer );
1889  emit changed();
1890 }
1891 
1893 {
1894  if ( !mLayer )
1895  {
1896  return;
1897  }
1898 
1899  mLayer->setFillColor( color );
1900  emit changed();
1901 }
1902 
1904 {
1905  if ( !mLayer )
1906  {
1907  return;
1908  }
1909 
1910  mLayer->setOutlineColor( color );
1911  emit changed();
1912 }
1913 
1915 {
1916  if ( mLayer )
1917  {
1918  mLayer->setOutlineWidth( d );
1919  emit changed();
1920  }
1921 }
1922 
1924 {
1925  if ( mLayer )
1926  {
1927  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1928  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1929  emit changed();
1930  }
1931 }
1932 
1934 {
1935  if ( mLayer )
1936  {
1937  mLayer->setOutlineWidthUnit( mBorderWidthUnitWidget->unit() );
1938  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1939  emit changed();
1940  }
1941 }
1942 
1944 {
1945  if ( mLayer )
1946  {
1947  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1948  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1949  emit changed();
1950  }
1951 }
1952 
1954 {
1955  if ( mLayer )
1956  {
1958  emit changed();
1959  }
1960 }
1961 
1963 {
1964  if ( mLayer )
1965  {
1967  emit changed();
1968  }
1969 }
1970 
1972 
1974 {
1975  mLayer = nullptr;
1976  setupUi( this );
1977  mTextureWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1978  mSvgOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
1979  mSvgTreeView->setHeaderHidden( true );
1980  insertIcons();
1981 
1982  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1983  mChangeColorButton->setContext( "symbology" );
1984  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1985  mChangeBorderColorButton->setContext( "symbology" );
1986 
1987  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
1988  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1989 }
1990 
1992 {
1993  if ( !layer )
1994  {
1995  return;
1996  }
1997 
1998  if ( layer->layerType() != "SVGFill" )
1999  {
2000  return;
2001  }
2002 
2003  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
2004  if ( mLayer )
2005  {
2006  double width = mLayer->patternWidth();
2007  mTextureWidthSpinBox->blockSignals( true );
2008  mTextureWidthSpinBox->setValue( width );
2009  mTextureWidthSpinBox->blockSignals( false );
2010  mSVGLineEdit->setText( mLayer->svgFilePath() );
2011  mRotationSpinBox->blockSignals( true );
2012  mRotationSpinBox->setValue( mLayer->angle() );
2013  mRotationSpinBox->blockSignals( false );
2014  mTextureWidthUnitWidget->blockSignals( true );
2015  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2016  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2017  mTextureWidthUnitWidget->blockSignals( false );
2018  mSvgOutlineWidthUnitWidget->blockSignals( true );
2019  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2020  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2021  mSvgOutlineWidthUnitWidget->blockSignals( false );
2022  mChangeColorButton->blockSignals( true );
2023  mChangeColorButton->setColor( mLayer->svgFillColor() );
2024  mChangeColorButton->blockSignals( false );
2025  mChangeBorderColorButton->blockSignals( true );
2026  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2027  mChangeBorderColorButton->blockSignals( false );
2028  mBorderWidthSpinBox->blockSignals( true );
2029  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2030  mBorderWidthSpinBox->blockSignals( false );
2031  }
2032  updateParamGui( false );
2033 
2040 }
2041 
2043 {
2044  return mLayer;
2045 }
2046 
2047 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2048 {
2049  QString filePath = QFileDialog::getOpenFileName( nullptr, tr( "Select SVG texture file" ), QDir::homePath(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2050  if ( !filePath.isNull() )
2051  {
2052  mSVGLineEdit->setText( filePath );
2053  emit changed();
2054  }
2055 }
2056 
2057 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2058 {
2059  if ( mLayer )
2060  {
2061  mLayer->setPatternWidth( d );
2062  emit changed();
2063  }
2064 }
2065 
2066 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2067 {
2068  if ( !mLayer )
2069  {
2070  return;
2071  }
2072 
2073  QFileInfo fi( text );
2074  if ( !fi.exists() )
2075  {
2076  return;
2077  }
2078  mLayer->setSvgFilePath( text );
2079  updateParamGui();
2080  emit changed();
2081 }
2082 
2083 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2084 {
2085  if ( !mLayer )
2086  {
2087  return;
2088  }
2089 
2090  QFileInfo fi( mSVGLineEdit->text() );
2091  if ( !fi.exists() )
2092  {
2093  QUrl url( mSVGLineEdit->text() );
2094  if ( !url.isValid() )
2095  {
2096  return;
2097  }
2098  }
2099 
2100  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2101  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2103 
2104  updateParamGui();
2105  emit changed();
2106 }
2107 
2108 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2109 {
2110  QString file = item.data( Qt::UserRole ).toString();
2111  mLayer->setSvgFilePath( file );
2112  mSVGLineEdit->setText( file );
2113 
2114  updateParamGui();
2115  emit changed();
2116 }
2117 
2119 {
2120  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2121  mSvgTreeView->setModel( g );
2122  // Set the tree expanded at the first level
2123  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2124  for ( int i = 0; i < rows; i++ )
2125  {
2126  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2127  }
2128 
2129  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2130  mSvgListView->setModel( m );
2131 }
2132 
2133 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2134 {
2135  QString path = idx.data( Qt::UserRole + 1 ).toString();
2136 
2137  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2138  mSvgListView->setModel( m );
2139 
2140  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2141  emit changed();
2142 }
2143 
2144 
2145 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2146 {
2147  if ( mLayer )
2148  {
2149  mLayer->setAngle( d );
2150  emit changed();
2151  }
2152 }
2153 
2155 {
2156  //activate gui for svg parameters only if supported by the svg file
2157  bool hasFillParam, hasFillOpacityParam, hasOutlineParam, hasOutlineWidthParam, hasOutlineOpacityParam;
2158  QColor defaultFill, defaultOutline;
2159  double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity;
2160  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity;
2161  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, hasDefaultFillColor, defaultFill,
2162  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2163  hasOutlineParam, hasDefaultOutlineColor, defaultOutline,
2164  hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth,
2165  hasOutlineOpacityParam, hasDefaultOutlineOpacity, defaultOutlineOpacity );
2166  if ( resetValues )
2167  {
2168  QColor fill = mChangeColorButton->color();
2169  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2170  if ( hasDefaultFillColor )
2171  {
2172  fill = defaultFill;
2173  }
2174  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2175  mChangeColorButton->setColor( fill );
2176  }
2177  mChangeColorButton->setEnabled( hasFillParam );
2178  mChangeColorButton->setAllowAlpha( hasFillOpacityParam );
2179  if ( resetValues )
2180  {
2181  QColor outline = mChangeBorderColorButton->color();
2182  double newOpacity = hasOutlineOpacityParam ? outline.alphaF() : 1.0;
2183  if ( hasDefaultOutlineColor )
2184  {
2185  outline = defaultOutline;
2186  }
2187  outline.setAlphaF( hasDefaultOutlineOpacity ? defaultOutlineOpacity : newOpacity );
2188  mChangeBorderColorButton->setColor( outline );
2189  }
2190  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2191  mChangeBorderColorButton->setAllowAlpha( hasOutlineOpacityParam );
2192  if ( hasDefaultOutlineWidth && resetValues )
2193  {
2194  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2195  }
2196  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2197 }
2198 
2199 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2200 {
2201  if ( !mLayer )
2202  {
2203  return;
2204  }
2205 
2206  mLayer->setSvgFillColor( color );
2207  emit changed();
2208 }
2209 
2210 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2211 {
2212  if ( !mLayer )
2213  {
2214  return;
2215  }
2216 
2217  mLayer->setSvgOutlineColor( color );
2218  emit changed();
2219 }
2220 
2221 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2222 {
2223  if ( mLayer )
2224  {
2225  mLayer->setSvgOutlineWidth( d );
2226  emit changed();
2227  }
2228 }
2229 
2230 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2231 {
2232  if ( mLayer )
2233  {
2234  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2235  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2236  emit changed();
2237  }
2238 }
2239 
2240 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2241 {
2242  if ( mLayer )
2243  {
2244  mLayer->setSvgOutlineWidthUnit( mSvgOutlineWidthUnitWidget->unit() );
2245  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2246  emit changed();
2247  }
2248 }
2249 
2251 
2253  QgsSymbolLayerV2Widget( parent, vl ), mLayer( nullptr )
2254 {
2255  setupUi( this );
2256  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2257  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2258  mOffsetSpinBox->setClearValue( 0 );
2259 }
2260 
2262 {
2263  if ( layer->layerType() != "LinePatternFill" )
2264  {
2265  return;
2266  }
2267 
2268  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2269  if ( patternLayer )
2270  {
2271  mLayer = patternLayer;
2272  mAngleSpinBox->blockSignals( true );
2273  mAngleSpinBox->setValue( mLayer->lineAngle() );
2274  mAngleSpinBox->blockSignals( false );
2275  mDistanceSpinBox->blockSignals( true );
2276  mDistanceSpinBox->setValue( mLayer->distance() );
2277  mDistanceSpinBox->blockSignals( false );
2278  mOffsetSpinBox->blockSignals( true );
2279  mOffsetSpinBox->setValue( mLayer->offset() );
2280  mOffsetSpinBox->blockSignals( false );
2281 
2282  //units
2283  mDistanceUnitWidget->blockSignals( true );
2284  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2285  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2286  mDistanceUnitWidget->blockSignals( false );
2287  mOffsetUnitWidget->blockSignals( true );
2288  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2289  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2290  mOffsetUnitWidget->blockSignals( false );
2291  }
2292 
2295 }
2296 
2298 {
2299  return mLayer;
2300 }
2301 
2302 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2303 {
2304  if ( mLayer )
2305  {
2306  mLayer->setLineAngle( d );
2307  emit changed();
2308  }
2309 }
2310 
2311 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2312 {
2313  if ( mLayer )
2314  {
2315  mLayer->setDistance( d );
2316  emit changed();
2317  }
2318 }
2319 
2320 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2321 {
2322  if ( mLayer )
2323  {
2324  mLayer->setOffset( d );
2325  emit changed();
2326  }
2327 }
2328 
2329 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2330 {
2331  if ( mLayer )
2332  {
2333  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2334  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2335  emit changed();
2336  }
2337 }
2338 
2339 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2340 {
2341  if ( mLayer )
2342  {
2343  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2344  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2345  emit changed();
2346  }
2347 }
2348 
2350 
2352  QgsSymbolLayerV2Widget( parent, vl ), mLayer( nullptr )
2353 {
2354  setupUi( this );
2355  mHorizontalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2356  mVerticalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2357  mHorizontalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2358  mVerticalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2359 }
2360 
2361 
2363 {
2364  if ( !layer || layer->layerType() != "PointPatternFill" )
2365  {
2366  return;
2367  }
2368 
2369  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2370  mHorizontalDistanceSpinBox->blockSignals( true );
2371  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2372  mHorizontalDistanceSpinBox->blockSignals( false );
2373  mVerticalDistanceSpinBox->blockSignals( true );
2374  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2375  mVerticalDistanceSpinBox->blockSignals( false );
2376  mHorizontalDisplacementSpinBox->blockSignals( true );
2377  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2378  mHorizontalDisplacementSpinBox->blockSignals( false );
2379  mVerticalDisplacementSpinBox->blockSignals( true );
2380  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2381  mVerticalDisplacementSpinBox->blockSignals( false );
2382 
2383  mHorizontalDistanceUnitWidget->blockSignals( true );
2384  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2385  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2386  mHorizontalDistanceUnitWidget->blockSignals( false );
2387  mVerticalDistanceUnitWidget->blockSignals( true );
2388  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2389  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2390  mVerticalDistanceUnitWidget->blockSignals( false );
2391  mHorizontalDisplacementUnitWidget->blockSignals( true );
2392  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2393  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2394  mHorizontalDisplacementUnitWidget->blockSignals( false );
2395  mVerticalDisplacementUnitWidget->blockSignals( true );
2396  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2397  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2398  mVerticalDisplacementUnitWidget->blockSignals( false );
2399 
2400  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2402  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2403  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2404 }
2405 
2407 {
2408  return mLayer;
2409 }
2410 
2411 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2412 {
2413  if ( mLayer )
2414  {
2415  mLayer->setDistanceX( d );
2416  emit changed();
2417  }
2418 }
2419 
2420 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2421 {
2422  if ( mLayer )
2423  {
2424  mLayer->setDistanceY( d );
2425  emit changed();
2426  }
2427 }
2428 
2429 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2430 {
2431  if ( mLayer )
2432  {
2433  mLayer->setDisplacementX( d );
2434  emit changed();
2435  }
2436 }
2437 
2438 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2439 {
2440  if ( mLayer )
2441  {
2442  mLayer->setDisplacementY( d );
2443  emit changed();
2444  }
2445 }
2446 
2447 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2448 {
2449  if ( mLayer )
2450  {
2451  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2452  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2453  emit changed();
2454  }
2455 }
2456 
2457 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2458 {
2459  if ( mLayer )
2460  {
2461  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2462  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2463  emit changed();
2464  }
2465 }
2466 
2467 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2468 {
2469  if ( mLayer )
2470  {
2471  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2472  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2473  emit changed();
2474  }
2475 }
2476 
2477 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2478 {
2479  if ( mLayer )
2480  {
2481  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2482  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2483  emit changed();
2484  }
2485 }
2486 
2488 
2490  : QgsSymbolLayerV2Widget( parent, vl )
2491 {
2492  mLayer = nullptr;
2493 
2494  setupUi( this );
2496  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2497  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2499  scrollArea->setWidget( widgetChar );
2500 
2501  btnColor->setAllowAlpha( true );
2502  btnColor->setColorDialogTitle( tr( "Select symbol fill color" ) );
2503  btnColor->setContext( "symbology" );
2504  btnBorderColor->setAllowAlpha( true );
2505  btnBorderColor->setColorDialogTitle( tr( "Select symbol outline color" ) );
2506  btnBorderColor->setContext( "symbology" );
2507 
2508  spinOffsetX->setClearValue( 0.0 );
2509  spinOffsetY->setClearValue( 0.0 );
2510 
2511  //make a temporary symbol for the size assistant preview
2512  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
2513 
2514  if ( mVectorLayer )
2515  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
2516 
2517  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2518  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2519  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penJoinStyleChanged() ) );
2520  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2521  connect( btnBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
2522  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penJoinStyleChanged() ) );
2523  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2524  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2525  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2526  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2527  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
2528 }
2529 
2531 {
2532  delete mAssistantPreviewSymbol;
2533 }
2534 
2536 {
2537  if ( layer->layerType() != "FontMarker" )
2538  return;
2539 
2540  // layer type is correct, we can do the cast
2541  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2542 
2543  QFont layerFont( mLayer->fontFamily() );
2544  // set values
2545  whileBlocking( cboFont )->setCurrentFont( layerFont );
2546  whileBlocking( spinSize )->setValue( mLayer->size() );
2547  whileBlocking( btnColor )->setColor( mLayer->color() );
2548  whileBlocking( btnBorderColor )->setColor( mLayer->outlineColor() );
2549  whileBlocking( mBorderWidthSpinBox )->setValue( mLayer->outlineWidth() );
2550  whileBlocking( spinAngle )->setValue( mLayer->angle() );
2551 
2552  widgetChar->blockSignals( true );
2553  widgetChar->updateFont( layerFont );
2555  widgetChar->blockSignals( false );
2556 
2557  //block
2558  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
2559  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
2560 
2561  mSizeUnitWidget->blockSignals( true );
2562  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2563  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2564  mSizeUnitWidget->blockSignals( false );
2565 
2566  mBorderWidthUnitWidget->blockSignals( true );
2567  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
2568  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
2569  mBorderWidthUnitWidget->blockSignals( false );
2570 
2571  mOffsetUnitWidget->blockSignals( true );
2572  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2573  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2574  mOffsetUnitWidget->blockSignals( false );
2575 
2576  whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
2577 
2578  //anchor points
2579  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2580  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
2581 
2589  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
2590  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
2592 
2593  updateAssistantSymbol();
2594 }
2595 
2597 {
2598  return mLayer;
2599 }
2600 
2602 {
2603  mLayer->setFontFamily( font.family() );
2604  widgetChar->updateFont( font );
2605  emit changed();
2606 }
2607 
2609 {
2610  mLayer->setColor( color );
2611  emit changed();
2612 }
2613 
2615 {
2616  mLayer->setOutlineColor( color );
2617  emit changed();
2618 }
2619 
2621 {
2622  mLayer->setSize( size );
2623  //widgetChar->updateSize(size);
2624  emit changed();
2625 }
2626 
2628 {
2629  mLayer->setAngle( angle );
2630  emit changed();
2631 }
2632 
2634 {
2635  mLayer->setCharacter( chr );
2636  emit changed();
2637 }
2638 
2640 {
2641  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2642  emit changed();
2643 }
2644 
2645 void QgsFontMarkerSymbolLayerV2Widget::penJoinStyleChanged()
2646 {
2647  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
2648  emit changed();
2649 }
2650 
2652 {
2653  if ( mLayer )
2654  {
2655  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2656  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2657  emit changed();
2658  }
2659 }
2660 
2662 {
2663  if ( mLayer )
2664  {
2665  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2666  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2667  emit changed();
2668  }
2669 }
2670 
2672 {
2673  if ( mLayer )
2674  {
2675  mLayer->setOutlineWidthUnit( mSizeUnitWidget->unit() );
2676  mLayer->setOutlineWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2677  emit changed();
2678  }
2679 }
2680 
2682 {
2683  if ( mLayer )
2684  {
2686  emit changed();
2687  }
2688 }
2689 
2691 {
2692  if ( mLayer )
2693  {
2695  emit changed();
2696  }
2697 }
2698 
2700 {
2701  if ( mLayer )
2702  {
2703  mLayer->setOutlineWidth( d );
2704  emit changed();
2705  }
2706 }
2707 
2708 void QgsFontMarkerSymbolLayerV2Widget::updateAssistantSymbol()
2709 {
2710  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2711  {
2712  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2713  }
2714  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2715  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
2716  if ( ddSize )
2717  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
2718 }
2719 
2721 
2722 
2724  : QgsSymbolLayerV2Widget( parent, vl )
2725 {
2726  mLayer = nullptr;
2727 
2728  setupUi( this );
2729 }
2730 
2732 {
2733  if ( layer->layerType() != "CentroidFill" )
2734  return;
2735 
2736  // layer type is correct, we can do the cast
2737  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2738 
2739  // set values
2740  whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
2741  whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
2742 }
2743 
2745 {
2746  return mLayer;
2747 }
2748 
2749 void QgsCentroidFillSymbolLayerV2Widget::on_mDrawInsideCheckBox_stateChanged( int state )
2750 {
2751  mLayer->setPointOnSurface( state == Qt::Checked );
2752  emit changed();
2753 }
2754 
2755 void QgsCentroidFillSymbolLayerV2Widget::on_mDrawAllPartsCheckBox_stateChanged( int state )
2756 {
2757  mLayer->setPointOnAllParts( state == Qt::Checked );
2758  emit changed();
2759 }
2760 
2762 
2764  : QgsSymbolLayerV2Widget( parent, vl )
2765 {
2766  mLayer = nullptr;
2767  setupUi( this );
2768 
2770  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2771 
2772  mSpinOffsetX->setClearValue( 0.0 );
2773  mSpinOffsetY->setClearValue( 0.0 );
2774 
2775  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2776  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2777  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2778 }
2779 
2781 {
2782  if ( !layer )
2783  {
2784  return;
2785  }
2786 
2787  if ( layer->layerType() != "RasterFill" )
2788  {
2789  return;
2790  }
2791 
2792  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2793  if ( !mLayer )
2794  {
2795  return;
2796  }
2797 
2798  mImageLineEdit->blockSignals( true );
2799  mImageLineEdit->setText( mLayer->imageFilePath() );
2800  mImageLineEdit->blockSignals( false );
2801 
2802  cboCoordinateMode->blockSignals( true );
2803  switch ( mLayer->coordinateMode() )
2804  {
2806  cboCoordinateMode->setCurrentIndex( 1 );
2807  break;
2809  default:
2810  cboCoordinateMode->setCurrentIndex( 0 );
2811  break;
2812  }
2813  cboCoordinateMode->blockSignals( false );
2814  mSpinTransparency->blockSignals( true );
2815  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2816  mSpinTransparency->blockSignals( false );
2817  mSliderTransparency->blockSignals( true );
2818  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2819  mSliderTransparency->blockSignals( false );
2820  mRotationSpinBox->blockSignals( true );
2821  mRotationSpinBox->setValue( mLayer->angle() );
2822  mRotationSpinBox->blockSignals( false );
2823 
2824  mSpinOffsetX->blockSignals( true );
2825  mSpinOffsetX->setValue( mLayer->offset().x() );
2826  mSpinOffsetX->blockSignals( false );
2827  mSpinOffsetY->blockSignals( true );
2828  mSpinOffsetY->setValue( mLayer->offset().y() );
2829  mSpinOffsetY->blockSignals( false );
2830  mOffsetUnitWidget->blockSignals( true );
2831  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2832  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2833  mOffsetUnitWidget->blockSignals( false );
2834 
2835  mWidthSpinBox->blockSignals( true );
2836  mWidthSpinBox->setValue( mLayer->width() );
2837  mWidthSpinBox->blockSignals( false );
2838  mWidthUnitWidget->blockSignals( true );
2839  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
2840  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2841  mWidthUnitWidget->blockSignals( false );
2842  updatePreviewImage();
2843 
2848 }
2849 
2851 {
2852  return mLayer;
2853 }
2854 
2855 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2856 {
2857  QSettings s;
2858  QString openDir;
2859  QString lineEditText = mImageLineEdit->text();
2860  if ( !lineEditText.isEmpty() )
2861  {
2862  QFileInfo openDirFileInfo( lineEditText );
2863  openDir = openDirFileInfo.path();
2864  }
2865 
2866  if ( openDir.isEmpty() )
2867  {
2868  openDir = s.value( "/UI/lastRasterFillImageDir", QDir::homePath() ).toString();
2869  }
2870 
2871  //show file dialog
2872  QString filePath = QFileDialog::getOpenFileName( nullptr, tr( "Select image file" ), openDir );
2873  if ( !filePath.isNull() )
2874  {
2875  //check if file exists
2876  QFileInfo fileInfo( filePath );
2877  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2878  {
2879  QMessageBox::critical( nullptr, "Invalid file", "Error, file does not exist or is not readable" );
2880  return;
2881  }
2882 
2883  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2884  mImageLineEdit->setText( filePath );
2885  on_mImageLineEdit_editingFinished();
2886  }
2887 }
2888 
2889 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2890 {
2891  if ( !mLayer )
2892  {
2893  return;
2894  }
2895 
2896  QFileInfo fi( mImageLineEdit->text() );
2897  if ( !fi.exists() )
2898  {
2899  QUrl url( mImageLineEdit->text() );
2900  if ( !url.isValid() )
2901  {
2902  return;
2903  }
2904  }
2905 
2906  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2907  mLayer->setImageFilePath( mImageLineEdit->text() );
2908  updatePreviewImage();
2910 
2911  emit changed();
2912 }
2913 
2914 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2915 {
2916  switch ( index )
2917  {
2918  case 0:
2919  //feature coordinate mode
2921  break;
2922  case 1:
2923  //viewport coordinate mode
2925  break;
2926  }
2927 
2928  emit changed();
2929 }
2930 
2931 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2932 {
2933  if ( !mLayer )
2934  {
2935  return;
2936  }
2937 
2938  mLayer->setAlpha( value / 100.0 );
2939  emit changed();
2940  updatePreviewImage();
2941 }
2942 
2943 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2944 {
2945  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2946  emit changed();
2947 }
2948 
2949 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2950 {
2951  if ( !mLayer )
2952  {
2953  return;
2954  }
2955  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2956  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2957  emit changed();
2958 }
2959 
2960 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2961 {
2962  if ( mLayer )
2963  {
2964  mLayer->setAngle( d );
2965  emit changed();
2966  }
2967 }
2968 
2969 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2970 {
2971  if ( !mLayer )
2972  {
2973  return;
2974  }
2975  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
2976  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2977  emit changed();
2978 }
2979 
2980 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2981 {
2982  if ( !mLayer )
2983  {
2984  return;
2985  }
2986  mLayer->setWidth( d );
2987  emit changed();
2988 }
2989 
2990 
2991 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2992 {
2993  if ( !mLayer )
2994  {
2995  return;
2996  }
2997 
2998  QImage image( mLayer->imageFilePath() );
2999  if ( image.isNull() )
3000  {
3001  mLabelImagePreview->setPixmap( QPixmap() );
3002  return;
3003  }
3004 
3005  if ( image.height() > 150 || image.width() > 150 )
3006  {
3007  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
3008  }
3009 
3010  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3011  previewImage.fill( Qt::transparent );
3012  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3013  QPainter p;
3014  p.begin( &previewImage );
3015  //draw a checkerboard background
3016  uchar pixDataRGB[] = { 150, 150, 150, 150,
3017  100, 100, 100, 150,
3018  100, 100, 100, 150,
3019  150, 150, 150, 150
3020  };
3021  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3022  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3023  QBrush checkerBrush;
3024  checkerBrush.setTexture( pix );
3025  p.fillRect( imageRect, checkerBrush );
3026 
3027  if ( mLayer->alpha() < 1.0 )
3028  {
3029  p.setOpacity( mLayer->alpha() );
3030  }
3031 
3032  p.drawImage( imageRect.left(), imageRect.top(), image );
3033  p.end();
3034  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3035 }
3036 
3037 
3039 
3040 QgsSvgListModel::QgsSvgListModel( QObject* parent ) : QAbstractListModel( parent )
3041 {
3043 }
3044 
3045 QgsSvgListModel::QgsSvgListModel( QObject* parent, const QString& path ) : QAbstractListModel( parent )
3046 {
3047  mSvgFiles = QgsSymbolLayerV2Utils::listSvgFilesAt( path );
3048 }
3049 
3050 int QgsSvgListModel::rowCount( const QModelIndex& parent ) const
3051 {
3052  Q_UNUSED( parent );
3053  return mSvgFiles.count();
3054 }
3055 
3056 QVariant QgsSvgListModel::data( const QModelIndex& index, int role ) const
3057 {
3058  QString entry = mSvgFiles.at( index.row() );
3059 
3060  if ( role == Qt::DecorationRole ) // icon
3061  {
3062  QPixmap pixmap;
3063  if ( !QPixmapCache::find( entry, pixmap ) )
3064  {
3065  // render SVG file
3066  QColor fill, outline;
3067  double outlineWidth, fillOpacity, outlineOpacity;
3068  bool fillParam, fillOpacityParam, outlineParam, outlineWidthParam, outlineOpacityParam;
3069  bool hasDefaultFillColor = false, hasDefaultFillOpacity = false, hasDefaultOutlineColor = false,
3070  hasDefaultOutlineWidth = false, hasDefaultOutlineOpacity = false;
3071  QgsSvgCache::instance()->containsParams( entry, fillParam, hasDefaultFillColor, fill,
3072  fillOpacityParam, hasDefaultFillOpacity, fillOpacity,
3073  outlineParam, hasDefaultOutlineColor, outline,
3074  outlineWidthParam, hasDefaultOutlineWidth, outlineWidth,
3075  outlineOpacityParam, hasDefaultOutlineOpacity, outlineOpacity );
3076 
3077  //if defaults not set in symbol, use these values
3078  if ( !hasDefaultFillColor )
3079  fill = QColor( 200, 200, 200 );
3080  fill.setAlphaF( hasDefaultFillOpacity ? fillOpacity : 1.0 );
3081  if ( !hasDefaultOutlineColor )
3082  outline = Qt::black;
3083  outline.setAlphaF( hasDefaultOutlineOpacity ? outlineOpacity : 1.0 );
3084  if ( !hasDefaultOutlineWidth )
3085  outlineWidth = 0.6;
3086 
3087  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
3088  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
3089  pixmap = QPixmap::fromImage( img );
3090  QPixmapCache::insert( entry, pixmap );
3091  }
3092 
3093  return pixmap;
3094  }
3095  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
3096  {
3097  return entry;
3098  }
3099 
3100  return QVariant();
3101 }
3102 
3103 
3104 QgsSvgGroupsModel::QgsSvgGroupsModel( QObject* parent ) : QStandardItemModel( parent )
3105 {
3107  QStandardItem *parentItem = invisibleRootItem();
3108 
3109  for ( int i = 0; i < svgPaths.size(); i++ )
3110  {
3111  QDir dir( svgPaths[i] );
3112  QStandardItem *baseGroup;
3113 
3114  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
3115  {
3116  baseGroup = new QStandardItem( QString( "App Symbols" ) );
3117  }
3118  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
3119  {
3120  baseGroup = new QStandardItem( QString( "User Symbols" ) );
3121  }
3122  else
3123  {
3124  baseGroup = new QStandardItem( dir.dirName() );
3125  }
3126  baseGroup->setData( QVariant( svgPaths[i] ) );
3127  baseGroup->setEditable( false );
3128  baseGroup->setCheckable( false );
3129  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
3130  baseGroup->setToolTip( dir.path() );
3131  parentItem->appendRow( baseGroup );
3132  createTree( baseGroup );
3133  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
3134  }
3135 }
3136 
3137 void QgsSvgGroupsModel::createTree( QStandardItem*& parentGroup )
3138 {
3139  QDir parentDir( parentGroup->data().toString() );
3140  Q_FOREACH ( const QString& item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3141  {
3142  QStandardItem* group = new QStandardItem( item );
3143  group->setData( QVariant( parentDir.path() + '/' + item ) );
3144  group->setEditable( false );
3145  group->setCheckable( false );
3146  group->setToolTip( parentDir.path() + '/' + item );
3147  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
3148  parentGroup->appendRow( group );
3149  createTree( group );
3150  }
3151 }
3152 
3153 
3155 
3156 
3157 
3158 
3159 
3160 
3162  : QgsSymbolLayerV2Widget( parent, vl )
3163  , mLayer( nullptr )
3164 {
3165  setupUi( this );
3166  modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer*>( vl ) );
3167  modificationExpressionSelector->loadFieldNames();
3168  cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPolygonLayer.svg" ), tr( "Polygon / MultiPolygon" ), QgsSymbolV2::Fill );
3169  cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconLineLayer.svg" ), tr( "LineString / MultiLineString" ), QgsSymbolV2::Line );
3170  cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPointLayer.svg" ), tr( "Point / MultiPoint" ), QgsSymbolV2::Marker );
3171  connect( modificationExpressionSelector, SIGNAL( expressionParsed( bool ) ), this, SLOT( updateExpression() ) );
3172  connect( cbxGeometryType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateSymbolType() ) );
3173 }
3174 
3176 {
3177  mLayer = static_cast<QgsGeometryGeneratorSymbolLayerV2*>( l );
3178 
3180  modificationExpressionSelector->setExpressionContext( *mPresetExpressionContext );
3181  modificationExpressionSelector->setExpressionText( mLayer->geometryExpression() );
3182  cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
3183 }
3184 
3186 {
3187  return mLayer;
3188 }
3189 
3190 void QgsGeometryGeneratorSymbolLayerWidget::updateExpression()
3191 {
3192  mLayer->setGeometryExpression( modificationExpressionSelector->expressionText() );
3193 
3194  emit changed();
3195 }
3196 
3197 void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
3198 {
3199  mLayer->setSymbolType( static_cast<QgsSymbolV2::SymbolType>( cbxGeometryType->itemData( cbxGeometryType->currentIndex() ).toInt() ) );
3200 
3201  emit symbolChanged();
3202 }
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&#39;s boundary...
void setOutlineStyle(Qt::PenStyle outlineStyle)
Set outline join style.
QgsShapeburstFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=nullptr)
QgsSymbolV2::OutputUnit outlineWidthUnit() const
bool isReadable() const
void setOutlineColor(const QColor &color) override
Set outline color.
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon&#39;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 setPenJoinStyle(Qt::PenJoinStyle style)
Set outline join style.
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
QString path() const
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())
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
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&#39;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
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
Set outline width map unit scale.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
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:67
Calculate scale by the diameter.
Definition: qgssymbolv2.h:90
void setOffset(QPointF offset)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image&#39;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:79
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 setColorBorder(const QColor &color)
Set outline color.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void on_mVerticalAnchorComboBox_currentIndexChanged(int index)
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features...
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:78
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&#39;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
Qt::PenJoinStyle penJoinStyle() const
Get outline join style.
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:64
double offsetAlongLine() const
Returns the offset along the line for the marker placement.
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit u)
A class for filling symbols with a repeated raster image.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
Qt::PenStyle borderStyle() const
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.
QString path() const
void fill(uint pixelValue)
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill&#39;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)
void setToolTip(const QString &toolTip)
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&#39;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.
QColor outlineColor() const override
Get outline color.
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:65
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:131
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)
bool exists() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
QgsCentroidFillSymbolLayerV2 * mLayer
QColor svgOutlineColor() const
void setOutlineWidth(double width)
Set outline width.
bool blockSignals(bool block)
static QString pkgDataPath()
Returns the common root path of all application data directories.
bool contains(QChar ch, Qt::CaseSensitivity cs) const
GradientSpread gradientSpread() const
Gradient spread mode.
const QgsMapUnitScale & distanceMapUnitScale() const
const QFont & font() 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:445
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&#39;s offset.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QVariant value(const QString &key, const QVariant &defaultValue) const
void setBorderColor(const QColor &color)
const QgsMapUnitScale & outlineWidthMapUnitScale() const
Get outline width map unit scale.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:328
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill&#39;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:443
QString dirName() const
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.
Qt::PenJoinStyle penJoinStyle() const
Get outline join style.
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
Get outline join style.
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:80
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)
void setPenJoinStyle(Qt::PenJoinStyle style)
Set outline join style.
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 const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
double outlineWidth() const
Get outline width.
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
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
Set outline width unit.
Calculate scale by the area.
Definition: qgssymbolv2.h:89
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&#39;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&#39;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)
QString absolutePath() const
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()
QObject * parent() const
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].
Abstract base class for color ramps.
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&#39;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&#39;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.
QgsSymbolV2::OutputUnit outlineWidthUnit() const
Get outline width unit.
void setBorderStyle(Qt::PenStyle borderStyle)
QgsLinePatternFillSymbolLayerWidget(const QgsVectorLayer *vl, QWidget *parent=nullptr)