From 4253c32dac1d2fd700ddb6e0db0089e48b30d6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 18 Oct 2019 10:17:50 +0200 Subject: [PATCH] #4857 RicIntersectionBox[XYZ]SliceFeature --- .../CMakeLists_files.cmake | 2 + .../RicIntersectionBoxXSliceFeature.cpp | 53 +++++++++-------- .../RicIntersectionBoxYSliceFeature.cpp | 56 ++++++++++-------- .../RicIntersectionBoxZSliceFeature.cpp | 56 ++++++++++-------- .../RicIntersectionFeatureImpl.cpp | 59 +++++++++++++++++++ .../RicIntersectionFeatureImpl.h | 26 ++++++++ 6 files changed, 174 insertions(+), 78 deletions(-) create mode 100644 ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.cpp create mode 100644 ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.h diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake index d6a827a118..8ecd003d12 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake @@ -1,5 +1,6 @@ set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionFeatureImpl.h ${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.h ${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.h @@ -9,6 +10,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxAtPosFeature.h ) set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionFeatureImpl.cpp ${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.cpp diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp index c51d96d512..0d08852e8e 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp @@ -18,6 +18,8 @@ #include "RicIntersectionBoxXSliceFeature.h" +#include "RicIntersectionFeatureImpl.h" + #include "RiaApplication.h" #include "RimCase.h" @@ -51,33 +53,32 @@ bool RicIntersectionBoxXSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxXSliceFeature::onActionTriggered( bool isChecked ) { - RimGridView* activeView = RiaApplication::instance()->activeGridView(); - if ( activeView ) - { - RimIntersectionCollection* coll = activeView->crossSectionCollection(); - CVF_ASSERT( coll ); + RicIntersectionFeatureImpl::createIntersectionBoxSlize("X-slice (Intersection box)", RimIntersectionBox::PLANE_STATE_X); - RimIntersectionBox* intersectionBox = new RimIntersectionBox(); - intersectionBox->name = QString( "X-slice (Intersection box)" ); - - coll->appendIntersectionBoxAndUpdate( intersectionBox ); - - cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); - intersectionBox->setToDefaultSizeSlice( RimIntersectionBox::PLANE_STATE_X, domainCoord ); - - coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox ); - - RimGridView* rimView = nullptr; - coll->firstAncestorOrThisOfType( rimView ); - if ( rimView ) - { - rimView->showGridCells( false ); - RiuMainWindow::instance()->refreshDrawStyleActions(); - - rimView->scheduleCreateDisplayModelAndRedraw(); - } - } + // RimGridView* activeView = RiaApplication::instance()->activeGridView(); + // RimGridView* activeMainOrComparisonView = RiaApplication::instance()->activeMainOrComparisonGridView(); + // + // if ( activeMainOrComparisonView ) + // { + // RimIntersectionCollection* coll = activeMainOrComparisonView->crossSectionCollection(); + // CVF_ASSERT( coll ); + // + // RimIntersectionBox* intersectionBox = new RimIntersectionBox(); + // intersectionBox->name = QString( "X-slice (Intersection box)" ); + // + // coll->appendIntersectionBoxAndUpdate( intersectionBox ); + // + // cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); + // intersectionBox->setToDefaultSizeSlice( RimIntersectionBox::PLANE_STATE_X, domainCoord ); + // + // coll->updateConnectedEditors(); + // RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox, false ); + // + // activeMainOrComparisonView->showGridCells(false); + // RiuMainWindow::instance()->refreshDrawStyleActions(); + // + // activeView->scheduleCreateDisplayModelAndRedraw(); + // } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp index c8a259862d..03b1f8af3f 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp @@ -18,6 +18,8 @@ #include "RicIntersectionBoxYSliceFeature.h" +#include "RicIntersectionFeatureImpl.h" + #include "RiaApplication.h" #include "RimCase.h" @@ -51,33 +53,35 @@ bool RicIntersectionBoxYSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxYSliceFeature::onActionTriggered( bool isChecked ) { - RimGridView* activeView = RiaApplication::instance()->activeGridView(); - if ( activeView ) - { - RimIntersectionCollection* coll = activeView->crossSectionCollection(); - CVF_ASSERT( coll ); + RicIntersectionFeatureImpl::createIntersectionBoxSlize("Y-slice (Intersection box)", RimIntersectionBox::PLANE_STATE_Y); - RimIntersectionBox* intersectionBox = new RimIntersectionBox(); - intersectionBox->name = QString( "Y-slice (Intersection box)" ); - - coll->appendIntersectionBoxAndUpdate( intersectionBox ); - - cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); - intersectionBox->setToDefaultSizeSlice( RimIntersectionBox::PLANE_STATE_Y, domainCoord ); - - coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox ); - - RimGridView* rimView = nullptr; - coll->firstAncestorOrThisOfType( rimView ); - if ( rimView ) - { - rimView->showGridCells( false ); - RiuMainWindow::instance()->refreshDrawStyleActions(); - - rimView->scheduleCreateDisplayModelAndRedraw(); - } - } + //RimGridView* activeView = RiaApplication::instance()->activeGridView(); + //if ( activeView ) + //{ + // RimIntersectionCollection* coll = activeView->crossSectionCollection(); + // CVF_ASSERT( coll ); + // + // RimIntersectionBox* intersectionBox = new RimIntersectionBox(); + // intersectionBox->name = QString( "Y-slice (Intersection box)" ); + // + // coll->appendIntersectionBoxAndUpdate( intersectionBox ); + // + // cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); + // intersectionBox->setToDefaultSizeSlice( RimIntersectionBox::PLANE_STATE_Y, domainCoord ); + // + // coll->updateConnectedEditors(); + // RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox ); + // + // RimGridView* rimView = nullptr; + // coll->firstAncestorOrThisOfType( rimView ); + // if ( rimView ) + // { + // rimView->showGridCells( false ); + // RiuMainWindow::instance()->refreshDrawStyleActions(); + // + // rimView->scheduleCreateDisplayModelAndRedraw(); + // } + //} } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp index 6240ad7140..fd8fa59fa3 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp @@ -18,6 +18,8 @@ #include "RicIntersectionBoxZSliceFeature.h" +#include "RicIntersectionFeatureImpl.h" + #include "RiaApplication.h" #include "RimCase.h" @@ -51,33 +53,35 @@ bool RicIntersectionBoxZSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxZSliceFeature::onActionTriggered( bool isChecked ) { - RimGridView* activeView = RiaApplication::instance()->activeGridView(); - if ( activeView ) - { - RimIntersectionCollection* coll = activeView->crossSectionCollection(); - CVF_ASSERT( coll ); + RicIntersectionFeatureImpl::createIntersectionBoxSlize("Z-slice (Intersection box)", RimIntersectionBox::PLANE_STATE_Z); - RimIntersectionBox* intersectionBox = new RimIntersectionBox(); - intersectionBox->name = QString( "Z-slice (Intersection box)" ); - - coll->appendIntersectionBoxAndUpdate( intersectionBox ); - cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); - - intersectionBox->setToDefaultSizeSlice( RimIntersectionBox::PLANE_STATE_Z, domainCoord ); - - coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox ); - - RimGridView* rimView = nullptr; - coll->firstAncestorOrThisOfType( rimView ); - if ( rimView ) - { - rimView->showGridCells( false ); - RiuMainWindow::instance()->refreshDrawStyleActions(); - - rimView->scheduleCreateDisplayModelAndRedraw(); - } - } + // RimGridView* activeView = RiaApplication::instance()->activeGridView(); + // if ( activeView ) + // { + // RimIntersectionCollection* coll = activeView->crossSectionCollection(); + // CVF_ASSERT( coll ); + // + // RimIntersectionBox* intersectionBox = new RimIntersectionBox(); + // intersectionBox->name = QString( "Z-slice (Intersection box)" ); + // + // coll->appendIntersectionBoxAndUpdate( intersectionBox ); + // cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); + // + // intersectionBox->setToDefaultSizeSlice( RimIntersectionBox::PLANE_STATE_Z, domainCoord ); + // + // coll->updateConnectedEditors(); + // RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox ); + // + // RimGridView* rimView = nullptr; + // coll->firstAncestorOrThisOfType( rimView ); + // if ( rimView ) + // { + // rimView->showGridCells( false ); + // RiuMainWindow::instance()->refreshDrawStyleActions(); + // + // rimView->scheduleCreateDisplayModelAndRedraw(); + // } + // } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.cpp new file mode 100644 index 0000000000..334607d957 --- /dev/null +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RicIntersectionFeatureImpl.h" + +#include "RiaApplication.h" + +#include "RimGridView.h" +#include "RimIntersectionBox.h" +#include "RimIntersectionCollection.h" + +#include "RiuMainWindow.h" +#include "RiuViewer.h" +#include "RiuViewerCommands.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicIntersectionFeatureImpl::createIntersectionBoxSlize(const QString& name, RimIntersectionBox::SinglePlaneState plane) +{ + RimGridView* activeView = RiaApplication::instance()->activeGridView(); + RimGridView* activeMainOrComparisonView = RiaApplication::instance()->activeMainOrComparisonGridView(); + + if ( activeMainOrComparisonView ) + { + RimIntersectionCollection* coll = activeMainOrComparisonView->crossSectionCollection(); + CVF_ASSERT( coll ); + + cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords(); + + RimIntersectionBox* intersectionBox = new RimIntersectionBox(); + intersectionBox->name = name; + + coll->appendIntersectionBoxNoUpdate( intersectionBox ); + intersectionBox->setToDefaultSizeSlice( plane, domainCoord ); + coll->updateConnectedEditors(); + + activeMainOrComparisonView->showGridCells(false); + activeMainOrComparisonView->scheduleCreateDisplayModelAndRedraw(); + activeView->scheduleCreateDisplayModelAndRedraw(); + + RiuMainWindow::instance()->selectAsCurrentItem( intersectionBox, false ); + RiuMainWindow::instance()->refreshDrawStyleActions(); + } +} diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.h b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.h new file mode 100644 index 0000000000..20e198a92a --- /dev/null +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionFeatureImpl.h @@ -0,0 +1,26 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimIntersectionBox.h" + +class QString; + +class RicIntersectionFeatureImpl +{ +public : + static void createIntersectionBoxSlize(const QString& name, RimIntersectionBox::SinglePlaneState plane ); +};