Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Aug 27, 2024
1 parent de456f2 commit 7d27bcc
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 64 deletions.
12 changes: 12 additions & 0 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
16 changes: 6 additions & 10 deletions app/map/inputmapsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 28 additions & 28 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 27 additions & 22 deletions app/qml/map/MMMeasurementTools.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -77,41 +78,45 @@ 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

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
Expand Down
8 changes: 4 additions & 4 deletions app/qml/map/components/MMMapLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +43,7 @@ Item {
id: row

anchors.centerIn: parent
leftPadding: 20 * __dp
leftPadding: 8 * __dp
rightPadding: leftPadding
spacing: 4 * __dp
height: parent.height
Expand All @@ -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 {
Expand All @@ -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
}
}
Expand Down

0 comments on commit 7d27bcc

Please sign in to comment.