mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
remove line decoration symbol layer (fixes #8379)
This commit is contained in:
parent
7f8b259209
commit
aaef947800
@ -138,41 +138,3 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
|
||||
void renderPolylineVertex( const QPolygonF& points, QgsSymbolV2RenderContext& context );
|
||||
void renderPolylineCentral( const QPolygonF& points, QgsSymbolV2RenderContext& context );
|
||||
};
|
||||
|
||||
/////////
|
||||
|
||||
class QgsLineDecorationSymbolLayerV2 : QgsLineSymbolLayerV2
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgslinesymbollayerv2.h>
|
||||
%End
|
||||
|
||||
public:
|
||||
QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR,
|
||||
double width = DEFAULT_LINEDECORATION_WIDTH );
|
||||
|
||||
~QgsLineDecorationSymbolLayerV2();
|
||||
|
||||
// static stuff
|
||||
|
||||
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
|
||||
|
||||
// implemented from base classes
|
||||
|
||||
QString layerType() const;
|
||||
|
||||
void startRender( QgsSymbolV2RenderContext& context );
|
||||
|
||||
void stopRender( QgsSymbolV2RenderContext& context );
|
||||
|
||||
void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
|
||||
|
||||
QgsStringMap properties() const;
|
||||
|
||||
QgsSymbolLayerV2* clone() const /Factory/;
|
||||
|
||||
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
|
||||
|
||||
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
|
||||
QgsSymbolV2::OutputUnit outputUnit() const;
|
||||
};
|
||||
|
@ -24,9 +24,7 @@ class QgsSymbolLayerV2
|
||||
break;
|
||||
|
||||
case QgsSymbolV2::Line:
|
||||
if (dynamic_cast<QgsLineDecorationSymbolLayerV2*>(sipCpp) != NULL)
|
||||
sipClass = sipClass_QgsLineDecorationSymbolLayerV2;
|
||||
else if (dynamic_cast<QgsMarkerLineSymbolLayerV2*>(sipCpp) != NULL)
|
||||
if (dynamic_cast<QgsMarkerLineSymbolLayerV2*>(sipCpp) != NULL)
|
||||
sipClass = sipClass_QgsMarkerLineSymbolLayerV2;
|
||||
else if (dynamic_cast<QgsSimpleLineSymbolLayerV2*>(sipCpp) != NULL)
|
||||
sipClass = sipClass_QgsSimpleLineSymbolLayerV2;
|
||||
|
@ -183,29 +183,6 @@ class QgsSvgMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget
|
||||
|
||||
///////////
|
||||
|
||||
class QgsLineDecorationSymbolLayerV2Widget : QgsSymbolLayerV2Widget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgssymbollayerv2widget.h>
|
||||
%End
|
||||
|
||||
public:
|
||||
QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );
|
||||
|
||||
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) /Factory/;
|
||||
|
||||
// from base class
|
||||
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
|
||||
virtual QgsSymbolLayerV2* symbolLayer();
|
||||
|
||||
public slots:
|
||||
void colorChanged( const QColor& color );
|
||||
void penWidthChanged();
|
||||
void on_mWidthUnitComboBox_currentIndexChanged( int index );
|
||||
};
|
||||
|
||||
//////////
|
||||
|
||||
class QgsSVGFillSymbolLayerWidget : QgsSymbolLayerV2Widget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
|
@ -1086,155 +1086,3 @@ QgsSymbolV2::OutputUnit QgsMarkerLineSymbolLayerV2::outputUnit() const
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
/////////////
|
||||
|
||||
QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color, double width )
|
||||
{
|
||||
mColor = color;
|
||||
mWidth = width;
|
||||
}
|
||||
|
||||
QgsLineDecorationSymbolLayerV2::~QgsLineDecorationSymbolLayerV2()
|
||||
{
|
||||
}
|
||||
|
||||
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::create( const QgsStringMap& props )
|
||||
{
|
||||
QColor color = DEFAULT_LINEDECORATION_COLOR;
|
||||
double width = DEFAULT_LINEDECORATION_WIDTH;
|
||||
|
||||
if ( props.contains( "color" ) )
|
||||
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
|
||||
if ( props.contains( "width" ) )
|
||||
width = props["width"].toDouble();
|
||||
|
||||
|
||||
QgsLineDecorationSymbolLayerV2* layer = new QgsLineDecorationSymbolLayerV2( color, width );
|
||||
if ( props.contains( "width_unit" ) )
|
||||
{
|
||||
layer->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["width_unit"] ) );
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
QString QgsLineDecorationSymbolLayerV2::layerType() const
|
||||
{
|
||||
return "LineDecoration";
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
|
||||
{
|
||||
QColor penColor = mColor;
|
||||
penColor.setAlphaF( mColor.alphaF() * context.alpha() );
|
||||
|
||||
double width = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
|
||||
mPen.setWidth( width );
|
||||
mPen.setColor( penColor );
|
||||
QColor selColor = context.renderContext().selectionColor();
|
||||
if ( ! selectionIsOpaque )
|
||||
selColor.setAlphaF( context.alpha() );
|
||||
mSelPen.setWidth( width ); //context.outputLineWidth( width ) );
|
||||
mSelPen.setColor( selColor );
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
|
||||
{
|
||||
Q_UNUSED( context );
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
|
||||
{
|
||||
// draw arrow at the end of line
|
||||
|
||||
QPainter* p = context.renderContext().painter();
|
||||
if ( !p )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int cnt = points.count();
|
||||
if ( cnt < 2 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QPointF p2 = points.at( --cnt );
|
||||
QPointF p1 = points.at( --cnt );
|
||||
while ( p2 == p1 && cnt )
|
||||
p1 = points.at( --cnt );
|
||||
if ( p1 == p2 )
|
||||
{
|
||||
// this is a collapsed line... don't bother drawing an arrow
|
||||
// with arbitrary orientation
|
||||
return;
|
||||
}
|
||||
|
||||
double angle = atan2( p2.y() - p1.y(), p2.x() - p1.x() );
|
||||
double size = ( mWidth * 8 ) * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
|
||||
double angle1 = angle + M_PI / 6;
|
||||
double angle2 = angle - M_PI / 6;
|
||||
|
||||
QPointF p2_1 = p2 - QPointF( size * cos( angle1 ), size * sin( angle1 ) );
|
||||
QPointF p2_2 = p2 - QPointF( size * cos( angle2 ), size * sin( angle2 ) );
|
||||
|
||||
p->setPen( context.selected() ? mSelPen : mPen );
|
||||
p->drawLine( p2, p2_1 );
|
||||
p->drawLine( p2, p2_2 );
|
||||
}
|
||||
|
||||
QgsStringMap QgsLineDecorationSymbolLayerV2::properties() const
|
||||
{
|
||||
QgsStringMap map;
|
||||
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
|
||||
map["width"] = QString::number( mWidth );
|
||||
map["width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mWidthUnit );
|
||||
return map;
|
||||
}
|
||||
|
||||
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::clone() const
|
||||
{
|
||||
QgsLineDecorationSymbolLayerV2* layer = new QgsLineDecorationSymbolLayerV2( mColor, mWidth );
|
||||
layer->setWidthUnit( mWidthUnit );
|
||||
return layer;
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
|
||||
{
|
||||
QDomElement symbolizerElem = doc.createElement( "se:LineSymbolizer" );
|
||||
if ( !props.value( "uom", "" ).isEmpty() )
|
||||
symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
|
||||
element.appendChild( symbolizerElem );
|
||||
|
||||
QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom" , "" ) );
|
||||
|
||||
// <Stroke>
|
||||
QDomElement strokeElem = doc.createElement( "se:Stroke" );
|
||||
symbolizerElem.appendChild( strokeElem );
|
||||
|
||||
// <GraphicStroke>
|
||||
QDomElement graphicStrokeElem = doc.createElement( "se:GraphicStroke" );
|
||||
strokeElem.appendChild( graphicStrokeElem );
|
||||
|
||||
// <Graphic>
|
||||
QDomElement graphicElem = doc.createElement( "se:Graphic" );
|
||||
graphicStrokeElem.appendChild( graphicElem );
|
||||
|
||||
// <Mark>
|
||||
QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, "arrowhead", QColor(), mColor, mWidth, mWidth*8 );
|
||||
|
||||
// <Rotation>
|
||||
QgsSymbolLayerV2Utils::createRotationElement( doc, graphicElem, props.value( "angle", "" ) );
|
||||
|
||||
// use <VendorOption> to draw the decoration at end of the line
|
||||
symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "lastPoint" ) );
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2::setOutputUnit( QgsSymbolV2::OutputUnit unit )
|
||||
{
|
||||
mWidthUnit = unit;
|
||||
}
|
||||
|
||||
QgsSymbolV2::OutputUnit QgsLineDecorationSymbolLayerV2::outputUnit() const
|
||||
{
|
||||
return mWidthUnit;
|
||||
}
|
||||
|
@ -200,46 +200,4 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
|
||||
Placement mPlacement;
|
||||
};
|
||||
|
||||
/////////
|
||||
|
||||
#define DEFAULT_LINEDECORATION_COLOR QColor(0,0,0)
|
||||
#define DEFAULT_LINEDECORATION_WIDTH DEFAULT_LINE_WIDTH
|
||||
|
||||
class CORE_EXPORT QgsLineDecorationSymbolLayerV2 : public QgsLineSymbolLayerV2
|
||||
{
|
||||
public:
|
||||
QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR,
|
||||
double width = DEFAULT_LINEDECORATION_WIDTH );
|
||||
|
||||
~QgsLineDecorationSymbolLayerV2();
|
||||
|
||||
// static stuff
|
||||
|
||||
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
|
||||
|
||||
// implemented from base classes
|
||||
|
||||
QString layerType() const;
|
||||
|
||||
void startRender( QgsSymbolV2RenderContext& context );
|
||||
|
||||
void stopRender( QgsSymbolV2RenderContext& context );
|
||||
|
||||
void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
|
||||
|
||||
QgsStringMap properties() const;
|
||||
|
||||
QgsSymbolLayerV2* clone() const;
|
||||
|
||||
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
|
||||
|
||||
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
|
||||
QgsSymbolV2::OutputUnit outputUnit() const;
|
||||
|
||||
protected:
|
||||
QPen mPen;
|
||||
QPen mSelPen;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,8 +30,6 @@ QgsSymbolLayerV2Registry::QgsSymbolLayerV2Registry()
|
||||
QgsSimpleLineSymbolLayerV2::create, QgsSimpleLineSymbolLayerV2::createFromSld ) );
|
||||
addSymbolLayerType( new QgsSymbolLayerV2Metadata( "MarkerLine", QObject::tr( "Marker line" ), QgsSymbolV2::Line,
|
||||
QgsMarkerLineSymbolLayerV2::create, QgsMarkerLineSymbolLayerV2::createFromSld ) );
|
||||
addSymbolLayerType( new QgsSymbolLayerV2Metadata( "LineDecoration", QObject::tr( "Line decoration" ), QgsSymbolV2::Line,
|
||||
QgsLineDecorationSymbolLayerV2::create ) );
|
||||
|
||||
addSymbolLayerType( new QgsSymbolLayerV2Metadata( "SimpleMarker", QObject::tr( "Simple marker" ), QgsSymbolV2::Marker,
|
||||
QgsSimpleMarkerSymbolLayerV2::create, QgsSimpleMarkerSymbolLayerV2::createFromSld ) );
|
||||
|
@ -59,7 +59,6 @@ static void _initWidgetFunctions()
|
||||
|
||||
_initWidgetFunction( "SimpleLine", QgsSimpleLineSymbolLayerV2Widget::create );
|
||||
_initWidgetFunction( "MarkerLine", QgsMarkerLineSymbolLayerV2Widget::create );
|
||||
_initWidgetFunction( "LineDecoration", QgsLineDecorationSymbolLayerV2Widget::create );
|
||||
|
||||
_initWidgetFunction( "SimpleMarker", QgsSimpleMarkerSymbolLayerV2Widget::create );
|
||||
_initWidgetFunction( "SvgMarker", QgsSvgMarkerSymbolLayerV2Widget::create );
|
||||
|
@ -1151,63 +1151,6 @@ void QgsSvgMarkerSymbolLayerV2Widget::on_mDataDefinedPropertiesButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////
|
||||
|
||||
QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
|
||||
: QgsSymbolLayerV2Widget( parent, vl )
|
||||
{
|
||||
mLayer = NULL;
|
||||
|
||||
setupUi( this );
|
||||
|
||||
connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
|
||||
connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
|
||||
{
|
||||
if ( layer->layerType() != "LineDecoration" )
|
||||
return;
|
||||
|
||||
// layer type is correct, we can do the cast
|
||||
mLayer = static_cast<QgsLineDecorationSymbolLayerV2*>( layer );
|
||||
|
||||
// set values
|
||||
btnChangeColor->setColor( mLayer->color() );
|
||||
btnChangeColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
|
||||
spinWidth->setValue( mLayer->width() );
|
||||
|
||||
mWidthUnitComboBox->blockSignals( true );
|
||||
mWidthUnitComboBox->setCurrentIndex( mLayer->widthUnit() );
|
||||
mWidthUnitComboBox->blockSignals( false );
|
||||
}
|
||||
|
||||
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2Widget::symbolLayer()
|
||||
{
|
||||
return mLayer;
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2Widget::colorChanged( const QColor& color )
|
||||
{
|
||||
mLayer->setColor( color );
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2Widget::penWidthChanged()
|
||||
{
|
||||
mLayer->setWidth( spinWidth->value() );
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void QgsLineDecorationSymbolLayerV2Widget::on_mWidthUnitComboBox_currentIndexChanged( int index )
|
||||
{
|
||||
if ( mLayer )
|
||||
{
|
||||
mLayer->setWidthUnit(( QgsSymbolV2::OutputUnit ) index );
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
|
||||
/////////////
|
||||
|
||||
#include <QFileDialog>
|
||||
|
@ -233,34 +233,6 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget
|
||||
|
||||
///////////
|
||||
|
||||
#include "ui_widget_linedecoration.h"
|
||||
|
||||
class QgsLineDecorationSymbolLayerV2;
|
||||
|
||||
class GUI_EXPORT QgsLineDecorationSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetLineDecoration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );
|
||||
|
||||
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsLineDecorationSymbolLayerV2Widget( vl ); }
|
||||
|
||||
// from base class
|
||||
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
|
||||
virtual QgsSymbolLayerV2* symbolLayer();
|
||||
|
||||
public slots:
|
||||
void colorChanged( const QColor& color );
|
||||
void penWidthChanged();
|
||||
void on_mWidthUnitComboBox_currentIndexChanged( int index );
|
||||
|
||||
protected:
|
||||
QgsLineDecorationSymbolLayerV2* mLayer;
|
||||
};
|
||||
|
||||
//////////
|
||||
|
||||
#include "ui_widget_svgfill.h"
|
||||
|
||||
class QgsSVGFillSymbolLayer;
|
||||
|
@ -1,119 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>WidgetLineDecoration</class>
|
||||
<widget class="QWidget" name="WidgetLineDecoration">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>194</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>28</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QgsColorButton" name="btnChangeColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Pen width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinWidth">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="mWidthUnitComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Millimeter</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Map unit</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QgsColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>qgscolorbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user