summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-10-02 10:28:42 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2014-10-02 10:30:54 +0300
commitd5535488b30e4c8f1d826fa4bb1442eb9fa908b9 (patch)
tree49c40e4c7cc32d2f5dcc177f95ead1c95bb2a4de /src
parent7d79c15989cf75da3d3d3591d6b139b91b3e0d43 (diff)
Fixed ordering of subviews
Task-number: QTRD-2790 Change-Id: I8ac6ce89920a9c988c7a059e1b02c980a0264200 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/engine/q3dscene.cpp40
-rw-r--r--src/datavisualization/engine/q3dscene_p.h2
2 files changed, 29 insertions, 13 deletions
diff --git a/src/datavisualization/engine/q3dscene.cpp b/src/datavisualization/engine/q3dscene.cpp
index 87826a8b..6ea41d6a 100644
--- a/src/datavisualization/engine/q3dscene.cpp
+++ b/src/datavisualization/engine/q3dscene.cpp
@@ -159,7 +159,6 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* A constant property providing an invalid point for selection.
*/
-
/*!
* Constructs a basic scene with one light and one camera in it. An
* optional \a parent parameter can be given and is then passed to QObject constructor.
@@ -219,33 +218,35 @@ void Q3DScene::setPrimarySubViewport(const QRect &primarySubViewport)
/*!
* Returns whether the given \a point resides inside the primary subview or not.
* \return \c true if the point is inside the primary subview.
+ * \note If subviews are superimposed, and the given \a point resides inside both, result is
+ * \c true only when the primary subview is on top.
*/
bool Q3DScene::isPointInPrimarySubView(const QPoint &point)
{
int x = point.x();
int y = point.y();
- int areaMinX = d_ptr->m_primarySubViewport.x();
- int areaMaxX = d_ptr->m_primarySubViewport.x() + d_ptr->m_primarySubViewport.width();
- int areaMinY = d_ptr->m_primarySubViewport.y();
- int areaMaxY = d_ptr->m_primarySubViewport.y() + d_ptr->m_primarySubViewport.height();
-
- return ( x > areaMinX && x < areaMaxX && y > areaMinY && y < areaMaxY );
+ bool isInSecondary = d_ptr->isInArea(d_ptr->m_secondarySubViewport, x, y);
+ if (!isInSecondary || (isInSecondary && !d_ptr->m_isSecondarySubviewOnTop))
+ return d_ptr->isInArea(d_ptr->m_primarySubViewport, x, y);
+ else
+ return false;
}
/*!
* Returns whether the given \a point resides inside the secondary subview or not.
* \return \c true if the point is inside the secondary subview.
+ * \note If subviews are superimposed, and the given \a point resides inside both, result is
+ * \c true only when the secondary subview is on top.
*/
bool Q3DScene::isPointInSecondarySubView(const QPoint &point)
{
int x = point.x();
int y = point.y();
- int areaMinX = d_ptr->m_secondarySubViewport.x();
- int areaMaxX = d_ptr->m_secondarySubViewport.x() + d_ptr->m_secondarySubViewport.width();
- int areaMinY = d_ptr->m_secondarySubViewport.y();
- int areaMaxY = d_ptr->m_secondarySubViewport.y() + d_ptr->m_secondarySubViewport.height();
-
- return ( x > areaMinX && x < areaMaxX && y > areaMinY && y < areaMaxY );
+ bool isInPrimary = d_ptr->isInArea(d_ptr->m_primarySubViewport, x, y);
+ if (!isInPrimary || (isInPrimary && d_ptr->m_isSecondarySubviewOnTop))
+ return d_ptr->isInArea(d_ptr->m_secondarySubViewport, x, y);
+ else
+ return false;
}
/*!
@@ -368,6 +369,10 @@ void Q3DScene::setSlicingActive(bool isSlicing)
d_ptr->m_changeTracker.slicingActivatedChanged = true;
d_ptr->m_sceneDirty = true;
+ // Set secondary subview behind primary to achieve default functionality (= clicking on
+ // primary disables slice)
+ setSecondarySubviewOnTop(!isSlicing);
+
d_ptr->calculateSubViewports();
emit slicingActiveChanged(isSlicing);
emit d_ptr->needRender();
@@ -719,4 +724,13 @@ void Q3DScenePrivate::markDirty()
emit needRender();
}
+bool Q3DScenePrivate::isInArea(const QRect &area, int x, int y) const
+{
+ int areaMinX = area.x();
+ int areaMaxX = area.x() + area.width();
+ int areaMinY = area.y();
+ int areaMaxY = area.y() + area.height();
+ return ( x >= areaMinX && x <= areaMaxX && y >= areaMinY && y <= areaMaxY );
+}
+
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/engine/q3dscene_p.h b/src/datavisualization/engine/q3dscene_p.h
index b7321c25..d0f6e735 100644
--- a/src/datavisualization/engine/q3dscene_p.h
+++ b/src/datavisualization/engine/q3dscene_p.h
@@ -93,6 +93,8 @@ public:
void markDirty();
+ bool isInArea(const QRect &area, int x, int y) const;
+
signals:
void needRender();