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