QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgssymbollayerv2widget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerv2widget.cpp - symbol layer widgets
3 
4  ---------------------
5  begin : November 2009
6  copyright : (C) 2009 by Martin Dobias
7  email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgssymbollayerv2widget.h"
18 
19 #include "qgslinesymbollayerv2.h"
20 #include "qgsmarkersymbollayerv2.h"
21 #include "qgsfillsymbollayerv2.h"
22 
23 #include "characterwidget.h"
24 #include "qgsdashspacedialog.h"
27 #include "qgssvgcache.h"
28 #include "qgssymbollayerv2utils.h"
29 #include "qgsvectorcolorrampv2.h"
31 #include "qgsdatadefined.h"
32 #include "qgsstylev2.h" //for symbol selector dialog
33 
34 #include "qgsapplication.h"
35 
36 #include "qgslogger.h"
37 #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  if ( mVectorLayer )
342  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
343 
344  QSize size = lstNames->iconSize();
345  QStringList names;
346  names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
347  << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead";
348  double markerSize = DEFAULT_POINT_SIZE * 2;
349  for ( int i = 0; i < names.count(); ++i )
350  {
351  QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
353  QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
354  item->setData( Qt::UserRole, names[i] );
355  delete lyr;
356  }
357 
358  connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
359  connect( btnChangeColorBorder, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
360  connect( btnChangeColorFill, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorFill( const QColor& ) ) );
361  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
362  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
363  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
364  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
365  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
366 }
367 
369 {
370  delete mAssistantPreviewSymbol;
371 }
372 
374 {
375  if ( layer->layerType() != "SimpleMarker" )
376  return;
377 
378  // layer type is correct, we can do the cast
379  mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
380 
381  // set values
382  QString name = mLayer->name();
383  for ( int i = 0; i < lstNames->count(); ++i )
384  {
385  if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
386  {
387  lstNames->setCurrentRow( i );
388  break;
389  }
390  }
391  btnChangeColorBorder->blockSignals( true );
392  btnChangeColorBorder->setColor( mLayer->borderColor() );
393  btnChangeColorBorder->blockSignals( false );
394  btnChangeColorFill->blockSignals( true );
395  btnChangeColorFill->setColor( mLayer->color() );
396  btnChangeColorFill->blockSignals( false );
397  spinSize->blockSignals( true );
398  spinSize->setValue( mLayer->size() );
399  spinSize->blockSignals( false );
400  spinAngle->blockSignals( true );
401  spinAngle->setValue( mLayer->angle() );
402  spinAngle->blockSignals( false );
403  mOutlineStyleComboBox->blockSignals( true );
404  mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
405  mOutlineStyleComboBox->blockSignals( false );
406  mOutlineWidthSpinBox->blockSignals( true );
407  mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
408  mOutlineWidthSpinBox->blockSignals( false );
409 
410  // without blocking signals the value gets changed because of slot setOffset()
411  spinOffsetX->blockSignals( true );
412  spinOffsetX->setValue( mLayer->offset().x() );
413  spinOffsetX->blockSignals( false );
414  spinOffsetY->blockSignals( true );
415  spinOffsetY->setValue( mLayer->offset().y() );
416  spinOffsetY->blockSignals( false );
417 
418  mSizeUnitWidget->blockSignals( true );
419  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
420  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
421  mSizeUnitWidget->blockSignals( false );
422  mOffsetUnitWidget->blockSignals( true );
423  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
424  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
425  mOffsetUnitWidget->blockSignals( false );
426  mOutlineWidthUnitWidget->blockSignals( true );
427  mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
428  mOutlineWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
429  mOutlineWidthUnitWidget->blockSignals( false );
430 
431  //anchor points
432  mHorizontalAnchorComboBox->blockSignals( true );
433  mVerticalAnchorComboBox->blockSignals( true );
434  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
435  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
436  mHorizontalAnchorComboBox->blockSignals( false );
437  mVerticalAnchorComboBox->blockSignals( false );
438 
439  registerDataDefinedButton( mNameDDBtn, "name", QgsDataDefinedButton::String, tr( "string " ) + QString( "[<b>square</b>|<b>rectangle</b>|<b>diamond</b>|"
440  "<b>pentagon</b>|<b>triangle</b>|<b>equilateral_triangle</b>|"
441  "<b>star</b>|<b>regular_star</b>|<b>arrow</b>|<b>filled_arrowhead</b>|"
442  "<b>circle</b>|<b>cross</b>|<b>x</b>|"
443  "<b>cross2</b>|<b>line</b>|<b>arrowhead</b>]" ) );
451  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
452  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
453 
454  updateAssistantSymbol();
455 }
456 
458 {
459  return mLayer;
460 }
461 
463 {
464  mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
465  emit changed();
466 }
467 
469 {
470  mLayer->setBorderColor( color );
471  emit changed();
472 }
473 
475 {
476  mLayer->setColor( color );
477  emit changed();
478 }
479 
481 {
482  mLayer->setSize( spinSize->value() );
483  emit changed();
484 }
485 
487 {
488  mLayer->setAngle( spinAngle->value() );
489  emit changed();
490 }
491 
493 {
494  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
495  emit changed();
496 }
497 
499 {
500  Q_UNUSED( index );
501 
502  if ( mLayer )
503  {
504  mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
505  emit changed();
506  }
507 }
508 
510 {
511  if ( mLayer )
512  {
513  mLayer->setOutlineWidth( d );
514  emit changed();
515  }
516 }
517 
519 {
520  if ( mLayer )
521  {
522  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
523  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
524  emit changed();
525  }
526 }
527 
529 {
530  if ( mLayer )
531  {
532  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
533  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
534  emit changed();
535  }
536 }
537 
539 {
540  if ( mLayer )
541  {
542  mLayer->setOutlineWidthUnit( mOutlineWidthUnitWidget->unit() );
543  mLayer->setOutlineWidthMapUnitScale( mOutlineWidthUnitWidget->getMapUnitScale() );
544  emit changed();
545  }
546 }
547 
549 {
550  if ( mLayer )
551  {
553  emit changed();
554  }
555 }
556 
558 {
559  if ( mLayer )
560  {
562  emit changed();
563  }
564 }
565 
566 void QgsSimpleMarkerSymbolLayerV2Widget::updateAssistantSymbol()
567 {
568  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
569  {
570  mAssistantPreviewSymbol->deleteSymbolLayer( i );
571  }
572  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
573  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
574  if ( ddSize )
575  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
576 }
577 
578 
580 
582  : QgsSymbolLayerV2Widget( parent, vl )
583 {
584  mLayer = NULL;
585 
586  setupUi( this );
587  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
588  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
589 
590  btnChangeColor->setAllowAlpha( true );
591  btnChangeColor->setColorDialogTitle( tr( "Select fill color" ) );
592  btnChangeColor->setContext( "symbology" );
593  btnChangeColor->setShowNoColor( true );
594  btnChangeColor->setNoColorString( tr( "Transparent fill" ) );
595  btnChangeBorderColor->setAllowAlpha( true );
596  btnChangeBorderColor->setColorDialogTitle( tr( "Select border color" ) );
597  btnChangeBorderColor->setContext( "symbology" );
598  btnChangeBorderColor->setShowNoColor( true );
599  btnChangeBorderColor->setNoColorString( tr( "Transparent border" ) );
600 
601  spinOffsetX->setClearValue( 0.0 );
602  spinOffsetY->setClearValue( 0.0 );
603 
604  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
605  connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
606  connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
607  connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
608  connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
609  connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
610  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
611  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
612 }
613 
615 {
616  if ( layer->layerType() != "SimpleFill" )
617  return;
618 
619  // layer type is correct, we can do the cast
620  mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
621 
622  // set values
623  btnChangeColor->blockSignals( true );
624  btnChangeColor->setColor( mLayer->color() );
625  btnChangeColor->blockSignals( false );
626  cboFillStyle->blockSignals( true );
627  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
628  cboFillStyle->blockSignals( false );
629  btnChangeBorderColor->blockSignals( true );
630  btnChangeBorderColor->setColor( mLayer->borderColor() );
631  btnChangeBorderColor->blockSignals( false );
632  cboBorderStyle->blockSignals( true );
633  cboBorderStyle->setPenStyle( mLayer->borderStyle() );
634  cboBorderStyle->blockSignals( false );
635  spinBorderWidth->blockSignals( true );
636  spinBorderWidth->setValue( mLayer->borderWidth() );
637  spinBorderWidth->blockSignals( false );
638  cboJoinStyle->blockSignals( true );
639  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
640  cboJoinStyle->blockSignals( false );
641  spinOffsetX->blockSignals( true );
642  spinOffsetX->setValue( mLayer->offset().x() );
643  spinOffsetX->blockSignals( false );
644  spinOffsetY->blockSignals( true );
645  spinOffsetY->setValue( mLayer->offset().y() );
646  spinOffsetY->blockSignals( false );
647 
648  mBorderWidthUnitWidget->blockSignals( true );
649  mBorderWidthUnitWidget->setUnit( mLayer->borderWidthUnit() );
650  mBorderWidthUnitWidget->setMapUnitScale( mLayer->borderWidthMapUnitScale() );
651  mBorderWidthUnitWidget->blockSignals( false );
652  mOffsetUnitWidget->blockSignals( true );
653  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
654  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
655  mOffsetUnitWidget->blockSignals( false );
656 
663 
664 }
665 
667 {
668  return mLayer;
669 }
670 
672 {
673  mLayer->setColor( color );
674  emit changed();
675 }
676 
678 {
679  mLayer->setBorderColor( color );
680  emit changed();
681 }
682 
684 {
685  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
686  emit changed();
687 }
688 
690 {
691  mLayer->setBorderWidth( spinBorderWidth->value() );
692  emit changed();
693 }
694 
696 {
697  mLayer->setBorderStyle( cboBorderStyle->penStyle() );
698  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
699  emit changed();
700 }
701 
703 {
704  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
705  emit changed();
706 }
707 
709 {
710  if ( mLayer )
711  {
712  mLayer->setBorderWidthUnit( mBorderWidthUnitWidget->unit() );
713  mLayer->setBorderWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
714  emit changed();
715  }
716 }
717 
719 {
720  if ( mLayer )
721  {
722  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
723  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
724  emit changed();
725  }
726 }
727 
729 
731  : QgsSymbolLayerV2Widget( parent, vl )
732 {
733  mLayer = NULL;
734 
735  setupUi( this );
736  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
737 
738  cboGradientColorRamp->setShowGradientOnly( true );
739  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
740 
741  btnChangeColor->setAllowAlpha( true );
742  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
743  btnChangeColor->setContext( "symbology" );
744  btnChangeColor->setShowNoColor( true );
745  btnChangeColor->setNoColorString( tr( "Transparent" ) );
746  btnChangeColor2->setAllowAlpha( true );
747  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
748  btnChangeColor2->setContext( "symbology" );
749  btnChangeColor2->setShowNoColor( true );
750  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
751 
752  spinOffsetX->setClearValue( 0.0 );
753  spinOffsetY->setClearValue( 0.0 );
754 
755  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
756  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
757  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
758  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
759  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
760  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
761  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
762  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
763  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
764  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
765  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
766  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
767  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
768  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
769  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
770 }
771 
773 {
774  if ( layer->layerType() != "GradientFill" )
775  return;
776 
777  // layer type is correct, we can do the cast
778  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
779 
780  // set values
781  btnChangeColor->blockSignals( true );
782  btnChangeColor->setColor( mLayer->color() );
783  btnChangeColor->blockSignals( false );
784  btnChangeColor2->blockSignals( true );
785  btnChangeColor2->setColor( mLayer->color2() );
786  btnChangeColor2->blockSignals( false );
787 
789  {
790  radioTwoColor->setChecked( true );
791  cboGradientColorRamp->setEnabled( false );
792  }
793  else
794  {
795  radioColorRamp->setChecked( true );
796  btnChangeColor->setEnabled( false );
797  btnChangeColor2->setEnabled( false );
798  }
799 
800  // set source color ramp
801  if ( mLayer->colorRamp() )
802  {
803  cboGradientColorRamp->blockSignals( true );
804  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
805  cboGradientColorRamp->blockSignals( false );
806  }
807 
808  cboGradientType->blockSignals( true );
809  switch ( mLayer->gradientType() )
810  {
812  cboGradientType->setCurrentIndex( 0 );
813  break;
815  cboGradientType->setCurrentIndex( 1 );
816  break;
818  cboGradientType->setCurrentIndex( 2 );
819  break;
820  }
821  cboGradientType->blockSignals( false );
822 
823  cboCoordinateMode->blockSignals( true );
824  switch ( mLayer->coordinateMode() )
825  {
827  cboCoordinateMode->setCurrentIndex( 1 );
828  checkRefPoint1Centroid->setEnabled( false );
829  checkRefPoint2Centroid->setEnabled( false );
830  break;
832  default:
833  cboCoordinateMode->setCurrentIndex( 0 );
834  break;
835  }
836  cboCoordinateMode->blockSignals( false );
837 
838  cboGradientSpread->blockSignals( true );
839  switch ( mLayer->gradientSpread() )
840  {
842  cboGradientSpread->setCurrentIndex( 0 );
843  break;
845  cboGradientSpread->setCurrentIndex( 1 );
846  break;
848  cboGradientSpread->setCurrentIndex( 2 );
849  break;
850  }
851  cboGradientSpread->blockSignals( false );
852 
853  spinRefPoint1X->blockSignals( true );
854  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
855  spinRefPoint1X->blockSignals( false );
856  spinRefPoint1Y->blockSignals( true );
857  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
858  spinRefPoint1Y->blockSignals( false );
859  checkRefPoint1Centroid->blockSignals( true );
860  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
862  {
863  spinRefPoint1X->setEnabled( false );
864  spinRefPoint1Y->setEnabled( false );
865  }
866  checkRefPoint1Centroid->blockSignals( false );
867  spinRefPoint2X->blockSignals( true );
868  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
869  spinRefPoint2X->blockSignals( false );
870  spinRefPoint2Y->blockSignals( true );
871  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
872  spinRefPoint2Y->blockSignals( false );
873  checkRefPoint2Centroid->blockSignals( true );
874  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
876  {
877  spinRefPoint2X->setEnabled( false );
878  spinRefPoint2Y->setEnabled( false );
879  }
880  checkRefPoint2Centroid->blockSignals( false );
881 
882  spinOffsetX->blockSignals( true );
883  spinOffsetX->setValue( mLayer->offset().x() );
884  spinOffsetX->blockSignals( false );
885  spinOffsetY->blockSignals( true );
886  spinOffsetY->setValue( mLayer->offset().y() );
887  spinOffsetY->blockSignals( false );
888  mSpinAngle->blockSignals( true );
889  mSpinAngle->setValue( mLayer->angle() );
890  mSpinAngle->blockSignals( false );
891 
892  mOffsetUnitWidget->blockSignals( true );
893  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
894  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
895  mOffsetUnitWidget->blockSignals( false );
896 
905  registerDataDefinedButton( mRefPoint1CentroidDDBtn, "reference1_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
908  registerDataDefinedButton( mRefPoint2CentroidDDBtn, "reference2_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
909 }
910 
912 {
913  return mLayer;
914 }
915 
917 {
918  mLayer->setColor( color );
919  emit changed();
920 }
921 
923 {
924  mLayer->setColor2( color );
925  emit changed();
926 }
927 
929 {
930  if ( radioTwoColor->isChecked() )
931  {
933  }
934  else
935  {
937  }
938  emit changed();
939 }
940 
942 {
943  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
944  if ( ramp == NULL )
945  return;
946 
947  mLayer->setColorRamp( ramp );
948  emit changed();
949 }
950 
952 {
953  if ( mLayer->colorRamp()->type() == "gradient" )
954  {
956  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
957  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
958 
959  if ( dlg.exec() && gradRamp )
960  {
961  mLayer->setColorRamp( gradRamp );
962  cboGradientColorRamp->blockSignals( true );
963  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
964  cboGradientColorRamp->blockSignals( false );
965  emit changed();
966  }
967  else
968  {
969  delete ramp;
970  }
971  }
972 }
973 
975 {
976  switch ( index )
977  {
978  case 0:
980  //set sensible default reference points
981  spinRefPoint1X->setValue( 0.5 );
982  spinRefPoint1Y->setValue( 0 );
983  spinRefPoint2X->setValue( 0.5 );
984  spinRefPoint2Y->setValue( 1 );
985  break;
986  case 1:
988  //set sensible default reference points
989  spinRefPoint1X->setValue( 0 );
990  spinRefPoint1Y->setValue( 0 );
991  spinRefPoint2X->setValue( 1 );
992  spinRefPoint2Y->setValue( 1 );
993  break;
994  case 2:
996  spinRefPoint1X->setValue( 0.5 );
997  spinRefPoint1Y->setValue( 0.5 );
998  spinRefPoint2X->setValue( 1 );
999  spinRefPoint2Y->setValue( 1 );
1000  break;
1001  }
1002  emit changed();
1003 }
1004 
1006 {
1007 
1008  switch ( index )
1009  {
1010  case 0:
1011  //feature coordinate mode
1013  //allow choice of centroid reference positions
1014  checkRefPoint1Centroid->setEnabled( true );
1015  checkRefPoint2Centroid->setEnabled( true );
1016  break;
1017  case 1:
1018  //viewport coordinate mode
1020  //disable choice of centroid reference positions
1021  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1022  checkRefPoint1Centroid->setEnabled( false );
1023  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1024  checkRefPoint2Centroid->setEnabled( false );
1025  break;
1026  }
1027 
1028  emit changed();
1029 }
1030 
1032 {
1033  switch ( index )
1034  {
1035  case 0:
1037  break;
1038  case 1:
1040  break;
1041  case 2:
1043  break;
1044  }
1045 
1046  emit changed();
1047 }
1048 
1050 {
1051  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1052  emit changed();
1053 }
1054 
1056 {
1057  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1058  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1059  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1060  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1061  emit changed();
1062 }
1063 
1065 {
1066  mLayer->setAngle( value );
1067  emit changed();
1068 }
1069 
1071 {
1072  if ( mLayer )
1073  {
1074  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1075  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1076  emit changed();
1077  }
1078 }
1079 
1081 
1083  : QgsSymbolLayerV2Widget( parent, vl )
1084 {
1085  mLayer = NULL;
1086 
1087  setupUi( this );
1088  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1089  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1090 
1091  btnChangeColor->setAllowAlpha( true );
1092  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1093  btnChangeColor->setContext( "symbology" );
1094  btnChangeColor->setShowNoColor( true );
1095  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1096  btnChangeColor2->setAllowAlpha( true );
1097  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1098  btnChangeColor2->setContext( "symbology" );
1099  btnChangeColor2->setShowNoColor( true );
1100  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1101 
1102  spinOffsetX->setClearValue( 0.0 );
1103  spinOffsetY->setClearValue( 0.0 );
1104 
1105  cboGradientColorRamp->setShowGradientOnly( true );
1106  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1107 
1108  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1109  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1110  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1111  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1112  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1113  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1114 
1115  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1116  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1117 }
1118 
1120 {
1121  if ( layer->layerType() != "ShapeburstFill" )
1122  return;
1123 
1124  // layer type is correct, we can do the cast
1125  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1126 
1127  // set values
1128  btnChangeColor->blockSignals( true );
1129  btnChangeColor->setColor( mLayer->color() );
1130  btnChangeColor->blockSignals( false );
1131  btnChangeColor2->blockSignals( true );
1132  btnChangeColor2->setColor( mLayer->color2() );
1133  btnChangeColor2->blockSignals( false );
1134 
1136  {
1137  radioTwoColor->setChecked( true );
1138  cboGradientColorRamp->setEnabled( false );
1139  }
1140  else
1141  {
1142  radioColorRamp->setChecked( true );
1143  btnChangeColor->setEnabled( false );
1144  btnChangeColor2->setEnabled( false );
1145  }
1146 
1147  mSpinBlurRadius->blockSignals( true );
1148  mBlurSlider->blockSignals( true );
1149  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1150  mBlurSlider->setValue( mLayer->blurRadius() );
1151  mSpinBlurRadius->blockSignals( false );
1152  mBlurSlider->blockSignals( false );
1153 
1154  mSpinMaxDistance->blockSignals( true );
1155  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1156  mSpinMaxDistance->blockSignals( false );
1157 
1158  mRadioUseWholeShape->blockSignals( true );
1159  mRadioUseMaxDistance->blockSignals( true );
1160  if ( mLayer->useWholeShape() )
1161  {
1162  mRadioUseWholeShape->setChecked( true );
1163  mSpinMaxDistance->setEnabled( false );
1164  mDistanceUnitWidget->setEnabled( false );
1165  }
1166  else
1167  {
1168  mRadioUseMaxDistance->setChecked( true );
1169  mSpinMaxDistance->setEnabled( true );
1170  mDistanceUnitWidget->setEnabled( true );
1171  }
1172  mRadioUseWholeShape->blockSignals( false );
1173  mRadioUseMaxDistance->blockSignals( false );
1174 
1175  mDistanceUnitWidget->blockSignals( true );
1176  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1177  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1178  mDistanceUnitWidget->blockSignals( false );
1179 
1180  mIgnoreRingsCheckBox->blockSignals( true );
1181  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1182  mIgnoreRingsCheckBox->blockSignals( false );
1183 
1184  // set source color ramp
1185  if ( mLayer->colorRamp() )
1186  {
1187  cboGradientColorRamp->blockSignals( true );
1188  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1189  cboGradientColorRamp->blockSignals( false );
1190  }
1191 
1192  spinOffsetX->blockSignals( true );
1193  spinOffsetX->setValue( mLayer->offset().x() );
1194  spinOffsetX->blockSignals( false );
1195  spinOffsetY->blockSignals( true );
1196  spinOffsetY->setValue( mLayer->offset().y() );
1197  spinOffsetY->blockSignals( false );
1198  mOffsetUnitWidget->blockSignals( true );
1199  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1200  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1201  mOffsetUnitWidget->blockSignals( false );
1202 
1205  registerDataDefinedButton( mBlurRadiusDDBtn, "blur_radius", QgsDataDefinedButton::Int, tr( "Integer between 0 and 18" ) );
1206  registerDataDefinedButton( mShadeWholeShapeDDBtn, "use_whole_shape", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1209 }
1210 
1212 {
1213  return mLayer;
1214 }
1215 
1217 {
1218  if ( mLayer )
1219  {
1220  mLayer->setColor( color );
1221  emit changed();
1222  }
1223 }
1224 
1226 {
1227  if ( mLayer )
1228  {
1229  mLayer->setColor2( color );
1230  emit changed();
1231  }
1232 }
1233 
1235 {
1236  if ( !mLayer )
1237  {
1238  return;
1239  }
1240 
1241  if ( radioTwoColor->isChecked() )
1242  {
1244  }
1245  else
1246  {
1248  }
1249  emit changed();
1250 }
1251 
1253 {
1254  if ( mLayer )
1255  {
1256  mLayer->setBlurRadius( value );
1257  emit changed();
1258  }
1259 }
1260 
1262 {
1263  if ( mLayer )
1264  {
1265  mLayer->setMaxDistance( value );
1266  emit changed();
1267  }
1268 }
1269 
1271 {
1272  if ( mLayer )
1273  {
1274  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1275  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1276  emit changed();
1277  }
1278 }
1279 
1281 {
1282  if ( mLayer )
1283  {
1284  mLayer->setUseWholeShape( value );
1285  mDistanceUnitWidget->setEnabled( !value );
1286  emit changed();
1287  }
1288 }
1289 
1291 {
1292  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1293  if ( ramp == NULL )
1294  return;
1295 
1296  mLayer->setColorRamp( ramp );
1297  emit changed();
1298 }
1299 
1301 {
1302  if ( mLayer->colorRamp()->type() == "gradient" )
1303  {
1305  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
1306  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
1307 
1308  if ( dlg.exec() && gradRamp )
1309  {
1310  mLayer->setColorRamp( gradRamp );
1311  cboGradientColorRamp->blockSignals( true );
1312  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1313  cboGradientColorRamp->blockSignals( false );
1314  emit changed();
1315  }
1316  else
1317  {
1318  delete ramp;
1319  }
1320  }
1321 }
1322 
1324 {
1325  if ( mLayer )
1326  {
1327  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1328  emit changed();
1329  }
1330 }
1331 
1333 {
1334  if ( mLayer )
1335  {
1336  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1337  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1338  emit changed();
1339  }
1340 }
1341 
1342 
1344 {
1345  bool checked = ( state == Qt::Checked );
1346  mLayer->setIgnoreRings( checked );
1347  emit changed();
1348 }
1349 
1351 
1353  : QgsSymbolLayerV2Widget( parent, vl )
1354 {
1355  mLayer = NULL;
1356 
1357  setupUi( this );
1358  mIntervalUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1359  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1360  mOffsetAlongLineUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1361 
1362  spinOffset->setClearValue( 0.0 );
1363 
1364  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1365  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1366  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1367  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1368  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1369  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1370  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1371  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1372  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1373 }
1374 
1376 {
1377  if ( layer->layerType() != "MarkerLine" )
1378  return;
1379 
1380  // layer type is correct, we can do the cast
1381  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1382 
1383  // set values
1384  spinInterval->blockSignals( true );
1385  spinInterval->setValue( mLayer->interval() );
1386  spinInterval->blockSignals( false );
1387  mSpinOffsetAlongLine->blockSignals( true );
1388  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1389  mSpinOffsetAlongLine->blockSignals( false );
1390  chkRotateMarker->blockSignals( true );
1391  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1392  chkRotateMarker->blockSignals( false );
1393  spinOffset->blockSignals( true );
1394  spinOffset->setValue( mLayer->offset() );
1395  spinOffset->blockSignals( false );
1397  radInterval->setChecked( true );
1399  radVertex->setChecked( true );
1401  radVertexLast->setChecked( true );
1403  radCentralPoint->setChecked( true );
1404  else
1405  radVertexFirst->setChecked( true );
1406 
1407  // set units
1408  mIntervalUnitWidget->blockSignals( true );
1409  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1410  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1411  mIntervalUnitWidget->blockSignals( false );
1412  mOffsetUnitWidget->blockSignals( true );
1413  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1414  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1415  mOffsetUnitWidget->blockSignals( false );
1416  mOffsetAlongLineUnitWidget->blockSignals( true );
1417  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1418  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1419  mOffsetAlongLineUnitWidget->blockSignals( false );
1420 
1421  setPlacement(); // update gui
1422 
1425  registerDataDefinedButton( mPlacementDDBtn, "placement", QgsDataDefinedButton::String, tr( "string " ) + QString( "[<b>vertex</b>|<b>lastvertex</b>|<b>firstvertex</b>|<b>centerpoint</b>]" ) );
1426  registerDataDefinedButton( mOffsetAlongLineDDBtn, "offset_along_line", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
1427 }
1428 
1430 {
1431  return mLayer;
1432 }
1433 
1435 {
1436  mLayer->setInterval( val );
1437  emit changed();
1438 }
1439 
1441 {
1442  mLayer->setOffsetAlongLine( val );
1443  emit changed();
1444 }
1445 
1447 {
1448  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1449  emit changed();
1450 }
1451 
1453 {
1454  mLayer->setOffset( spinOffset->value() );
1455  emit changed();
1456 }
1457 
1459 {
1460  bool interval = radInterval->isChecked();
1461  spinInterval->setEnabled( interval );
1462  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1463  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1464  if ( radInterval->isChecked() )
1466  else if ( radVertex->isChecked() )
1468  else if ( radVertexLast->isChecked() )
1470  else if ( radVertexFirst->isChecked() )
1472  else
1474 
1475  emit changed();
1476 }
1477 
1479 {
1480  if ( mLayer )
1481  {
1482  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1483  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1484  emit changed();
1485  }
1486 }
1487 
1489 {
1490  if ( mLayer )
1491  {
1492  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1493  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1494  emit changed();
1495  }
1496 }
1497 
1499 {
1500  if ( mLayer )
1501  {
1502  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1503  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1504  }
1505  emit changed();
1506 }
1507 
1509 
1510 
1512  : QgsSymbolLayerV2Widget( parent, vl )
1513 {
1514  mLayer = NULL;
1515 
1516  setupUi( this );
1517  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1518  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1519  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1520  viewGroups->setHeaderHidden( true );
1521 
1522  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1523  mChangeColorButton->setContext( "symbology" );
1524  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1525  mChangeColorButton->setContext( "symbology" );
1526 
1527  spinOffsetX->setClearValue( 0.0 );
1528  spinOffsetY->setClearValue( 0.0 );
1529 
1530  populateList();
1531 
1532  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1533  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1534  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1535  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1536  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1537  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1538  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
1539 
1540  //make a temporary symbol for the size assistant preview
1541  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
1542  if ( mVectorLayer )
1543  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
1544 }
1545 
1547 {
1548  delete mAssistantPreviewSymbol;
1549 }
1550 
1551 #include <QTime>
1552 #include <QAbstractListModel>
1553 #include <QPixmapCache>
1554 #include <QStyle>
1555 
1557 {
1558  public:
1560  {
1562  }
1563 
1564  // Constructor to create model for icons in a specific path
1566  {
1568  }
1569 
1570  int rowCount( const QModelIndex & parent = QModelIndex() ) const override
1571  {
1572  Q_UNUSED( parent );
1573  return mSvgFiles.count();
1574  }
1575 
1576  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override
1577  {
1578  QString entry = mSvgFiles.at( index.row() );
1579 
1580  if ( role == Qt::DecorationRole ) // icon
1581  {
1582  QPixmap pixmap;
1583  if ( !QPixmapCache::find( entry, pixmap ) )
1584  {
1585  // render SVG file
1586  QColor fill, outline;
1587  double outlineWidth;
1588  bool fillParam, outlineParam, outlineWidthParam;
1589  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1590 
1591  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1592  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1593  pixmap = QPixmap::fromImage( img );
1594  QPixmapCache::insert( entry, pixmap );
1595  }
1596 
1597  return pixmap;
1598  }
1599  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1600  {
1601  return entry;
1602  }
1603 
1604  return QVariant();
1605  }
1606 
1607  protected:
1609 };
1610 
1612 {
1613  public:
1615  {
1617  QStandardItem *parentItem = invisibleRootItem();
1618 
1619  for ( int i = 0; i < svgPaths.size(); i++ )
1620  {
1621  QDir dir( svgPaths[i] );
1622  QStandardItem *baseGroup;
1623 
1624  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1625  {
1626  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1627  }
1628  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1629  {
1630  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1631  }
1632  else
1633  {
1634  baseGroup = new QStandardItem( dir.dirName() );
1635  }
1636  baseGroup->setData( QVariant( svgPaths[i] ) );
1637  baseGroup->setEditable( false );
1638  baseGroup->setCheckable( false );
1639  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1640  baseGroup->setToolTip( dir.path() );
1641  parentItem->appendRow( baseGroup );
1642  createTree( baseGroup );
1643  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1644  }
1645  }
1646  private:
1647  void createTree( QStandardItem* &parentGroup )
1648  {
1649  QDir parentDir( parentGroup->data().toString() );
1650  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1651  {
1652  QStandardItem* group = new QStandardItem( item );
1653  group->setData( QVariant( parentDir.path() + "/" + item ) );
1654  group->setEditable( false );
1655  group->setCheckable( false );
1656  group->setToolTip( parentDir.path() + "/" + item );
1657  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1658  parentGroup->appendRow( group );
1659  createTree( group );
1660  }
1661  }
1662 };
1663 
1665 {
1666  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1667  viewGroups->setModel( g );
1668  // Set the tree expanded at the first level
1669  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1670  for ( int i = 0; i < rows; i++ )
1671  {
1672  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1673  }
1674 
1675  // Initally load the icons in the List view without any grouping
1676  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1677  viewImages->setModel( m );
1678 }
1679 
1681 {
1682  QString path = idx.data( Qt::UserRole + 1 ).toString();
1683 
1684  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1685  viewImages->setModel( m );
1686 
1687  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1688  emit changed();
1689 }
1690 
1692 {
1693  if ( !layer )
1694  {
1695  return;
1696  }
1697 
1698  //activate gui for svg parameters only if supported by the svg file
1699  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1700  QColor defaultFill, defaultOutline;
1701  double defaultOutlineWidth;
1702  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1703  mChangeColorButton->setEnabled( hasFillParam );
1704  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1705  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1706 
1707  if ( hasFillParam )
1708  {
1709  if ( layer->fillColor().isValid() )
1710  {
1711  mChangeColorButton->setColor( layer->fillColor() );
1712  }
1713  else
1714  {
1715  mChangeColorButton->setColor( defaultFill );
1716  }
1717  }
1718  if ( hasOutlineParam )
1719  {
1720  if ( layer->outlineColor().isValid() )
1721  {
1722  mChangeBorderColorButton->setColor( layer->outlineColor() );
1723  }
1724  else
1725  {
1726  mChangeBorderColorButton->setColor( defaultOutline );
1727  }
1728  }
1729 
1730  mFileLineEdit->blockSignals( true );
1731  mFileLineEdit->setText( layer->path() );
1732  mFileLineEdit->blockSignals( false );
1733 
1734  mBorderWidthSpinBox->blockSignals( true );
1735  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1736  mBorderWidthSpinBox->blockSignals( false );
1737 }
1738 
1739 void QgsSvgMarkerSymbolLayerV2Widget::updateAssistantSymbol()
1740 {
1741  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1742  {
1743  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1744  }
1745  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1746  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
1747  if ( ddSize )
1748  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
1749 }
1750 
1751 
1753 {
1754  if ( !layer )
1755  {
1756  return;
1757  }
1758 
1759  if ( layer->layerType() != "SvgMarker" )
1760  return;
1761 
1762  // layer type is correct, we can do the cast
1763  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1764 
1765  // set values
1766 
1767  QAbstractItemModel* m = viewImages->model();
1768  QItemSelectionModel* selModel = viewImages->selectionModel();
1769  for ( int i = 0; i < m->rowCount(); i++ )
1770  {
1771  QModelIndex idx( m->index( i, 0 ) );
1772  if ( m->data( idx ).toString() == mLayer->path() )
1773  {
1774  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1775  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1776  setName( idx );
1777  break;
1778  }
1779  }
1780 
1781  spinSize->blockSignals( true );
1782  spinSize->setValue( mLayer->size() );
1783  spinSize->blockSignals( false );
1784  spinAngle->blockSignals( true );
1785  spinAngle->setValue( mLayer->angle() );
1786  spinAngle->blockSignals( false );
1787 
1788  // without blocking signals the value gets changed because of slot setOffset()
1789  spinOffsetX->blockSignals( true );
1790  spinOffsetX->setValue( mLayer->offset().x() );
1791  spinOffsetX->blockSignals( false );
1792  spinOffsetY->blockSignals( true );
1793  spinOffsetY->setValue( mLayer->offset().y() );
1794  spinOffsetY->blockSignals( false );
1795 
1796  mSizeUnitWidget->blockSignals( true );
1797  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1798  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1799  mSizeUnitWidget->blockSignals( false );
1800  mBorderWidthUnitWidget->blockSignals( true );
1801  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1802  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1803  mBorderWidthUnitWidget->blockSignals( false );
1804  mOffsetUnitWidget->blockSignals( true );
1805  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1806  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1807  mOffsetUnitWidget->blockSignals( false );
1808 
1809  //anchor points
1810  mHorizontalAnchorComboBox->blockSignals( true );
1811  mVerticalAnchorComboBox->blockSignals( true );
1812  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1813  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1814  mHorizontalAnchorComboBox->blockSignals( false );
1815  mVerticalAnchorComboBox->blockSignals( false );
1816 
1817  setGuiForSvg( mLayer );
1818 
1826  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
1827  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
1828 
1829  updateAssistantSymbol();
1830 }
1831 
1833 {
1834  return mLayer;
1835 }
1836 
1838 {
1839  QString name = idx.data( Qt::UserRole ).toString();
1840  mLayer->setPath( name );
1841  mFileLineEdit->setText( name );
1842 
1843  setGuiForSvg( mLayer );
1844  emit changed();
1845 }
1846 
1848 {
1849  mLayer->setSize( spinSize->value() );
1850  emit changed();
1851 }
1852 
1854 {
1855  mLayer->setAngle( spinAngle->value() );
1856  emit changed();
1857 }
1858 
1860 {
1861  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1862  emit changed();
1863 }
1864 
1866 {
1867  QSettings s;
1869  tr( "Select SVG file" ),
1870  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1871  tr( "SVG files" ) + " (*.svg)" );
1872  QFileInfo fi( file );
1873  if ( file.isEmpty() || !fi.exists() )
1874  {
1875  return;
1876  }
1877  mFileLineEdit->setText( file );
1878  mLayer->setPath( file );
1879  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1880  emit changed();
1881 }
1882 
1884 {
1885  if ( !QFileInfo( text ).exists() )
1886  {
1887  return;
1888  }
1889  mLayer->setPath( text );
1890  setGuiForSvg( mLayer );
1891  emit changed();
1892 }
1893 
1895 {
1896  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1897  {
1898  QUrl url( mFileLineEdit->text() );
1899  if ( !url.isValid() )
1900  {
1901  return;
1902  }
1903  }
1904 
1905  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1906  mLayer->setPath( mFileLineEdit->text() );
1908 
1909  setGuiForSvg( mLayer );
1910  emit changed();
1911 }
1912 
1914 {
1915  if ( !mLayer )
1916  {
1917  return;
1918  }
1919 
1920  mLayer->setFillColor( color );
1921  emit changed();
1922 }
1923 
1925 {
1926  if ( !mLayer )
1927  {
1928  return;
1929  }
1930 
1931  mLayer->setOutlineColor( color );
1932  emit changed();
1933 }
1934 
1936 {
1937  if ( mLayer )
1938  {
1939  mLayer->setOutlineWidth( d );
1940  emit changed();
1941  }
1942 }
1943 
1945 {
1946  if ( mLayer )
1947  {
1948  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1949  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1950  emit changed();
1951  }
1952 }
1953 
1955 {
1956  if ( mLayer )
1957  {
1958  mLayer->setOutlineWidthUnit( mBorderWidthUnitWidget->unit() );
1959  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1960  emit changed();
1961  }
1962 }
1963 
1965 {
1966  if ( mLayer )
1967  {
1968  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1969  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1970  emit changed();
1971  }
1972 }
1973 
1975 {
1976  if ( mLayer )
1977  {
1979  emit changed();
1980  }
1981 }
1982 
1984 {
1985  if ( mLayer )
1986  {
1988  emit changed();
1989  }
1990 }
1991 
1993 
1995 {
1996  mLayer = 0;
1997  setupUi( this );
1998  mTextureWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1999  mSvgOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2000  mSvgTreeView->setHeaderHidden( true );
2001  insertIcons();
2002 
2003  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
2004  mChangeColorButton->setContext( "symbology" );
2005  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
2006  mChangeBorderColorButton->setContext( "symbology" );
2007 
2008  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2009  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
2010 }
2011 
2013 {
2014  if ( !layer )
2015  {
2016  return;
2017  }
2018 
2019  if ( layer->layerType() != "SVGFill" )
2020  {
2021  return;
2022  }
2023 
2024  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
2025  if ( mLayer )
2026  {
2027  double width = mLayer->patternWidth();
2028  mTextureWidthSpinBox->blockSignals( true );
2029  mTextureWidthSpinBox->setValue( width );
2030  mTextureWidthSpinBox->blockSignals( false );
2031  mSVGLineEdit->setText( mLayer->svgFilePath() );
2032  mRotationSpinBox->blockSignals( true );
2033  mRotationSpinBox->setValue( mLayer->angle() );
2034  mRotationSpinBox->blockSignals( false );
2035  mTextureWidthUnitWidget->blockSignals( true );
2036  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2037  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2038  mTextureWidthUnitWidget->blockSignals( false );
2039  mSvgOutlineWidthUnitWidget->blockSignals( true );
2040  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
2041  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2042  mSvgOutlineWidthUnitWidget->blockSignals( false );
2043  mChangeColorButton->blockSignals( true );
2044  mChangeColorButton->setColor( mLayer->svgFillColor() );
2045  mChangeColorButton->blockSignals( false );
2046  mChangeBorderColorButton->blockSignals( true );
2047  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2048  mChangeBorderColorButton->blockSignals( false );
2049  mBorderWidthSpinBox->blockSignals( true );
2050  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2051  mBorderWidthSpinBox->blockSignals( false );
2052  }
2053  updateParamGui( false );
2054 
2061 }
2062 
2064 {
2065  return mLayer;
2066 }
2067 
2068 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2069 {
2070  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2071  if ( !filePath.isNull() )
2072  {
2073  mSVGLineEdit->setText( filePath );
2074  emit changed();
2075  }
2076 }
2077 
2078 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2079 {
2080  if ( mLayer )
2081  {
2082  mLayer->setPatternWidth( d );
2083  emit changed();
2084  }
2085 }
2086 
2087 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2088 {
2089  if ( !mLayer )
2090  {
2091  return;
2092  }
2093 
2094  QFileInfo fi( text );
2095  if ( !fi.exists() )
2096  {
2097  return;
2098  }
2099  mLayer->setSvgFilePath( text );
2100  updateParamGui();
2101  emit changed();
2102 }
2103 
2104 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2105 {
2106  if ( !mLayer )
2107  {
2108  return;
2109  }
2110 
2111  QFileInfo fi( mSVGLineEdit->text() );
2112  if ( !fi.exists() )
2113  {
2114  QUrl url( mSVGLineEdit->text() );
2115  if ( !url.isValid() )
2116  {
2117  return;
2118  }
2119  }
2120 
2121  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2122  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2124 
2125  updateParamGui();
2126  emit changed();
2127 }
2128 
2129 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2130 {
2131  QString file = item.data( Qt::UserRole ).toString();
2132  mLayer->setSvgFilePath( file );
2133  mSVGLineEdit->setText( file );
2134 
2135  updateParamGui();
2136  emit changed();
2137 }
2138 
2140 {
2141  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2142  mSvgTreeView->setModel( g );
2143  // Set the tree expanded at the first level
2144  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2145  for ( int i = 0; i < rows; i++ )
2146  {
2147  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2148  }
2149 
2150  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2151  mSvgListView->setModel( m );
2152 }
2153 
2154 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2155 {
2156  QString path = idx.data( Qt::UserRole + 1 ).toString();
2157 
2158  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2159  mSvgListView->setModel( m );
2160 
2161  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2162  emit changed();
2163 }
2164 
2165 
2166 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2167 {
2168  if ( mLayer )
2169  {
2170  mLayer->setAngle( d );
2171  emit changed();
2172  }
2173 }
2174 
2176 {
2177  //activate gui for svg parameters only if supported by the svg file
2178  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2179  QColor defaultFill, defaultOutline;
2180  double defaultOutlineWidth;
2181  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2182  if ( hasFillParam && resetValues )
2183  {
2184  mChangeColorButton->setColor( defaultFill );
2185  }
2186  mChangeColorButton->setEnabled( hasFillParam );
2187  if ( hasOutlineParam && resetValues )
2188  {
2189  mChangeBorderColorButton->setColor( defaultOutline );
2190  }
2191  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2192  if ( hasOutlineWidthParam && resetValues )
2193  {
2194  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2195  }
2196  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2197 }
2198 
2199 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2200 {
2201  if ( !mLayer )
2202  {
2203  return;
2204  }
2205 
2206  mLayer->setSvgFillColor( color );
2207  emit changed();
2208 }
2209 
2210 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2211 {
2212  if ( !mLayer )
2213  {
2214  return;
2215  }
2216 
2217  mLayer->setSvgOutlineColor( color );
2218  emit changed();
2219 }
2220 
2221 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2222 {
2223  if ( mLayer )
2224  {
2225  mLayer->setSvgOutlineWidth( d );
2226  emit changed();
2227  }
2228 }
2229 
2230 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2231 {
2232  if ( mLayer )
2233  {
2234  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2235  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2236  emit changed();
2237  }
2238 }
2239 
2240 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2241 {
2242  if ( mLayer )
2243  {
2244  mLayer->setSvgOutlineWidthUnit( mSvgOutlineWidthUnitWidget->unit() );
2245  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2246  emit changed();
2247  }
2248 }
2249 
2251 
2253  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2254 {
2255  setupUi( this );
2256  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2257  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2258 }
2259 
2261 {
2262  if ( layer->layerType() != "LinePatternFill" )
2263  {
2264  return;
2265  }
2266 
2267  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2268  if ( patternLayer )
2269  {
2270  mLayer = patternLayer;
2271  mAngleSpinBox->blockSignals( true );
2272  mAngleSpinBox->setValue( mLayer->lineAngle() );
2273  mAngleSpinBox->blockSignals( false );
2274  mDistanceSpinBox->blockSignals( true );
2275  mDistanceSpinBox->setValue( mLayer->distance() );
2276  mDistanceSpinBox->blockSignals( false );
2277  mOffsetSpinBox->blockSignals( true );
2278  mOffsetSpinBox->setValue( mLayer->offset() );
2279  mOffsetSpinBox->blockSignals( false );
2280 
2281  //units
2282  mDistanceUnitWidget->blockSignals( true );
2283  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2284  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2285  mDistanceUnitWidget->blockSignals( false );
2286  mOffsetUnitWidget->blockSignals( true );
2287  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2288  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2289  mOffsetUnitWidget->blockSignals( false );
2290  }
2291 
2294 }
2295 
2297 {
2298  return mLayer;
2299 }
2300 
2301 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2302 {
2303  if ( mLayer )
2304  {
2305  mLayer->setLineAngle( d );
2306  emit changed();
2307  }
2308 }
2309 
2310 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2311 {
2312  if ( mLayer )
2313  {
2314  mLayer->setDistance( d );
2315  emit changed();
2316  }
2317 }
2318 
2319 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2320 {
2321  if ( mLayer )
2322  {
2323  mLayer->setOffset( d );
2324  emit changed();
2325  }
2326 }
2327 
2328 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2329 {
2330  if ( mLayer )
2331  {
2332  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2333  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2334  emit changed();
2335  }
2336 }
2337 
2338 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2339 {
2340  if ( mLayer )
2341  {
2342  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2343  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2344  emit changed();
2345  }
2346 }
2347 
2349 
2351  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2352 {
2353  setupUi( this );
2354  mHorizontalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2355  mVerticalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2356  mHorizontalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2357  mVerticalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2358 }
2359 
2360 
2362 {
2363  if ( !layer || layer->layerType() != "PointPatternFill" )
2364  {
2365  return;
2366  }
2367 
2368  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2369  mHorizontalDistanceSpinBox->blockSignals( true );
2370  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2371  mHorizontalDistanceSpinBox->blockSignals( false );
2372  mVerticalDistanceSpinBox->blockSignals( true );
2373  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2374  mVerticalDistanceSpinBox->blockSignals( false );
2375  mHorizontalDisplacementSpinBox->blockSignals( true );
2376  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2377  mHorizontalDisplacementSpinBox->blockSignals( false );
2378  mVerticalDisplacementSpinBox->blockSignals( true );
2379  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2380  mVerticalDisplacementSpinBox->blockSignals( false );
2381 
2382  mHorizontalDistanceUnitWidget->blockSignals( true );
2383  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2384  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2385  mHorizontalDistanceUnitWidget->blockSignals( false );
2386  mVerticalDistanceUnitWidget->blockSignals( true );
2387  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2388  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2389  mVerticalDistanceUnitWidget->blockSignals( false );
2390  mHorizontalDisplacementUnitWidget->blockSignals( true );
2391  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2392  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2393  mHorizontalDisplacementUnitWidget->blockSignals( false );
2394  mVerticalDisplacementUnitWidget->blockSignals( true );
2395  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2396  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2397  mVerticalDisplacementUnitWidget->blockSignals( false );
2398 
2399  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2401  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2402  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2403 }
2404 
2406 {
2407  return mLayer;
2408 }
2409 
2410 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2411 {
2412  if ( mLayer )
2413  {
2414  mLayer->setDistanceX( d );
2415  emit changed();
2416  }
2417 }
2418 
2419 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2420 {
2421  if ( mLayer )
2422  {
2423  mLayer->setDistanceY( d );
2424  emit changed();
2425  }
2426 }
2427 
2428 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2429 {
2430  if ( mLayer )
2431  {
2432  mLayer->setDisplacementX( d );
2433  emit changed();
2434  }
2435 }
2436 
2437 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2438 {
2439  if ( mLayer )
2440  {
2441  mLayer->setDisplacementY( d );
2442  emit changed();
2443  }
2444 }
2445 
2446 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2447 {
2448  if ( mLayer )
2449  {
2450  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2451  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2452  emit changed();
2453  }
2454 }
2455 
2456 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2457 {
2458  if ( mLayer )
2459  {
2460  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2461  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2462  emit changed();
2463  }
2464 }
2465 
2466 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2467 {
2468  if ( mLayer )
2469  {
2470  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2471  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2472  emit changed();
2473  }
2474 }
2475 
2476 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2477 {
2478  if ( mLayer )
2479  {
2480  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2481  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2482  emit changed();
2483  }
2484 }
2485 
2487 
2489  : QgsSymbolLayerV2Widget( parent, vl )
2490 {
2491  mLayer = NULL;
2492 
2493  setupUi( this );
2494  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2495  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2497  scrollArea->setWidget( widgetChar );
2498 
2499  btnColor->setAllowAlpha( true );
2500  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2501  btnColor->setContext( "symbology" );
2502 
2503  spinOffsetX->setClearValue( 0.0 );
2504  spinOffsetY->setClearValue( 0.0 );
2505 
2506  //make a temporary symbol for the size assistant preview
2507  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
2508 
2509  if ( mVectorLayer )
2510  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
2511 
2512  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2513  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2514  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2515  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2516  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2517  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2518  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2519  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
2520 }
2521 
2523 {
2524  delete mAssistantPreviewSymbol;
2525 }
2526 
2528 {
2529  if ( layer->layerType() != "FontMarker" )
2530  return;
2531 
2532  // layer type is correct, we can do the cast
2533  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2534 
2535  QFont layerFont( mLayer->fontFamily() );
2536  // set values
2537  cboFont->blockSignals( true );
2538  cboFont->setCurrentFont( layerFont );
2539  cboFont->blockSignals( false );
2540  spinSize->blockSignals( true );
2541  spinSize->setValue( mLayer->size() );
2542  spinSize->blockSignals( false );
2543  btnColor->blockSignals( true );
2544  btnColor->setColor( mLayer->color() );
2545  btnColor->blockSignals( false );
2546  spinAngle->blockSignals( true );
2547  spinAngle->setValue( mLayer->angle() );
2548  spinAngle->blockSignals( false );
2549 
2550  widgetChar->blockSignals( true );
2551  widgetChar->updateFont( layerFont );
2553  widgetChar->blockSignals( false );
2554 
2555  //block
2556  spinOffsetX->blockSignals( true );
2557  spinOffsetX->setValue( mLayer->offset().x() );
2558  spinOffsetX->blockSignals( false );
2559  spinOffsetY->blockSignals( true );
2560  spinOffsetY->setValue( mLayer->offset().y() );
2561  spinOffsetY->blockSignals( false );
2562 
2563  mSizeUnitWidget->blockSignals( true );
2564  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2565  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2566  mSizeUnitWidget->blockSignals( false );
2567 
2568  mOffsetUnitWidget->blockSignals( true );
2569  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2570  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2571  mOffsetUnitWidget->blockSignals( false );
2572 
2573  //anchor points
2574  mHorizontalAnchorComboBox->blockSignals( true );
2575  mVerticalAnchorComboBox->blockSignals( true );
2576  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2577  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2578  mHorizontalAnchorComboBox->blockSignals( false );
2579  mVerticalAnchorComboBox->blockSignals( false );
2580 
2585  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
2586  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
2588 
2589  updateAssistantSymbol();
2590 }
2591 
2593 {
2594  return mLayer;
2595 }
2596 
2598 {
2599  mLayer->setFontFamily( font.family() );
2600  widgetChar->updateFont( font );
2601  emit changed();
2602 }
2603 
2605 {
2606  mLayer->setColor( color );
2607  emit changed();
2608 }
2609 
2611 {
2612  mLayer->setSize( size );
2613  //widgetChar->updateSize(size);
2614  emit changed();
2615 }
2616 
2618 {
2619  mLayer->setAngle( angle );
2620  emit changed();
2621 }
2622 
2624 {
2625  mLayer->setCharacter( chr );
2626  emit changed();
2627 }
2628 
2630 {
2631  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2632  emit changed();
2633 }
2634 
2636 {
2637  if ( mLayer )
2638  {
2639  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2640  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2641  emit changed();
2642  }
2643 }
2644 
2646 {
2647  if ( mLayer )
2648  {
2649  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2650  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2651  emit changed();
2652  }
2653 }
2654 
2656 {
2657  if ( mLayer )
2658  {
2660  emit changed();
2661  }
2662 }
2663 
2665 {
2666  if ( mLayer )
2667  {
2669  emit changed();
2670  }
2671 }
2672 
2673 void QgsFontMarkerSymbolLayerV2Widget::updateAssistantSymbol()
2674 {
2675  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2676  {
2677  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2678  }
2679  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2680  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
2681  if ( ddSize )
2682  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
2683 }
2684 
2686 
2687 
2689  : QgsSymbolLayerV2Widget( parent, vl )
2690 {
2691  mLayer = NULL;
2692 
2693  setupUi( this );
2694 }
2695 
2697 {
2698  if ( layer->layerType() != "CentroidFill" )
2699  return;
2700 
2701  // layer type is correct, we can do the cast
2702  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2703 
2704  // set values
2705  mDrawInsideCheckBox->blockSignals( true );
2706  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2707  mDrawInsideCheckBox->blockSignals( false );
2708 }
2709 
2711 {
2712  return mLayer;
2713 }
2714 
2716 {
2717  mLayer->setPointOnSurface( state == Qt::Checked );
2718  emit changed();
2719 }
2720 
2722 
2724  : QgsSymbolLayerV2Widget( parent, vl )
2725 {
2726  mLayer = 0;
2727  setupUi( this );
2728 
2730  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2731 
2732  mSpinOffsetX->setClearValue( 0.0 );
2733  mSpinOffsetY->setClearValue( 0.0 );
2734 
2735  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2736  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2737  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2738 }
2739 
2741 {
2742  if ( !layer )
2743  {
2744  return;
2745  }
2746 
2747  if ( layer->layerType() != "RasterFill" )
2748  {
2749  return;
2750  }
2751 
2752  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2753  if ( !mLayer )
2754  {
2755  return;
2756  }
2757 
2758  mImageLineEdit->blockSignals( true );
2759  mImageLineEdit->setText( mLayer->imageFilePath() );
2760  mImageLineEdit->blockSignals( false );
2761 
2762  cboCoordinateMode->blockSignals( true );
2763  switch ( mLayer->coordinateMode() )
2764  {
2766  cboCoordinateMode->setCurrentIndex( 1 );
2767  break;
2769  default:
2770  cboCoordinateMode->setCurrentIndex( 0 );
2771  break;
2772  }
2773  cboCoordinateMode->blockSignals( false );
2774  mSpinTransparency->blockSignals( true );
2775  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2776  mSpinTransparency->blockSignals( false );
2777  mSliderTransparency->blockSignals( true );
2778  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2779  mSliderTransparency->blockSignals( false );
2780  mRotationSpinBox->blockSignals( true );
2781  mRotationSpinBox->setValue( mLayer->angle() );
2782  mRotationSpinBox->blockSignals( false );
2783 
2784  mSpinOffsetX->blockSignals( true );
2785  mSpinOffsetX->setValue( mLayer->offset().x() );
2786  mSpinOffsetX->blockSignals( false );
2787  mSpinOffsetY->blockSignals( true );
2788  mSpinOffsetY->setValue( mLayer->offset().y() );
2789  mSpinOffsetY->blockSignals( false );
2790  mOffsetUnitWidget->blockSignals( true );
2791  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2792  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2793  mOffsetUnitWidget->blockSignals( false );
2794 
2795  mWidthSpinBox->blockSignals( true );
2796  mWidthSpinBox->setValue( mLayer->width() );
2797  mWidthSpinBox->blockSignals( false );
2798  mWidthUnitWidget->blockSignals( true );
2799  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
2800  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2801  mWidthUnitWidget->blockSignals( false );
2802  updatePreviewImage();
2803 
2808 }
2809 
2811 {
2812  return mLayer;
2813 }
2814 
2815 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2816 {
2817  QSettings s;
2818  QString openDir;
2819  QString lineEditText = mImageLineEdit->text();
2820  if ( !lineEditText.isEmpty() )
2821  {
2822  QFileInfo openDirFileInfo( lineEditText );
2823  openDir = openDirFileInfo.path();
2824  }
2825 
2826  if ( openDir.isEmpty() )
2827  {
2828  openDir = s.value( "/UI/lastRasterFillImageDir", "" ).toString();
2829  }
2830 
2831  //show file dialog
2832  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select image file" ), openDir );
2833  if ( !filePath.isNull() )
2834  {
2835  //check if file exists
2836  QFileInfo fileInfo( filePath );
2837  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2838  {
2839  QMessageBox::critical( 0, "Invalid file", "Error, file does not exist or is not readable" );
2840  return;
2841  }
2842 
2843  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2844  mImageLineEdit->setText( filePath );
2845  on_mImageLineEdit_editingFinished();
2846  }
2847 }
2848 
2849 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2850 {
2851  if ( !mLayer )
2852  {
2853  return;
2854  }
2855 
2856  QFileInfo fi( mImageLineEdit->text() );
2857  if ( !fi.exists() )
2858  {
2859  QUrl url( mImageLineEdit->text() );
2860  if ( !url.isValid() )
2861  {
2862  return;
2863  }
2864  }
2865 
2866  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2867  mLayer->setImageFilePath( mImageLineEdit->text() );
2868  updatePreviewImage();
2870 
2871  emit changed();
2872 }
2873 
2874 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2875 {
2876  switch ( index )
2877  {
2878  case 0:
2879  //feature coordinate mode
2881  break;
2882  case 1:
2883  //viewport coordinate mode
2885  break;
2886  }
2887 
2888  emit changed();
2889 }
2890 
2891 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2892 {
2893  if ( !mLayer )
2894  {
2895  return;
2896  }
2897 
2898  mLayer->setAlpha( value / 100.0 );
2899  emit changed();
2900  updatePreviewImage();
2901 }
2902 
2903 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2904 {
2905  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2906  emit changed();
2907 }
2908 
2909 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2910 {
2911  if ( !mLayer )
2912  {
2913  return;
2914  }
2915  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2916  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2917  emit changed();
2918 }
2919 
2920 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2921 {
2922  if ( mLayer )
2923  {
2924  mLayer->setAngle( d );
2925  emit changed();
2926  }
2927 }
2928 
2929 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2930 {
2931  if ( !mLayer )
2932  {
2933  return;
2934  }
2935  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
2936  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2937  emit changed();
2938 }
2939 
2940 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2941 {
2942  if ( !mLayer )
2943  {
2944  return;
2945  }
2946  mLayer->setWidth( d );
2947  emit changed();
2948 }
2949 
2950 
2951 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2952 {
2953  if ( !mLayer )
2954  {
2955  return;
2956  }
2957 
2958  QImage image( mLayer->imageFilePath() );
2959  if ( image.isNull() )
2960  {
2961  mLabelImagePreview->setPixmap( QPixmap() );
2962  return;
2963  }
2964 
2965  if ( image.height() > 150 || image.width() > 150 )
2966  {
2967  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
2968  }
2969 
2970  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
2971  previewImage.fill( Qt::transparent );
2972  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
2973  QPainter p;
2974  p.begin( &previewImage );
2975  //draw a checkerboard background
2976  uchar pixDataRGB[] = { 150, 150, 150, 150,
2977  100, 100, 100, 150,
2978  100, 100, 100, 150,
2979  150, 150, 150, 150
2980  };
2981  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
2982  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
2983  QBrush checkerBrush;
2984  checkerBrush.setTexture( pix );
2985  p.fillRect( imageRect, checkerBrush );
2986 
2987  if ( mLayer->alpha() < 1.0 )
2988  {
2989  p.setOpacity( mLayer->alpha() );
2990  }
2991 
2992  p.drawImage( imageRect.left(), imageRect.top(), image );
2993  p.end();
2994  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
2995 }
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:97
void setDrawInsidePolygon(bool drawInsidePolygon)
void setGradientType(GradientType gradientType)
void setValue(const QString &key, const QVariant &value)
QSize size() const
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
const QImage & svgAsImage(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool &fitsInCache)
Get SVG as QImage.
const char * name() const
QgsSymbolV2::OutputUnit offsetUnit() const
QgsSymbolLayerV2 * clone() const override
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
QgsShapeburstFillSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
double offsetAlongLine() const
Returns the offset along the line for the marker placement.
int count(const T &value) const
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit u)
A class for filling symbols with a repeated raster image.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
Qt::PenStyle borderStyle() const
qreal x() const
qreal y() const
A dialog to enter a custom dash space pattern for lines.
void on_mChangeColorButton_colorChanged(const QColor &color)
void setBorderColor(const QColor &color)
void setOffset(double offset)
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)