mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
#884 Intersection collection is responsible for adding box manipulator geometry to model used in 3D viewer
This commit is contained in:
parent
1f1fd72f02
commit
7659f58fd6
@ -6,7 +6,6 @@ endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.h
|
||||
@ -16,7 +15,6 @@ ${CEE_CURRENT_LIST_DIR}RicIntersectionBoxAtPosFeature.h
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.cpp
|
||||
@ -35,7 +33,6 @@ ${SOURCE_GROUP_SOURCE_FILES}
|
||||
set (QT_MOC_HEADERS
|
||||
${QT_MOC_HEADERS}
|
||||
${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxFeature.h
|
||||
)
|
||||
|
||||
|
||||
|
@ -22,7 +22,6 @@ RicBoxManipulatorEventHandler::RicBoxManipulatorEventHandler(caf::Viewer* viewer
|
||||
: m_viewer(viewer)
|
||||
{
|
||||
m_partManager = new caf::BoxManipulatorPartManager;
|
||||
m_model = new cvf::ModelBasicList;
|
||||
|
||||
m_viewer->installEventFilter(this);
|
||||
}
|
||||
@ -32,10 +31,7 @@ RicBoxManipulatorEventHandler::RicBoxManipulatorEventHandler(caf::Viewer* viewer
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicBoxManipulatorEventHandler::~RicBoxManipulatorEventHandler()
|
||||
{
|
||||
m_viewer->removeEventFilter(this);
|
||||
|
||||
// Make sure the model owned by this manipulator is not used anywhere else
|
||||
CVF_ASSERT(m_model->refCount() == 1);
|
||||
if (m_viewer) m_viewer->removeEventFilter(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -45,7 +41,6 @@ void RicBoxManipulatorEventHandler::setOrigin(const cvf::Vec3d& origin)
|
||||
{
|
||||
m_partManager->setOrigin(origin);
|
||||
|
||||
updateParts();
|
||||
emit notifyRedraw();
|
||||
}
|
||||
|
||||
@ -56,16 +51,15 @@ void RicBoxManipulatorEventHandler::setSize(const cvf::Vec3d& size)
|
||||
{
|
||||
m_partManager->setSize(size);
|
||||
|
||||
updateParts();
|
||||
emit notifyRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Model* RicBoxManipulatorEventHandler::model()
|
||||
void RicBoxManipulatorEventHandler::appendPartsToModel(cvf::ModelBasicList* model)
|
||||
{
|
||||
return m_model.p();
|
||||
m_partManager->appendPartsToModel(model);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -86,7 +80,6 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
|
||||
|
||||
if(m_partManager->isManipulatorActive())
|
||||
{
|
||||
updateParts();
|
||||
emit notifyRedraw();
|
||||
|
||||
return true;
|
||||
@ -110,8 +103,6 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
|
||||
{
|
||||
m_partManager->updateManipulatorFromRay(ray.p());
|
||||
|
||||
updateParts();
|
||||
|
||||
cvf::Vec3d origin;
|
||||
cvf::Vec3d size;
|
||||
m_partManager->originAndSize(&origin, &size);
|
||||
@ -143,14 +134,3 @@ bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::updateParts()
|
||||
{
|
||||
m_model->removeAllParts();
|
||||
|
||||
m_partManager->appendPartsToModel(m_model.p());
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
void setOrigin(const cvf::Vec3d& origin);
|
||||
void setSize(const cvf::Vec3d& size);
|
||||
|
||||
cvf::Model* model();
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
|
||||
signals:
|
||||
void notifyRedraw();
|
||||
@ -49,10 +49,6 @@ protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
private:
|
||||
void updateParts();
|
||||
|
||||
private:
|
||||
cvf::ref<cvf::ModelBasicList> m_model;
|
||||
QPointer<caf::Viewer> m_viewer;
|
||||
|
||||
cvf::ref<caf::BoxManipulatorPartManager> m_partManager;
|
||||
|
@ -1,146 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicEditIntersectionBoxFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicBoxManipulatorEventHandler.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicEditIntersectionBoxFeature, "RicEditIntersectionBoxFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicEditIntersectionBoxFeature::RicEditIntersectionBoxFeature()
|
||||
: m_eventHandler(nullptr),
|
||||
m_intersectionBox(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxFeature::slotScheduleRedraw()
|
||||
{
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
activeView->viewer()->addStaticModelOnce(m_eventHandler->model());
|
||||
|
||||
activeView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxFeature::slotUpdateGeometry(const cvf::Vec3d& origin, const cvf::Vec3d& size)
|
||||
{
|
||||
if (m_intersectionBox)
|
||||
{
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (activeView)
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = activeView->displayCoordTransform();
|
||||
|
||||
cvf::Vec3d domainOrigin = transForm->transformToDomainCoord(origin);
|
||||
cvf::Vec3d domainSize = transForm->scaleToDomainSize(size);
|
||||
|
||||
m_intersectionBox->setFromOriginAndSize(domainOrigin, domainSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditIntersectionBoxFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiuViewer* viewer = nullptr;
|
||||
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
viewer = activeView->viewer();
|
||||
}
|
||||
|
||||
if (isCommandChecked() && m_eventHandler)
|
||||
{
|
||||
if (viewer)
|
||||
{
|
||||
viewer->removeStaticModel(m_eventHandler->model());
|
||||
}
|
||||
|
||||
m_eventHandler->deleteLater();
|
||||
m_eventHandler = nullptr;
|
||||
|
||||
m_intersectionBox = nullptr;
|
||||
}
|
||||
else if (viewer)
|
||||
{
|
||||
m_intersectionBox = dynamic_cast<RimIntersectionBox*>(viewer->lastPickedObject());
|
||||
if (m_intersectionBox)
|
||||
{
|
||||
m_eventHandler = new RicBoxManipulatorEventHandler(viewer);
|
||||
connect(m_eventHandler, SIGNAL(notifyRedraw()), this, SLOT(slotScheduleRedraw()));
|
||||
connect(m_eventHandler, SIGNAL(notifyUpdate(const cvf::Vec3d&, const cvf::Vec3d&)), this, SLOT(slotUpdateGeometry(const cvf::Vec3d&, const cvf::Vec3d&)));
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = activeView->displayCoordTransform();
|
||||
|
||||
m_eventHandler->setOrigin(transForm->transformToDisplayCoord(m_intersectionBox->boxOrigin().translation()));
|
||||
m_eventHandler->setSize(transForm->scaleToDisplaySize(m_intersectionBox->boxSize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/IntersectionBox16x16.png"));
|
||||
actionToSetup->setText("Edit Intersection Box");
|
||||
actionToSetup->setCheckable(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditIntersectionBoxFeature::isCommandChecked()
|
||||
{
|
||||
return m_eventHandler != NULL;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
class RicBoxManipulatorEventHandler;
|
||||
class RimIntersectionBox;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEditIntersectionBoxFeature : public caf::CmdFeature
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicEditIntersectionBoxFeature();
|
||||
|
||||
public slots:
|
||||
void slotScheduleRedraw();
|
||||
void slotUpdateGeometry(const cvf::Vec3d& origin, const cvf::Vec3d& size);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
virtual bool isCommandChecked() override;
|
||||
|
||||
private:
|
||||
RicBoxManipulatorEventHandler* m_eventHandler;
|
||||
RimIntersectionBox* m_intersectionBox;
|
||||
};
|
||||
|
@ -50,7 +50,6 @@ public:
|
||||
void applySingleColorEffect();
|
||||
void updateCellResultColor(size_t timeStepIndex);
|
||||
|
||||
|
||||
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
|
||||
@ -71,6 +70,7 @@ private:
|
||||
const cvf::ScalarMapper* mapper);
|
||||
|
||||
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
|
||||
|
||||
private:
|
||||
const RimIntersectionBox* m_rimIntersectionBox;
|
||||
|
||||
|
@ -96,10 +96,8 @@ RimIntersectionBox::RimIntersectionBox()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersectionBox::~RimIntersectionBox()
|
||||
{
|
||||
if (m_boxManipulator && viewer())
|
||||
if (m_boxManipulator)
|
||||
{
|
||||
viewer()->removeStaticModel(m_boxManipulator->model());
|
||||
|
||||
m_boxManipulator->deleteLater();
|
||||
}
|
||||
}
|
||||
@ -144,6 +142,14 @@ void RimIntersectionBox::setFromOriginAndSize(const cvf::Vec3d& origin, const cv
|
||||
rebuildGeometryAndScheduleCreateDisplayModel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimIntersectionBox::show3dManipulator() const
|
||||
{
|
||||
return m_show3DManipulator;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -213,6 +219,17 @@ RivIntersectionBoxPartMgr* RimIntersectionBox::intersectionBoxPartMgr()
|
||||
return m_intersectionBoxPartMgr.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionBox::appendManipulatorPartsToModel(cvf::ModelBasicList* model)
|
||||
{
|
||||
if (show3dManipulator() && m_boxManipulator)
|
||||
{
|
||||
m_boxManipulator->appendPartsToModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -269,11 +286,6 @@ void RimIntersectionBox::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel
|
||||
{
|
||||
if (m_boxManipulator)
|
||||
{
|
||||
if (viewer())
|
||||
{
|
||||
viewer()->removeStaticModel(m_boxManipulator->model());
|
||||
}
|
||||
|
||||
m_boxManipulator->deleteLater();
|
||||
m_boxManipulator = nullptr;
|
||||
}
|
||||
@ -410,15 +422,10 @@ void RimIntersectionBox::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionBox::slotScheduleRedraw()
|
||||
{
|
||||
if (viewer())
|
||||
{
|
||||
viewer()->addStaticModelOnce(m_boxManipulator->model());
|
||||
|
||||
RimView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfType(rimView);
|
||||
RimView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfType(rimView);
|
||||
|
||||
rimView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
rimView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -32,6 +32,10 @@ class RicBoxManipulatorEventHandler;
|
||||
class RiuViewer;
|
||||
class RivIntersectionBoxPartMgr;
|
||||
|
||||
namespace cvf {
|
||||
class ModelBasicList;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
@ -66,7 +70,9 @@ public:
|
||||
SinglePlaneState singlePlaneState() const;
|
||||
void setFromOriginAndSize(const cvf::Vec3d& origin, const cvf::Vec3d& size);
|
||||
|
||||
bool show3dManipulator() const;
|
||||
RivIntersectionBoxPartMgr* intersectionBoxPartMgr();
|
||||
void appendManipulatorPartsToModel(cvf::ModelBasicList* model);
|
||||
|
||||
void setToDefaultSizeBox();
|
||||
void setToDefaultSizeSlice(SinglePlaneState plane, const cvf::Vec3d& position);
|
||||
|
@ -147,6 +147,11 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c
|
||||
{
|
||||
cs->intersectionBoxPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
|
||||
cs->intersectionBoxPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
|
||||
|
||||
if (cs->show3dManipulator())
|
||||
{
|
||||
cs->appendManipulatorPartsToModel(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user