Skip to content

Commit

Permalink
updating samples with reticle
Browse files Browse the repository at this point in the history
  • Loading branch information
ldanzinger committed Jul 15, 2024
1 parent fa800b4 commit 9945c6e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CppSamples/EditData/SnapGeometryEdits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Snapping is used to maintain data integrity between different sources of data wh

To snap to polygon and polyline layers, the recommended approach is to set the `FeatureLayer`'s feature tiling mode to `FeatureTilingMode::EnabledWithFullResolutionWhenSupported` and use the default `ServiceFeatureTable` feature request mode `FeatureRequestMode::OnInteractionCache`. Local data sources, such as geodatabases, always provide full resolution geometries. Point and multipoint feature layers are also always full resolution.

Snapping can be used during interactive edits that move existing vertices using the `VertexTool`. It is also supported for adding new vertices for input devices with a hover event (such as a mouse move without a mouse button press). Using the magnifier to perform a vertex move allows users of touch devices to clearly see the visual cues for snapping.
Snapping can be used during interactive edits that move existing vertices using the `VertexTool` or `ReticleVertexTool`. When adding new vertices, snapping also works with a hover event (such as a mouse move without a mouse button press). Using the `ReticleVertexTool` to add and move vertices allows users of touch screen devices to clearly see the visual cues for snapping.

## Tags

Expand Down
11 changes: 9 additions & 2 deletions CppSamples/EditData/SnapGeometryEdits/SnapGeometryEdits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "MapTypes.h"
#include "Portal.h"
#include "PortalItem.h"
#include "ReticleVertexTool.h"
#include "SimpleFillSymbol.h"
#include "SimpleLineSymbol.h"
#include "SimpleMarkerSymbol.h"
Expand All @@ -50,6 +51,7 @@
#include "SnapSourceListModel.h"

#include <QFuture>
#include <QtCore/qglobal.h>

using namespace Esri::ArcGISRuntime;

Expand All @@ -62,6 +64,12 @@ SnapGeometryEdits::SnapGeometryEdits(QObject* parent /* = nullptr */) :

m_geometryEditor = new GeometryEditor(this);
m_graphicsOverlay = new GraphicsOverlay(this);

// if mobile, use ReticleVertexTool
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
m_geometryEditor->setTool(new ReticleVertexTool(this));
#endif // defined(Q_OS_IOS) || defined(Q_OS_ANDROID)

connect (m_map, &Map::doneLoading, this, [this]()
{
for (Layer* layer : *m_map->operationalLayers())
Expand Down Expand Up @@ -108,8 +116,7 @@ void SnapGeometryEdits::setMapView(MapQuickView* mapView)
m_mapView->graphicsOverlays()->append(m_graphicsOverlay);

// Set the geometry editor on the map view
m_mapView->setGeometryEditor(m_geometryEditor);
m_mapView->setMagnifierEnabled(true);
m_mapView->setGeometryEditor(m_geometryEditor);

emit mapViewChanged();
createInitialSymbols();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "PolygonBuilder.h"
#include "Polyline.h"
#include "PolylineBuilder.h"
#include "ReticleVertexTool.h"
#include "ShapeTool.h"
#include "SimpleFillSymbol.h"
#include "SimpleLineSymbol.h"
Expand Down Expand Up @@ -70,6 +71,7 @@ CreateAndEditGeometries::CreateAndEditGeometries(QObject* parent /* = nullptr */
m_ellipseTool = ShapeTool::create(ShapeToolType::Ellipse, this);
m_rectangleTool = ShapeTool::create(ShapeToolType::Rectangle, this);
m_triangleTool = ShapeTool::create(ShapeToolType::Triangle, this);
m_reticleTool = new ReticleVertexTool(this);
}

CreateAndEditGeometries::~CreateAndEditGeometries() = default;
Expand Down Expand Up @@ -221,6 +223,9 @@ void CreateAndEditGeometries::setTool(GeometryEditorToolType toolType)
m_geometryEditor->setTool(m_triangleTool);
break;

case GeometryEditorToolType::Reticle:
m_geometryEditor->setTool(m_reticleTool);

default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace Esri::ArcGISRuntime
class SimpleLineSymbol;
class SimpleFillSymbol;
class VertexTool;
class ReticleVertexTool;
}

#include <QObject>
Expand Down Expand Up @@ -72,7 +73,8 @@ class CreateAndEditGeometries : public QObject
Arrow,
Ellipse,
Rectangle,
Triangle
Triangle,
Reticle
};

Q_ENUM(GeometryEditorToolType)
Expand Down Expand Up @@ -126,6 +128,7 @@ class CreateAndEditGeometries : public QObject
Esri::ArcGISRuntime::ShapeTool* m_ellipseTool = nullptr;
Esri::ArcGISRuntime::ShapeTool* m_rectangleTool = nullptr;
Esri::ArcGISRuntime::ShapeTool* m_triangleTool = nullptr;
Esri::ArcGISRuntime::ReticleVertexTool* m_reticleTool = nullptr;

QObject* m_tempGraphicsParent = nullptr;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ Item {

ComboBox {
id: toolCombo
model: [qsTr("Vertex Tool"), qsTr("Freehand Tool"), qsTr("Arrow Shape Tool"), qsTr("Ellipse Shape Tool"), qsTr("Rectangle Shape Tool"), qsTr("Triangle Shape Tool")]
model: [qsTr("Vertex Tool"), qsTr("Freehand Tool"), qsTr("Arrow Shape Tool"), qsTr("Ellipse Shape Tool"),
("Rectangle Shape Tool"), qsTr("Triangle Shape Tool"), qsTr("Reticle Tool")]
Layout.columnSpan: 2
Layout.fillWidth: true

Expand Down Expand Up @@ -171,6 +172,9 @@ Item {
case 5: // ShapeTool with triangle shape type
model.setTool(CreateAndEditGeometriesSample.Triangle);
break;
case 6: // Reticle Vertex Tool
model.setTool(CreateAndEditGeometriesSample.Reticle);
break;
default:
model.setTool(CreateAndEditGeometriesSample.Vertex);
}
Expand Down
8 changes: 5 additions & 3 deletions CppSamples/Geometry/CreateAndEditGeometries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ A field worker can mark features of interest on a map using an appropriate geome

To create a new geometry, press the button appropriate for the geometry type you want to create (i.e. points, multipoints, polyline, or polygon) and interactively tap and drag on the map view to create the geometry.

To edit an existing geometry, tap the geometry to be edited in the map to select it and then edit the geometry by tapping and dragging elements of the geometry.
To edit an existing geometry, tap the geometry to be edited in the map and then perform edits by tapping and dragging its elements.

When the whole geometry is selected, you can use the control handles to scale and rotate the geometry.

If creating or editing polyline or polygon geometries, choose the desired creation/editing tool from the combo box.
If creating or editing polyline or polygon geometries, choose the desired creation/editing tool (i.e. `VertexTool`, `ReticleVertexTool`, `FreehandTool`, or one of the available `ShapeTool`s).

When using the `ReticleVertexTool`, you can move the map position of the reticle by dragging and zooming the map. Insert a vertex under the reticle by tapping on the map. Move a vertex by tapping when the reticle is located over a vertex, drag the map to move the position of the reticle, then tap a second time to place the vertex.

Use the control panel to undo or redo changes made to the geometry, delete a selected element, save the geometry, stop the editing session and discard any edits, and remove all geometries from the map.

Expand All @@ -30,7 +32,7 @@ Use the control panel to undo or redo changes made to the geometry, delete a sel
- Find the desired graphic in the `IdentifyGraphicsOverlayResult::graphics()` list.
- Access the geometry associated with the `Graphic` using `Graphic::geometry()` - this will be used in the `GeometryEditor::start(Geometry)` method.

3. Create `VertexTool`, `FreehandTool`, or `ShapeTool` objects which define how the user interacts with the view to create or edit geometries, using `GeometryEditor::setTool(GeometryEditorTool)`.
3. Create `VertexTool`, `ReticleVertexTool`, `FreehandTool`, or `ShapeTool` objects which define how the user interacts with the view to create or edit geometries, and set the geometry editor tool using `GeometryEditor::setTool(GeometryEditorTool)`.
4. Edit a tool's `InteractionConfiguration` to set the `GeometryEditorScaleMode` to allow either uniform or stretch scale mode.
5. Check to see if undo and redo are possible during an editing session using `GeometryEditor::canUndo()` and `GeometryEditor::canRedo()`. If it's possible, use `GeometryEditor::undo()` and `GeometryEditor::redo()`.
6. Check whether the currently selected `GeometryEditorElement` can be deleted (`GeometryEditor::selectedElement::canDelete()`). If the element can be deleted, delete using `GeometryEditor::deleteSelectedElement()`.
Expand Down

0 comments on commit 9945c6e

Please sign in to comment.