Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add default Z value option. Added the ability to create shape with 2.…
…5d geometry. Change add feature tool fo create geometry with default Z value.
  • Loading branch information
alisovenko committed Dec 26, 2016
1 parent 0a686c4 commit d2f41ac
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -146,7 +146,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
else if ( layerWKBType == QgsWkbTypes::Point25D )
{
g = QgsGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), 0.0 ) );
g = QgsGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), getDefaultZValue() ) );
}
else if ( layerWKBType == QgsWkbTypes::MultiPoint )
{
Expand All @@ -155,7 +155,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
else if ( layerWKBType == QgsWkbTypes::MultiPoint25D )
{
QgsMultiPointV2* mp = new QgsMultiPointV2();
mp->addGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), 0.0 ) );
mp->addGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), getDefaultZValue() ) );
g = QgsGeometry( mp );
}
else
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -854,6 +854,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )

mLineGhostCheckBox->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/line_ghost" ), false ).toBool() );

mDefaultZValueSpinBox->setValue(
mSettings->value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble()
);

//default snap mode
mSnappingEnabledDefault->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool() );
mDefaultSnapModeComboBox->addItem( tr( "Vertex" ), QgsSnappingConfig::Vertex );
Expand Down Expand Up @@ -1362,6 +1366,8 @@ void QgsOptions::saveOptions()

settings.setValue( QStringLiteral( "/qgis/digitizing/line_ghost" ), mLineGhostCheckBox->isChecked() );

mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), mDefaultZValueSpinBox->value() );

//default snap mode
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), mSnappingEnabledDefault->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_type" ), mDefaultSnapModeComboBox->currentData().toInt() );
Expand Down
1 change: 1 addition & 0 deletions src/core/qgis.cpp
Expand Up @@ -87,6 +87,7 @@ double Qgis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM = 1.0;

double Qgis::SCALE_PRECISION = 0.9999999999;

double Qgis::DEFAULT_Z_COORDINATE = 0.0;

double qgsPermissiveToDouble( QString string, bool &ok )
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgis.h
Expand Up @@ -113,6 +113,11 @@ class CORE_EXPORT Qgis
* @note added in 2.15*/
static double SCALE_PRECISION;

/**
*
* @note added in 3.0 */
static double DEFAULT_Z_COORDINATE;

private:
// String representation of unit types (set in qgis.cpp)
static const char *qgisUnitTypes[];
Expand Down
5 changes: 4 additions & 1 deletion src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -46,6 +46,7 @@ QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizin
#ifdef Q_OS_WIN
, mSkipNextContextMenuEvent( 0 )
#endif
, mDefaultZValue(Qgis::DEFAULT_Z_COORDINATE)
{
mCaptureMode = mode;

Expand Down Expand Up @@ -84,6 +85,8 @@ void QgsMapToolCapture::activate()
mTempRubberBand->show();

QgsMapToolAdvancedDigitizing::activate();

mDefaultZValue = QSettings().value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble();
}

void QgsMapToolCapture::deactivate()
Expand Down Expand Up @@ -332,7 +335,7 @@ int QgsMapToolCapture::nextPoint( const QgsPointV2& mapPoint, QgsPointV2& layerP
QgsPoint mapP( mapPoint.x(), mapPoint.y() );
layerPoint = QgsPointV2( toLayerCoordinates( vlayer, mapP ) ); //transform snapped point back to layer crs
if ( QgsWkbTypes::hasZ( vlayer->wkbType() ) )
layerPoint.addZValue( 0.0 );
layerPoint.addZValue( getDefaultZValue() );
if ( QgsWkbTypes::hasM( vlayer->wkbType() ) )
layerPoint.addMValue( 0.0 );
}
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsmaptoolcapture.h
Expand Up @@ -82,6 +82,11 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
*/
void deleteTempRubberBand();

/**
* Return defalut Z value
*/
double getDefaultZValue() {return mDefaultZValue;};

private slots:
void validationFinished();
void currentLayerChanged( QgsMapLayer *layer );
Expand Down Expand Up @@ -212,6 +217,7 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing

QgsVertexMarker* mSnappingMarker;

double mDefaultZValue;
#ifdef Q_OS_WIN
int mSkipNextContextMenuEvent;
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsnewvectorlayerdialog.cpp
Expand Up @@ -147,14 +147,20 @@ QgsWkbTypes::Type QgsNewVectorLayerDialog::selectedType() const
{
if ( mPointRadioButton->isChecked() )
{
if (mGeometryWithZCheckBox->isChecked())
return QgsWkbTypes::Point25D;
return QgsWkbTypes::Point;
}
else if ( mLineRadioButton->isChecked() )
{
if (mGeometryWithZCheckBox->isChecked())
return QgsWkbTypes::LineString25D;
return QgsWkbTypes::LineString;
}
else if ( mPolygonRadioButton->isChecked() )
{
if (mGeometryWithZCheckBox->isChecked())
return QgsWkbTypes::Polygon25D;
return QgsWkbTypes::Polygon;
}
return QgsWkbTypes::Unknown;
Expand Down
18 changes: 18 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -2671,21 +2671,39 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
case QgsWkbTypes::Point:
OGRvectortype = wkbPoint;
break;
case QgsWkbTypes::Point25D:
OGRvectortype = wkbPoint25D;
break;
case QgsWkbTypes::LineString:
OGRvectortype = wkbLineString;
break;
case QgsWkbTypes::LineString25D:
OGRvectortype = wkbLineString25D;
break;
case QgsWkbTypes::Polygon:
OGRvectortype = wkbPolygon;
break;
case QgsWkbTypes::Polygon25D:
OGRvectortype = wkbPolygon25D;
break;
case QgsWkbTypes::MultiPoint:
OGRvectortype = wkbMultiPoint;
break;
case QgsWkbTypes::MultiPoint25D:
OGRvectortype = wkbMultiPoint25D;
break;
case QgsWkbTypes::MultiLineString:
OGRvectortype = wkbMultiLineString;
break;
case QgsWkbTypes::MultiLineString25D:
OGRvectortype = wkbMultiLineString25D;
break;
case QgsWkbTypes::MultiPolygon:
OGRvectortype = wkbMultiPolygon;
break;
case QgsWkbTypes::MultiPolygon25D:
OGRvectortype = wkbMultiPolygon25D;
break;
default:
{
QgsMessageLog::logMessage( QObject::tr( "Unknown vector type of %1" ).arg(( int )( vectortype ) ), QObject::tr( "OGR" ) );
Expand Down
21 changes: 14 additions & 7 deletions src/ui/qgsnewvectorlayerdialogbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>444</width>
<width>471</width>
<height>578</height>
</rect>
</property>
Expand Down Expand Up @@ -69,22 +69,29 @@
<property name="title">
<string>Type</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QRadioButton" name="mLineRadioButton">
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="mPointRadioButton">
<property name="text">
<string>Point</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="mLineRadioButton">
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="mGeometryWithZCheckBox">
<property name="text">
<string>Line</string>
<string>Geometries with Z coordinate</string>
</property>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="QRadioButton" name="mPolygonRadioButton">
<property name="text">
<string>Polygon</string>
Expand Down
51 changes: 37 additions & 14 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -1023,7 +1023,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<width>839</width>
<height>850</height>
</rect>
</property>
Expand Down Expand Up @@ -1813,7 +1813,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-299</y>
<y>0</y>
<width>839</width>
<height>982</height>
</rect>
Expand Down Expand Up @@ -3755,8 +3755,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>701</height>
<width>839</width>
<height>734</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
Expand All @@ -3769,16 +3769,6 @@
<string>Feature creation</string>
</property>
<layout class="QGridLayout" name="gridLayout_28">
<item row="2" column="2">
<widget class="QComboBox" name="mValidateGeometries">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
Expand Down Expand Up @@ -3819,6 +3809,39 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mDefaultZValueLabel">
<property name="text">
<string>Default Z value</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="mDefaultZValueSpinBox">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>-999999.998999999952503</double>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="mValidateGeometries">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit d2f41ac

Please sign in to comment.