QGIS API Documentation  2.11.0-Master
 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( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
759  connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
760  connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
761  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
762  connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
763  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
764  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
765  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
766  connect( spinRefPoint1X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
767  connect( spinRefPoint1Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
768  connect( checkRefPoint1Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
769  connect( spinRefPoint2X, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
770  connect( spinRefPoint2Y, SIGNAL( valueChanged( double ) ), this, SLOT( referencePointChanged() ) );
771  connect( checkRefPoint2Centroid, SIGNAL( toggled( bool ) ), this, SLOT( referencePointChanged() ) );
772 }
773 
775 {
776  if ( layer->layerType() != "GradientFill" )
777  return;
778 
779  // layer type is correct, we can do the cast
780  mLayer = static_cast<QgsGradientFillSymbolLayerV2*>( layer );
781 
782  // set values
783  btnChangeColor->blockSignals( true );
784  btnChangeColor->setColor( mLayer->color() );
785  btnChangeColor->blockSignals( false );
786  btnChangeColor2->blockSignals( true );
787  btnChangeColor2->setColor( mLayer->color2() );
788  btnChangeColor2->blockSignals( false );
789 
791  {
792  radioTwoColor->setChecked( true );
793  cboGradientColorRamp->setEnabled( false );
794  }
795  else
796  {
797  radioColorRamp->setChecked( true );
798  btnChangeColor->setEnabled( false );
799  btnChangeColor2->setEnabled( false );
800  }
801 
802  // set source color ramp
803  if ( mLayer->colorRamp() )
804  {
805  cboGradientColorRamp->blockSignals( true );
806  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
807  cboGradientColorRamp->blockSignals( false );
808  }
809 
810  cboGradientType->blockSignals( true );
811  switch ( mLayer->gradientType() )
812  {
814  cboGradientType->setCurrentIndex( 0 );
815  break;
817  cboGradientType->setCurrentIndex( 1 );
818  break;
820  cboGradientType->setCurrentIndex( 2 );
821  break;
822  }
823  cboGradientType->blockSignals( false );
824 
825  cboCoordinateMode->blockSignals( true );
826  switch ( mLayer->coordinateMode() )
827  {
829  cboCoordinateMode->setCurrentIndex( 1 );
830  checkRefPoint1Centroid->setEnabled( false );
831  checkRefPoint2Centroid->setEnabled( false );
832  break;
834  default:
835  cboCoordinateMode->setCurrentIndex( 0 );
836  break;
837  }
838  cboCoordinateMode->blockSignals( false );
839 
840  cboGradientSpread->blockSignals( true );
841  switch ( mLayer->gradientSpread() )
842  {
844  cboGradientSpread->setCurrentIndex( 0 );
845  break;
847  cboGradientSpread->setCurrentIndex( 1 );
848  break;
850  cboGradientSpread->setCurrentIndex( 2 );
851  break;
852  }
853  cboGradientSpread->blockSignals( false );
854 
855  spinRefPoint1X->blockSignals( true );
856  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
857  spinRefPoint1X->blockSignals( false );
858  spinRefPoint1Y->blockSignals( true );
859  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
860  spinRefPoint1Y->blockSignals( false );
861  checkRefPoint1Centroid->blockSignals( true );
862  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
864  {
865  spinRefPoint1X->setEnabled( false );
866  spinRefPoint1Y->setEnabled( false );
867  }
868  checkRefPoint1Centroid->blockSignals( false );
869  spinRefPoint2X->blockSignals( true );
870  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
871  spinRefPoint2X->blockSignals( false );
872  spinRefPoint2Y->blockSignals( true );
873  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
874  spinRefPoint2Y->blockSignals( false );
875  checkRefPoint2Centroid->blockSignals( true );
876  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
878  {
879  spinRefPoint2X->setEnabled( false );
880  spinRefPoint2Y->setEnabled( false );
881  }
882  checkRefPoint2Centroid->blockSignals( false );
883 
884  spinOffsetX->blockSignals( true );
885  spinOffsetX->setValue( mLayer->offset().x() );
886  spinOffsetX->blockSignals( false );
887  spinOffsetY->blockSignals( true );
888  spinOffsetY->setValue( mLayer->offset().y() );
889  spinOffsetY->blockSignals( false );
890  mSpinAngle->blockSignals( true );
891  mSpinAngle->setValue( mLayer->angle() );
892  mSpinAngle->blockSignals( false );
893 
894  mOffsetUnitWidget->blockSignals( true );
895  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
896  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
897  mOffsetUnitWidget->blockSignals( false );
898 
907  registerDataDefinedButton( mRefPoint1CentroidDDBtn, "reference1_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
910  registerDataDefinedButton( mRefPoint2CentroidDDBtn, "reference2_iscentroid", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
911 }
912 
914 {
915  return mLayer;
916 }
917 
919 {
920  mLayer->setColor( color );
921  emit changed();
922 }
923 
925 {
926  mLayer->setColor2( color );
927  emit changed();
928 }
929 
931 {
932  if ( radioTwoColor->isChecked() )
933  {
935  }
936  else
937  {
939  }
940  emit changed();
941 }
942 
944 {
945  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
946  if ( ramp == NULL )
947  return;
948 
949  mLayer->setColorRamp( ramp );
950  emit changed();
951 }
952 
954 {
955  switch ( index )
956  {
957  case 0:
959  //set sensible default reference points
960  spinRefPoint1X->setValue( 0.5 );
961  spinRefPoint1Y->setValue( 0 );
962  spinRefPoint2X->setValue( 0.5 );
963  spinRefPoint2Y->setValue( 1 );
964  break;
965  case 1:
967  //set sensible default reference points
968  spinRefPoint1X->setValue( 0 );
969  spinRefPoint1Y->setValue( 0 );
970  spinRefPoint2X->setValue( 1 );
971  spinRefPoint2Y->setValue( 1 );
972  break;
973  case 2:
975  spinRefPoint1X->setValue( 0.5 );
976  spinRefPoint1Y->setValue( 0.5 );
977  spinRefPoint2X->setValue( 1 );
978  spinRefPoint2Y->setValue( 1 );
979  break;
980  }
981  emit changed();
982 }
983 
985 {
986 
987  switch ( index )
988  {
989  case 0:
990  //feature coordinate mode
992  //allow choice of centroid reference positions
993  checkRefPoint1Centroid->setEnabled( true );
994  checkRefPoint2Centroid->setEnabled( true );
995  break;
996  case 1:
997  //viewport coordinate mode
999  //disable choice of centroid reference positions
1000  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1001  checkRefPoint1Centroid->setEnabled( false );
1002  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1003  checkRefPoint2Centroid->setEnabled( false );
1004  break;
1005  }
1006 
1007  emit changed();
1008 }
1009 
1011 {
1012  switch ( index )
1013  {
1014  case 0:
1016  break;
1017  case 1:
1019  break;
1020  case 2:
1022  break;
1023  }
1024 
1025  emit changed();
1026 }
1027 
1029 {
1030  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1031  emit changed();
1032 }
1033 
1035 {
1036  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1037  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1038  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1039  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1040  emit changed();
1041 }
1042 
1044 {
1045  mLayer->setAngle( value );
1046  emit changed();
1047 }
1048 
1050 {
1051  if ( mLayer )
1052  {
1053  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1054  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1055  emit changed();
1056  }
1057 }
1058 
1060 
1062  : QgsSymbolLayerV2Widget( parent, vl )
1063 {
1064  mLayer = NULL;
1065 
1066  setupUi( this );
1067  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1068  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1069 
1070  btnChangeColor->setAllowAlpha( true );
1071  btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
1072  btnChangeColor->setContext( "symbology" );
1073  btnChangeColor->setShowNoColor( true );
1074  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1075  btnChangeColor2->setAllowAlpha( true );
1076  btnChangeColor2->setColorDialogTitle( tr( "Select gradient color" ) );
1077  btnChangeColor2->setContext( "symbology" );
1078  btnChangeColor2->setShowNoColor( true );
1079  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1080 
1081  spinOffsetX->setClearValue( 0.0 );
1082  spinOffsetY->setClearValue( 0.0 );
1083 
1084  cboGradientColorRamp->populate( QgsStyleV2::defaultStyle() );
1085 
1086  connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1087  connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
1088  connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
1089 
1090  connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
1091  connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
1092  connect( radioTwoColor, SIGNAL( toggled( bool ) ), this, SLOT( colorModeChanged() ) );
1093  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1094  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
1095 
1096  connect( mBlurSlider, SIGNAL( valueChanged( int ) ), mSpinBlurRadius, SLOT( setValue( int ) ) );
1097  connect( mSpinBlurRadius, SIGNAL( valueChanged( int ) ), mBlurSlider, SLOT( setValue( int ) ) );
1098 }
1099 
1101 {
1102  if ( layer->layerType() != "ShapeburstFill" )
1103  return;
1104 
1105  // layer type is correct, we can do the cast
1106  mLayer = static_cast<QgsShapeburstFillSymbolLayerV2*>( layer );
1107 
1108  // set values
1109  btnChangeColor->blockSignals( true );
1110  btnChangeColor->setColor( mLayer->color() );
1111  btnChangeColor->blockSignals( false );
1112  btnChangeColor2->blockSignals( true );
1113  btnChangeColor2->setColor( mLayer->color2() );
1114  btnChangeColor2->blockSignals( false );
1115 
1117  {
1118  radioTwoColor->setChecked( true );
1119  cboGradientColorRamp->setEnabled( false );
1120  }
1121  else
1122  {
1123  radioColorRamp->setChecked( true );
1124  btnChangeColor->setEnabled( false );
1125  btnChangeColor2->setEnabled( false );
1126  }
1127 
1128  mSpinBlurRadius->blockSignals( true );
1129  mBlurSlider->blockSignals( true );
1130  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1131  mBlurSlider->setValue( mLayer->blurRadius() );
1132  mSpinBlurRadius->blockSignals( false );
1133  mBlurSlider->blockSignals( false );
1134 
1135  mSpinMaxDistance->blockSignals( true );
1136  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1137  mSpinMaxDistance->blockSignals( false );
1138 
1139  mRadioUseWholeShape->blockSignals( true );
1140  mRadioUseMaxDistance->blockSignals( true );
1141  if ( mLayer->useWholeShape() )
1142  {
1143  mRadioUseWholeShape->setChecked( true );
1144  mSpinMaxDistance->setEnabled( false );
1145  mDistanceUnitWidget->setEnabled( false );
1146  }
1147  else
1148  {
1149  mRadioUseMaxDistance->setChecked( true );
1150  mSpinMaxDistance->setEnabled( true );
1151  mDistanceUnitWidget->setEnabled( true );
1152  }
1153  mRadioUseWholeShape->blockSignals( false );
1154  mRadioUseMaxDistance->blockSignals( false );
1155 
1156  mDistanceUnitWidget->blockSignals( true );
1157  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1158  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1159  mDistanceUnitWidget->blockSignals( false );
1160 
1161  mIgnoreRingsCheckBox->blockSignals( true );
1162  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1163  mIgnoreRingsCheckBox->blockSignals( false );
1164 
1165  // set source color ramp
1166  if ( mLayer->colorRamp() )
1167  {
1168  cboGradientColorRamp->blockSignals( true );
1169  cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1170  cboGradientColorRamp->blockSignals( false );
1171  }
1172 
1173  spinOffsetX->blockSignals( true );
1174  spinOffsetX->setValue( mLayer->offset().x() );
1175  spinOffsetX->blockSignals( false );
1176  spinOffsetY->blockSignals( true );
1177  spinOffsetY->setValue( mLayer->offset().y() );
1178  spinOffsetY->blockSignals( false );
1179  mOffsetUnitWidget->blockSignals( true );
1180  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1181  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1182  mOffsetUnitWidget->blockSignals( false );
1183 
1186  registerDataDefinedButton( mBlurRadiusDDBtn, "blur_radius", QgsDataDefinedButton::Int, tr( "Integer between 0 and 18" ) );
1187  registerDataDefinedButton( mShadeWholeShapeDDBtn, "use_whole_shape", QgsDataDefinedButton::Int, QgsDataDefinedButton::boolDesc() );
1190 }
1191 
1193 {
1194  return mLayer;
1195 }
1196 
1198 {
1199  if ( mLayer )
1200  {
1201  mLayer->setColor( color );
1202  emit changed();
1203  }
1204 }
1205 
1207 {
1208  if ( mLayer )
1209  {
1210  mLayer->setColor2( color );
1211  emit changed();
1212  }
1213 }
1214 
1216 {
1217  if ( !mLayer )
1218  {
1219  return;
1220  }
1221 
1222  if ( radioTwoColor->isChecked() )
1223  {
1225  }
1226  else
1227  {
1229  }
1230  emit changed();
1231 }
1232 
1234 {
1235  if ( mLayer )
1236  {
1237  mLayer->setBlurRadius( value );
1238  emit changed();
1239  }
1240 }
1241 
1243 {
1244  if ( mLayer )
1245  {
1246  mLayer->setMaxDistance( value );
1247  emit changed();
1248  }
1249 }
1250 
1252 {
1253  if ( mLayer )
1254  {
1255  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1256  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1257  emit changed();
1258  }
1259 }
1260 
1262 {
1263  if ( mLayer )
1264  {
1265  mLayer->setUseWholeShape( value );
1266  mDistanceUnitWidget->setEnabled( !value );
1267  emit changed();
1268  }
1269 }
1270 
1272 {
1273  QgsVectorColorRampV2* ramp = cboGradientColorRamp->currentColorRamp();
1274  if ( ramp == NULL )
1275  return;
1276 
1277  mLayer->setColorRamp( ramp );
1278  emit changed();
1279 }
1280 
1282 {
1283  if ( mLayer )
1284  {
1285  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1286  emit changed();
1287  }
1288 }
1289 
1291 {
1292  if ( mLayer )
1293  {
1294  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1295  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1296  emit changed();
1297  }
1298 }
1299 
1300 
1302 {
1303  bool checked = ( state == Qt::Checked );
1304  mLayer->setIgnoreRings( checked );
1305  emit changed();
1306 }
1307 
1309 
1311  : QgsSymbolLayerV2Widget( parent, vl )
1312 {
1313  mLayer = NULL;
1314 
1315  setupUi( this );
1316  mIntervalUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1317  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1318  mOffsetAlongLineUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1319 
1320  spinOffset->setClearValue( 0.0 );
1321 
1322  connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
1323  connect( mSpinOffsetAlongLine, SIGNAL( valueChanged( double ) ), this, SLOT( setOffsetAlongLine( double ) ) );
1324  connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
1325  connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1326  connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1327  connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1328  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1329  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1330  connect( radCentralPoint, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
1331 }
1332 
1334 {
1335  if ( layer->layerType() != "MarkerLine" )
1336  return;
1337 
1338  // layer type is correct, we can do the cast
1339  mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
1340 
1341  // set values
1342  spinInterval->blockSignals( true );
1343  spinInterval->setValue( mLayer->interval() );
1344  spinInterval->blockSignals( false );
1345  mSpinOffsetAlongLine->blockSignals( true );
1346  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1347  mSpinOffsetAlongLine->blockSignals( false );
1348  chkRotateMarker->blockSignals( true );
1349  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1350  chkRotateMarker->blockSignals( false );
1351  spinOffset->blockSignals( true );
1352  spinOffset->setValue( mLayer->offset() );
1353  spinOffset->blockSignals( false );
1355  radInterval->setChecked( true );
1357  radVertex->setChecked( true );
1359  radVertexLast->setChecked( true );
1361  radCentralPoint->setChecked( true );
1362  else
1363  radVertexFirst->setChecked( true );
1364 
1365  // set units
1366  mIntervalUnitWidget->blockSignals( true );
1367  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1368  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1369  mIntervalUnitWidget->blockSignals( false );
1370  mOffsetUnitWidget->blockSignals( true );
1371  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1372  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1373  mOffsetUnitWidget->blockSignals( false );
1374  mOffsetAlongLineUnitWidget->blockSignals( true );
1375  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1376  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1377  mOffsetAlongLineUnitWidget->blockSignals( false );
1378 
1379  setPlacement(); // update gui
1380 
1383  registerDataDefinedButton( mPlacementDDBtn, "placement", QgsDataDefinedButton::String, tr( "string " ) + QString( "[<b>vertex</b>|<b>lastvertex</b>|<b>firstvertex</b>|<b>centerpoint</b>]" ) );
1384  registerDataDefinedButton( mOffsetAlongLineDDBtn, "offset_along_line", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
1385 }
1386 
1388 {
1389  return mLayer;
1390 }
1391 
1393 {
1394  mLayer->setInterval( val );
1395  emit changed();
1396 }
1397 
1399 {
1400  mLayer->setOffsetAlongLine( val );
1401  emit changed();
1402 }
1403 
1405 {
1406  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1407  emit changed();
1408 }
1409 
1411 {
1412  mLayer->setOffset( spinOffset->value() );
1413  emit changed();
1414 }
1415 
1417 {
1418  bool interval = radInterval->isChecked();
1419  spinInterval->setEnabled( interval );
1420  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1421  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
1422  if ( radInterval->isChecked() )
1424  else if ( radVertex->isChecked() )
1426  else if ( radVertexLast->isChecked() )
1428  else if ( radVertexFirst->isChecked() )
1430  else
1432 
1433  emit changed();
1434 }
1435 
1437 {
1438  if ( mLayer )
1439  {
1440  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1441  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1442  emit changed();
1443  }
1444 }
1445 
1447 {
1448  if ( mLayer )
1449  {
1450  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1451  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1452  emit changed();
1453  }
1454 }
1455 
1457 {
1458  if ( mLayer )
1459  {
1460  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1461  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1462  }
1463  emit changed();
1464 }
1465 
1467 
1468 
1470  : QgsSymbolLayerV2Widget( parent, vl )
1471 {
1472  mLayer = NULL;
1473 
1474  setupUi( this );
1475  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1476  mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1477  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1478  viewGroups->setHeaderHidden( true );
1479 
1480  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1481  mChangeColorButton->setContext( "symbology" );
1482  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1483  mChangeColorButton->setContext( "symbology" );
1484 
1485  spinOffsetX->setClearValue( 0.0 );
1486  spinOffsetY->setClearValue( 0.0 );
1487 
1488  populateList();
1489 
1490  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1491  connect( viewGroups->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1492  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
1493  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
1494  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1495  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
1496  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
1497 
1498  //make a temporary symbol for the size assistant preview
1499  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
1500  if ( mVectorLayer )
1501  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
1502 }
1503 
1505 {
1506  delete mAssistantPreviewSymbol;
1507 }
1508 
1509 #include <QTime>
1510 #include <QAbstractListModel>
1511 #include <QPixmapCache>
1512 #include <QStyle>
1513 
1515 {
1516  public:
1518  {
1520  }
1521 
1522  // Constructor to create model for icons in a specific path
1524  {
1526  }
1527 
1528  int rowCount( const QModelIndex & parent = QModelIndex() ) const override
1529  {
1530  Q_UNUSED( parent );
1531  return mSvgFiles.count();
1532  }
1533 
1534  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override
1535  {
1536  QString entry = mSvgFiles.at( index.row() );
1537 
1538  if ( role == Qt::DecorationRole ) // icon
1539  {
1540  QPixmap pixmap;
1541  if ( !QPixmapCache::find( entry, pixmap ) )
1542  {
1543  // render SVG file
1544  QColor fill, outline;
1545  double outlineWidth;
1546  bool fillParam, outlineParam, outlineWidthParam;
1547  QgsSvgCache::instance()->containsParams( entry, fillParam, fill, outlineParam, outline, outlineWidthParam, outlineWidth );
1548 
1549  bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
1550  const QImage& img = QgsSvgCache::instance()->svgAsImage( entry, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
1551  pixmap = QPixmap::fromImage( img );
1552  QPixmapCache::insert( entry, pixmap );
1553  }
1554 
1555  return pixmap;
1556  }
1557  else if ( role == Qt::UserRole || role == Qt::ToolTipRole )
1558  {
1559  return entry;
1560  }
1561 
1562  return QVariant();
1563  }
1564 
1565  protected:
1567 };
1568 
1570 {
1571  public:
1573  {
1575  QStandardItem *parentItem = invisibleRootItem();
1576 
1577  for ( int i = 0; i < svgPaths.size(); i++ )
1578  {
1579  QDir dir( svgPaths[i] );
1580  QStandardItem *baseGroup;
1581 
1582  if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
1583  {
1584  baseGroup = new QStandardItem( QString( "App Symbols" ) );
1585  }
1586  else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
1587  {
1588  baseGroup = new QStandardItem( QString( "User Symbols" ) );
1589  }
1590  else
1591  {
1592  baseGroup = new QStandardItem( dir.dirName() );
1593  }
1594  baseGroup->setData( QVariant( svgPaths[i] ) );
1595  baseGroup->setEditable( false );
1596  baseGroup->setCheckable( false );
1597  baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1598  baseGroup->setToolTip( dir.path() );
1599  parentItem->appendRow( baseGroup );
1600  createTree( baseGroup );
1601  QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
1602  }
1603  }
1604  private:
1605  void createTree( QStandardItem* &parentGroup )
1606  {
1607  QDir parentDir( parentGroup->data().toString() );
1608  foreach ( QString item, parentDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
1609  {
1610  QStandardItem* group = new QStandardItem( item );
1611  group->setData( QVariant( parentDir.path() + "/" + item ) );
1612  group->setEditable( false );
1613  group->setCheckable( false );
1614  group->setToolTip( parentDir.path() + "/" + item );
1615  group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
1616  parentGroup->appendRow( group );
1617  createTree( group );
1618  }
1619  }
1620 };
1621 
1623 {
1624  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups );
1625  viewGroups->setModel( g );
1626  // Set the tree expanded at the first level
1627  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1628  for ( int i = 0; i < rows; i++ )
1629  {
1630  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1631  }
1632 
1633  // Initally load the icons in the List view without any grouping
1634  QgsSvgListModel* m = new QgsSvgListModel( viewImages );
1635  viewImages->setModel( m );
1636 }
1637 
1639 {
1640  QString path = idx.data( Qt::UserRole + 1 ).toString();
1641 
1642  QgsSvgListModel* m = new QgsSvgListModel( viewImages, path );
1643  viewImages->setModel( m );
1644 
1645  connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
1646  emit changed();
1647 }
1648 
1650 {
1651  if ( !layer )
1652  {
1653  return;
1654  }
1655 
1656  //activate gui for svg parameters only if supported by the svg file
1657  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1658  QColor defaultFill, defaultOutline;
1659  double defaultOutlineWidth;
1660  QgsSvgCache::instance()->containsParams( layer->path(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
1661  mChangeColorButton->setEnabled( hasFillParam );
1662  mChangeBorderColorButton->setEnabled( hasOutlineParam );
1663  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
1664 
1665  if ( hasFillParam )
1666  {
1667  if ( layer->fillColor().isValid() )
1668  {
1669  mChangeColorButton->setColor( layer->fillColor() );
1670  }
1671  else
1672  {
1673  mChangeColorButton->setColor( defaultFill );
1674  }
1675  }
1676  if ( hasOutlineParam )
1677  {
1678  if ( layer->outlineColor().isValid() )
1679  {
1680  mChangeBorderColorButton->setColor( layer->outlineColor() );
1681  }
1682  else
1683  {
1684  mChangeBorderColorButton->setColor( defaultOutline );
1685  }
1686  }
1687 
1688  mFileLineEdit->blockSignals( true );
1689  mFileLineEdit->setText( layer->path() );
1690  mFileLineEdit->blockSignals( false );
1691 
1692  mBorderWidthSpinBox->blockSignals( true );
1693  mBorderWidthSpinBox->setValue( layer->outlineWidth() );
1694  mBorderWidthSpinBox->blockSignals( false );
1695 }
1696 
1697 void QgsSvgMarkerSymbolLayerV2Widget::updateAssistantSymbol()
1698 {
1699  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1700  {
1701  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1702  }
1703  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1704  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
1705  if ( ddSize )
1706  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
1707 }
1708 
1709 
1711 {
1712  if ( !layer )
1713  {
1714  return;
1715  }
1716 
1717  if ( layer->layerType() != "SvgMarker" )
1718  return;
1719 
1720  // layer type is correct, we can do the cast
1721  mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
1722 
1723  // set values
1724 
1725  QAbstractItemModel* m = viewImages->model();
1726  QItemSelectionModel* selModel = viewImages->selectionModel();
1727  for ( int i = 0; i < m->rowCount(); i++ )
1728  {
1729  QModelIndex idx( m->index( i, 0 ) );
1730  if ( m->data( idx ).toString() == mLayer->path() )
1731  {
1732  selModel->select( idx, QItemSelectionModel::SelectCurrent );
1733  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
1734  setName( idx );
1735  break;
1736  }
1737  }
1738 
1739  spinSize->blockSignals( true );
1740  spinSize->setValue( mLayer->size() );
1741  spinSize->blockSignals( false );
1742  spinAngle->blockSignals( true );
1743  spinAngle->setValue( mLayer->angle() );
1744  spinAngle->blockSignals( false );
1745 
1746  // without blocking signals the value gets changed because of slot setOffset()
1747  spinOffsetX->blockSignals( true );
1748  spinOffsetX->setValue( mLayer->offset().x() );
1749  spinOffsetX->blockSignals( false );
1750  spinOffsetY->blockSignals( true );
1751  spinOffsetY->setValue( mLayer->offset().y() );
1752  spinOffsetY->blockSignals( false );
1753 
1754  mSizeUnitWidget->blockSignals( true );
1755  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1756  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1757  mSizeUnitWidget->blockSignals( false );
1758  mBorderWidthUnitWidget->blockSignals( true );
1759  mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
1760  mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
1761  mBorderWidthUnitWidget->blockSignals( false );
1762  mOffsetUnitWidget->blockSignals( true );
1763  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1764  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1765  mOffsetUnitWidget->blockSignals( false );
1766 
1767  //anchor points
1768  mHorizontalAnchorComboBox->blockSignals( true );
1769  mVerticalAnchorComboBox->blockSignals( true );
1770  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1771  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
1772  mHorizontalAnchorComboBox->blockSignals( false );
1773  mVerticalAnchorComboBox->blockSignals( false );
1774 
1775  setGuiForSvg( mLayer );
1776 
1784  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
1785  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
1786 
1787  updateAssistantSymbol();
1788 }
1789 
1791 {
1792  return mLayer;
1793 }
1794 
1796 {
1797  QString name = idx.data( Qt::UserRole ).toString();
1798  mLayer->setPath( name );
1799  mFileLineEdit->setText( name );
1800 
1801  setGuiForSvg( mLayer );
1802  emit changed();
1803 }
1804 
1806 {
1807  mLayer->setSize( spinSize->value() );
1808  emit changed();
1809 }
1810 
1812 {
1813  mLayer->setAngle( spinAngle->value() );
1814  emit changed();
1815 }
1816 
1818 {
1819  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1820  emit changed();
1821 }
1822 
1824 {
1825  QSettings s;
1827  tr( "Select SVG file" ),
1828  s.value( "/UI/lastSVGMarkerDir" ).toString(),
1829  tr( "SVG files" ) + " (*.svg)" );
1830  QFileInfo fi( file );
1831  if ( file.isEmpty() || !fi.exists() )
1832  {
1833  return;
1834  }
1835  mFileLineEdit->setText( file );
1836  mLayer->setPath( file );
1837  s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
1838  emit changed();
1839 }
1840 
1842 {
1843  if ( !QFileInfo( text ).exists() )
1844  {
1845  return;
1846  }
1847  mLayer->setPath( text );
1848  setGuiForSvg( mLayer );
1849  emit changed();
1850 }
1851 
1853 {
1854  if ( !QFileInfo( mFileLineEdit->text() ).exists() )
1855  {
1856  QUrl url( mFileLineEdit->text() );
1857  if ( !url.isValid() )
1858  {
1859  return;
1860  }
1861  }
1862 
1863  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1864  mLayer->setPath( mFileLineEdit->text() );
1866 
1867  setGuiForSvg( mLayer );
1868  emit changed();
1869 }
1870 
1872 {
1873  if ( !mLayer )
1874  {
1875  return;
1876  }
1877 
1878  mLayer->setFillColor( color );
1879  emit changed();
1880 }
1881 
1883 {
1884  if ( !mLayer )
1885  {
1886  return;
1887  }
1888 
1889  mLayer->setOutlineColor( color );
1890  emit changed();
1891 }
1892 
1894 {
1895  if ( mLayer )
1896  {
1897  mLayer->setOutlineWidth( d );
1898  emit changed();
1899  }
1900 }
1901 
1903 {
1904  if ( mLayer )
1905  {
1906  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1907  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1908  emit changed();
1909  }
1910 }
1911 
1913 {
1914  if ( mLayer )
1915  {
1916  mLayer->setOutlineWidthUnit( mBorderWidthUnitWidget->unit() );
1917  mLayer->setOutlineWidthMapUnitScale( mBorderWidthUnitWidget->getMapUnitScale() );
1918  emit changed();
1919  }
1920 }
1921 
1923 {
1924  if ( mLayer )
1925  {
1926  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1927  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1928  emit changed();
1929  }
1930 }
1931 
1933 {
1934  if ( mLayer )
1935  {
1937  emit changed();
1938  }
1939 }
1940 
1942 {
1943  if ( mLayer )
1944  {
1946  emit changed();
1947  }
1948 }
1949 
1951 
1953 {
1954  mLayer = 0;
1955  setupUi( this );
1956  mTextureWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1957  mSvgOutlineWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
1958  mSvgTreeView->setHeaderHidden( true );
1959  insertIcons();
1960 
1961  mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
1962  mChangeColorButton->setContext( "symbology" );
1963  mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1964  mChangeBorderColorButton->setContext( "symbology" );
1965 
1966  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
1967  connect( mSvgTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( populateIcons( const QModelIndex& ) ) );
1968 }
1969 
1971 {
1972  if ( !layer )
1973  {
1974  return;
1975  }
1976 
1977  if ( layer->layerType() != "SVGFill" )
1978  {
1979  return;
1980  }
1981 
1982  mLayer = dynamic_cast<QgsSVGFillSymbolLayer*>( layer );
1983  if ( mLayer )
1984  {
1985  double width = mLayer->patternWidth();
1986  mTextureWidthSpinBox->blockSignals( true );
1987  mTextureWidthSpinBox->setValue( width );
1988  mTextureWidthSpinBox->blockSignals( false );
1989  mSVGLineEdit->setText( mLayer->svgFilePath() );
1990  mRotationSpinBox->blockSignals( true );
1991  mRotationSpinBox->setValue( mLayer->angle() );
1992  mRotationSpinBox->blockSignals( false );
1993  mTextureWidthUnitWidget->blockSignals( true );
1994  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
1995  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
1996  mTextureWidthUnitWidget->blockSignals( false );
1997  mSvgOutlineWidthUnitWidget->blockSignals( true );
1998  mSvgOutlineWidthUnitWidget->setUnit( mLayer->svgOutlineWidthUnit() );
1999  mSvgOutlineWidthUnitWidget->setMapUnitScale( mLayer->svgOutlineWidthMapUnitScale() );
2000  mSvgOutlineWidthUnitWidget->blockSignals( false );
2001  mChangeColorButton->blockSignals( true );
2002  mChangeColorButton->setColor( mLayer->svgFillColor() );
2003  mChangeColorButton->blockSignals( false );
2004  mChangeBorderColorButton->blockSignals( true );
2005  mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
2006  mChangeBorderColorButton->blockSignals( false );
2007  mBorderWidthSpinBox->blockSignals( true );
2008  mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
2009  mBorderWidthSpinBox->blockSignals( false );
2010  }
2011  updateParamGui( false );
2012 
2019 }
2020 
2022 {
2023  return mLayer;
2024 }
2025 
2026 void QgsSVGFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2027 {
2028  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select SVG texture file" ), QString(), tr( "SVG file" ) + " (*.svg);;" + tr( "All files" ) + " (*.*)" );
2029  if ( !filePath.isNull() )
2030  {
2031  mSVGLineEdit->setText( filePath );
2032  emit changed();
2033  }
2034 }
2035 
2036 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthSpinBox_valueChanged( double d )
2037 {
2038  if ( mLayer )
2039  {
2040  mLayer->setPatternWidth( d );
2041  emit changed();
2042  }
2043 }
2044 
2045 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_textEdited( const QString & text )
2046 {
2047  if ( !mLayer )
2048  {
2049  return;
2050  }
2051 
2052  QFileInfo fi( text );
2053  if ( !fi.exists() )
2054  {
2055  return;
2056  }
2057  mLayer->setSvgFilePath( text );
2058  updateParamGui();
2059  emit changed();
2060 }
2061 
2062 void QgsSVGFillSymbolLayerWidget::on_mSVGLineEdit_editingFinished()
2063 {
2064  if ( !mLayer )
2065  {
2066  return;
2067  }
2068 
2069  QFileInfo fi( mSVGLineEdit->text() );
2070  if ( !fi.exists() )
2071  {
2072  QUrl url( mSVGLineEdit->text() );
2073  if ( !url.isValid() )
2074  {
2075  return;
2076  }
2077  }
2078 
2079  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2080  mLayer->setSvgFilePath( mSVGLineEdit->text() );
2082 
2083  updateParamGui();
2084  emit changed();
2085 }
2086 
2087 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex& item )
2088 {
2089  QString file = item.data( Qt::UserRole ).toString();
2090  mLayer->setSvgFilePath( file );
2091  mSVGLineEdit->setText( file );
2092 
2093  updateParamGui();
2094  emit changed();
2095 }
2096 
2098 {
2099  QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView );
2100  mSvgTreeView->setModel( g );
2101  // Set the tree expanded at the first level
2102  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2103  for ( int i = 0; i < rows; i++ )
2104  {
2105  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2106  }
2107 
2108  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView );
2109  mSvgListView->setModel( m );
2110 }
2111 
2112 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex& idx )
2113 {
2114  QString path = idx.data( Qt::UserRole + 1 ).toString();
2115 
2116  QgsSvgListModel* m = new QgsSvgListModel( mSvgListView, path );
2117  mSvgListView->setModel( m );
2118 
2119  connect( mSvgListView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setFile( const QModelIndex& ) ) );
2120  emit changed();
2121 }
2122 
2123 
2124 void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2125 {
2126  if ( mLayer )
2127  {
2128  mLayer->setAngle( d );
2129  emit changed();
2130  }
2131 }
2132 
2134 {
2135  //activate gui for svg parameters only if supported by the svg file
2136  bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2137  QColor defaultFill, defaultOutline;
2138  double defaultOutlineWidth;
2139  QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
2140  if ( hasFillParam && resetValues )
2141  {
2142  mChangeColorButton->setColor( defaultFill );
2143  }
2144  mChangeColorButton->setEnabled( hasFillParam );
2145  if ( hasOutlineParam && resetValues )
2146  {
2147  mChangeBorderColorButton->setColor( defaultOutline );
2148  }
2149  mChangeBorderColorButton->setEnabled( hasOutlineParam );
2150  if ( hasOutlineWidthParam && resetValues )
2151  {
2152  mBorderWidthSpinBox->setValue( defaultOutlineWidth );
2153  }
2154  mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
2155 }
2156 
2157 void QgsSVGFillSymbolLayerWidget::on_mChangeColorButton_colorChanged( const QColor& color )
2158 {
2159  if ( !mLayer )
2160  {
2161  return;
2162  }
2163 
2164  mLayer->setSvgFillColor( color );
2165  emit changed();
2166 }
2167 
2168 void QgsSVGFillSymbolLayerWidget::on_mChangeBorderColorButton_colorChanged( const QColor& color )
2169 {
2170  if ( !mLayer )
2171  {
2172  return;
2173  }
2174 
2175  mLayer->setSvgOutlineColor( color );
2176  emit changed();
2177 }
2178 
2179 void QgsSVGFillSymbolLayerWidget::on_mBorderWidthSpinBox_valueChanged( double d )
2180 {
2181  if ( mLayer )
2182  {
2183  mLayer->setSvgOutlineWidth( d );
2184  emit changed();
2185  }
2186 }
2187 
2188 void QgsSVGFillSymbolLayerWidget::on_mTextureWidthUnitWidget_changed()
2189 {
2190  if ( mLayer )
2191  {
2192  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2193  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2194  emit changed();
2195  }
2196 }
2197 
2198 void QgsSVGFillSymbolLayerWidget::on_mSvgOutlineWidthUnitWidget_changed()
2199 {
2200  if ( mLayer )
2201  {
2202  mLayer->setSvgOutlineWidthUnit( mSvgOutlineWidthUnitWidget->unit() );
2203  mLayer->setSvgOutlineWidthMapUnitScale( mSvgOutlineWidthUnitWidget->getMapUnitScale() );
2204  emit changed();
2205  }
2206 }
2207 
2209 
2211  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2212 {
2213  setupUi( this );
2214  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2215  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2216  mOffsetSpinBox->setClearValue( 0 );
2217 }
2218 
2220 {
2221  if ( layer->layerType() != "LinePatternFill" )
2222  {
2223  return;
2224  }
2225 
2226  QgsLinePatternFillSymbolLayer* patternLayer = static_cast<QgsLinePatternFillSymbolLayer*>( layer );
2227  if ( patternLayer )
2228  {
2229  mLayer = patternLayer;
2230  mAngleSpinBox->blockSignals( true );
2231  mAngleSpinBox->setValue( mLayer->lineAngle() );
2232  mAngleSpinBox->blockSignals( false );
2233  mDistanceSpinBox->blockSignals( true );
2234  mDistanceSpinBox->setValue( mLayer->distance() );
2235  mDistanceSpinBox->blockSignals( false );
2236  mOffsetSpinBox->blockSignals( true );
2237  mOffsetSpinBox->setValue( mLayer->offset() );
2238  mOffsetSpinBox->blockSignals( false );
2239 
2240  //units
2241  mDistanceUnitWidget->blockSignals( true );
2242  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2243  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2244  mDistanceUnitWidget->blockSignals( false );
2245  mOffsetUnitWidget->blockSignals( true );
2246  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2247  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2248  mOffsetUnitWidget->blockSignals( false );
2249  }
2250 
2253 }
2254 
2256 {
2257  return mLayer;
2258 }
2259 
2260 void QgsLinePatternFillSymbolLayerWidget::on_mAngleSpinBox_valueChanged( double d )
2261 {
2262  if ( mLayer )
2263  {
2264  mLayer->setLineAngle( d );
2265  emit changed();
2266  }
2267 }
2268 
2269 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceSpinBox_valueChanged( double d )
2270 {
2271  if ( mLayer )
2272  {
2273  mLayer->setDistance( d );
2274  emit changed();
2275  }
2276 }
2277 
2278 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetSpinBox_valueChanged( double d )
2279 {
2280  if ( mLayer )
2281  {
2282  mLayer->setOffset( d );
2283  emit changed();
2284  }
2285 }
2286 
2287 void QgsLinePatternFillSymbolLayerWidget::on_mDistanceUnitWidget_changed()
2288 {
2289  if ( mLayer )
2290  {
2291  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2292  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2293  emit changed();
2294  }
2295 }
2296 
2297 void QgsLinePatternFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2298 {
2299  if ( mLayer )
2300  {
2301  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2302  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2303  emit changed();
2304  }
2305 }
2306 
2308 
2310  QgsSymbolLayerV2Widget( parent, vl ), mLayer( 0 )
2311 {
2312  setupUi( this );
2313  mHorizontalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2314  mVerticalDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2315  mHorizontalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2316  mVerticalDisplacementUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2317 }
2318 
2319 
2321 {
2322  if ( !layer || layer->layerType() != "PointPatternFill" )
2323  {
2324  return;
2325  }
2326 
2327  mLayer = static_cast<QgsPointPatternFillSymbolLayer*>( layer );
2328  mHorizontalDistanceSpinBox->blockSignals( true );
2329  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2330  mHorizontalDistanceSpinBox->blockSignals( false );
2331  mVerticalDistanceSpinBox->blockSignals( true );
2332  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2333  mVerticalDistanceSpinBox->blockSignals( false );
2334  mHorizontalDisplacementSpinBox->blockSignals( true );
2335  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2336  mHorizontalDisplacementSpinBox->blockSignals( false );
2337  mVerticalDisplacementSpinBox->blockSignals( true );
2338  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2339  mVerticalDisplacementSpinBox->blockSignals( false );
2340 
2341  mHorizontalDistanceUnitWidget->blockSignals( true );
2342  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2343  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2344  mHorizontalDistanceUnitWidget->blockSignals( false );
2345  mVerticalDistanceUnitWidget->blockSignals( true );
2346  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2347  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2348  mVerticalDistanceUnitWidget->blockSignals( false );
2349  mHorizontalDisplacementUnitWidget->blockSignals( true );
2350  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2351  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2352  mHorizontalDisplacementUnitWidget->blockSignals( false );
2353  mVerticalDisplacementUnitWidget->blockSignals( true );
2354  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2355  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2356  mVerticalDisplacementUnitWidget->blockSignals( false );
2357 
2358  registerDataDefinedButton( mHorizontalDistanceDDBtn, "distance_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2360  registerDataDefinedButton( mHorizontalDisplacementDDBtn, "displacement_x", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2361  registerDataDefinedButton( mVerticalDisplacementDDBtn, "displacement_y", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
2362 }
2363 
2365 {
2366  return mLayer;
2367 }
2368 
2369 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceSpinBox_valueChanged( double d )
2370 {
2371  if ( mLayer )
2372  {
2373  mLayer->setDistanceX( d );
2374  emit changed();
2375  }
2376 }
2377 
2378 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceSpinBox_valueChanged( double d )
2379 {
2380  if ( mLayer )
2381  {
2382  mLayer->setDistanceY( d );
2383  emit changed();
2384  }
2385 }
2386 
2387 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementSpinBox_valueChanged( double d )
2388 {
2389  if ( mLayer )
2390  {
2391  mLayer->setDisplacementX( d );
2392  emit changed();
2393  }
2394 }
2395 
2396 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementSpinBox_valueChanged( double d )
2397 {
2398  if ( mLayer )
2399  {
2400  mLayer->setDisplacementY( d );
2401  emit changed();
2402  }
2403 }
2404 
2405 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDistanceUnitWidget_changed()
2406 {
2407  if ( mLayer )
2408  {
2409  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2410  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2411  emit changed();
2412  }
2413 }
2414 
2415 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDistanceUnitWidget_changed()
2416 {
2417  if ( mLayer )
2418  {
2419  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2420  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2421  emit changed();
2422  }
2423 }
2424 
2425 void QgsPointPatternFillSymbolLayerWidget::on_mHorizontalDisplacementUnitWidget_changed()
2426 {
2427  if ( mLayer )
2428  {
2429  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2430  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2431  emit changed();
2432  }
2433 }
2434 
2435 void QgsPointPatternFillSymbolLayerWidget::on_mVerticalDisplacementUnitWidget_changed()
2436 {
2437  if ( mLayer )
2438  {
2439  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2440  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2441  emit changed();
2442  }
2443 }
2444 
2446 
2448  : QgsSymbolLayerV2Widget( parent, vl )
2449 {
2450  mLayer = NULL;
2451 
2452  setupUi( this );
2453  mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2454  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2456  scrollArea->setWidget( widgetChar );
2457 
2458  btnColor->setAllowAlpha( true );
2459  btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
2460  btnColor->setContext( "symbology" );
2461 
2462  spinOffsetX->setClearValue( 0.0 );
2463  spinOffsetY->setClearValue( 0.0 );
2464 
2465  //make a temporary symbol for the size assistant preview
2466  mAssistantPreviewSymbol = new QgsMarkerSymbolV2();
2467 
2468  if ( mVectorLayer )
2469  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mVectorLayer, mAssistantPreviewSymbol ) );
2470 
2471  connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
2472  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
2473  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
2474  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
2475  connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2476  connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
2477  connect( widgetChar, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
2478  connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
2479 }
2480 
2482 {
2483  delete mAssistantPreviewSymbol;
2484 }
2485 
2487 {
2488  if ( layer->layerType() != "FontMarker" )
2489  return;
2490 
2491  // layer type is correct, we can do the cast
2492  mLayer = static_cast<QgsFontMarkerSymbolLayerV2*>( layer );
2493 
2494  QFont layerFont( mLayer->fontFamily() );
2495  // set values
2496  cboFont->blockSignals( true );
2497  cboFont->setCurrentFont( layerFont );
2498  cboFont->blockSignals( false );
2499  spinSize->blockSignals( true );
2500  spinSize->setValue( mLayer->size() );
2501  spinSize->blockSignals( false );
2502  btnColor->blockSignals( true );
2503  btnColor->setColor( mLayer->color() );
2504  btnColor->blockSignals( false );
2505  spinAngle->blockSignals( true );
2506  spinAngle->setValue( mLayer->angle() );
2507  spinAngle->blockSignals( false );
2508 
2509  widgetChar->blockSignals( true );
2510  widgetChar->updateFont( layerFont );
2512  widgetChar->blockSignals( false );
2513 
2514  //block
2515  spinOffsetX->blockSignals( true );
2516  spinOffsetX->setValue( mLayer->offset().x() );
2517  spinOffsetX->blockSignals( false );
2518  spinOffsetY->blockSignals( true );
2519  spinOffsetY->setValue( mLayer->offset().y() );
2520  spinOffsetY->blockSignals( false );
2521 
2522  mSizeUnitWidget->blockSignals( true );
2523  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2524  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2525  mSizeUnitWidget->blockSignals( false );
2526 
2527  mOffsetUnitWidget->blockSignals( true );
2528  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2529  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2530  mOffsetUnitWidget->blockSignals( false );
2531 
2532  //anchor points
2533  mHorizontalAnchorComboBox->blockSignals( true );
2534  mVerticalAnchorComboBox->blockSignals( true );
2535  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2536  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2537  mHorizontalAnchorComboBox->blockSignals( false );
2538  mVerticalAnchorComboBox->blockSignals( false );
2539 
2544  registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
2545  registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
2547 
2548  updateAssistantSymbol();
2549 }
2550 
2552 {
2553  return mLayer;
2554 }
2555 
2557 {
2558  mLayer->setFontFamily( font.family() );
2559  widgetChar->updateFont( font );
2560  emit changed();
2561 }
2562 
2564 {
2565  mLayer->setColor( color );
2566  emit changed();
2567 }
2568 
2570 {
2571  mLayer->setSize( size );
2572  //widgetChar->updateSize(size);
2573  emit changed();
2574 }
2575 
2577 {
2578  mLayer->setAngle( angle );
2579  emit changed();
2580 }
2581 
2583 {
2584  mLayer->setCharacter( chr );
2585  emit changed();
2586 }
2587 
2589 {
2590  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2591  emit changed();
2592 }
2593 
2595 {
2596  if ( mLayer )
2597  {
2598  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2599  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2600  emit changed();
2601  }
2602 }
2603 
2605 {
2606  if ( mLayer )
2607  {
2608  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2609  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2610  emit changed();
2611  }
2612 }
2613 
2615 {
2616  if ( mLayer )
2617  {
2619  emit changed();
2620  }
2621 }
2622 
2624 {
2625  if ( mLayer )
2626  {
2628  emit changed();
2629  }
2630 }
2631 
2632 void QgsFontMarkerSymbolLayerV2Widget::updateAssistantSymbol()
2633 {
2634  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2635  {
2636  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2637  }
2638  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2639  QgsDataDefined* ddSize = mLayer->getDataDefinedProperty( "size" );
2640  if ( ddSize )
2641  mAssistantPreviewSymbol->setDataDefinedSize( *ddSize );
2642 }
2643 
2645 
2646 
2648  : QgsSymbolLayerV2Widget( parent, vl )
2649 {
2650  mLayer = NULL;
2651 
2652  setupUi( this );
2653 }
2654 
2656 {
2657  if ( layer->layerType() != "CentroidFill" )
2658  return;
2659 
2660  // layer type is correct, we can do the cast
2661  mLayer = static_cast<QgsCentroidFillSymbolLayerV2*>( layer );
2662 
2663  // set values
2664  mDrawInsideCheckBox->blockSignals( true );
2665  mDrawInsideCheckBox->setChecked( mLayer->pointOnSurface() );
2666  mDrawInsideCheckBox->blockSignals( false );
2667 }
2668 
2670 {
2671  return mLayer;
2672 }
2673 
2675 {
2676  mLayer->setPointOnSurface( state == Qt::Checked );
2677  emit changed();
2678 }
2679 
2681 
2683  : QgsSymbolLayerV2Widget( parent, vl )
2684 {
2685  mLayer = 0;
2686  setupUi( this );
2687 
2689  mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit );
2690 
2691  mSpinOffsetX->setClearValue( 0.0 );
2692  mSpinOffsetY->setClearValue( 0.0 );
2693 
2694  connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
2695  connect( mSpinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2696  connect( mSpinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
2697 }
2698 
2700 {
2701  if ( !layer )
2702  {
2703  return;
2704  }
2705 
2706  if ( layer->layerType() != "RasterFill" )
2707  {
2708  return;
2709  }
2710 
2711  mLayer = dynamic_cast<QgsRasterFillSymbolLayer*>( layer );
2712  if ( !mLayer )
2713  {
2714  return;
2715  }
2716 
2717  mImageLineEdit->blockSignals( true );
2718  mImageLineEdit->setText( mLayer->imageFilePath() );
2719  mImageLineEdit->blockSignals( false );
2720 
2721  cboCoordinateMode->blockSignals( true );
2722  switch ( mLayer->coordinateMode() )
2723  {
2725  cboCoordinateMode->setCurrentIndex( 1 );
2726  break;
2728  default:
2729  cboCoordinateMode->setCurrentIndex( 0 );
2730  break;
2731  }
2732  cboCoordinateMode->blockSignals( false );
2733  mSpinTransparency->blockSignals( true );
2734  mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
2735  mSpinTransparency->blockSignals( false );
2736  mSliderTransparency->blockSignals( true );
2737  mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
2738  mSliderTransparency->blockSignals( false );
2739  mRotationSpinBox->blockSignals( true );
2740  mRotationSpinBox->setValue( mLayer->angle() );
2741  mRotationSpinBox->blockSignals( false );
2742 
2743  mSpinOffsetX->blockSignals( true );
2744  mSpinOffsetX->setValue( mLayer->offset().x() );
2745  mSpinOffsetX->blockSignals( false );
2746  mSpinOffsetY->blockSignals( true );
2747  mSpinOffsetY->setValue( mLayer->offset().y() );
2748  mSpinOffsetY->blockSignals( false );
2749  mOffsetUnitWidget->blockSignals( true );
2750  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2751  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2752  mOffsetUnitWidget->blockSignals( false );
2753 
2754  mWidthSpinBox->blockSignals( true );
2755  mWidthSpinBox->setValue( mLayer->width() );
2756  mWidthSpinBox->blockSignals( false );
2757  mWidthUnitWidget->blockSignals( true );
2758  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
2759  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
2760  mWidthUnitWidget->blockSignals( false );
2761  updatePreviewImage();
2762 
2767 }
2768 
2770 {
2771  return mLayer;
2772 }
2773 
2774 void QgsRasterFillSymbolLayerWidget::on_mBrowseToolButton_clicked()
2775 {
2776  QSettings s;
2777  QString openDir;
2778  QString lineEditText = mImageLineEdit->text();
2779  if ( !lineEditText.isEmpty() )
2780  {
2781  QFileInfo openDirFileInfo( lineEditText );
2782  openDir = openDirFileInfo.path();
2783  }
2784 
2785  if ( openDir.isEmpty() )
2786  {
2787  openDir = s.value( "/UI/lastRasterFillImageDir", "" ).toString();
2788  }
2789 
2790  //show file dialog
2791  QString filePath = QFileDialog::getOpenFileName( 0, tr( "Select image file" ), openDir );
2792  if ( !filePath.isNull() )
2793  {
2794  //check if file exists
2795  QFileInfo fileInfo( filePath );
2796  if ( !fileInfo.exists() || !fileInfo.isReadable() )
2797  {
2798  QMessageBox::critical( 0, "Invalid file", "Error, file does not exist or is not readable" );
2799  return;
2800  }
2801 
2802  s.setValue( "/UI/lastRasterFillImageDir", fileInfo.absolutePath() );
2803  mImageLineEdit->setText( filePath );
2804  on_mImageLineEdit_editingFinished();
2805  }
2806 }
2807 
2808 void QgsRasterFillSymbolLayerWidget::on_mImageLineEdit_editingFinished()
2809 {
2810  if ( !mLayer )
2811  {
2812  return;
2813  }
2814 
2815  QFileInfo fi( mImageLineEdit->text() );
2816  if ( !fi.exists() )
2817  {
2818  QUrl url( mImageLineEdit->text() );
2819  if ( !url.isValid() )
2820  {
2821  return;
2822  }
2823  }
2824 
2825  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2826  mLayer->setImageFilePath( mImageLineEdit->text() );
2827  updatePreviewImage();
2829 
2830  emit changed();
2831 }
2832 
2833 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
2834 {
2835  switch ( index )
2836  {
2837  case 0:
2838  //feature coordinate mode
2840  break;
2841  case 1:
2842  //viewport coordinate mode
2844  break;
2845  }
2846 
2847  emit changed();
2848 }
2849 
2850 void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
2851 {
2852  if ( !mLayer )
2853  {
2854  return;
2855  }
2856 
2857  mLayer->setAlpha( value / 100.0 );
2858  emit changed();
2859  updatePreviewImage();
2860 }
2861 
2862 void QgsRasterFillSymbolLayerWidget::offsetChanged()
2863 {
2864  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
2865  emit changed();
2866 }
2867 
2868 void QgsRasterFillSymbolLayerWidget::on_mOffsetUnitWidget_changed()
2869 {
2870  if ( !mLayer )
2871  {
2872  return;
2873  }
2874  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2875  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2876  emit changed();
2877 }
2878 
2879 void QgsRasterFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
2880 {
2881  if ( mLayer )
2882  {
2883  mLayer->setAngle( d );
2884  emit changed();
2885  }
2886 }
2887 
2888 void QgsRasterFillSymbolLayerWidget::on_mWidthUnitWidget_changed()
2889 {
2890  if ( !mLayer )
2891  {
2892  return;
2893  }
2894  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
2895  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2896  emit changed();
2897 }
2898 
2899 void QgsRasterFillSymbolLayerWidget::on_mWidthSpinBox_valueChanged( double d )
2900 {
2901  if ( !mLayer )
2902  {
2903  return;
2904  }
2905  mLayer->setWidth( d );
2906  emit changed();
2907 }
2908 
2909 
2910 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
2911 {
2912  if ( !mLayer )
2913  {
2914  return;
2915  }
2916 
2917  QImage image( mLayer->imageFilePath() );
2918  if ( image.isNull() )
2919  {
2920  mLabelImagePreview->setPixmap( QPixmap() );
2921  return;
2922  }
2923 
2924  if ( image.height() > 150 || image.width() > 150 )
2925  {
2926  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
2927  }
2928 
2929  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
2930  previewImage.fill( Qt::transparent );
2931  QRect imageRect(( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
2932  QPainter p;
2933  p.begin( &previewImage );
2934  //draw a checkerboard background
2935  uchar pixDataRGB[] = { 150, 150, 150, 150,
2936  100, 100, 100, 150,
2937  100, 100, 100, 150,
2938  150, 150, 150, 150
2939  };
2940  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
2941  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
2942  QBrush checkerBrush;
2943  checkerBrush.setTexture( pix );
2944  p.fillRect( imageRect, checkerBrush );
2945 
2946  if ( mLayer->alpha() < 1.0 )
2947  {
2948  p.setOpacity( mLayer->alpha() );
2949  }
2950 
2951  p.drawImage( imageRect.left(), imageRect.top(), image );
2952  p.end();
2953  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
2954 }
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.
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
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 Ownership will be transferred.
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer) override
void setMapUnitScale(const QgsMapUnitScale &scale) override
QVariant property(const char *name) const
virtual QgsSymbolLayerV2 * symbolLayer() override
static QString penJoinStyleDesc()
virtual QgsSymbolLayerV2 * symbolLayer() override
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
QModelIndex indexFromItem(const QStandardItem *item) const
QString path() const
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setPenJoinStyle(Qt::PenJoinStyle style)
void setBrushStyle(Qt::BrushStyle style)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
QgsSimpleLineSymbolLayerV2Widget(const QgsVectorLayer *vl, QWidget *parent=NULL)
static QString double180RotDesc()
static QString gradientTypeDesc()
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void registerDataDefinedButton(QgsDataDefinedButton *button, const QString &propertyName, QgsDataDefinedButton::DataType type, const QString &description)
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
void appendRow(const QList< QStandardItem * > &items)
static QStringList listSvgFiles()
Return a list of all available svg files.
QgsSvgListModel(QObject *parent, QString path)
const QgsMapUnitScale & offsetMapUnitScale() const
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)