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 
51 {
52  const QgsDataDefined* dd = symbolLayer()->getDataDefinedProperty( propertyName );
53  button->init( mVectorLayer, dd, type, description );
54  button->setProperty( "propertyName", propertyName );
55  connect( button, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
56  connect( button, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
57 }
58 
60 {
61  QgsDataDefinedButton* button = qobject_cast<QgsDataDefinedButton*>( sender() );
62  const QString propertyName( button->property( "propertyName" ).toString() );
63 
64  QgsDataDefined* dd = symbolLayer()->getDataDefinedProperty( propertyName );
65  if ( !dd )
66  {
67  dd = new QgsDataDefined();
68  symbolLayer()->setDataDefinedProperty( propertyName, dd );
69  }
70  button->updateDataDefined( dd );
71 
72  emit changed();
73 }
74 
76 {
77  QString label = entryName;
78  if ( entryName == "size" )
79  {
80  label = tr( "Size" );
81  QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
82  if ( layer )
83  {
84  switch ( layer->scaleMethod() )
85  {
87  label += " (" + tr( "area" ) + ")";
88  break;
90  label += " (" + tr( "diameter" ) + ")";
91  break;
92  }
93  }
94  }
95  return label;
96 }
97 
99  : QgsSymbolLayerV2Widget( parent, vl )
100 {
101  mLayer = NULL;
102 
103  setupUi( this );
104  mPenWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
105  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
106  mDashPatternUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
107 
108  btnChangeColor->setAllowAlpha( true );
109  btnChangeColor->setColorDialogTitle( tr( "Select line color" ) );
110  btnChangeColor->setContext( "symbology" );
111 
112  spinOffset->setClearValue( 0.0 );
113 
114  if ( vl && vl->geometryType() != QGis::Polygon )
115  {
116  //draw inside polygon checkbox only makes sense for polygon layers
117  mDrawInsideCheckBox->hide();
118  }
119 
120  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
121  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
122  connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
123  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
124  connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
125  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
127 
128 }
129 
131 {
132  if ( !layer || layer->layerType() != "SimpleLine" )
133  return;
134 
135  // layer type is correct, we can do the cast
136  mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
137 
138  // set units
139  mPenWidthUnitWidget->blockSignals( true );
140  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
141  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
142  mPenWidthUnitWidget->blockSignals( false );
143  mOffsetUnitWidget->blockSignals( true );
144  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
145  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
146  mOffsetUnitWidget->blockSignals( false );
147  mDashPatternUnitWidget->blockSignals( true );
148  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
149  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
150  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
151  mDashPatternUnitWidget->blockSignals( false );
152 
153  // set values
154  spinWidth->blockSignals( true );
155  spinWidth->setValue( mLayer->width() );
156  spinWidth->blockSignals( false );
157  btnChangeColor->blockSignals( true );
158  btnChangeColor->setColor( mLayer->color() );
159  btnChangeColor->blockSignals( false );
160  spinOffset->blockSignals( true );
161  spinOffset->setValue( mLayer->offset() );
162  spinOffset->blockSignals( false );
163  cboPenStyle->blockSignals( true );
164  cboJoinStyle->blockSignals( true );
165  cboCapStyle->blockSignals( true );
166  cboPenStyle->setPenStyle( mLayer->penStyle() );
167  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
168  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
169  cboPenStyle->blockSignals( false );
170  cboJoinStyle->blockSignals( false );
171  cboCapStyle->blockSignals( false );
172 
173  //use a custom dash pattern?
174  bool useCustomDashPattern = mLayer->useCustomDashPattern();
175  mChangePatternButton->setEnabled( useCustomDashPattern );
176  label_3->setEnabled( !useCustomDashPattern );
177  cboPenStyle->setEnabled( !useCustomDashPattern );
178  mCustomCheckBox->blockSignals( true );
179  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
180  mCustomCheckBox->blockSignals( false );
181 
182  //draw inside polygon?
183  bool drawInsidePolygon = mLayer->drawInsidePolygon();
184  mDrawInsideCheckBox->blockSignals( true );
185  mDrawInsideCheckBox->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
186  mDrawInsideCheckBox->blockSignals( false );
187 
189 
197 }
198 
200 {
201  return mLayer;
202 }
203 
205 {
206  mLayer->setWidth( spinWidth->value() );
208  emit changed();
209 }
210 
212 {
213  mLayer->setColor( color );
215  emit changed();
216 }
217 
219 {
220  mLayer->setPenStyle( cboPenStyle->penStyle() );
221  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
222  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
223  emit changed();
224 }
225 
227 {
228  mLayer->setOffset( spinOffset->value() );
230  emit changed();
231 }
232 
234 {
235  bool checked = ( state == Qt::Checked );
236  mChangePatternButton->setEnabled( checked );
237  label_3->setEnabled( !checked );
238  cboPenStyle->setEnabled( !checked );
239 
240  mLayer->setUseCustomDashPattern( checked );
241  emit changed();
242 }
243 
245 {
247  if ( d.exec() == QDialog::Accepted )
248  {
249  mLayer->setCustomDashVector( d.dashDotVector() );
251  emit changed();
252  }
253 }
254 
256 {
257  if ( mLayer )
258  {
259  mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
260  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
261  emit changed();
262  }
263 }
264 
266 {
267  if ( mLayer )
268  {
269  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
270  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
271  emit changed();
272  }
273 }
274 
276 {
277  if ( mLayer )
278  {
279  mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
280  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
281  emit changed();
282  }
283 }
284 
286 {
287  bool checked = ( state == Qt::Checked );
288  mLayer->setDrawInsidePolygon( checked );
289  emit changed();
290 }
291 
292 
294 {
295  if ( !mLayer )
296  {
297  return;
298  }
299  QgsSimpleLineSymbolLayerV2* layerCopy = dynamic_cast<QgsSimpleLineSymbolLayerV2*>( mLayer->clone() );
300  if ( !layerCopy )
301  {
302  return;
303  }
304  layerCopy->setUseCustomDashPattern( true );
305  QIcon buttonIcon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( layerCopy, QgsSymbolV2::MM, mChangePatternButton->iconSize() );
306  mChangePatternButton->setIcon( buttonIcon );
307  delete layerCopy;
308 }
309 
310 
312 
313 
315  : QgsSymbolLayerV2Widget( parent, vl )
316 {
317  mLayer = NULL;
318 
319  setupUi( this );
320  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
321  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
322  mOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
323 
324  btnChangeColorFill->setAllowAlpha( true );
325  btnChangeColorFill->setColorDialogTitle( tr( "Select fill color" ) );
326  btnChangeColorFill->setContext( "symbology" );
327  btnChangeColorFill->setShowNoColor( true );
328  btnChangeColorFill->setNoColorString( tr( "Transparent fill" ) );
329  btnChangeColorBorder->setAllowAlpha( true );
330  btnChangeColorBorder->setColorDialogTitle( tr( "Select border color" ) );
331  btnChangeColorBorder->setContext( "symbology" );
332  btnChangeColorBorder->setShowNoColor( true );
333  btnChangeColorBorder->setNoColorString( tr( "Transparent border" ) );
334 
335  spinOffsetX->setClearValue( 0.0 );
336  spinOffsetY->setClearValue( 0.0 );
337 
338  //make a temporary symbol for the size assistant preview
339  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
340 
341  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
342 
343  QSize size = lstNames->iconSize();
344  QStringList names;
345  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
346  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
347  double markerSize = DEFAULT_POINT_SIZE * 2;
348  for ( int i = 0; i < names.count(); ++i )
349  {
350  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
352  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
353  item->setData( Qt::UserRole, names[i] );
354  delete lyr;
355  }
356 
357  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
358  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
359  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
360  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
361  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
362  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
363  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
364  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
365 }
366 
368 {
369  delete mAssistantPreviewSymbol;
370 }
371 
373 {
374  if ( layer->layerType() != "SimpleMarker" )
375  return;
376 
377  // layer type is correct, we can do the cast
378  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
379 
380  // set values
381  QString name = mLayer->name();
382  for ( int i = 0; i < lstNames->count(); ++i )
383  {
384  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
385  {
386  lstNames->setCurrentRow( i );
387  break;
388  }
389  }
390  btnChangeColorBorder->blockSignals( true );
391  btnChangeColorBorder->setColor( mLayer->borderColor() );
392  btnChangeColorBorder->blockSignals( false );
393  btnChangeColorFill->blockSignals( true );
394  btnChangeColorFill->setColor( mLayer->color() );
395  btnChangeColorFill->blockSignals( false );
396  spinSize->blockSignals( true );
397  spinSize->setValue( mLayer->size() );
398  spinSize->blockSignals( false );
399  spinAngle->blockSignals( true );
400  spinAngle->setValue( mLayer->angle() );
401  spinAngle->blockSignals( false );
402  mOutlineStyleComboBox->blockSignals( true );
403  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
404  mOutlineStyleComboBox->blockSignals( false );
405  mOutlineWidthSpinBox->blockSignals( true );
406  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
407  mOutlineWidthSpinBox->blockSignals( false );
408 
409  // without blocking signals the value gets changed because of slot setOffset()
410  spinOffsetX->blockSignals( true );
411  spinOffsetX->setValue( mLayer->offset().x() );
412  spinOffsetX->blockSignals( false );
413  spinOffsetY->blockSignals( true );
414  spinOffsetY->setValue( mLayer->offset().y() );
415  spinOffsetY->blockSignals( false );
416 
417  mSizeUnitWidget->blockSignals( true );
418  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
419  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
420  mSizeUnitWidget->blockSignals( false );
421  mOffsetUnitWidget->blockSignals( true );
422  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
423  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
424  mOffsetUnitWidget->blockSignals( false );
425  mOutlineWidthUnitWidget->blockSignals( true );
426  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
427  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
428  mOutlineWidthUnitWidget->blockSignals( false );
429 
430  //anchor points
431  mHorizontalAnchorComboBox->blockSignals( true );
432  mVerticalAnchorComboBox->blockSignals( true );
433  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
434  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
435  mHorizontalAnchorComboBox->blockSignals( false );
436  mVerticalAnchorComboBox->blockSignals( false );
437 
438  registerDataDefinedButton( mNameDDBtn, "name", QgsDataDefinedButton::String, tr( "string " ) + QString( "[<b>square</b>|<b>rectangle</b>|<b>diamond</b>|"
439  "<b>pentagon</b>|<b>triangle</b>|<b>equilateral_triangle</b>|"
440  "<b>star</b>|<b>regular_star</b>|<b>arrow</b>|<b>filled_arrowhead</b>|"
441  "<b>circle</b>|<b>cross</b>|<b>x</b>|"
442  "<b>cross2</b>|<b>line</b>|<b>arrowhead</b>]" ) );
450  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
451  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
452 
453  updateAssistantSymbol();
454 }
455 
457 {
458  return mLayer;
459 }
460 
462 {
463  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
464  emit changed();
465 }
466 
468 {
469  mLayer->setBorderColor( color );
470  emit changed();
471 }
472 
474 {
475  mLayer->setColor( color );
476  emit changed();
477 }
478 
480 {
481  mLayer->setSize( spinSize->value() );
482  emit changed();
483 }
484 
486 {
487  mLayer->setAngle( spinAngle->value() );
488  emit changed();
489 }
490 
492 {
493  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
494  emit changed();
495 }
496 
498 {
499  Q_UNUSED( index );
500 
501  if ( mLayer )
502  {
503  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
504  emit changed();
505  }
506 }
507 
509 {
510  if ( mLayer )
511  {
512  mLayer->setOutlineWidth( d );
513  emit changed();
514  }
515 }
516 
518 {
519  if ( mLayer )
520  {
521  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
522  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
523  emit changed();
524  }
525 }
526 
528 {
529  if ( mLayer )
530  {
531  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
532  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
533  emit changed();
534  }
535 }
536 
538 {
539  if ( mLayer )
540  {
541  mLayer->setOutlineWidthUnit( mOutlineWidthUnitWidget->unit() );
542  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
543  emit changed();
544  }
545 }
546 
548 {
549  if ( mLayer )
550  {
552  emit changed();
553  }
554 }
555 
557 {
558  if ( mLayer )
559  {
561  emit changed();
562  }
563 }
564 
565 void QgsSimpleMarkerSymbolLayerV2Widget::updateAssistantSymbol()
566 {
567  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
568  {
569  mAssistantPreviewSymbol->deleteSymbolLayer( i );
570  }
571  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
572  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
573  if ( ddSize )
574  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
575 }
576 
577 
579 
581  : QgsSymbolLayerV2Widget( parent, vl )
582 {
583  mLayer = NULL;
584 
585  setupUi( this );
586  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
587  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
588 
589  btnChangeColor->setAllowAlpha( true );
590  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
591  btnChangeColor->setContext( "symbology" );
592  btnChangeColor->setShowNoColor( true );
593  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
594  btnChangeBorderColor->setAllowAlpha( true );
595  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
596  btnChangeBorderColor->setContext( "symbology" );
597  btnChangeBorderColor->setShowNoColor( true );
598  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
599 
600  spinOffsetX->setClearValue( 0.0 );
601  spinOffsetY->setClearValue( 0.0 );
602 
603  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
604  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
605  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
606  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
607  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
608  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
609  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
610  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
611 }
612 
614 {
615  if ( layer->layerType() != "SimpleFill" )
616  return;
617 
618  // layer type is correct, we can do the cast
619  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
620 
621  // set values
622  btnChangeColor->blockSignals( true );
623  btnChangeColor->setColor( mLayer->color() );
624  btnChangeColor->blockSignals( false );
625  cboFillStyle->blockSignals( true );
626  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
627  cboFillStyle->blockSignals( false );
628  btnChangeBorderColor->blockSignals( true );
629  btnChangeBorderColor->setColor( mLayer->borderColor() );
630  btnChangeBorderColor->blockSignals( false );
631  cboBorderStyle->blockSignals( true );
632  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
633  cboBorderStyle->blockSignals( false );
634  spinBorderWidth->blockSignals( true );
635  spinBorderWidth->setValue( mLayer->borderWidth() );
636  spinBorderWidth->blockSignals( false );
637  cboJoinStyle->blockSignals( true );
638  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
639  cboJoinStyle->blockSignals( false );
640  spinOffsetX->blockSignals( true );
641  spinOffsetX->setValue( mLayer->offset().x() );
642  spinOffsetX->blockSignals( false );
643  spinOffsetY->blockSignals( true );
644  spinOffsetY->setValue( mLayer->offset().y() );
645  spinOffsetY->blockSignals( false );
646 
647  mBorderWidthUnitWidget->blockSignals( true );
648  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
649  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
650  mBorderWidthUnitWidget->blockSignals( false );
651  mOffsetUnitWidget->blockSignals( true );
652  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
653  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
654  mOffsetUnitWidget->blockSignals( false );
655 
662 
663 }
664 
666 {
667  return mLayer;
668 }
669 
671 {
672  mLayer->setColor( color );
673  emit changed();
674 }
675 
677 {
678  mLayer->setBorderColor( color );
679  emit changed();
680 }
681 
683 {
684  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
685  emit changed();
686 }
687 
689 {
690  mLayer->setBorderWidth( spinBorderWidth->value() );
691  emit changed();
692 }
693 
695 {
696  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
697  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
698  emit changed();
699 }
700 
702 {
703  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
704  emit changed();
705 }
706 
708 {
709  if ( mLayer )
710  {
711  mLayer->setBorderWidthUnit( mBorderWidthUnitWidget->unit() );
712  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
713  emit changed();
714  }
715 }
716 
718 {
719  if ( mLayer )
720  {
721  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
722  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
723  emit changed();
724  }
725 }
726 
728 
730  : QgsSymbolLayerV2Widget( parent, vl )
731 {
732  mLayer = NULL;
733 
734  setupUi( this );
735  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
736 
737  cboGradientColorRamp->setShowGradientOnly( true );
738  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
739 
740  btnChangeColor->setAllowAlpha( true );
741  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
742  btnChangeColor->setContext( "symbology" );
743  btnChangeColor->setShowNoColor( true );
744  btnChangeColor->setNoColorString( tr( "Transparent" ) );
745  btnChangeColor2->setAllowAlpha( true );
746  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
747  btnChangeColor2->setContext( "symbology" );
748  btnChangeColor2->setShowNoColor( true );
749  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
750 
751  spinOffsetX->setClearValue( 0.0 );
752  spinOffsetY->setClearValue( 0.0 );
753 
754  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
755  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
756  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
757  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
758  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
759  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
760  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
761  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
762  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
763  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
764  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
765  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
766  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
767  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
768  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
769 }
770 
772 {
773  if ( layer->layerType() != "GradientFill" )
774  return;
775 
776  // layer type is correct, we can do the cast
777  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
778 
779  // set values
780  btnChangeColor->blockSignals( true );
781  btnChangeColor->setColor( mLayer->color() );
782  btnChangeColor->blockSignals( false );
783  btnChangeColor2->blockSignals( true );
784  btnChangeColor2->setColor( mLayer->color2() );
785  btnChangeColor2->blockSignals( false );
786 
788  {
789  radioTwoColor->setChecked( true );
790  cboGradientColorRamp->setEnabled( false );
791  }
792  else
793  {
794  radioColorRamp->setChecked( true );
795  btnChangeColor->setEnabled( false );
796  btnChangeColor2->setEnabled( false );
797  }
798 
799  // set source color ramp
800  if ( mLayer->colorRamp() )
801  {
802  cboGradientColorRamp->blockSignals( true );
803  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
804  cboGradientColorRamp->blockSignals( false );
805  }
806 
807  cboGradientType->blockSignals( true );
808  switch ( mLayer->gradientType() )
809  {
811  cboGradientType->setCurrentIndex( 0 );
812  break;
814  cboGradientType->setCurrentIndex( 1 );
815  break;
817  cboGradientType->setCurrentIndex( 2 );
818  break;
819  }
820  cboGradientType->blockSignals( false );
821 
822  cboCoordinateMode->blockSignals( true );
823  switch ( mLayer->coordinateMode() )
824  {
826  cboCoordinateMode->setCurrentIndex( 1 );
827  checkRefPoint1Centroid->setEnabled( false );
828  checkRefPoint2Centroid->setEnabled( false );
829  break;
831  default:
832  cboCoordinateMode->setCurrentIndex( 0 );
833  break;
834  }
835  cboCoordinateMode->blockSignals( false );
836 
837  cboGradientSpread->blockSignals( true );
838  switch ( mLayer->gradientSpread() )
839  {
841  cboGradientSpread->setCurrentIndex( 0 );
842  break;
844  cboGradientSpread->setCurrentIndex( 1 );
845  break;
847  cboGradientSpread->setCurrentIndex( 2 );
848  break;
849  }
850  cboGradientSpread->blockSignals( false );
851 
852  spinRefPoint1X->blockSignals( true );
853  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
854  spinRefPoint1X->blockSignals( false );
855  spinRefPoint1Y->blockSignals( true );
856  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
857  spinRefPoint1Y->blockSignals( false );
858  checkRefPoint1Centroid->blockSignals( true );
859  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
861  {
862  spinRefPoint1X->setEnabled( false );
863  spinRefPoint1Y->setEnabled( false );
864  }
865  checkRefPoint1Centroid->blockSignals( false );
866  spinRefPoint2X->blockSignals( true );
867  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
868  spinRefPoint2X->blockSignals( false );
869  spinRefPoint2Y->blockSignals( true );
870  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
871  spinRefPoint2Y->blockSignals( false );
872  checkRefPoint2Centroid->blockSignals( true );
873  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
875  {
876  spinRefPoint2X->setEnabled( false );
877  spinRefPoint2Y->setEnabled( false );
878  }
879  checkRefPoint2Centroid->blockSignals( false );
880 
881  spinOffsetX->blockSignals( true );
882  spinOffsetX->setValue( mLayer->offset().x() );
883  spinOffsetX->blockSignals( false );
884  spinOffsetY->blockSignals( true );
885  spinOffsetY->setValue( mLayer->offset().y() );
886  spinOffsetY->blockSignals( false );
887  mSpinAngle->blockSignals( true );
888  mSpinAngle->setValue( mLayer->angle() );
889  mSpinAngle->blockSignals( false );
890 
891  mOffsetUnitWidget->blockSignals( true );
892  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
893  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
894  mOffsetUnitWidget->blockSignals( false );
895 
904  registerDataDefinedButton( mRefPoint1CentroidDDBtn, "reference1_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
907  registerDataDefinedButton( mRefPoint2CentroidDDBtn, "reference2_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
908 }
909 
911 {
912  return mLayer;
913 }
914 
916 {
917  mLayer->setColor( color );
918  emit changed();
919 }
920 
922 {
923  mLayer->setColor2( color );
924  emit changed();
925 }
926 
928 {
929  if ( radioTwoColor->isChecked() )
930  {
932  }
933  else
934  {
936  }
937  emit changed();
938 }
939 
941 {
942  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
943  if ( ramp == NULL )
944  return;
945 
946  mLayer->setColorRamp( ramp );
947  emit changed();
948 }
949 
951 {
952  if ( mLayer->colorRamp()->type() == "gradient" )
953  {
955  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
956  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
957 
958  if ( dlg.exec() && gradRamp )
959  {
960  mLayer->setColorRamp( gradRamp );
961  cboGradientColorRamp->blockSignals( true );
962  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
963  cboGradientColorRamp->blockSignals( false );
964  emit changed();
965  }
966  else
967  {
968  delete ramp;
969  }
970  }
971 }
972 
974 {
975  switch ( index )
976  {
977  case 0:
979  //set sensible default reference points
980  spinRefPoint1X->setValue( 0.5 );
981  spinRefPoint1Y->setValue( 0 );
982  spinRefPoint2X->setValue( 0.5 );
983  spinRefPoint2Y->setValue( 1 );
984  break;
985  case 1:
987  //set sensible default reference points
988  spinRefPoint1X->setValue( 0 );
989  spinRefPoint1Y->setValue( 0 );
990  spinRefPoint2X->setValue( 1 );
991  spinRefPoint2Y->setValue( 1 );
992  break;
993  case 2:
995  spinRefPoint1X->setValue( 0.5 );
996  spinRefPoint1Y->setValue( 0.5 );
997  spinRefPoint2X->setValue( 1 );
998  spinRefPoint2Y->setValue( 1 );
999  break;
1000  }
1001  emit changed();
1002 }
1003 
1005 {
1006 
1007  switch ( index )
1008  {
1009  case 0:
1010  //feature coordinate mode
1012  //allow choice of centroid reference positions
1013  checkRefPoint1Centroid->setEnabled( true );
1014  checkRefPoint2Centroid->setEnabled( true );
1015  break;
1016  case 1:
1017  //viewport coordinate mode
1019  //disable choice of centroid reference positions
1020  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1021  checkRefPoint1Centroid->setEnabled( false );
1022  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1023  checkRefPoint2Centroid->setEnabled( false );
1024  break;
1025  }
1026 
1027  emit changed();
1028 }
1029 
1031 {
1032  switch ( index )
1033  {
1034  case 0:
1036  break;
1037  case 1:
1039  break;
1040  case 2:
1042  break;
1043  }
1044 
1045  emit changed();
1046 }
1047 
1049 {
1050  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1051  emit changed();
1052 }
1053 
1055 {
1056  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1057  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1058  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1059  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1060  emit changed();
1061 }
1062 
1064 {
1065  mLayer->setAngle( value );
1066  emit changed();
1067 }
1068 
1070 {
1071  if ( mLayer )
1072  {
1073  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1074  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1075  emit changed();
1076  }
1077 }
1078 
1080 
1082  : QgsSymbolLayerV2Widget( parent, vl )
1083 {
1084  mLayer = NULL;
1085 
1086  setupUi( this );
1087  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1088  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1089 
1090  btnChangeColor->setAllowAlpha( true );
1091  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1092  btnChangeColor->setContext( "symbology" );
1093  btnChangeColor->setShowNoColor( true );
1094  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1095  btnChangeColor2->setAllowAlpha( true );
1096  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1097  btnChangeColor2->setContext( "symbology" );
1098  btnChangeColor2->setShowNoColor( true );
1099  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1100 
1101  spinOffsetX->setClearValue( 0.0 );
1102  spinOffsetY->setClearValue( 0.0 );
1103 
1104  cboGradientColorRamp->setShowGradientOnly( true );
1105  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1106 
1107  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1108  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1109  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1110  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1111  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1112  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1113 
1114  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1115  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1116 }
1117 
1119 {
1120  if ( layer->layerType() != "ShapeburstFill" )
1121  return;
1122 
1123  // layer type is correct, we can do the cast
1124  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1125 
1126  // set values
1127  btnChangeColor->blockSignals( true );
1128  btnChangeColor->setColor( mLayer->color() );
1129  btnChangeColor->blockSignals( false );
1130  btnChangeColor2->blockSignals( true );
1131  btnChangeColor2->setColor( mLayer->color2() );
1132  btnChangeColor2->blockSignals( false );
1133 
1135  {
1136  radioTwoColor->setChecked( true );
1137  cboGradientColorRamp->setEnabled( false );
1138  }
1139  else
1140  {
1141  radioColorRamp->setChecked( true );
1142  btnChangeColor->setEnabled( false );
1143  btnChangeColor2->setEnabled( false );
1144  }
1145 
1146  mSpinBlurRadius->blockSignals( true );
1147  mBlurSlider->blockSignals( true );
1148  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1149  mBlurSlider->setValue( mLayer->blurRadius() );
1150  mSpinBlurRadius->blockSignals( false );
1151  mBlurSlider->blockSignals( false );
1152 
1153  mSpinMaxDistance->blockSignals( true );
1154  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1155  mSpinMaxDistance->blockSignals( false );
1156 
1157  mRadioUseWholeShape->blockSignals( true );
1158  mRadioUseMaxDistance->blockSignals( true );
1159  if ( mLayer->useWholeShape() )
1160  {
1161  mRadioUseWholeShape->setChecked( true );
1162  mSpinMaxDistance->setEnabled( false );
1163  mDistanceUnitWidget->setEnabled( false );
1164  }
1165  else
1166  {
1167  mRadioUseMaxDistance->setChecked( true );
1168  mSpinMaxDistance->setEnabled( true );
1169  mDistanceUnitWidget->setEnabled( true );
1170  }
1171  mRadioUseWholeShape->blockSignals( false );
1172  mRadioUseMaxDistance->blockSignals( false );
1173 
1174  mDistanceUnitWidget->blockSignals( true );
1175  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1176  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1177  mDistanceUnitWidget->blockSignals( false );
1178 
1179  mIgnoreRingsCheckBox->blockSignals( true );
1180  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1181  mIgnoreRingsCheckBox->blockSignals( false );
1182 
1183  // set source color ramp
1184  if ( mLayer->colorRamp() )
1185  {
1186  cboGradientColorRamp->blockSignals( true );
1187  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1188  cboGradientColorRamp->blockSignals( false );
1189  }
1190 
1191  spinOffsetX->blockSignals( true );
1192  spinOffsetX->setValue( mLayer->offset().x() );
1193  spinOffsetX->blockSignals( false );
1194  spinOffsetY->blockSignals( true );
1195  spinOffsetY->setValue( mLayer->offset().y() );
1196  spinOffsetY->blockSignals( false );
1197  mOffsetUnitWidget->blockSignals( true );
1198  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1199  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1200  mOffsetUnitWidget->blockSignals( false );
1201 
1204  registerDataDefinedButton( mBlurRadiusDDBtn, "blur_radius", QgsDataDefinedButton::Int, tr( "Integer between 0 and 18" ) );
1205  registerDataDefinedButton( mShadeWholeShapeDDBtn, "use_whole_shape", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1208 }
1209 
1211 {
1212  return mLayer;
1213 }
1214 
1216 {
1217  if ( mLayer )
1218  {
1219  mLayer->setColor( color );
1220  emit changed();
1221  }
1222 }
1223 
1225 {
1226  if ( mLayer )
1227  {
1228  mLayer->setColor2( color );
1229  emit changed();
1230  }
1231 }
1232 
1234 {
1235  if ( !mLayer )
1236  {
1237  return;
1238  }
1239 
1240  if ( radioTwoColor->isChecked() )
1241  {
1243  }
1244  else
1245  {
1247  }
1248  emit changed();
1249 }
1250 
1252 {
1253  if ( mLayer )
1254  {
1255  mLayer->setBlurRadius( value );
1256  emit changed();
1257  }
1258 }
1259 
1261 {
1262  if ( mLayer )
1263  {
1264  mLayer->setMaxDistance( value );
1265  emit changed();
1266  }
1267 }
1268 
1270 {
1271  if ( mLayer )
1272  {
1273  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1274  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1275  emit changed();
1276  }
1277 }
1278 
1280 {
1281  if ( mLayer )
1282  {
1283  mLayer->setUseWholeShape( value );
1284  mDistanceUnitWidget->setEnabled( !value );
1285  emit changed();
1286  }
1287 }
1288 
1290 {
1291  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1292  if ( ramp == NULL )
1293  return;
1294 
1295  mLayer->setColorRamp( ramp );
1296  emit changed();
1297 }
1298 
1300 {
1301  if ( mLayer->colorRamp()->type() == "gradient" )
1302  {
1304  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
1305  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
1306 
1307  if ( dlg.exec() && gradRamp )
1308  {
1309  mLayer->setColorRamp( gradRamp );
1310  cboGradientColorRamp->blockSignals( true );
1311  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1312  cboGradientColorRamp->blockSignals( false );
1313  emit changed();
1314  }
1315  else
1316  {
1317  delete ramp;
1318  }
1319  }
1320 }
1321 
1323 {
1324  if ( mLayer )
1325  {
1326  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1327  emit changed();
1328  }
1329 }
1330 
1332 {
1333  if ( mLayer )
1334  {
1335  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1336  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1337  emit changed();
1338  }
1339 }
1340 
1341 
1343 {
1344  bool checked = ( state == Qt::Checked );
1345  mLayer->setIgnoreRings( checked );
1346  emit changed();
1347 }
1348 
1350 
1352  : QgsSymbolLayerV2Widget( parent, vl )
1353 {
1354  mLayer = NULL;
1355 
1356  setupUi( this );
1357  mIntervalUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1358  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1359  mOffsetAlongLineUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1360 
1361  spinOffset->setClearValue( 0.0 );
1362 
1363  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1364  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1365  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1366  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1367  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1368  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1369  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1370  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1371  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1372 }
1373 
1375 {
1376  if ( layer->layerType() != "MarkerLine" )
1377  return;
1378 
1379  // layer type is correct, we can do the cast
1380  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1381 
1382  // set values
1383  spinInterval->blockSignals( true );
1384  spinInterval->setValue( mLayer->interval() );
1385  spinInterval->blockSignals( false );
1386  mSpinOffsetAlongLine->blockSignals( true );
1387  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1388  mSpinOffsetAlongLine->blockSignals( false );
1389  chkRotateMarker->blockSignals( true );
1390  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1391  chkRotateMarker->blockSignals( false );
1392  spinOffset->blockSignals( true );
1393  spinOffset->setValue( mLayer->offset() );
1394  spinOffset->blockSignals( false );
1396  radInterval->setChecked( true );
1398  radVertex->setChecked( true );
1400  radVertexLast->setChecked( true );
1402  radCentralPoint->setChecked( true );
1403  else
1404  radVertexFirst->setChecked( true );
1405 
1406  // set units
1407  mIntervalUnitWidget->blockSignals( true );
1408  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1409  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1410  mIntervalUnitWidget->blockSignals( false );
1411  mOffsetUnitWidget->blockSignals( true );
1412  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1413  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1414  mOffsetUnitWidget->blockSignals( false );
1415  mOffsetAlongLineUnitWidget->blockSignals( true );
1416  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1417  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1418  mOffsetAlongLineUnitWidget->blockSignals( false );
1419 
1420  setPlacement(); // update gui
1421 
1424  registerDataDefinedButton( mPlacementDDBtn, "placement", QgsDataDefinedButton::String, tr( "string " ) + QString( "[<b>vertex</b>|<b>lastvertex</b>|<b>firstvertex</b>|<b>centerpoint</b>]" ) );
1425  registerDataDefinedButton( mOffsetAlongLineDDBtn, "offset_along_line", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
1426 }
1427 
1429 {
1430  return mLayer;
1431 }
1432 
1434 {
1435  mLayer->setInterval( val );
1436  emit changed();
1437 }
1438 
1440 {
1441  mLayer->setOffsetAlongLine( val );
1442  emit changed();
1443 }
1444 
1446 {
1447  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1448  emit changed();
1449 }
1450 
1452 {
1453  mLayer->setOffset( spinOffset->value() );
1454  emit changed();
1455 }
1456 
1458 {
1459  bool interval = radInterval->isChecked();
1460  spinInterval->setEnabled( interval );
1461  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1462  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1463  if ( radInterval->isChecked() )
1465  else if ( radVertex->isChecked() )
1467  else if ( radVertexLast->isChecked() )
1469  else if ( radVertexFirst->isChecked() )
1471  else
1473 
1474  emit changed();
1475 }
1476 
1478 {
1479  if ( mLayer )
1480  {
1481  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1482  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1483  emit changed();
1484  }
1485 }
1486 
1488 {
1489  if ( mLayer )
1490  {
1491  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1492  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1493  emit changed();
1494  }
1495 }
1496 
1498 {
1499  if ( mLayer )
1500  {
1501  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1502  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1503  }
1504  emit changed();
1505 }
1506 
1508 
1509 
1511  : QgsSymbolLayerV2Widget( parent, vl )
1512 {
1513  mLayer = NULL;
1514 
1515  setupUi( this );
1516  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1517  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1518  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1519  viewGroups->setHeaderHidden( true );
1520 
1521  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1522  mChangeColorButton->setContext( "symbology" );
1523  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1524  mChangeColorButton->setContext( "symbology" );
1525 
1526  spinOffsetX->setClearValue( 0.0 );
1527  spinOffsetY->setClearValue( 0.0 );
1528 
1529  populateList();
1530 
1531  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1532  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1533  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1534  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1535  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1536  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1537  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
1538 
1539  //make a temporary symbol for the size assistant preview
1540  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
1541  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
1542 }
1543 
1545 {
1546  delete mAssistantPreviewSymbol;
1547 }
1548 
1549 #include <QTime>
1550 #include <QAbstractListModel>
1551 #include <QPixmapCache>
1552 #include <QStyle>
1553 
1555 {
1556  public:
1558  {
1560  }
1561 
1562  // Constructor to create model for icons in a specific path
1564  {
1566  }
1567 
1568  int rowCount( const QModelIndex & parent = QModelIndex() ) const override
1569  {
1570  Q_UNUSED( parent );
1571  return mSvgFiles.count();
1572  }
1573 
1574  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override
1575  {
1576  QString entry = mSvgFiles.at( index.row() );
1577 
1578  if ( role == Qt::DecorationRole ) // icon
1579  {
1580  QPixmap pixmap;
1581  if ( !QPixmapCache::find( entry, pixmap ) )
1582  {
1583  // render SVG file
1584  QColor fill, outline;
1585  double outlineWidth;
1586  bool fillParam, outlineParam, outlineWidthParam;
1587  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1588 
1589  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1590  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1591  pixmap = QPixmap::fromImage( img );
1592  QPixmapCache::insert( entry, pixmap );
1593  }
1594 
1595  return pixmap;
1596  }
1597  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1598  {
1599  return entry;
1600  }
1601 
1602  return QVariant();
1603  }
1604 
1605  protected:
1607 };
1608 
1610 {
1611  public:
1613  {
1615  QStandardItem *parentItem = invisibleRootItem();
1616 
1617  for ( int i = 0; i < svgPaths.size(); i++ )
1618  {
1619  QDir dir( svgPaths[i] );
1620  QStandardItem *baseGroup;
1621 
1622  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1623  {
1624  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1625  }
1626  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1627  {
1628  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1629  }
1630  else
1631  {
1632  baseGroup = new QStandardItem( dir.dirName() );
1633  }
1634  baseGroup->setData( QVariant( svgPaths[i] ) );
1635  baseGroup->setEditable( false );
1636  baseGroup->setCheckable( false );
1637  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1638  baseGroup->setToolTip( dir.path() );
1639  parentItem->appendRow( baseGroup );
1640  createTree( baseGroup );
1641  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1642  }
1643  }
1644  private:
1645  void createTree( QStandardItem* &parentGroup )
1646  {
1647  QDir parentDir( parentGroup->data().toString() );
1648  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1649  {
1650  QStandardItem* group = new QStandardItem( item );
1651  group->setData( QVariant( parentDir.path() + "/" + item ) );
1652  group->setEditable( false );
1653  group->setCheckable( false );
1654  group->setToolTip( parentDir.path() + "/" + item );
1655  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1656  parentGroup->appendRow( group );
1657  createTree( group );
1658  }
1659  }
1660 };
1661 
1663 {
1664  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1665  viewGroups->setModel( g );
1666  // Set the tree expanded at the first level
1667  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1668  for ( int i = 0; i < rows; i++ )
1669  {
1670  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1671  }
1672 
1673  // Initally load the icons in the List view without any grouping
1674  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1675  viewImages->setModel( m );
1676 }
1677 
1679 {
1680  QString path = idx.data( Qt::UserRole + 1 ).toString();
1681 
1682  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1683  viewImages->setModel( m );
1684 
1685  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1686  emit changed();
1687 }
1688 
1690 {
1691  if ( !layer )
1692  {
1693  return;
1694  }
1695 
1696  //activate gui for svg parameters only if supported by the svg file
1697  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1698  QColor defaultFill, defaultOutline;
1699  double defaultOutlineWidth;
1700  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1701  mChangeColorButton->setEnabled( hasFillParam );
1702  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1703  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1704 
1705  if ( hasFillParam )
1706  {
1707  if ( layer->fillColor().isValid() )
1708  {
1709  mChangeColorButton->setColor( layer->fillColor() );
1710  }
1711  else
1712  {
1713  mChangeColorButton->setColor( defaultFill );
1714  }
1715  }
1716  if ( hasOutlineParam )
1717  {
1718  if ( layer->outlineColor().isValid() )
1719  {
1720  mChangeBorderColorButton->setColor( layer->outlineColor() );
1721  }
1722  else
1723  {
1724  mChangeBorderColorButton->setColor( defaultOutline );
1725  }
1726  }
1727 
1728  mFileLineEdit->blockSignals( true );
1729  mFileLineEdit->setText( layer->path() );
1730  mFileLineEdit->blockSignals( false );
1731 
1732  mBorderWidthSpinBox->blockSignals( true );
1733  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1734  mBorderWidthSpinBox->blockSignals( false );
1735 }
1736 
1737 void QgsSvgMarkerSymbolLayerV2Widget::updateAssistantSymbol()
1738 {
1739  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1740  {
1741  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1742  }
1743  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1744  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
1745  if ( ddSize )
1746  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
1747 }
1748 
1749 
1751 {
1752  if ( !layer )
1753  {
1754  return;
1755  }
1756 
1757  if ( layer->layerType() != "SvgMarker" )
1758  return;
1759 
1760  // layer type is correct, we can do the cast
1761  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1762 
1763  // set values
1764 
1765  QAbstractItemModel* m = viewImages->model();
1766  QItemSelectionModel* selModel = viewImages->selectionModel();
1767  for ( int i = 0; i < m->rowCount(); i++ )
1768  {
1769  QModelIndex idx( m->index( i, 0 ) );
1770  if ( m->data( idx ).toString() == mLayer->path() )
1771  {
1772  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1773  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1774  setName( idx );
1775  break;
1776  }
1777  }
1778 
1779  spinSize->blockSignals( true );
1780  spinSize->setValue( mLayer->size() );
1781  spinSize->blockSignals( false );
1782  spinAngle->blockSignals( true );
1783  spinAngle->setValue( mLayer->angle() );
1784  spinAngle->blockSignals( false );
1785 
1786  // without blocking signals the value gets changed because of slot setOffset()
1787  spinOffsetX->blockSignals( true );
1788  spinOffsetX->setValue( mLayer->offset().x() );
1789  spinOffsetX->blockSignals( false );
1790  spinOffsetY->blockSignals( true );
1791  spinOffsetY->setValue( mLayer->offset().y() );
1792  spinOffsetY->blockSignals( false );
1793 
1794  mSizeUnitWidget->blockSignals( true );
1795  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1796  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1797  mSizeUnitWidget->blockSignals( false );
1798  mBorderWidthUnitWidget->blockSignals( true );
1799  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1800  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1801  mBorderWidthUnitWidget->blockSignals( false );
1802  mOffsetUnitWidget->blockSignals( true );
1803  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1804  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1805  mOffsetUnitWidget->blockSignals( false );
1806 
1807  //anchor points
1808  mHorizontalAnchorComboBox->blockSignals( true );
1809  mVerticalAnchorComboBox->blockSignals( true );
1810  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1811  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1812  mHorizontalAnchorComboBox->blockSignals( false );
1813  mVerticalAnchorComboBox->blockSignals( false );
1814 
1815  setGuiForSvg( mLayer );
1816 
1824  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
1825  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
1826 
1827  updateAssistantSymbol();
1828 }
1829 
1831 {
1832  return mLayer;
1833 }
1834 
1836 {
1837  QString name = idx.data( Qt::UserRole ).toString();
1838  mLayer->setPath( name );
1839  mFileLineEdit->setText( name );
1840 
1841  setGuiForSvg( mLayer );
1842  emit changed();
1843 }
1844 
1846 {
1847  mLayer->setSize( spinSize->value() );
1848  emit changed();
1849 }
1850 
1852 {
1853  mLayer->setAngle( spinAngle->value() );
1854  emit changed();
1855 }
1856 
1858 {
1859  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1860  emit changed();
1861 }
1862 
1864 {
1865  QSettings s;
1867  tr( "Select SVG file" ),
1868  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1869  tr( "SVG files" ) + " (*.svg)" );
1870  QFileInfo fi( file );
1871  if ( file.isEmpty() || !fi.exists() )
1872  {
1873  return;
1874  }
1875  mFileLineEdit->setText( file );
1876  mLayer->setPath( file );
1877  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1878  emit changed();
1879 }
1880 
1882 {
1883  if ( !QFileInfo( text ).exists() )
1884  {
1885  return;
1886  }
1887  mLayer->setPath( text );
1888  setGuiForSvg( mLayer );
1889  emit changed();
1890 }
1891 
1893 {
1894  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1895  {
1896  QUrl url( mFileLineEdit->text() );
1897  if ( !url.isValid() )
1898  {
1899  return;
1900  }
1901  }
1902 
1903  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1904  mLayer->setPath( mFileLineEdit->text() );
1906 
1907  setGuiForSvg( mLayer );
1908  emit changed();
1909 }
1910 
1912 {
1913  if ( !mLayer )
1914  {
1915  return;
1916  }
1917 
1918  mLayer->setFillColor( color );
1919  emit changed();
1920 }
1921 
1923 {
1924  if ( !mLayer )
1925  {
1926  return;
1927  }
1928 
1929  mLayer->setOutlineColor( color );
1930  emit changed();
1931 }
1932 
1934 {
1935  if ( mLayer )
1936  {
1937  mLayer->setOutlineWidth( d );
1938  emit changed();
1939  }
1940 }
1941 
1943 {
1944  if ( mLayer )
1945  {
1946  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1947  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1948  emit changed();
1949  }
1950 }
1951 
1953 {
1954  if ( mLayer )
1955  {
1956  mLayer->setOutlineWidthUnit( mBorderWidthUnitWidget->unit() );
1957  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1958  emit changed();
1959  }
1960 }
1961 
1963 {
1964  if ( mLayer )
1965  {
1966  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1967  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1968  emit changed();
1969  }
1970 }
1971 
1973 {
1974  if ( mLayer )
1975  {
1977  emit changed();
1978  }
1979 }
1980 
1982 {
1983  if ( mLayer )
1984  {
1986  emit changed();
1987  }
1988 }
1989 
1991 
1993 {
1994  mLayer = 0;
1995  setupUi( this );
1996  mTextureWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1997  mSvgOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1998  mSvgTreeView->setHeaderHidden( true );
1999  insertIcons();
2000 
2001  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
2002  mChangeColorButton->setContext( "symbology" );
2003  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
2004  mChangeBorderColorButton->setContext( "symbology" );
2005 
2006  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2007  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
2008 }
2009 
2011 {
2012  if ( !layer )
2013  {
2014  return;
2015  }
2016 
2017  if ( layer->layerType() != "SVGFill" )
2018  {
2019  return;
2020  }
2021 
2022  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
2023  if ( mLayer )
2024  {
2025  double width = mLayer->patternWidth();
2026  mTextureWidthSpinBox->blockSignals( true );
2027  mTextureWidthSpinBox->setValue( width );
2028  mTextureWidthSpinBox->blockSignals( false );
2029  mSVGLineEdit->setText( mLayer->svgFilePath() );
2030  mRotationSpinBox->blockSignals( true );
2031  mRotationSpinBox->setValue( mLayer->angle() );
2032  mRotationSpinBox->blockSignals( false );
2033  mTextureWidthUnitWidget->blockSignals( true );
2034  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2035  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2036  mTextureWidthUnitWidget->blockSignals( false );
2037  mSvgOutlineWidthUnitWidget->blockSignals( true );
2038  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2039  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2040  mSvgOutlineWidthUnitWidget->blockSignals( false );
2041  mChangeColorButton->blockSignals( true );
2042  mChangeColorButton->setColor( mLayer->svgFillColor() );
2043  mChangeColorButton->blockSignals( false );
2044  mChangeBorderColorButton->blockSignals( true );
2045  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2046  mChangeBorderColorButton->blockSignals( false );
2047  mBorderWidthSpinBox->blockSignals( true );
2048  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2049  mBorderWidthSpinBox->blockSignals( false );
2050  }
2051  updateParamGui( false );
2052 
2059 }
2060 
2062 {
2063  return mLayer;
2064 }
2065 
2066 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2067 {
2068  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2069  if ( !filePath.isNull() )
2070  {
2071  mSVGLineEdit->setText( filePath );
2072  emit changed();
2073  }
2074 }
2075 
2076 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2077 {
2078  if ( mLayer )
2079  {
2080  mLayer->setPatternWidth( d );
2081  emit changed();
2082  }
2083 }
2084 
2085 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2086 {
2087  if ( !mLayer )
2088  {
2089  return;
2090  }
2091 
2092  QFileInfo fi( text );
2093  if ( !fi.exists() )
2094  {
2095  return;
2096  }
2097  mLayer->setSvgFilePath( text );
2098  updateParamGui();
2099  emit changed();
2100 }
2101 
2102 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2103 {
2104  if ( !mLayer )
2105  {
2106  return;
2107  }
2108 
2109  QFileInfo fi( mSVGLineEdit->text() );
2110  if ( !fi.exists() )
2111  {
2112  QUrl url( mSVGLineEdit->text() );
2113  if ( !url.isValid() )
2114  {
2115  return;
2116  }
2117  }
2118 
2119  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2120  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2122 
2123  updateParamGui();
2124  emit changed();
2125 }
2126 
2127 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2128 {
2129  QString file = item.data( Qt::UserRole ).toString();
2130  mLayer->setSvgFilePath( file );
2131  mSVGLineEdit->setText( file );
2132 
2133  updateParamGui();
2134  emit changed();
2135 }
2136 
2138 {
2139  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2140  mSvgTreeView->setModel( g );
2141  // Set the tree expanded at the first level
2142  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2143  for ( int i = 0; i < rows; i++ )
2144  {
2145  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2146  }
2147 
2148  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2149  mSvgListView->setModel( m );
2150 }
2151 
2152 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2153 {
2154  QString path = idx.data( Qt::UserRole + 1 ).toString();
2155 
2156  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2157  mSvgListView->setModel( m );
2158 
2159  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2160  emit changed();
2161 }
2162 
2163 
2164 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2165 {
2166  if ( mLayer )
2167  {
2168  mLayer->setAngle( d );
2169  emit changed();
2170  }
2171 }
2172 
2174 {
2175  //activate gui for svg parameters only if supported by the svg file
2176  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2177  QColor defaultFill, defaultOutline;
2178  double defaultOutlineWidth;
2179  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2180  if ( hasFillParam && resetValues )
2181  {
2182  mChangeColorButton->setColor( defaultFill );
2183  }
2184  mChangeColorButton->setEnabled( hasFillParam );
2185  if ( hasOutlineParam && resetValues )
2186  {
2187  mChangeBorderColorButton->setColor( defaultOutline );
2188  }
2189  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2190  if ( hasOutlineWidthParam && resetValues )
2191  {
2192  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2193  }
2194  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2195 }
2196 
2197 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2198 {
2199  if ( !mLayer )
2200  {
2201  return;
2202  }
2203 
2204  mLayer->setSvgFillColor( color );
2205  emit changed();
2206 }
2207 
2208 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2209 {
2210  if ( !mLayer )
2211  {
2212  return;
2213  }
2214 
2215  mLayer->setSvgOutlineColor( color );
2216  emit changed();
2217 }
2218 
2219 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2220 {
2221  if ( mLayer )
2222  {
2223  mLayer->setSvgOutlineWidth( d );
2224  emit changed();
2225  }
2226 }
2227 
2228 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2229 {
2230  if ( mLayer )
2231  {
2232  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2233  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2234  emit changed();
2235  }
2236 }
2237 
2238 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2239 {
2240  if ( mLayer )
2241  {
2242  mLayer->setSvgOutlineWidthUnit( mSvgOutlineWidthUnitWidget->unit() );
2243  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2244  emit changed();
2245  }
2246 }
2247 
2249 
2251  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2252 {
2253  setupUi( this );
2254  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2255  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2256 }
2257 
2259 {
2260  if ( layer->layerType() != "LinePatternFill" )
2261  {
2262  return;
2263  }
2264 
2265  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2266  if ( patternLayer )
2267  {
2268  mLayer = patternLayer;
2269  mAngleSpinBox->blockSignals( true );
2270  mAngleSpinBox->setValue( mLayer->lineAngle() );
2271  mAngleSpinBox->blockSignals( false );
2272  mDistanceSpinBox->blockSignals( true );
2273  mDistanceSpinBox->setValue( mLayer->distance() );
2274  mDistanceSpinBox->blockSignals( false );
2275  mOffsetSpinBox->blockSignals( true );
2276  mOffsetSpinBox->setValue( mLayer->offset() );
2277  mOffsetSpinBox->blockSignals( false );
2278 
2279  //units
2280  mDistanceUnitWidget->blockSignals( true );
2281  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2282  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2283  mDistanceUnitWidget->blockSignals( false );
2284  mOffsetUnitWidget->blockSignals( true );
2285  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2286  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2287  mOffsetUnitWidget->blockSignals( false );
2288  }
2289 
2292 }
2293 
2295 {
2296  return mLayer;
2297 }
2298 
2299 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2300 {
2301  if ( mLayer )
2302  {
2303  mLayer->setLineAngle( d );
2304  emit changed();
2305  }
2306 }
2307 
2308 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2309 {
2310  if ( mLayer )
2311  {
2312  mLayer->setDistance( d );
2313  emit changed();
2314  }
2315 }
2316 
2317 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2318 {
2319  if ( mLayer )
2320  {
2321  mLayer->setOffset( d );
2322  emit changed();
2323  }
2324 }
2325 
2326 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2327 {
2328  if ( mLayer )
2329  {
2330  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2331  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2332  emit changed();
2333  }
2334 }
2335 
2336 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2337 {
2338  if ( mLayer )
2339  {
2340  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2341  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2342  emit changed();
2343  }
2344 }
2345 
2347 
2349  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2350 {
2351  setupUi( this );
2352  mHorizontalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2353  mVerticalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2354  mHorizontalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2355  mVerticalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2356 }
2357 
2358 
2360 {
2361  if ( !layer || layer->layerType() != "PointPatternFill" )
2362  {
2363  return;
2364  }
2365 
2366  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2367  mHorizontalDistanceSpinBox->blockSignals( true );
2368  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2369  mHorizontalDistanceSpinBox->blockSignals( false );
2370  mVerticalDistanceSpinBox->blockSignals( true );
2371  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2372  mVerticalDistanceSpinBox->blockSignals( false );
2373  mHorizontalDisplacementSpinBox->blockSignals( true );
2374  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2375  mHorizontalDisplacementSpinBox->blockSignals( false );
2376  mVerticalDisplacementSpinBox->blockSignals( true );
2377  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2378  mVerticalDisplacementSpinBox->blockSignals( false );
2379 
2380  mHorizontalDistanceUnitWidget->blockSignals( true );
2381  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2382  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2383  mHorizontalDistanceUnitWidget->blockSignals( false );
2384  mVerticalDistanceUnitWidget->blockSignals( true );
2385  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2386  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2387  mVerticalDistanceUnitWidget->blockSignals( false );
2388  mHorizontalDisplacementUnitWidget->blockSignals( true );
2389  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2390  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2391  mHorizontalDisplacementUnitWidget->blockSignals( false );
2392  mVerticalDisplacementUnitWidget->blockSignals( true );
2393  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2394  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2395  mVerticalDisplacementUnitWidget->blockSignals( false );
2396 
2397  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2399  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2400  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2401 }
2402 
2404 {
2405  return mLayer;
2406 }
2407 
2408 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2409 {
2410  if ( mLayer )
2411  {
2412  mLayer->setDistanceX( d );
2413  emit changed();
2414  }
2415 }
2416 
2417 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2418 {
2419  if ( mLayer )
2420  {
2421  mLayer->setDistanceY( d );
2422  emit changed();
2423  }
2424 }
2425 
2426 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2427 {
2428  if ( mLayer )
2429  {
2430  mLayer->setDisplacementX( d );
2431  emit changed();
2432  }
2433 }
2434 
2435 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2436 {
2437  if ( mLayer )
2438  {
2439  mLayer->setDisplacementY( d );
2440  emit changed();
2441  }
2442 }
2443 
2444 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2445 {
2446  if ( mLayer )
2447  {
2448  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2449  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2450  emit changed();
2451  }
2452 }
2453 
2454 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2455 {
2456  if ( mLayer )
2457  {
2458  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2459  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2460  emit changed();
2461  }
2462 }
2463 
2464 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2465 {
2466  if ( mLayer )
2467  {
2468  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2469  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2470  emit changed();
2471  }
2472 }
2473 
2474 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2475 {
2476  if ( mLayer )
2477  {
2478  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2479  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2480  emit changed();
2481  }
2482 }
2483 
2485 
2487  : QgsSymbolLayerV2Widget( parent, vl )
2488 {
2489  mLayer = NULL;
2490 
2491  setupUi( this );
2492  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2493  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2495  scrollArea->setWidget( widgetChar );
2496 
2497  btnColor->setAllowAlpha( true );
2498  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2499  btnColor->setContext( "symbology" );
2500 
2501  spinOffsetX->setClearValue( 0.0 );
2502  spinOffsetY->setClearValue( 0.0 );
2503 
2504  //make a temporary symbol for the size assistant preview
2505  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
2506 
2507  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
2508 
2509  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2510  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2511  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2512  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2513  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2514  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2515  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2516  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
2517 }
2518 
2520 {
2521  delete mAssistantPreviewSymbol;
2522 }
2523 
2525 {
2526  if ( layer->layerType() != "FontMarker" )
2527  return;
2528 
2529  // layer type is correct, we can do the cast
2530  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2531 
2532  QFont layerFont( mLayer->fontFamily() );
2533  // set values
2534  cboFont->blockSignals( true );
2535  cboFont->setCurrentFont( layerFont );
2536  cboFont->blockSignals( false );
2537  spinSize->blockSignals( true );
2538  spinSize->setValue( mLayer->size() );
2539  spinSize->blockSignals( false );
2540  btnColor->blockSignals( true );
2541  btnColor->setColor( mLayer->color() );
2542  btnColor->blockSignals( false );
2543  spinAngle->blockSignals( true );
2544  spinAngle->setValue( mLayer->angle() );
2545  spinAngle->blockSignals( false );
2546 
2547  widgetChar->blockSignals( true );
2548  widgetChar->updateFont( layerFont );
2550  widgetChar->blockSignals( false );
2551 
2552  //block
2553  spinOffsetX->blockSignals( true );
2554  spinOffsetX->setValue( mLayer->offset().x() );
2555  spinOffsetX->blockSignals( false );
2556  spinOffsetY->blockSignals( true );
2557  spinOffsetY->setValue( mLayer->offset().y() );
2558  spinOffsetY->blockSignals( false );
2559 
2560  mSizeUnitWidget->blockSignals( true );
2561  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2562  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2563  mSizeUnitWidget->blockSignals( false );
2564 
2565  mOffsetUnitWidget->blockSignals( true );
2566  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2567  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2568  mOffsetUnitWidget->blockSignals( false );
2569 
2570  //anchor points
2571  mHorizontalAnchorComboBox->blockSignals( true );
2572  mVerticalAnchorComboBox->blockSignals( true );
2573  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2574  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2575  mHorizontalAnchorComboBox->blockSignals( false );
2576  mVerticalAnchorComboBox->blockSignals( false );
2577 
2582  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
2583  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
2585 
2586  updateAssistantSymbol();
2587 }
2588 
2590 {
2591  return mLayer;
2592 }
2593 
2595 {
2596  mLayer->setFontFamily( font.family() );
2597  widgetChar->updateFont( font );
2598  emit changed();
2599 }
2600 
2602 {
2603  mLayer->setColor( color );
2604  emit changed();
2605 }
2606 
2608 {
2609  mLayer->setSize( size );
2610  //widgetChar->updateSize(size);
2611  emit changed();
2612 }
2613 
2615 {
2616  mLayer->setAngle( angle );
2617  emit changed();
2618 }
2619 
2621 {
2622  mLayer->setCharacter( chr );
2623  emit changed();
2624 }
2625 
2627 {
2628  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2629  emit changed();
2630 }
2631 
2633 {
2634  if ( mLayer )
2635  {
2636  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2637  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2638  emit changed();
2639  }
2640 }
2641 
2643 {
2644  if ( mLayer )
2645  {
2646  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2647  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2648  emit changed();
2649  }
2650 }
2651 
2653 {
2654  if ( mLayer )
2655  {
2657  emit changed();
2658  }
2659 }
2660 
2662 {
2663  if ( mLayer )
2664  {
2666  emit changed();
2667  }
2668 }
2669 
2670 void QgsFontMarkerSymbolLayerV2Widget::updateAssistantSymbol()
2671 {
2672  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2673  {
2674  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2675  }
2676  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2677  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
2678  if ( ddSize )
2679  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
2680 }
2681 
2683 
2684 
2686  : QgsSymbolLayerV2Widget( parent, vl )
2687 {
2688  mLayer = NULL;
2689 
2690  setupUi( this );
2691 }
2692 
2694 {
2695  if ( layer->layerType() != "CentroidFill" )
2696  return;
2697 
2698  // layer type is correct, we can do the cast
2699  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2700 
2701  // set values
2702  mDrawInsideCheckBox->blockSignals( true );
2703  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2704  mDrawInsideCheckBox->blockSignals( false );
2705 }
2706 
2708 {
2709  return mLayer;
2710 }
2711 
2713 {
2714  mLayer->setPointOnSurface( state == Qt::Checked );
2715  emit changed();
2716 }
2717 
2719 
2721  : QgsSymbolLayerV2Widget( parent, vl )
2722 {
2723  mLayer = 0;
2724  setupUi( this );
2725 
2727  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2728 
2729  mSpinOffsetX->setClearValue( 0.0 );
2730  mSpinOffsetY->setClearValue( 0.0 );
2731 
2732  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2733  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2734  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2735 }
2736 
2738 {
2739  if ( !layer )
2740  {
2741  return;
2742  }
2743 
2744  if ( layer->layerType() != "RasterFill" )
2745  {
2746  return;
2747  }
2748 
2749  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2750  if ( !mLayer )
2751  {
2752  return;
2753  }
2754 
2755  mImageLineEdit->blockSignals( true );
2756  mImageLineEdit->setText( mLayer->imageFilePath() );
2757  mImageLineEdit->blockSignals( false );
2758 
2759  cboCoordinateMode->blockSignals( true );
2760  switch ( mLayer->coordinateMode() )
2761  {
2763  cboCoordinateMode->setCurrentIndex( 1 );
2764  break;
2766  default:
2767  cboCoordinateMode->setCurrentIndex( 0 );
2768  break;
2769  }
2770  cboCoordinateMode->blockSignals( false );
2771  mSpinTransparency->blockSignals( true );
2772  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2773  mSpinTransparency->blockSignals( false );
2774  mSliderTransparency->blockSignals( true );
2775  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2776  mSliderTransparency->blockSignals( false );
2777  mRotationSpinBox->blockSignals( true );
2778  mRotationSpinBox->setValue( mLayer->angle() );
2779  mRotationSpinBox->blockSignals( false );
2780 
2781  mSpinOffsetX->blockSignals( true );
2782  mSpinOffsetX->setValue( mLayer->offset().x() );
2783  mSpinOffsetX->blockSignals( false );
2784  mSpinOffsetY->blockSignals( true );
2785  mSpinOffsetY->setValue( mLayer->offset().y() );
2786  mSpinOffsetY->blockSignals( false );
2787  mOffsetUnitWidget->blockSignals( true );
2788  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2789  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2790  mOffsetUnitWidget->blockSignals( false );
2791 
2792  mWidthSpinBox->blockSignals( true );
2793  mWidthSpinBox->setValue( mLayer->width() );
2794  mWidthSpinBox->blockSignals( false );
2795  mWidthUnitWidget->blockSignals( true );
2796  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
2797  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2798  mWidthUnitWidget->blockSignals( false );
2799  updatePreviewImage();
2800 
2805 }
2806 
2808 {
2809  return mLayer;
2810 }
2811 
2812 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2813 {
2814  QSettings s;
2815  QString openDir;
2816  QString lineEditText = mImageLineEdit->text();
2817  if ( !lineEditText.isEmpty() )
2818  {
2819  QFileInfo openDirFileInfo( lineEditText );
2820  openDir = openDirFileInfo.path();
2821  }
2822 
2823  if ( openDir.isEmpty() )
2824  {
2825  openDir = s.value( "/UI/lastRasterFillImageDir", "" ).toString();
2826  }
2827 
2828  //show file dialog
2829  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select image file" ), openDir );
2830  if ( !filePath.isNull() )
2831  {
2832  //check if file exists
2833  QFileInfo fileInfo( filePath );
2834  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2835  {
2836  QMessageBox::critical( 0, "Invalid file", "Error, file does not exist or is not readable" );
2837  return;
2838  }
2839 
2840  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2841  mImageLineEdit->setText( filePath );
2842  on_mImageLineEdit_editingFinished();
2843  }
2844 }
2845 
2846 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2847 {
2848  if ( !mLayer )
2849  {
2850  return;
2851  }
2852 
2853  QFileInfo fi( mImageLineEdit->text() );
2854  if ( !fi.exists() )
2855  {
2856  QUrl url( mImageLineEdit->text() );
2857  if ( !url.isValid() )
2858  {
2859  return;
2860  }
2861  }
2862 
2863  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2864  mLayer->setImageFilePath( mImageLineEdit->text() );
2865  updatePreviewImage();
2867 
2868  emit changed();
2869 }
2870 
2871 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2872 {
2873  switch ( index )
2874  {
2875  case 0:
2876  //feature coordinate mode
2878  break;
2879  case 1:
2880  //viewport coordinate mode
2882  break;
2883  }
2884 
2885  emit changed();
2886 }
2887 
2888 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2889 {
2890  if ( !mLayer )
2891  {
2892  return;
2893  }
2894 
2895  mLayer->setAlpha( value / 100.0 );
2896  emit changed();
2897  updatePreviewImage();
2898 }
2899 
2900 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2901 {
2902  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2903  emit changed();
2904 }
2905 
2906 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2907 {
2908  if ( !mLayer )
2909  {
2910  return;
2911  }
2912  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2913  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2914  emit changed();
2915 }
2916 
2917 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2918 {
2919  if ( mLayer )
2920  {
2921  mLayer->setAngle( d );
2922  emit changed();
2923  }
2924 }
2925 
2926 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2927 {
2928  if ( !mLayer )
2929  {
2930  return;
2931  }
2932  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
2933  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2934  emit changed();
2935 }
2936 
2937 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2938 {
2939  if ( !mLayer )
2940  {
2941  return;
2942  }
2943  mLayer->setWidth( d );
2944  emit changed();
2945 }
2946 
2947 
2948 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2949 {
2950  if ( !mLayer )
2951  {
2952  return;
2953  }
2954 
2955  QImage image( mLayer->imageFilePath() );
2956  if ( image.isNull() )
2957  {
2958  mLabelImagePreview->setPixmap( QPixmap() );
2959  return;
2960  }
2961 
2962  if ( image.height() > 150 || image.width() > 150 )
2963  {
2964  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
2965  }
2966 
2967  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
2968  previewImage.fill( Qt::transparent );
2969  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
2970  QPainter p;
2971  p.begin( &previewImage );
2972  //draw a checkerboard background
2973  uchar pixDataRGB[] = { 150, 150, 150, 150,
2974  100, 100, 100, 150,
2975  100, 100, 100, 150,
2976  150, 150, 150, 150
2977  };
2978  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
2979  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
2980  QBrush checkerBrush;
2981  checkerBrush.setTexture( pix );
2982  p.fillRect( imageRect, checkerBrush );
2983 
2984  if ( mLayer->alpha() < 1.0 )
2985  {
2986  p.setOpacity( mLayer->alpha() );
2987  }
2988 
2989  p.drawImage( imageRect.left(), imageRect.top(), image );
2990  p.end();
2991  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
2992 }
void setIntervalUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit customDashPatternUnit() const
void setBorderWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
QgsVectorColorRampV2 * colorRamp()
Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp...
VerticalAnchorPoint verticalAnchorPoint() const
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
QgsSymbolV2::OutputUnit intervalUnit() const
QgsSymbolV2::OutputUnit patternWidthUnit() const
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
void setOutlineStyle(Qt::PenStyle outlineStyle)
QgsSymbolV2::OutputUnit outlineWidthUnit() const
static const QString pkgDataPath()
Returns the common root path of all application data directories.
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon's boundary.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
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.
virtual QString type() const =0
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
virtual QgsSymbolLayerV2 * symbolLayer() override
void setCoordinateMode(GradientCoordinateMode coordinateMode)
virtual double width() const
QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QgsGradientFillSymbolLayerV2 * mLayer
QgsSymbolV2::OutputUnit distanceXUnit() const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
virtual QgsSymbolLayerV2 * symbolLayer() override
static QString doublePosDesc()
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
QgsSimpleLineSymbolLayerV2 * mLayer
HorizontalAnchorPoint horizontalAnchorPoint() const
static const QStringList svgPaths()
Returns the pathes to svg directories.
QgsSymbolV2::OutputUnit offsetUnit() const
QgsSimpleMarkerSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
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
int exec()
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
static const QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
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:96
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)
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
append symbol layer at the end of the list
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)
virtual QgsVectorColorRampV2 * clone() const =0
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
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
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)
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)
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.
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.
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)
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image's width.
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)