mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2332 2D Intersection View: Command to create view
This commit is contained in:
@@ -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 )
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
};
|
||||
Reference in New Issue
Block a user