#2332 2D Intersection View: Command to create view

This commit is contained in:
Magne Sjaastad 2018-01-17 11:05:31 +01:00
parent b53603e906
commit 03de2aba5b
10 changed files with 205 additions and 0 deletions

View File

@ -123,6 +123,7 @@ list( APPEND REFERENCED_CMAKE_FILES
Commands/ExportCommands/CMakeLists_files.cmake
Commands/FlowCommands/CMakeLists_files.cmake
Commands/IntersectionBoxCommands/CMakeLists_files.cmake
Commands/IntersectionViewCommands/CMakeLists_files.cmake
Commands/OctaveScriptCommands/CMakeLists_files.cmake
Commands/OperationsUsingObjReferences/CMakeLists_files.cmake
Commands/SummaryPlotCommands/CMakeLists_files.cmake

View File

@ -0,0 +1,23 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicNewIntersectionViewFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicNewIntersectionViewFeature.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\IntersectionView" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "RicNewIntersectionViewFeature.h"
#include "Rim2dIntersectionView.h"
#include "RimCase.h"
#include "RimIntersection.h"
#include "RiuMainWindow.h"
#include "RiuSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewIntersectionViewFeature::isCommandEnabled()
{
std::vector<RimIntersection*> objects = selectedIntersections();
return !objects.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked)
{
std::vector<RimIntersection*> intersections = selectedIntersections();
Rim2dIntersectionView* objectToSelect = nullptr;
for (auto intersection : intersections)
{
if (!intersection) continue;
RimCase* rimCase = nullptr;
intersection->firstAncestorOrThisOfType(rimCase);
if (rimCase)
{
Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection);
intersectionView->loadDataAndUpdate();
rimCase->updateConnectedEditors();
objectToSelect = intersectionView;
}
}
if (objectToSelect)
{
RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("New Intersection View");
// actionToSetup->setIcon(QIcon(":/chain.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimIntersection*> RicNewIntersectionViewFeature::selectedIntersections()
{
std::vector<RimIntersection*> objects = caf::selectedObjectsByType<RimIntersection*>();
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
RiuGeneralSelectionItem* generalSelectionItem = static_cast<RiuGeneralSelectionItem*>(selItem);
if (generalSelectionItem)
{
RimIntersection* intersection = dynamic_cast<RimIntersection*>(generalSelectionItem->m_object);
if (intersection)
{
objects.push_back(intersection);
}
}
return objects;
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 <vector>
class RimIntersection;
//==================================================================================================
///
//==================================================================================================
class RicNewIntersectionViewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
private:
static std::vector<RimIntersection*> selectedIntersections();
};

View File

@ -51,6 +51,14 @@ Rim2dIntersectionView::~Rim2dIntersectionView(void)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::setIntersection(RimIntersection* intersection)
{
m_intersection = intersection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -39,6 +39,8 @@ public:
Rim2dIntersectionView(void);
virtual ~Rim2dIntersectionView(void);
void setIntersection(RimIntersection* intersection);
virtual bool isUsingFormationNames() const override;
virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override;

View File

@ -29,6 +29,7 @@
#include "cafPdmObjectFactory.h"
#include "Rim2dIntersectionView.h"
#include "RimIntersection.h"
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase");
@ -112,6 +113,22 @@ size_t RimCase::uiToNativeTimeStepIndex(size_t uiTimeStepIndex)
return uiTimeStepIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* RimCase::createAndAddIntersectionView(RimIntersection* intersection)
{
Rim2dIntersectionView* intersectionView = new Rim2dIntersectionView;
intersectionView->setIntersection(intersection);
QString name = QString("View of Intersection %1").arg(intersection->name());
intersectionView->name = name;
m_intersectionViews.push_back(intersectionView);
return intersectionView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -34,6 +34,7 @@ class Rim3dView;
class RimFormationNames;
class RimTimeStepFilter;
class Rim2dIntersectionView;
class RimIntersection;
namespace cvf {
class BoundingBox;
@ -71,6 +72,8 @@ public:
size_t uiToNativeTimeStepIndex(size_t uiTimeStepIndex);
Rim2dIntersectionView* createAndAddIntersectionView(RimIntersection* intersection);
protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual std::vector<Rim3dView*> allSpecialViews() const = 0;

View File

@ -454,6 +454,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicAppendIntersectionFeature";
menuBuilder << "RicAppendIntersectionBoxFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewIntersectionViewFeature";
}
else if (dynamic_cast<RimIntersectionBox*>(uiItem))
{

View File

@ -221,6 +221,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menuBuilder << "RicHideIntersectionFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewIntersectionViewFeature";
menuBuilder.addSeparator();
}
else if (intersectionBoxSourceInfo)
{