mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#884) Added prototype of event handler for interaction with box
This commit is contained in:
@@ -5,6 +5,9 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxEventFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.h
|
||||
@@ -12,6 +15,9 @@ ${CEE_CURRENT_LIST_DIR}RicIntersectionBoxZSliceFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxEventFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.cpp
|
||||
@@ -26,4 +32,11 @@ list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
set (QT_MOC_HEADERS
|
||||
${QT_MOC_HEADERS}
|
||||
${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEditIntersectionBoxEventFeature.h
|
||||
)
|
||||
|
||||
|
||||
source_group( "CommandFeature\\IntersectionBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class RimIntersectionBoxCollection;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
|
||||
#include "RicBoxManipulatorEventHandler.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
|
||||
#include "cvfHitItemCollection.h"
|
||||
|
||||
#include "cafViewer.h"
|
||||
#include "cafBoxManipulatorPartManager.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicBoxManipulatorEventHandler::RicBoxManipulatorEventHandler(caf::Viewer* viewer)
|
||||
: m_viewer(viewer),
|
||||
m_scaleZ(1.0),
|
||||
m_isGeometryCreated(false)
|
||||
{
|
||||
m_partManager = new caf::BoxManipulatorPartManager;
|
||||
m_model = new cvf::ModelBasicList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicBoxManipulatorEventHandler::~RicBoxManipulatorEventHandler()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::setScaleZ(double scaleZ)
|
||||
{
|
||||
m_scaleZ = scaleZ;
|
||||
|
||||
updatePartManagerCoords();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::setDisplayModelOffset(cvf::Vec3d offset)
|
||||
{
|
||||
m_displayModelOffset = offset;
|
||||
|
||||
updatePartManagerCoords();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::setOrigin(const cvf::Mat4d& origin)
|
||||
{
|
||||
m_domainCoordOrigin = origin;
|
||||
|
||||
updatePartManagerCoords();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::setSize(const cvf::Vec3d& size)
|
||||
{
|
||||
m_domainCoordSize = size;
|
||||
|
||||
updatePartManagerCoords();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Model* RicBoxManipulatorEventHandler::model()
|
||||
{
|
||||
return m_model.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicBoxManipulatorEventHandler::eventFilter(QObject *obj, QEvent* inputEvent)
|
||||
{
|
||||
if (!m_isGeometryCreated)
|
||||
{
|
||||
updateParts();
|
||||
|
||||
emit geometryUpdated();
|
||||
|
||||
inputEvent->setAccepted(true);
|
||||
|
||||
m_isGeometryCreated = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
/*
|
||||
if (inputEvent->type() == QEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(inputEvent);
|
||||
|
||||
cvf::HitItemCollection hitItems;
|
||||
if (m_viewer->rayPick(mouseEvent->x(), mouseEvent->y(), &hitItems))
|
||||
{
|
||||
// TODO: Test if the first hit item is part of the manipulator
|
||||
/ *
|
||||
if (hitItems.firstItem() && hitItems.firstItem()->part())
|
||||
{
|
||||
const cvf::Object* siConstObj = hitItems.firstItem()->part()->sourceInfo();
|
||||
cvf::Object* siObj = const_cast<cvf::Object*>(siConstObj);
|
||||
|
||||
caf::BoxManipulatorSourceInfo* sourceInfo = dynamic_cast<caf::BoxManipulatorSourceInfo*>(siObj);
|
||||
if (sourceInfo)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
* /
|
||||
|
||||
switch (inputEvent->type())
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
mouseMoveEvent(static_cast<QMouseEvent*>(inputEvent));
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
mouseReleaseEvent(static_cast<QMouseEvent*>(inputEvent));
|
||||
break;
|
||||
case QEvent::MouseMove:
|
||||
mouseMoveEvent(static_cast<QMouseEvent*>(inputEvent));
|
||||
break;
|
||||
}
|
||||
|
||||
updateParts();
|
||||
|
||||
emit geometryUpdated();
|
||||
|
||||
inputEvent->setAccepted(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::updateParts()
|
||||
{
|
||||
m_model->removeAllParts();
|
||||
|
||||
m_partManager->appendPartsToModel(m_model.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicBoxManipulatorEventHandler::updatePartManagerCoords()
|
||||
{
|
||||
cvf::Mat4d displayCoordOrigin = m_domainCoordOrigin;
|
||||
cvf::Vec3d domainCoordTrans = m_domainCoordOrigin.translation();
|
||||
displayCoordOrigin.setTranslation(displayModelCoordFromDomainCoord(domainCoordTrans));
|
||||
|
||||
m_partManager->setOrigin(displayCoordOrigin);
|
||||
|
||||
cvf::Vec3d domainCoordSize = m_domainCoordSize;
|
||||
domainCoordSize.z() *= m_scaleZ;
|
||||
m_partManager->setSize(domainCoordSize);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RicBoxManipulatorEventHandler::displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const
|
||||
{
|
||||
cvf::Vec3d coord = domainCoord - m_displayModelOffset;
|
||||
coord.z() *= m_scaleZ;
|
||||
|
||||
return coord;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
namespace cvf {
|
||||
class Model;
|
||||
class ModelBasicList;
|
||||
};
|
||||
|
||||
|
||||
namespace caf {
|
||||
class BoxManipulatorPartManager;
|
||||
class Viewer;
|
||||
};
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RicBoxManipulatorEventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RicBoxManipulatorEventHandler(caf::Viewer* viewer);
|
||||
~RicBoxManipulatorEventHandler();
|
||||
|
||||
void setScaleZ(double scaleZ);
|
||||
void setDisplayModelOffset(cvf::Vec3d offset);
|
||||
|
||||
void setOrigin(const cvf::Mat4d& origin);
|
||||
void setSize(const cvf::Vec3d& size);
|
||||
|
||||
cvf::Model* model();
|
||||
|
||||
signals:
|
||||
void geometryUpdated();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
|
||||
private:
|
||||
void updateParts();
|
||||
|
||||
void updatePartManagerCoords();
|
||||
|
||||
cvf::Vec3d displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const;
|
||||
|
||||
private:
|
||||
cvf::ref<caf::BoxManipulatorPartManager> m_partManager;
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> m_model;
|
||||
QPointer<caf::Viewer> m_viewer;
|
||||
|
||||
double m_scaleZ;
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
|
||||
cvf::Mat4d m_domainCoordOrigin;
|
||||
cvf::Vec3d m_domainCoordSize;
|
||||
|
||||
bool m_isGeometryCreated;
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicEditIntersectionBoxEventFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicBoxManipulatorEventHandler.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimView.h"
|
||||
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicEditIntersectionBoxEventFeature, "RicEditIntersectionBoxEventFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicEditIntersectionBoxEventFeature::RicEditIntersectionBoxEventFeature()
|
||||
: m_eventHandler(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxEventFeature::updateGeometry()
|
||||
{
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
activeView->viewer()->addStaticModelOnce(m_eventHandler->model());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditIntersectionBoxEventFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxEventFeature::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->removeEventFilter(m_eventHandler);
|
||||
viewer->removeStaticModel(m_eventHandler->model());
|
||||
}
|
||||
|
||||
m_eventHandler->deleteLater();
|
||||
m_eventHandler = nullptr;
|
||||
}
|
||||
else if (viewer)
|
||||
{
|
||||
RimIntersectionBox* intersectionBox = dynamic_cast<RimIntersectionBox*>(viewer->lastPickedObject());
|
||||
if (intersectionBox)
|
||||
{
|
||||
m_eventHandler = new RicBoxManipulatorEventHandler(viewer);
|
||||
|
||||
cvf::Mat4d myMat = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, 0.0);
|
||||
myMat.setTranslation(intersectionBox->boxOrigin().translation());
|
||||
m_eventHandler->setOrigin(myMat);
|
||||
|
||||
m_eventHandler->setSize(intersectionBox->boxSize());
|
||||
m_eventHandler->setScaleZ(activeView->scaleZ());
|
||||
|
||||
RimCase* rimCase = activeView->ownerCase();
|
||||
m_eventHandler->setDisplayModelOffset(rimCase->displayModelOffset());
|
||||
|
||||
viewer->installEventFilter(m_eventHandler);
|
||||
connect(m_eventHandler, SIGNAL(geometryUpdated()), this, SLOT(updateGeometry()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxEventFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/IntersectionBox16x16.png"));
|
||||
actionToSetup->setText("Edit Intersection Box (event handler)");
|
||||
actionToSetup->setCheckable(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditIntersectionBoxEventFeature::isCommandChecked()
|
||||
{
|
||||
return m_eventHandler != NULL;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
|
||||
class RicBoxManipulatorEventHandler;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEditIntersectionBoxEventFeature : public caf::CmdFeature
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicEditIntersectionBoxEventFeature();
|
||||
|
||||
public slots:
|
||||
void updateGeometry();
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimCase.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafBoxManipulatorGeometryGenerator.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfTransform.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicEditIntersectionBoxFeature, "RicEditIntersectionBoxFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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_model.notNull())
|
||||
{
|
||||
if (viewer) viewer->removeStaticModel(m_model.p());
|
||||
m_model = nullptr;
|
||||
}
|
||||
else if (viewer)
|
||||
{
|
||||
RimIntersectionBox* intersectionBox = dynamic_cast<RimIntersectionBox*>(viewer->lastPickedObject());
|
||||
if (intersectionBox)
|
||||
{
|
||||
caf::BoxManipulatorGeometryGenerator boxGen;
|
||||
|
||||
// TODO: boxGen operates in display coordinates, conversion is missing
|
||||
boxGen.setOrigin(intersectionBox->boxOrigin());
|
||||
boxGen.setSize(intersectionBox->boxSize());
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geoMesh = boxGen.createBoundingBoxMeshDrawable();
|
||||
if (geoMesh.notNull())
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Cross Section mesh");
|
||||
part->setDrawable(geoMesh.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
// part->setEnableMask(meshFaultBit);
|
||||
// part->setPriority(priMesh);
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);
|
||||
eff = CrossSectionEffGen.generateCachedEffect();
|
||||
part->setEffect(eff.p());
|
||||
|
||||
m_model = new cvf::ModelBasicList;
|
||||
m_model->addPart(part.p());
|
||||
viewer->addStaticModelOnce(m_model.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditIntersectionBoxFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/IntersectionBox16x16.png"));
|
||||
actionToSetup->setText("Edit Intersection Box");
|
||||
actionToSetup->setCheckable(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditIntersectionBoxFeature::isCommandChecked()
|
||||
{
|
||||
return m_model.notNull();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafCmdExecuteCommand.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
|
||||
namespace caf {
|
||||
class BoxManipulatorGeometryGenerator;
|
||||
};
|
||||
|
||||
namespace cvf {
|
||||
class ModelBasicList;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEditIntersectionBoxFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
virtual bool isCommandChecked() override;
|
||||
|
||||
private:
|
||||
// cvf::ref<caf::BoxManipulatorGeometryGenerator> m_boxManipulatorGeometryGenerator;
|
||||
cvf::ref<cvf::ModelBasicList> m_model;
|
||||
};
|
||||
|
||||
@@ -40,3 +40,11 @@ const std::vector<size_t>& RivIntersectionBoxSourceInfo::triangleToCellIndex() c
|
||||
return m_intersectionBoxGeometryGenerator->triangleToCellIndex();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimIntersectionBox* RivIntersectionBoxSourceInfo::intersectionBox() const
|
||||
{
|
||||
return m_intersectionBoxGeometryGenerator->intersectionBox();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
|
||||
const RimIntersectionBox* intersectionBox() const;
|
||||
|
||||
private:
|
||||
cvf::cref<RivIntersectionBoxGeometryGenerator> m_intersectionBoxGeometryGenerator;
|
||||
};
|
||||
|
||||
@@ -699,6 +699,16 @@ cvf::Vec3d RiuViewer::lastPickPositionInDomainCoords() const
|
||||
return m_viewerCommands->lastPickPositionInDomainCoords();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RiuViewer::lastPickedObject() const
|
||||
{
|
||||
CVF_ASSERT(m_viewerCommands);
|
||||
|
||||
return m_viewerCommands->currentPickedObject();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
void setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel);
|
||||
|
||||
cvf::Vec3d lastPickPositionInDomainCoords() const;
|
||||
caf::PdmObject* lastPickedObject() const;
|
||||
|
||||
public slots:
|
||||
virtual void slotSetCurrentFrame(int frameIndex);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
#include "RimViewController.h"
|
||||
@@ -133,6 +134,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
{
|
||||
m_currentGridIdx = cvf::UNDEFINED_SIZE_T;
|
||||
m_currentCellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
m_currentPickedObject = nullptr;
|
||||
|
||||
int winPosX = event->x();
|
||||
int winPosY = event->y();
|
||||
@@ -195,7 +197,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
{
|
||||
findCellAndGridIndex(crossSectionSourceInfo, firstPartTriangleIndex, &m_currentCellIndex, &m_currentGridIdx);
|
||||
m_currentFaceIndex = cvf::StructGridInterface::NO_FACE;
|
||||
m_currentCrossSection = const_cast<RimIntersection*>(crossSectionSourceInfo->crossSection());
|
||||
m_currentPickedObject = const_cast<RimIntersection*>(crossSectionSourceInfo->crossSection());
|
||||
|
||||
menu.addAction(QString("Hide intersection"), this, SLOT(slotHideIntersection()));
|
||||
}
|
||||
@@ -203,6 +205,16 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
{
|
||||
findCellAndGridIndex(intersectionBoxSourceInfo, firstPartTriangleIndex, &m_currentCellIndex, &m_currentGridIdx);
|
||||
m_currentFaceIndex = cvf::StructGridInterface::NO_FACE;
|
||||
|
||||
m_currentPickedObject = const_cast<RimIntersectionBox*>(intersectionBoxSourceInfo->intersectionBox());
|
||||
menu.addAction(caf::CmdFeatureManager::instance()->action("RicEditIntersectionBoxFeature"));
|
||||
menu.addAction(caf::CmdFeatureManager::instance()->action("RicEditIntersectionBoxEventFeature"));
|
||||
menu.addSeparator();
|
||||
|
||||
QStringList commandIdList;
|
||||
commandIdList << "RicEditIntersectionBoxFeature";
|
||||
commandIdList << "RicEditIntersectionBoxEventFeature";
|
||||
caf::CmdFeatureManager::instance()->refreshCheckedState(commandIdList);
|
||||
}
|
||||
|
||||
// IJK -slice commands
|
||||
@@ -442,10 +454,11 @@ void RiuViewerCommands::slotAddGeoMechPropertyFilter()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::slotHideIntersection()
|
||||
{
|
||||
if (m_currentCrossSection)
|
||||
RimIntersection* rimIntersection = dynamic_cast<RimIntersection*>(currentPickedObject());
|
||||
if (rimIntersection)
|
||||
{
|
||||
m_currentCrossSection->isActive = false;
|
||||
m_currentCrossSection->updateConnectedEditors();
|
||||
rimIntersection->isActive = false;
|
||||
rimIntersection->updateConnectedEditors();
|
||||
|
||||
if (m_reservoirView)
|
||||
{
|
||||
@@ -591,6 +604,14 @@ cvf::Vec3d RiuViewerCommands::lastPickPositionInDomainCoords() const
|
||||
return m_currentPickPositionInDomainCoords;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RiuViewerCommands::currentPickedObject() const
|
||||
{
|
||||
return m_currentPickedObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -36,6 +36,10 @@ class RivIntersectionSourceInfo;
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
namespace caf {
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
namespace cvf {
|
||||
class HitItemCollection;
|
||||
class Part;
|
||||
@@ -55,6 +59,8 @@ public:
|
||||
void handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers);
|
||||
cvf::Vec3d lastPickPositionInDomainCoords() const;
|
||||
|
||||
caf::PdmObject* currentPickedObject() const;
|
||||
|
||||
private slots:
|
||||
void slotRangeFilterI();
|
||||
void slotRangeFilterJ();
|
||||
@@ -80,7 +86,7 @@ private:
|
||||
cvf::Vec3d m_currentPickPositionInDomainCoords;
|
||||
|
||||
caf::PdmPointer<RimView> m_reservoirView;
|
||||
caf::PdmPointer<RimIntersection> m_currentCrossSection;
|
||||
caf::PdmPointer<caf::PdmObject> m_currentPickedObject;
|
||||
|
||||
QPointer<RiuViewer> m_viewer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user