[QGIS Commit] r12155 - in trunk/qgis/src: core/symbology-ng gui/symbology-ng ui/symbollayer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Nov 16 19:18:47 EST 2009


Author: wonder
Date: 2009-11-16 19:18:45 -0500 (Mon, 16 Nov 2009)
New Revision: 12155

Modified:
   trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp
   trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h
   trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp
   trunk/qgis/src/gui/symbology-ng/qgspenstylecombobox.cpp
   trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
   trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h
   trunk/qgis/src/ui/symbollayer/widget_simplefill.ui
Log:
simple fill: added border style and width
pen style combo box: added "no pen"


Modified: trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp	2009-11-17 00:18:45 UTC (rev 12155)
@@ -6,8 +6,8 @@
 
 #include <QPainter>
 
-QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, QColor borderColor, Qt::BrushStyle style)
-  : mBrushStyle(style), mBorderColor(borderColor)
+QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth)
+  : mBrushStyle(style), mBorderColor(borderColor), mBorderStyle(borderStyle), mBorderWidth(borderWidth)
 {
   mColor = color;
 }
@@ -16,17 +16,23 @@
 QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create(const QgsStringMap& props)
 {
   QColor color = DEFAULT_SIMPLEFILL_COLOR;
+  Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE;
   QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR;
-  Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE;
-  
+  Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE;
+  double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH;
+
   if (props.contains("color"))
     color = QgsSymbolLayerV2Utils::decodeColor(props["color"]);
+  if (props.contains("style"))
+    style = QgsSymbolLayerV2Utils::decodeBrushStyle(props["style"]);
   if (props.contains("color_border"))
     borderColor = QgsSymbolLayerV2Utils::decodeColor(props["color_border"]);
-  if (props.contains("style"))
-    style = QgsSymbolLayerV2Utils::decodeBrushStyle(props["style"]);
-  
-  return new QgsSimpleFillSymbolLayerV2(color, borderColor, style);
+  if (props.contains("style_border"))
+    borderStyle = QgsSymbolLayerV2Utils::decodePenStyle(props["style_border"]);
+  if (props.contains("width_border"))
+    borderWidth = props["width_border"].toDouble();
+
+  return new QgsSimpleFillSymbolLayerV2(color, style, borderColor, borderStyle, borderWidth);
 }
 
 
@@ -39,6 +45,8 @@
 {
   mBrush = QBrush(mColor, mBrushStyle);
   mPen = QPen(mBorderColor);
+  mPen.setStyle(mBorderStyle);
+  mPen.setWidthF(mBorderWidth);
 }
 
 void QgsSimpleFillSymbolLayerV2::stopRender(QgsRenderContext& context)
@@ -73,12 +81,14 @@
 {
   QgsStringMap map;
   map["color"] = QgsSymbolLayerV2Utils::encodeColor(mColor);
+  map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle(mBrushStyle);
   map["color_border"] = QgsSymbolLayerV2Utils::encodeColor(mBorderColor);
-  map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle(mBrushStyle);
+  map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle(mBorderStyle);
+  map["width_border"] = QString::number(mBorderWidth);
   return map;
 }
 
 QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const
 {
-  return new QgsSimpleFillSymbolLayerV2(mColor, mBorderColor, mBrushStyle);
+  return new QgsSimpleFillSymbolLayerV2(mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth);
 }

Modified: trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h	2009-11-17 00:18:45 UTC (rev 12155)
@@ -7,6 +7,8 @@
 #define DEFAULT_SIMPLEFILL_COLOR        QColor(0,0,255)
 #define DEFAULT_SIMPLEFILL_STYLE        Qt::SolidPattern
 #define DEFAULT_SIMPLEFILL_BORDERCOLOR  QColor(0,0,0)
+#define DEFAULT_SIMPLEFILL_BORDERSTYLE  Qt::SolidLine
+#define DEFAULT_SIMPLEFILL_BORDERWIDTH  1.0
 
 #include <QPen>
 #include <QBrush>
@@ -15,9 +17,11 @@
 {
   public:
     QgsSimpleFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR,
+                                Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
                                 QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
-                                Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE );
-
+                                Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
+                                double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH );
+	
     // static stuff
 
     static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
@@ -42,10 +46,18 @@
     QColor borderColor() const { return mBorderColor; }
     void setBorderColor( QColor borderColor ) { mBorderColor = borderColor; }
 
+    Qt::PenStyle borderStyle() const { return mBorderStyle; }
+    void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; }
+
+    double borderWidth() const { return mBorderWidth; }
+    void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }
+
   protected:
     QBrush mBrush;
     Qt::BrushStyle mBrushStyle;
     QColor mBorderColor;
+    Qt::PenStyle mBorderStyle;
+    double mBorderWidth;
     QPen mPen;
 };
 

Modified: trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp	2009-11-17 00:18:45 UTC (rev 12155)
@@ -31,6 +31,7 @@
 {
   switch ( style )
   {
+    case Qt::NoPen:          return "no";
     case Qt::SolidLine:      return "solid";
     case Qt::DashLine:       return "dash";
     case Qt::DotLine:        return "dot";
@@ -42,6 +43,7 @@
 
 Qt::PenStyle QgsSymbolLayerV2Utils::decodePenStyle( QString str )
 {
+  if ( str == "no" ) return Qt::NoPen;
   if ( str == "solid" ) return Qt::SolidLine;
   if ( str == "dash" ) return Qt::DashLine;
   if ( str == "dot" ) return Qt::DotLine;

Modified: trunk/qgis/src/gui/symbology-ng/qgspenstylecombobox.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgspenstylecombobox.cpp	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/gui/symbology-ng/qgspenstylecombobox.cpp	2009-11-17 00:18:45 UTC (rev 12155)
@@ -17,7 +17,8 @@
       << qMakePair(Qt::DashLine, QString("Dash Line"))
       << qMakePair(Qt::DotLine, QString("Dot Line"))
       << qMakePair(Qt::DashDotLine, QString("Dash Dot Line"))
-      << qMakePair(Qt::DashDotDotLine, QString("Dash Dot Dot Line"));
+      << qMakePair(Qt::DashDotDotLine, QString("Dash Dot Dot Line"))
+      << qMakePair(Qt::NoPen, QString("No Pen"));
   
   setIconSize(QSize(32,12));
   

Modified: trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp	2009-11-17 00:18:45 UTC (rev 12155)
@@ -212,8 +212,10 @@
   setupUi(this);
   
   connect(btnChangeColor, SIGNAL(clicked()), this, SLOT(setColor()));
+  connect(cboFillStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(setBrushStyle()));
   connect(btnChangeBorderColor, SIGNAL(clicked()), this, SLOT(setBorderColor()));
-  connect(cboFillStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(setBrushStyle()));
+  connect(spinBorderWidth, SIGNAL(valueChanged(double)), this, SLOT(borderWidthChanged()));
+  connect(cboBorderStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(borderStyleChanged()));
 }
 
 void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
@@ -226,8 +228,10 @@
   
   // set values
   btnChangeColor->setColor(mLayer->color());
+  cboFillStyle->setBrushStyle(mLayer->brushStyle());
   btnChangeBorderColor->setColor(mLayer->borderColor());
-  cboFillStyle->setBrushStyle(mLayer->brushStyle());
+  cboBorderStyle->setPenStyle(mLayer->borderStyle());
+  spinBorderWidth->setValue(mLayer->borderWidth());
 }
 
 QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2Widget::symbolLayer()
@@ -261,6 +265,18 @@
   emit changed();
 }
 
+void QgsSimpleFillSymbolLayerV2Widget::borderWidthChanged()
+{
+  mLayer->setBorderWidth(spinBorderWidth->value());
+  emit changed();
+}
+
+void QgsSimpleFillSymbolLayerV2Widget::borderStyleChanged()
+{
+  mLayer->setBorderStyle(cboBorderStyle->penStyle());
+  emit changed();
+}
+
 ///////////
 
 QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget(QWidget* parent)

Modified: trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h	2009-11-17 00:18:45 UTC (rev 12155)
@@ -105,6 +105,8 @@
     void setColor();
     void setBorderColor();
     void setBrushStyle();
+    void borderWidthChanged();
+    void borderStyleChanged();
 
   protected:
     QgsSimpleFillSymbolLayerV2* mLayer;

Modified: trunk/qgis/src/ui/symbollayer/widget_simplefill.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_simplefill.ui	2009-11-16 22:59:41 UTC (rev 12154)
+++ trunk/qgis/src/ui/symbollayer/widget_simplefill.ui	2009-11-17 00:18:45 UTC (rev 12155)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>335</width>
-    <height>154</height>
+    <height>206</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -30,7 +30,7 @@
        </property>
       </widget>
      </item>
-     <item row="0" column="2" rowspan="3">
+     <item row="0" column="2" rowspan="5">
       <spacer>
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
@@ -47,29 +47,53 @@
       </spacer>
      </item>
      <item row="2" column="0">
-      <widget class="QLabel" name="label_2">
+      <widget class="QLabel" name="label_3">
        <property name="text">
-        <string>Fill style:</string>
+        <string>Border color:</string>
        </property>
       </widget>
      </item>
      <item row="2" column="1">
+      <widget class="QgsColorButtonV2" name="btnChangeBorderColor">
+       <property name="text">
+        <string>Change</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
       <widget class="QgsBrushStyleComboBox" name="cboFillStyle"/>
      </item>
      <item row="1" column="0">
-      <widget class="QLabel" name="label_3">
+      <widget class="QLabel" name="label_2">
        <property name="text">
-        <string>Border color:</string>
+        <string>Fill style:</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="1">
-      <widget class="QgsColorButtonV2" name="btnChangeBorderColor">
+     <item row="3" column="0">
+      <widget class="QLabel" name="label_4">
        <property name="text">
-        <string>Change</string>
+        <string>Border style:</string>
        </property>
       </widget>
      </item>
+     <item row="3" column="1">
+      <widget class="QgsPenStyleComboBox" name="cboBorderStyle"/>
+     </item>
+     <item row="4" column="0">
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>Border width:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QDoubleSpinBox" name="spinBorderWidth">
+       <property name="decimals">
+        <number>1</number>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
@@ -98,11 +122,18 @@
    <extends>QPushButton</extends>
    <header>qgscolorbutton.h</header>
   </customwidget>
+  <customwidget>
+   <class>QgsPenStyleComboBox</class>
+   <extends>QComboBox</extends>
+   <header>qgspenstylecombobox.h</header>
+  </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>btnChangeColor</tabstop>
+  <tabstop>cboFillStyle</tabstop>
   <tabstop>btnChangeBorderColor</tabstop>
-  <tabstop>cboFillStyle</tabstop>
+  <tabstop>cboBorderStyle</tabstop>
+  <tabstop>spinBorderWidth</tabstop>
  </tabstops>
  <resources/>
  <connections/>



More information about the QGIS-commit mailing list