Skip to content

Commit ad3a805

Browse files
Merge pull request #360 from Esri/guil553/clipping-distance
Guil553/clipping distance
2 parents e57c204 + 1b3c4ec commit ad3a805

26 files changed

+201
-25
lines changed

Common/AR/qml/ClippingView.qml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*******************************************************************************
2+
* Copyright 2012-2020 Esri
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
******************************************************************************/
16+
17+
import QtQuick 2.12
18+
import QtQuick.Controls 2.2
19+
20+
/*!
21+
\qmltype ClippingView
22+
\ingroup ArcGISQtToolkitAR
23+
\ingroup ArcGISQtToolkitARCppApi
24+
\ingroup ArcGISQtToolkitARQmlApi
25+
\ingroup ArcGISQtToolkit
26+
\ingroup ArcGISQtToolkitCppApi
27+
\ingroup ArcGISQtToolkitQmlApi
28+
\inqmlmodule Esri.ArcGISRuntime.Toolkit.AR
29+
\since Esri.ArcGISRutime 100.8
30+
\brief An item displaying controls for adjusting a scene view's clipping distance.
31+
32+
This item can be used to change manually the clipping distance of the scene.
33+
*/
34+
35+
Item {
36+
id: root
37+
height: rect.height
38+
property alias clippingDistance: slider.value
39+
40+
Rectangle {
41+
id: rect
42+
anchors {
43+
left: parent.left
44+
right: parent.right
45+
bottom: parent.bottom
46+
}
47+
height: column.height + 20
48+
color: "#88ffffff" // transparent white
49+
radius: 5
50+
51+
Column {
52+
id: column
53+
anchors {
54+
left: parent.left
55+
right: parent.right
56+
bottom: parent.bottom
57+
margins: 10
58+
}
59+
spacing: 5
60+
61+
Text {
62+
width: parent.width
63+
text: "Clipping distance: " + Math.floor(slider.value) + " m"
64+
horizontalAlignment: Text.AlignHCenter
65+
font.bold: true
66+
}
67+
Slider {
68+
id: slider
69+
width: parent.width
70+
from: 0.0
71+
to: 5000.0
72+
value: 0.0
73+
}
74+
}
75+
}
76+
}

Common/AR/qml/ar.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<qresource prefix="/qml">
33
<file>CalibrationView.qml</file>
44
<file>CalibrationSlider.qml</file>
5+
<file>ClippingView.qml</file>
56
</qresource>
67
</RCC>

Examples/AR/CppArExample/CppArExample.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void CppArExample::setArcGISArView(ArcGISArView* arcGISArView)
6161
return;
6262

6363
m_arcGISArView = arcGISArView;
64+
m_arcGISArView->setClippingDistance(m_clippingDistance);
6465

6566
// Connect to the locationChanged signal, to update the QML messages
6667
connect(m_arcGISArView, &ArcGISArView::locationDataSourceChanged, this, [this]()
@@ -111,6 +112,12 @@ void CppArExample::setSceneView(SceneQuickView* sceneView)
111112
emit sceneViewChanged();
112113
}
113114

115+
void CppArExample::setClippingDistance(double clippingDistance)
116+
{
117+
m_clippingDistance = clippingDistance;
118+
m_arcGISArView->setClippingDistance(m_clippingDistance);
119+
}
120+
114121
// Update the origin camera using the values sent by the calibration view.
115122
// The m_originCamera is set when the scene is created.
116123
// The final origin camera sent to ArcGISArView is the sum of m_originCamera

Examples/AR/CppArExample/CppArExample.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class CppArExample : public QObject
3232
{
3333
Q_OBJECT
3434

35-
Q_PROPERTY(Esri::ArcGISRuntime::Toolkit::ArcGISArView* arcGISArView READ arcGISArView WRITE setArcGISArView
36-
NOTIFY arcGISArViewChanged)
35+
Q_PROPERTY(Esri::ArcGISRuntime::Toolkit::ArcGISArView* arcGISArView READ arcGISArView WRITE setArcGISArView NOTIFY arcGISArViewChanged)
3736
Q_PROPERTY(Esri::ArcGISRuntime::SceneQuickView* sceneView READ sceneView WRITE setSceneView NOTIFY sceneViewChanged)
3837
Q_PROPERTY(bool screenToLocationMode MEMBER m_screenToLocationMode NOTIFY screenToLocationModeChanged)
3938
Q_PROPERTY(bool tabletopMode MEMBER m_tabletopMode NOTIFY tabletopModeChanged)
@@ -49,6 +48,8 @@ class CppArExample : public QObject
4948
Esri::ArcGISRuntime::SceneQuickView* sceneView() const;
5049
void setSceneView(Esri::ArcGISRuntime::SceneQuickView* sceneView);
5150

51+
Q_INVOKABLE void setClippingDistance(double clippingDistance);
52+
5253
Q_INVOKABLE void updateOriginCamera(double latitude, double longitude, double altitude, double heading);
5354

5455
Q_INVOKABLE void showPointCloud(bool visible);
@@ -86,9 +87,12 @@ private slots:
8687
Esri::ArcGISRuntime::SceneQuickView* m_sceneView = nullptr;
8788
Esri::ArcGISRuntime::Scene* m_scene = nullptr;
8889

90+
// Clipping distance to origin camera.
91+
double m_clippingDistance = 0.0;
92+
8993
// Screen to location properties
9094
bool m_screenToLocationMode = false;
91-
95+
9296
// The origin camera set when the scene is created.
9397
Esri::ArcGISRuntime::Camera m_originCamera;
9498

Examples/AR/CppArExample/CppArExample.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ CONFIG += c++11
2222
TARGET = CppArExample
2323

2424
equals(QT_MAJOR_VERSION, 5) {
25-
lessThan(QT_MINOR_VERSION, 12) {
25+
lessThan(QT_MINOR_VERSION, 12) {
26+
error("$$TARGET requires Qt 5.12.6")
27+
}
28+
equals(QT_MINOR_VERSION, 12) : lessThan(QT_PATCH_VERSION, 6) {
2629
error("$$TARGET requires Qt 5.12.6")
2730
}
28-
equals(QT_MINOR_VERSION, 12) : lessThan(QT_PATCH_VERSION, 6) {
29-
error("$$TARGET requires Qt 5.12.6")
30-
}
3131
}
3232

3333
ARCGIS_RUNTIME_VERSION = 100.8

Examples/AR/CppArExample/qml/Message.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import QtQuick 2.6
22
import QtQuick.Controls 2.2
3-
import Esri.ArcGISRuntime 100.6
3+
import Esri.ArcGISRuntime 100.8
44
import Esri.ArcGISArToolkit 1.0
55

66
Rectangle {

Examples/AR/CppArExample/qml/SettingsWindow.qml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Item {
3030
signal ignoreTrackingClicked()
3131
signal initialTrackingClicked()
3232
signal continuousTrackingClicked()
33+
signal clippingClicked()
3334
signal calibrationClicked()
3435
signal resetCalibrationClicked()
3536
signal screenToLocationClicked()
@@ -114,6 +115,14 @@ Item {
114115
text: "Continuous tracking"
115116
onClicked: continuousTrackingClicked();
116117
}
118+
Button {
119+
width: buttonWidth
120+
text: "Clipping distance"
121+
onClicked: {
122+
settings.visible = false;
123+
clippingClicked();
124+
}
125+
}
117126
Button {
118127
width: buttonWidth
119128
text: "Calibration"

Examples/AR/CppArExample/qml/main.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ ApplicationWindow {
7777
visible: false
7878
onTriggered: arSample.updateOriginCamera(latitude, longitude, altitude, heading);
7979
}
80+
81+
ClippingView {
82+
id: clippingView
83+
width: parent.width
84+
visible: false
85+
onClippingDistanceChanged: arSample.setClippingDistance(clippingDistance);
86+
}
8087
}
8188

8289
SettingsWindow {
@@ -93,6 +100,7 @@ ApplicationWindow {
93100
onIgnoreTrackingClicked: arcGISArView.locationTrackingMode = ArEnums.Ignore;
94101
onInitialTrackingClicked: arcGISArView.locationTrackingMode = ArEnums.Initial;
95102
onContinuousTrackingClicked: arcGISArView.locationTrackingMode = ArEnums.Continuous;
103+
onClippingClicked: clippingView.visible = !clippingView.visible
96104
onCalibrationClicked: calibrationView.visible = !calibrationView.visible
97105
onResetCalibrationClicked: calibrationView.reset();
98106
onScreenToLocationClicked: arSample.screenToLocationMode = !arSample.screenToLocationMode

Examples/AR/QmlArExample/QmlArExample.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ TEMPLATE = app
3131
TARGET = QmlArExample
3232

3333
equals(QT_MAJOR_VERSION, 5) {
34-
lessThan(QT_MINOR_VERSION, 12) {
34+
lessThan(QT_MINOR_VERSION, 12) {
35+
error("$$TARGET requires Qt 5.12.6")
36+
}
37+
equals(QT_MINOR_VERSION, 12) : lessThan(QT_PATCH_VERSION, 6) {
3538
error("$$TARGET requires Qt 5.12.6")
3639
}
37-
equals(QT_MINOR_VERSION, 12) : lessThan(QT_PATCH_VERSION, 6) {
38-
error("$$TARGET requires Qt 5.12.6")
39-
}
4040
}
4141

4242
#-------------------------------------------------------------------------------

Examples/AR/QmlArExample/qml/Message.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import QtQuick 2.6
22
import QtQuick.Controls 2.2
3-
import Esri.ArcGISRuntime 100.6
3+
import Esri.ArcGISRuntime 100.8
44
import Esri.ArcGISArToolkit 1.0
55

66
Rectangle {

0 commit comments

Comments
 (0)