From 7d27bcc08703dabc1d7b37ed1eff1531f3338fe1 Mon Sep 17 00:00:00 2001 From: VitorVieiraZ Date: Tue, 27 Aug 2024 14:37:41 -0300 Subject: [PATCH] in progress --- app/inpututils.cpp | 12 ++++++ app/map/inputmapsettings.cpp | 16 +++----- app/qml/main.qml | 56 +++++++++++++-------------- app/qml/map/MMMeasurementTools.qml | 49 ++++++++++++----------- app/qml/map/components/MMMapLabel.qml | 8 ++-- 5 files changed, 77 insertions(+), 64 deletions(-) diff --git a/app/inpututils.cpp b/app/inpututils.cpp index 9904308f42..eed98bc2e8 100644 --- a/app/inpututils.cpp +++ b/app/inpututils.cpp @@ -843,35 +843,47 @@ QgsPoint InputUtils::transformPoint( const QgsCoordinateReferenceSystem &srcCrs, const QgsCoordinateTransformContext &context, const QgsPoint &srcPoint ) { + // we do not want to transform empty points, // QGIS would convert them to a valid (0, 0) points if ( srcPoint.isEmpty() ) { + qDebug() << "Source point is empty, returning an empty QgsPoint."; return QgsPoint(); } try { + qDebug() << "Creating QgsCoordinateTransform with srcCrs, destCrs, and context."; QgsCoordinateTransform ct( srcCrs, destCrs, context ); if ( ct.isValid() ) { + qDebug() << "CoordinateTransform is valid."; if ( !ct.isShortCircuited() ) { + qDebug() << "Transform is not short-circuited, transforming point."; const QgsPointXY transformed = ct.transform( srcPoint.x(), srcPoint.y() ); const QgsPoint pt( transformed.x(), transformed.y(), srcPoint.z(), srcPoint.m() ); return pt; } else { + qDebug() << "Transform is short-circuited, returning source point."; return srcPoint; } } + else + { + qDebug() << "CoordinateTransform is not valid."; + } } catch ( QgsCsException &cse ) { + qDebug() << "Caught QgsCsException during transformation:" << cse.what(); Q_UNUSED( cse ) } + qDebug() << "Returning an empty QgsPoint due to unsuccessful transformation."; return QgsPoint(); } diff --git a/app/map/inputmapsettings.cpp b/app/map/inputmapsettings.cpp index 991047c57f..0f6654b7f9 100644 --- a/app/map/inputmapsettings.cpp +++ b/app/map/inputmapsettings.cpp @@ -135,21 +135,17 @@ QgsRectangle InputMapSettings::visibleExtent() const QPointF InputMapSettings::coordinateToScreen( const QgsPoint &point ) const { - QgsPointXY pt( point.x(), point.y() ); + QgsPointXY pt( point.x(), point.y() ); - QgsPointXY pp = mMapSettings.mapToPixel().transform( pt ); + QgsPointXY pp = mMapSettings.mapToPixel().transform( pt ); - pp.setX( pp.x() / devicePixelRatio() ); - qDebug() << "DEBUG: devicePixelRatio=" << devicePixelRatio(); - qDebug() << "DEBUG: pp.setX =" << pp.x(); + pp.setX( pp.x() / devicePixelRatio() ); - pp.setY( pp.y() / devicePixelRatio() ); - qDebug() << "DEBUG: pp.setY =" << pp.y(); + pp.setY( pp.y() / devicePixelRatio() ); - QPointF result = pp.toQPointF(); - qDebug() << "DEBUG: Returning QPointF result =" << result; + QPointF result = pp.toQPointF(); - return result; + return result; } QgsPoint InputMapSettings::screenToCoordinate( const QPointF &point ) const diff --git a/app/qml/main.qml b/app/qml/main.qml index 08133e4cd9..c93e5566c3 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -613,34 +613,34 @@ ApplicationWindow { } } - Loader { - id: stakeoutPanelLoader - - focus: true - active: false - asynchronous: true - - sourceComponent: stakeoutPanelComponent - } - - Component { - id: stakeoutPanelComponent - - MMMeasureDrawer { - id: measurePanel - - width: window.width - mapCanvas: root.map - - //bind length and area to mapTool.length and mapTool.area / iconSource === or closeShape - onAddMeasurePoint: mapTool.addPoint( crosshair.recordPoint ) - onMeasureDone: finishMeasurementDialog.open() - onMeasureFinished: root.finishMeasurement() - onCloseShape: root.closeShape() - onRepeat: root.repeatMeasure() - onUndo: mapTool.removePoint() - } - } + // Loader { + // id: stakeoutPanelLoader + + // focus: true + // active: false + // asynchronous: true + + // sourceComponent: stakeoutPanelComponent + // } + + // Component { + // id: stakeoutPanelComponent + + // MMMeasureDrawer { + // id: measurePanel + + // width: window.width + // mapCanvas: root.map + + // //bind length and area to mapTool.length and mapTool.area / iconSource === or closeShape + // onAddMeasurePoint: mapTool.addPoint( crosshair.recordPoint ) + // onMeasureDone: finishMeasurementDialog.open() + // onMeasureFinished: root.finishMeasurement() + // onCloseShape: root.closeShape() + // onRepeat: root.repeatMeasure() + // onUndo: mapTool.removePoint() + // } + // } MMFormStackController { id: formsStackManager diff --git a/app/qml/map/MMMeasurementTools.qml b/app/qml/map/MMMeasurementTools.qml index 74d6c60f8d..a61e8af2d5 100644 --- a/app/qml/map/MMMeasurementTools.qml +++ b/app/qml/map/MMMeasurementTools.qml @@ -31,6 +31,7 @@ Item { MM.MeasurementMapTool { id: mapTool mapSettings: root.map.mapSettings + activeLayer: __activeLayer.vectorLayer onCanCloseShape: function( canClose ) { measurePanel.canCloseShape = canClose; } onCanUndo: function( canUndo ) { measurePanel.canUndo = canUndo; } @@ -77,20 +78,20 @@ Item { geometry: __inputUtils.transformGeometryToMapWithLayer( mapTool.recordedGeometry, __activeLayer.vectorLayer, root.map.mapSettings ) } - // MMMeasureDrawer { - // id: measurePanel + MMMeasureDrawer { + id: measurePanel - // width: window.width - // mapCanvas: root.map + width: window.width + mapCanvas: root.map - // //bind length and area to mapTool.length and mapTool.area / iconSource === or closeShape - // onAddMeasurePoint: mapTool.addPoint( crosshair.recordPoint ) - // onMeasureDone: finishMeasurementDialog.open() - // onMeasureFinished: root.finishMeasurement() - // onCloseShape: root.closeShape() - // onRepeat: root.repeatMeasure() - // onUndo: mapTool.removePoint() - // } + //bind length and area to mapTool.length and mapTool.area / iconSource === or closeShape + onAddMeasurePoint: mapTool.addPoint( crosshair.recordPoint ) + onMeasureDone: finishMeasurementDialog.open() + onMeasureFinished: root.finishMeasurement() + onCloseShape: root.closeShape() + onRepeat: root.repeatMeasure() + onUndo: mapTool.removePoint() + } MMCrosshair { id: crosshair @@ -98,20 +99,24 @@ Item { anchors.fill: parent qgsProject: __activeProject.qgsProject mapSettings: root.map.mapSettings + } - // MMMapLabel { - // id: mapLabel + MMMapLabel { + id: mapLabel - // text: qsTr( "0.0 m" ) - // bgColor: __style.forestColor - // textColor: __style.polarColor - // textBgColorInverted: false - // onClicked: console.log( "MapLabel: ", crosshair.height ) + text: qsTr( "0.0 m" ) - // y: crosshair.crosshairForeground.y - // anchors.horizontalCenter: crosshair.horizontalCenter - // } + //implicitWidth: crosshair.width + //implicitHeight: crosshair.crosshairForeground.height - 10 + bgColor: __style.forestColor + textColor: __style.polarColor + textBgColorInverted: false + onClicked: console.log( "MapLabel: ", crosshair.height ) + + y: crosshair.crosshairForeground.y + crosshair.crosshairForeground.height + anchors.horizontalCenter: crosshair.crosshairForeground.horizontalCenter + } MMFinishMeasurementDialog { id: finishMeasurementDialog diff --git a/app/qml/map/components/MMMapLabel.qml b/app/qml/map/components/MMMapLabel.qml index d5ef423bb2..f2e1795447 100644 --- a/app/qml/map/components/MMMapLabel.qml +++ b/app/qml/map/components/MMMapLabel.qml @@ -24,7 +24,7 @@ Item { required property string text property real maxWidth: implicitWidth - property url iconSource: "" + property string iconSource property color bgColor: __style.positiveColor property color textColor: __style.forestColor property bool textBgColorInverted: false @@ -43,7 +43,7 @@ Item { id: row anchors.centerIn: parent - leftPadding: 20 * __dp + leftPadding: 8 * __dp rightPadding: leftPadding spacing: 4 * __dp height: parent.height @@ -53,7 +53,7 @@ Item { anchors.verticalCenter: parent.verticalCenter source: control.iconSource ? control.iconSource : "" color: control.textColor - size: control.iconSource !== "" ? __style.icon24 : 0 + size: control.iconSource ? __style.icon24 : 0 } Rectangle { @@ -74,7 +74,7 @@ Item { anchors.centerIn: parent color: control.textBgColorInverted ? control.bgColor : control.textColor text: control.text - font: __style.t3 + font: __style.t5 elide: Text.ElideRight } }