Skip to content

Commit

Permalink
measure crosshair added
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Aug 16, 2024
1 parent 72ceeb6 commit ae17a36
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 265 deletions.
1 change: 1 addition & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ set(MM_QML
map/MMSplittingTools.qml
map/MMStakeoutTools.qml
map/MMRecordingTools.qml
map/MMMeasurementTools.qml
map/components/MMHidingBox.qml
map/components/MMCrosshair.qml
map/components/MMMapHidingLabel.qml
Expand Down
2 changes: 2 additions & 0 deletions app/qml/components/MMDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Drawer {
property string leftButtonIcon: ""
property string leftButtonText: ""
property string leftButtonType: MMButton.Types.Primary
signal leftButtonClicked

implicitHeight: contentHeight > maxHeight ? maxHeight : contentHeight
implicitWidth: ApplicationWindow.window?.width ?? 0
Expand Down Expand Up @@ -81,6 +82,7 @@ Drawer {
leftButtonIcon: root.leftButtonIcon
leftButtonText: root.leftButtonText
leftButtonType: root.leftButtonType
onLeftButtonClicked: root.leftButtonClicked()

onCloseClicked: {
root.close()
Expand Down
12 changes: 0 additions & 12 deletions app/qml/components/MMDrawerHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ Rectangle {
implicitHeight: 60 * __dp
implicitWidth: ApplicationWindow.window?.width ?? 0

// MMRoundButton {
// id: leftBtn

// iconSource: __style.addIcon
// iconColor: __style.forestColor

// bgndColor: __style.grassColor
// bgndHoverColor: __style.mediumGreenColor

// onClicked: root.createWorkspaceRequested()
// }

MMButton {
id: leftBtn

Expand Down
26 changes: 22 additions & 4 deletions app/qml/gps/MMMeasureDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ MMDrawer {
// targetPair,
// mapCanvas.mapSettings ) : -1
property bool closeShapeActive: true
property bool closeShapeDone: true

readonly property alias panelHeight: root.height

Expand All @@ -56,6 +57,22 @@ MMDrawer {
root.open()
}

function closeShape()
{
console.log(" close shape clicked ")
root.closeShapeActive = false
}

function addPoint()
{
console.log(" point added ")
}

function repeatMeasure()
{
console.log(" repeat measure ")
}

modal: false

closePolicy: Popup.CloseOnEscape // prevents the drawer closing while moving canvas
Expand All @@ -64,11 +81,12 @@ MMDrawer {

//onClosed: root.endStakeout()

leftButtonText: "Undo"
leftButtonIcon: __style.undoIcon
leftButtonText: closeShapeDone ? qsTr( "Repeat" ) : qsTr( "Undo" )
leftButtonIcon: closeShapeDone ? __style.syncIcon : __style.undoIcon
leftButtonType: MMButton.Types.Primary
onLeftButtonClicked: console.log("onLeftButtonClicked")

drawerHeader.title: qsTr("Measure")
drawerHeader.title: qsTr( "Measure" )

drawerContent: Column {
id: mainColumn
Expand Down Expand Up @@ -103,7 +121,7 @@ MMDrawer {
MMButton {
text: closeShapeActive ? qsTr( "Close shape" ) : qsTr( "Add point" )
iconSourceLeft: closeShapeActive ? __style.closeShapeIcon : __style.plusIcon
onClicked: console.log(" Add point or Close Shape")
onClicked: closeShapeActive ? root.closeShape() : root.addPoint()
}

MMButton {
Expand Down
15 changes: 8 additions & 7 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ ApplicationWindow {
// if stakeout panel is opened
return stakeoutPanelLoader.item.panelHeight - mapToolbar.height
}
else if ( measurePanelLoader.active )
{
return measurePanelLoader.item.panelHeight - mapToolbar.height
}
else if ( formsStackManager.takenVerticalSpace > 0 )
{
// if feature preview panel is opened
Expand Down Expand Up @@ -336,13 +340,8 @@ ApplicationWindow {
text: qsTr("Measure")
iconSource: __style.measurementToolIcon
onClicked: {
if ( __recordingLayersModel.rowCount() > 0 ) {
stateManager.state = "map"
map.measure()
}
else {
__notificationModel.addInfo( qsTr( "No editable layers found." ) )
}
stateManager.state = "map"
map.measure()
}
}

Expand Down Expand Up @@ -773,6 +772,8 @@ ApplicationWindow {

MMFinishMeasurementDialog {
id: finishMeasurementDialog

onFinishMeasurementRequested: measurePanelLoader.active = false
}

MMNotificationView {}
Expand Down
42 changes: 36 additions & 6 deletions app/qml/map/MMMapController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ Item {
sourceComponent: stakeoutToolsComponent
}

Loader {
id: measureLoader

anchors.fill: mapCanvas

asynchronous: true
active: root.state === "measure"

sourceComponent: measurementToolsComponent
}

Loader {
id: tracking

Expand Down Expand Up @@ -506,10 +517,10 @@ Item {

anchors.bottom: parent.bottom

anchors.bottomMargin: root.state === "stakeout" ? root.mapExtentOffset : 0
anchors.bottomMargin: root.state === "stakeout" || root.state === "measure" ? root.mapExtentOffset : 0

visible: {
if ( root.state === "stakeout" )
if ( root.state === "stakeout" || root.state === "measure" )
return true
else
return root.mapExtentOffset > 0 ? false : true
Expand Down Expand Up @@ -971,6 +982,17 @@ Item {
}
}

Component {
id: measurementToolsComponent

MMMeasurementTools {
anchors.fill: parent

map: mapCanvas
positionMarkerComponent: positionMarker
}
}

Component {
id: splittingToolsComponent

Expand Down Expand Up @@ -1120,6 +1142,12 @@ Item {
state = "stakeout"
}

function measure() {
internal.extentBeforeStakeout = mapCanvas.mapSettings.extent

state = "measure"
}

function toggleStreaming() {
// start/stop the streaming mode
if ( recordingToolsLoader.active ) {
Expand All @@ -1136,6 +1164,12 @@ Item {
root.centeredToGPS = internal.centeredToGPSBeforeStakeout
}

function stopMeasure() {
state = "view"

mapCanvas.mapSettings.extent = internal.extentBeforeStakeout
}

function centerToPair( pair ) {
__inputUtils.setExtentToFeature( pair, mapCanvas.mapSettings )
}
Expand Down Expand Up @@ -1254,10 +1288,6 @@ Item {
}
}

function measure() {
state = "measure"
}

function showInfoTextMessage( message ) {
hideInfoTextMessage()

Expand Down
Loading

0 comments on commit ae17a36

Please sign in to comment.