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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user