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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Dec 4 10:21:32 EST 2010


Author: wonder
Date: 2010-12-04 07:21:32 -0800 (Sat, 04 Dec 2010)
New Revision: 14836

Modified:
   trunk/qgis/CONTRIBUTORS
   trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp
   trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h
   trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
   trunk/qgis/src/ui/symbollayer/widget_markerline.ui
Log:
[FEATURE] Option to put marker only on first/last vertex of a line (#3279) - contributed by Cedric Moeri - thanks!


Modified: trunk/qgis/CONTRIBUTORS
===================================================================
--- trunk/qgis/CONTRIBUTORS	2010-12-04 08:47:21 UTC (rev 14835)
+++ trunk/qgis/CONTRIBUTORS	2010-12-04 15:21:32 UTC (rev 14836)
@@ -13,6 +13,7 @@
 Brook Milligan
 Carl Anderson
 Carlos Dávila
+Cédric Möri
 Christian Ferreira
 Diego Moreira
 Duarte Carreira

Modified: trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp	2010-12-04 08:47:21 UTC (rev 14835)
+++ trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp	2010-12-04 15:21:32 UTC (rev 14836)
@@ -239,7 +239,14 @@
   if ( props.contains( "offset" ) )
     x->setOffset( props["offset"].toDouble() );
   if ( props.contains( "placement" ) )
-    x->setPlacement( props["placement"] == "vertex" ? Vertex : Interval );
+    if ( props["placement"] == "vertex" )
+      x->setPlacement( Vertex );
+    else if ( props["placement"] == "lastvertex" )
+      x->setPlacement( LastVertex );
+    else if ( props["placement"] == "firstvertex" )
+      x->setPlacement( FirstVertex );
+    else
+      x->setPlacement( Interval );
   return x;
 }
 
@@ -279,18 +286,18 @@
 {
   if ( mOffset == 0 )
   {
-    if ( mPlacement == Vertex )
+    if ( mPlacement == Interval )
+      renderPolylineInterval( points, context );
+    else
       renderPolylineVertex( points, context );
-    else
-      renderPolylineInterval( points, context );
   }
   else
   {
     QPolygonF points2 = ::offsetLine( points, context.outputLineWidth( mOffset ) );
-    if ( mPlacement == Vertex )
+    if ( mPlacement == Interval )
+      renderPolylineInterval( points2, context );
+    else
       renderPolylineVertex( points2, context );
-    else
-      renderPolylineInterval( points2, context );
   }
 }
 
@@ -360,9 +367,26 @@
 
   double origAngle = mMarker->angle();
   double angle;
+  int i, maxCount;
 
-  for ( int i = 0; i < points.count(); ++i )
+  if ( mPlacement == FirstVertex )
   {
+    i = 0;
+    maxCount = 1;
+  }
+  else if ( mPlacement == LastVertex )
+  {
+    i = points.count() - 1;
+    maxCount = points.count();
+  }
+  else
+  {
+    i = 0;
+    maxCount = points.count();
+  }
+
+  for ( ; i < maxCount; ++i )
+  {
     const QPointF& pt = points[i];
 
     // rotate marker (if desired)
@@ -395,7 +419,7 @@
         double unitX = cos( a1 ) + cos( a2 ), unitY = sin( a1 ) + sin( a2 );
         angle = atan2( unitY, unitX );
       }
-      mMarker->setAngle( angle * 180 / M_PI );
+      mMarker->setAngle( origAngle + angle * 180 / M_PI );
     }
 
     mMarker->renderPoint( points.at( i ), rc, -1, context.selected() );
@@ -411,7 +435,14 @@
   map["rotate"] = ( mRotateMarker ? "1" : "0" );
   map["interval"] = QString::number( mInterval );
   map["offset"] = QString::number( mOffset );
-  map["placement"] = ( mPlacement == Vertex ? "vertex" : "interval" );
+  if ( mPlacement == Vertex )
+    map["placement"] = "vertex";
+  else if ( mPlacement == LastVertex )
+    map["placement"] = "lastvertex";
+  else if ( mPlacement == FirstVertex )
+    map["placement"] = "firstvertex";
+  else
+    map["placement"] = "interval";
   return map;
 }
 

Modified: trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h	2010-12-04 08:47:21 UTC (rev 14835)
+++ trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h	2010-12-04 15:21:32 UTC (rev 14836)
@@ -88,7 +88,9 @@
     enum Placement
     {
       Interval,
-      Vertex
+      Vertex,
+      LastVertex,
+      FirstVertex
     };
 
     // static stuff

Modified: trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp	2010-12-04 08:47:21 UTC (rev 14835)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp	2010-12-04 15:21:32 UTC (rev 14836)
@@ -361,6 +361,8 @@
   connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
   connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
   connect( radVertex, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
+  connect( radVertexLast, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
+  connect( radVertexFirst, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
 }
 
 void QgsMarkerLineSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
@@ -377,8 +379,12 @@
   spinOffset->setValue( mLayer->offset() );
   if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::Interval )
     radInterval->setChecked( true );
+  else if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::Vertex )
+    radVertex->setChecked( true );
+  else if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::LastVertex )
+    radVertexLast->setChecked( true );
   else
-    radVertex->setChecked( true );
+    radVertexFirst->setChecked( true );
   updateMarker();
   setPlacement(); // update gui
 }
@@ -426,8 +432,17 @@
 void QgsMarkerLineSymbolLayerV2Widget::setPlacement()
 {
   bool interval = radInterval->isChecked();
-  mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
   spinInterval->setEnabled( interval );
+  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
+  if ( radInterval->isChecked() )
+    mLayer->setPlacement( QgsMarkerLineSymbolLayerV2::Interval );
+  else if ( radVertex->isChecked() )
+    mLayer->setPlacement( QgsMarkerLineSymbolLayerV2::Vertex );
+  else if ( radVertexLast->isChecked() )
+    mLayer->setPlacement( QgsMarkerLineSymbolLayerV2::LastVertex );
+  else
+    mLayer->setPlacement( QgsMarkerLineSymbolLayerV2::FirstVertex );
+
   emit changed();
 }
 

Modified: trunk/qgis/src/ui/symbollayer/widget_markerline.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_markerline.ui	2010-12-04 08:47:21 UTC (rev 14835)
+++ trunk/qgis/src/ui/symbollayer/widget_markerline.ui	2010-12-04 15:21:32 UTC (rev 14836)
@@ -7,114 +7,124 @@
     <x>0</x>
     <y>0</y>
     <width>352</width>
-    <height>232</height>
+    <height>281</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QGridLayout" name="gridLayout">
-     <item row="0" column="0">
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>Marker</string>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="1">
-      <widget class="QPushButton" name="btnChangeMarker">
-       <property name="text">
-        <string>Change</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0" colspan="2">
-      <widget class="QLabel" name="label_2">
-       <property name="text">
-        <string>Marker placement</string>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="0">
-      <widget class="QRadioButton" name="radInterval">
-       <property name="text">
-        <string>with interval</string>
-       </property>
-       <property name="checked">
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="1">
-      <widget class="QDoubleSpinBox" name="spinInterval">
-       <property name="decimals">
-        <number>2</number>
-       </property>
-       <property name="maximum">
-        <double>100000.000000000000000</double>
-       </property>
-       <property name="value">
-        <double>1.000000000000000</double>
-       </property>
-      </widget>
-     </item>
-     <item row="3" column="0" colspan="2">
-      <widget class="QRadioButton" name="radVertex">
-       <property name="text">
-        <string>on every vertex</string>
-       </property>
-      </widget>
-     </item>
-     <item row="4" column="0" colspan="2">
-      <widget class="QCheckBox" name="chkRotateMarker">
-       <property name="text">
-        <string>Rotate marker</string>
-       </property>
-      </widget>
-     </item>
-     <item row="5" column="0">
-      <widget class="QLabel" name="label_3">
-       <property name="text">
-        <string>Line offset</string>
-       </property>
-      </widget>
-     </item>
-     <item row="5" column="1">
-      <widget class="QDoubleSpinBox" name="spinOffset">
-       <property name="decimals">
-        <number>2</number>
-       </property>
-       <property name="minimum">
-        <double>-100000.000000000000000</double>
-       </property>
-       <property name="maximum">
-        <double>100000.000000000000000</double>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="2" rowspan="6">
-      <spacer>
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeType">
-        <enum>QSizePolicy::Preferred</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>110</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Marker</string>
+     </property>
+    </widget>
    </item>
-   <item>
+   <item row="0" column="1">
+    <widget class="QPushButton" name="btnChangeMarker">
+     <property name="text">
+      <string>Change</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2">
     <spacer>
      <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Preferred</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>109</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="1" column="0" colspan="2">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Marker placement</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QRadioButton" name="radInterval">
+     <property name="text">
+      <string>with interval</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QDoubleSpinBox" name="spinInterval">
+     <property name="decimals">
+      <number>2</number>
+     </property>
+     <property name="maximum">
+      <double>100000.000000000000000</double>
+     </property>
+     <property name="value">
+      <double>1.000000000000000</double>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" colspan="2">
+    <widget class="QRadioButton" name="radVertex">
+     <property name="text">
+      <string>on every vertex</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0" colspan="2">
+    <widget class="QRadioButton" name="radVertexLast">
+     <property name="text">
+      <string>on last vertex only</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="0" colspan="2">
+    <widget class="QRadioButton" name="radVertexFirst">
+     <property name="text">
+      <string>on first vertex only</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0" colspan="2">
+    <widget class="QCheckBox" name="chkRotateMarker">
+     <property name="text">
+      <string>Rotate marker</string>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Line offset</string>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="1">
+    <widget class="QDoubleSpinBox" name="spinOffset">
+     <property name="decimals">
+      <number>2</number>
+     </property>
+     <property name="minimum">
+      <double>-100000.000000000000000</double>
+     </property>
+     <property name="maximum">
+      <double>100000.000000000000000</double>
+     </property>
+    </widget>
+   </item>
+   <item row="8" column="0" colspan="3">
+    <spacer>
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">



More information about the QGIS-commit mailing list