mirror of https://github.com/qt/qtgraphs.git
Make camera rotation limits public
QML only, public getters/setters already exist for widget Fixes: QTBUG-121318 Change-Id: I391e57c6570a572ec40bb41ec6a9f959815389e2 Reviewed-by: Sami Varanka <sami.varanka@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
ee5ede3108
commit
94d12f0a41
|
|
@ -742,19 +742,6 @@ void QQuickGraphsBars::componentComplete()
|
|||
|
||||
void QQuickGraphsBars::synchData()
|
||||
{
|
||||
if (!m_noZeroInRange) {
|
||||
setMinCameraYRotation(-90.0f);
|
||||
setMaxCameraYRotation(90.0f);
|
||||
} else {
|
||||
if ((m_hasNegativeValues && !valueAxis()->reversed())
|
||||
|| (!m_hasNegativeValues && valueAxis()->reversed())) {
|
||||
setMinCameraYRotation(-90.0f);
|
||||
setMaxCameraYRotation(0.0f);
|
||||
} else {
|
||||
setMinCameraYRotation(0.0f);
|
||||
setMaxCameraYRotation(90.0f);
|
||||
}
|
||||
}
|
||||
if (m_changeTracker.barSpecsChanged || !m_cachedBarThickness.isValid()) {
|
||||
updateBarSpecs(m_barThicknessRatio, m_barSpacing, m_isBarSpecRelative);
|
||||
m_changeTracker.barSpecsChanged = false;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,34 @@ constexpr float polarRoundness = 64.0f;
|
|||
* starting from the current base position.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlproperty float GraphsItem3D::minCameraXRotation
|
||||
*
|
||||
* \brief The minimum X-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{-180.0}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlproperty float GraphsItem3D::maxCameraXRotation
|
||||
*
|
||||
* \brief The maximum X-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{180.0}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlproperty float GraphsItem3D::minCameraYRotation
|
||||
*
|
||||
* \brief The minimum Y-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{0.0}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlproperty float GraphsItem3D::maxCameraYRotation
|
||||
*
|
||||
* \brief The maximum Y-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{90.0}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlproperty bool GraphsItem3D::zoomAtTargetEnabled
|
||||
*
|
||||
|
|
|
|||
|
|
@ -195,6 +195,14 @@ class Q_GRAPHS_EXPORT QQuickGraphsItem : public QQuick3DViewport
|
|||
cameraXRotationChanged)
|
||||
Q_PROPERTY(float cameraYRotation READ cameraYRotation WRITE setCameraYRotation NOTIFY
|
||||
cameraYRotationChanged)
|
||||
Q_PROPERTY(float minCameraXRotation READ minCameraXRotation WRITE setMinCameraXRotation NOTIFY
|
||||
minCameraXRotationChanged REVISION(6, 9))
|
||||
Q_PROPERTY(float maxCameraXRotation READ maxCameraXRotation WRITE setMaxCameraXRotation NOTIFY
|
||||
maxCameraXRotationChanged REVISION(6, 9))
|
||||
Q_PROPERTY(float minCameraYRotation READ minCameraYRotation WRITE setMinCameraYRotation NOTIFY
|
||||
minCameraYRotationChanged REVISION(6, 9))
|
||||
Q_PROPERTY(float maxCameraYRotation READ maxCameraYRotation WRITE setMaxCameraYRotation NOTIFY
|
||||
maxCameraYRotationChanged REVISION(6, 9))
|
||||
Q_PROPERTY(float cameraZoomLevel READ cameraZoomLevel WRITE setCameraZoomLevel NOTIFY
|
||||
cameraZoomLevelChanged)
|
||||
Q_PROPERTY(QtGraphs3D::CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset NOTIFY
|
||||
|
|
|
|||
|
|
@ -1863,7 +1863,6 @@ void QQuickGraphsScatter::synchData()
|
|||
|
||||
updatePointScaleSize();
|
||||
QQuickGraphsItem::synchData();
|
||||
setMinCameraYRotation(-90.0f);
|
||||
|
||||
m_pointScale = calculatePointScaleSize();
|
||||
|
||||
|
|
|
|||
|
|
@ -438,6 +438,7 @@ void Q3DGraphsWidgetItem::setCameraYRotation(float rotation)
|
|||
* \property Q3DGraphsWidgetItem::minCameraXRotation
|
||||
*
|
||||
* \brief The minimum X-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{-180.0}
|
||||
*/
|
||||
float Q3DGraphsWidgetItem::minCameraXRotation() const
|
||||
{
|
||||
|
|
@ -455,6 +456,7 @@ void Q3DGraphsWidgetItem::setMinCameraXRotation(float rotation)
|
|||
* \property Q3DGraphsWidgetItem::maxCameraXRotation
|
||||
*
|
||||
* \brief The maximum X-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{180.0}
|
||||
*/
|
||||
float Q3DGraphsWidgetItem::maxCameraXRotation() const
|
||||
{
|
||||
|
|
@ -472,6 +474,7 @@ void Q3DGraphsWidgetItem::setMaxCameraXRotation(float rotation)
|
|||
* \property Q3DGraphsWidgetItem::minCameraYRotation
|
||||
*
|
||||
* \brief The minimum Y-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{0.0}
|
||||
*/
|
||||
float Q3DGraphsWidgetItem::minCameraYRotation() const
|
||||
{
|
||||
|
|
@ -489,6 +492,7 @@ void Q3DGraphsWidgetItem::setMinCameraYRotation(float rotation)
|
|||
* \property Q3DGraphsWidgetItem::maxCameraYRotation
|
||||
*
|
||||
* \brief The maximum Y-rotation angle of the camera around the target point in degrees.
|
||||
* The default value is \c{90.0}
|
||||
*/
|
||||
float Q3DGraphsWidgetItem::maxCameraYRotation() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ void tst_bars::initialProperties()
|
|||
QCOMPARE(m_graph->lightColor(), QColor(Qt::white));
|
||||
QCOMPARE(m_graph->lightStrength(), 5.0f);
|
||||
QCOMPARE(m_graph->shadowStrength(), 25.0f);
|
||||
QCOMPARE(m_graph->minCameraXRotation(), -180);
|
||||
QCOMPARE(m_graph->maxCameraXRotation(), 180);
|
||||
QCOMPARE(m_graph->minCameraYRotation(), 0);
|
||||
QCOMPARE(m_graph->maxCameraYRotation(), 90);
|
||||
}
|
||||
|
||||
void tst_bars::initializeProperties()
|
||||
|
|
@ -270,6 +274,11 @@ void tst_bars::initializeProperties()
|
|||
QCOMPARE(maxCameraXRotSpy.size(), 0);
|
||||
QCOMPARE(minCameraYRotSpy.size(), 0);
|
||||
QCOMPARE(maxCameraYRotSpy.size(), 0);
|
||||
|
||||
QCOMPARE(m_graph->minCameraXRotation(), 10.0f);
|
||||
QCOMPARE(m_graph->maxCameraXRotation(), 45.0f);
|
||||
QCOMPARE(m_graph->minCameraYRotation(), 10.0f);
|
||||
QCOMPARE(m_graph->maxCameraYRotation(), 45.0f);
|
||||
}
|
||||
|
||||
void tst_bars::invalidProperties()
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ lightColor: \"black\"
|
|||
ambientLightStrength: 0.5
|
||||
lightStrength: 10.0
|
||||
shadowStrength: 50.0
|
||||
minCameraXRotation: 0.0
|
||||
maxCameraXRotation: 90.0
|
||||
minCameraYRotation: -90.0
|
||||
maxCameraYRotation: 0.0
|
||||
}", top)
|
||||
common_init.anchors.fill = top
|
||||
}
|
||||
|
|
@ -190,6 +194,10 @@ shadowStrength: 50.0
|
|||
compare(common.ambientLightStrength, 0.25, "ambientLightStrength")
|
||||
compare(common.lightStrength, 5.0, "lightStrength")
|
||||
compare(common.shadowStrength, 25.0, "shadowStrength")
|
||||
compare(common.minCameraXRotation, -180.0, "minCameraXRotation")
|
||||
compare(common.maxCameraXRotation, 180.0, "maxCameraXRotation")
|
||||
compare(common.minCameraYRotation, 0.0, "minCameraYRotation")
|
||||
compare(common.maxCameraYRotation, 90.0, "maxCameraYRotation")
|
||||
}
|
||||
|
||||
function test_2_change_common() {
|
||||
|
|
@ -217,6 +225,11 @@ shadowStrength: 50.0
|
|||
common.ambientLightStrength = 0.5
|
||||
common.lightStrength = 10.0
|
||||
common.shadowStrength = 50.0
|
||||
common.minCameraXRotation = 0
|
||||
common.maxCameraXRotation = 90
|
||||
common.minCameraYRotation = -90
|
||||
common.maxCameraYRotation = 0
|
||||
|
||||
compare(common.selectionMode,
|
||||
Graphs3D.SelectionFlag.Item | Graphs3D.SelectionFlag.Row
|
||||
| Graphs3D.SelectionFlag.Slice, "selectionMode")
|
||||
|
|
@ -242,6 +255,10 @@ shadowStrength: 50.0
|
|||
compare(common.ambientLightStrength, 0.5, "ambientLightStrength")
|
||||
compare(common.lightStrength, 10.0, "lightStrength")
|
||||
compare(common.shadowStrength, 50.0, "shadowStrength")
|
||||
compare(common.minCameraXRotation, 0.0, "minCameraXRotation")
|
||||
compare(common.maxCameraXRotation, 90.0, "maxCameraXRotation")
|
||||
compare(common.minCameraYRotation, -90.0, "minCameraYRotation")
|
||||
compare(common.maxCameraYRotation, 0.0, "maxCameraYRotation")
|
||||
}
|
||||
|
||||
function test_3_change_invalid_common() {
|
||||
|
|
@ -317,6 +334,10 @@ shadowStrength: 50.0
|
|||
"ambientLightStrength")
|
||||
compare(common_init.lightStrength, 10.0, "lightStrength")
|
||||
compare(common_init.shadowStrength, 50.0, "shadowStrength")
|
||||
compare(common_init.minCameraXRotation, 0.0, "minCameraXRotation")
|
||||
compare(common_init.maxCameraXRotation, 90.0, "maxCameraXRotation")
|
||||
compare(common_init.minCameraYRotation, -90.0, "minCameraYRotation")
|
||||
compare(common_init.maxCameraYRotation, 0.0, "maxCameraYRotation")
|
||||
|
||||
common_init.destroy()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1537,6 +1537,18 @@ void GraphModifier::setFloorLevel(int value)
|
|||
{
|
||||
m_graph->setFloorLevel(float(value));
|
||||
qDebug() << "Floor level:" << value;
|
||||
|
||||
//adjust camera min max
|
||||
if (value == 0) {
|
||||
m_graph->setMinCameraYRotation(-90);
|
||||
m_graph->setMaxCameraYRotation(90);
|
||||
} else if (value > 0) {
|
||||
m_graph->setMinCameraYRotation(-90);
|
||||
m_graph->setMaxCameraYRotation(0);
|
||||
} else {
|
||||
m_graph->setMinCameraYRotation(0);
|
||||
m_graph->setMaxCameraYRotation(90);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphModifier::setGraphMargin(int value)
|
||||
|
|
|
|||
Loading…
Reference in New Issue