mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[FEATURE] Option to put marker only on first/last vertex of a line (#3279) - contributed by Cedric Moeri - thanks!
git-svn-id: http://svn.osgeo.org/qgis/trunk@14836 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1539985778
commit
f99179eeed
@ -13,6 +13,7 @@ Brent Wood
|
|||||||
Brook Milligan
|
Brook Milligan
|
||||||
Carl Anderson
|
Carl Anderson
|
||||||
Carlos Dávila
|
Carlos Dávila
|
||||||
|
Cédric Möri
|
||||||
Christian Ferreira
|
Christian Ferreira
|
||||||
Diego Moreira
|
Diego Moreira
|
||||||
Duarte Carreira
|
Duarte Carreira
|
||||||
|
@ -239,7 +239,14 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::create( const QgsStringMap& props
|
|||||||
if ( props.contains( "offset" ) )
|
if ( props.contains( "offset" ) )
|
||||||
x->setOffset( props["offset"].toDouble() );
|
x->setOffset( props["offset"].toDouble() );
|
||||||
if ( props.contains( "placement" ) )
|
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;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,18 +286,18 @@ void QgsMarkerLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
|
|||||||
{
|
{
|
||||||
if ( mOffset == 0 )
|
if ( mOffset == 0 )
|
||||||
{
|
{
|
||||||
if ( mPlacement == Vertex )
|
if ( mPlacement == Interval )
|
||||||
renderPolylineVertex( points, context );
|
|
||||||
else
|
|
||||||
renderPolylineInterval( points, context );
|
renderPolylineInterval( points, context );
|
||||||
|
else
|
||||||
|
renderPolylineVertex( points, context );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPolygonF points2 = ::offsetLine( points, context.outputLineWidth( mOffset ) );
|
QPolygonF points2 = ::offsetLine( points, context.outputLineWidth( mOffset ) );
|
||||||
if ( mPlacement == Vertex )
|
if ( mPlacement == Interval )
|
||||||
renderPolylineVertex( points2, context );
|
|
||||||
else
|
|
||||||
renderPolylineInterval( points2, context );
|
renderPolylineInterval( points2, context );
|
||||||
|
else
|
||||||
|
renderPolylineVertex( points2, context );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,8 +367,25 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineVertex( const QPolygonF& points,
|
|||||||
|
|
||||||
double origAngle = mMarker->angle();
|
double origAngle = mMarker->angle();
|
||||||
double 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];
|
const QPointF& pt = points[i];
|
||||||
|
|
||||||
@ -395,7 +419,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineVertex( const QPolygonF& points,
|
|||||||
double unitX = cos( a1 ) + cos( a2 ), unitY = sin( a1 ) + sin( a2 );
|
double unitX = cos( a1 ) + cos( a2 ), unitY = sin( a1 ) + sin( a2 );
|
||||||
angle = atan2( unitY, unitX );
|
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() );
|
mMarker->renderPoint( points.at( i ), rc, -1, context.selected() );
|
||||||
@ -411,7 +435,14 @@ QgsStringMap QgsMarkerLineSymbolLayerV2::properties() const
|
|||||||
map["rotate"] = ( mRotateMarker ? "1" : "0" );
|
map["rotate"] = ( mRotateMarker ? "1" : "0" );
|
||||||
map["interval"] = QString::number( mInterval );
|
map["interval"] = QString::number( mInterval );
|
||||||
map["offset"] = QString::number( mOffset );
|
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;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,9 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
|
|||||||
enum Placement
|
enum Placement
|
||||||
{
|
{
|
||||||
Interval,
|
Interval,
|
||||||
Vertex
|
Vertex,
|
||||||
|
LastVertex,
|
||||||
|
FirstVertex
|
||||||
};
|
};
|
||||||
|
|
||||||
// static stuff
|
// static stuff
|
||||||
|
@ -361,6 +361,8 @@ QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget( QWidget* par
|
|||||||
connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
|
connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
|
||||||
connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
|
connect( radInterval, SIGNAL( clicked() ), this, SLOT( setPlacement() ) );
|
||||||
connect( radVertex, 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 )
|
void QgsMarkerLineSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
|
||||||
@ -377,8 +379,12 @@ void QgsMarkerLineSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
|
|||||||
spinOffset->setValue( mLayer->offset() );
|
spinOffset->setValue( mLayer->offset() );
|
||||||
if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::Interval )
|
if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::Interval )
|
||||||
radInterval->setChecked( true );
|
radInterval->setChecked( true );
|
||||||
else
|
else if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::Vertex )
|
||||||
radVertex->setChecked( true );
|
radVertex->setChecked( true );
|
||||||
|
else if ( mLayer->placement() == QgsMarkerLineSymbolLayerV2::LastVertex )
|
||||||
|
radVertexLast->setChecked( true );
|
||||||
|
else
|
||||||
|
radVertexFirst->setChecked( true );
|
||||||
updateMarker();
|
updateMarker();
|
||||||
setPlacement(); // update gui
|
setPlacement(); // update gui
|
||||||
}
|
}
|
||||||
@ -426,8 +432,17 @@ void QgsMarkerLineSymbolLayerV2Widget::updateMarker()
|
|||||||
void QgsMarkerLineSymbolLayerV2Widget::setPlacement()
|
void QgsMarkerLineSymbolLayerV2Widget::setPlacement()
|
||||||
{
|
{
|
||||||
bool interval = radInterval->isChecked();
|
bool interval = radInterval->isChecked();
|
||||||
mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayerV2::Interval : QgsMarkerLineSymbolLayerV2::Vertex );
|
|
||||||
spinInterval->setEnabled( interval );
|
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();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,112 +7,122 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>352</width>
|
<width>352</width>
|
||||||
<height>232</height>
|
<height>281</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<widget class="QLabel" name="label">
|
||||||
<item row="0" column="0">
|
<property name="text">
|
||||||
<widget class="QLabel" name="label">
|
<string>Marker</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Marker</string>
|
</widget>
|
||||||
</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>
|
|
||||||
</item>
|
</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>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user