#884 Improved interface to BoxManipulatorPartManager

This commit is contained in:
Magne Sjaastad
2016-09-30 15:10:39 +02:00
parent caf6a5dcf2
commit 58acd22afa
4 changed files with 48 additions and 29 deletions

View File

@@ -19,8 +19,7 @@
///
//--------------------------------------------------------------------------------------------------
RicBoxManipulatorEventHandler::RicBoxManipulatorEventHandler(caf::Viewer* viewer)
: m_viewer(viewer),
m_currentPartIndex(cvf::UNDEFINED_SIZE_T)
: m_viewer(viewer)
{
m_partManager = new caf::BoxManipulatorPartManager;
m_model = new cvf::ModelBasicList;
@@ -85,9 +84,9 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
{
if (hitItems.firstItem() && hitItems.firstItem()->part())
{
m_currentPartIndex = m_partManager->partIndexFromSourceInfo(hitItems.firstItem()->part(), hitItems.firstItem()->intersectionPoint());
m_partManager->activateManipulator(hitItems.firstItem()->part(), hitItems.firstItem()->intersectionPoint());
if (m_currentPartIndex != cvf::UNDEFINED_SIZE_T)
if (m_partManager->isManipulatorActive())
{
updateParts();
emit notifyRedraw();
@@ -100,7 +99,7 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
}
else if (inputEvent->type() == QEvent::MouseMove)
{
if (m_currentPartIndex != cvf::UNDEFINED_SIZE_T)
if (m_partManager->isManipulatorActive())
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(inputEvent);
@@ -112,7 +111,7 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
cvf::ref<cvf::Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
{
m_partManager->updateFromPartIndexAndRay(m_currentPartIndex, ray.p());
m_partManager->updateManipulatorFromRay(ray.p());
updateParts();
@@ -130,9 +129,9 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
}
else if (inputEvent->type() == QEvent::MouseButtonRelease)
{
if (m_currentPartIndex != cvf::UNDEFINED_SIZE_T)
if (m_partManager->isManipulatorActive())
{
m_currentPartIndex = cvf::UNDEFINED_SIZE_T;
m_partManager->endManipulator();
cvf::Vec3d origin;
cvf::Vec3d size;

View File

@@ -55,8 +55,6 @@ private:
cvf::ref<cvf::ModelBasicList> m_model;
QPointer<caf::Viewer> m_viewer;
size_t m_currentPartIndex;
cvf::ref<caf::BoxManipulatorPartManager> m_partManager;
};