mirror of
				https://github.com/OPM/ResInsight.git
				synced 2025-02-25 18:55:39 -06:00 
			
		
		
		
	WIP - commands for adding range filters
TODO: Implement actions when commands are triggered, and update project treeview
This commit is contained in:
		@@ -6,10 +6,16 @@ endif()
 | 
			
		||||
 | 
			
		||||
set (SOURCE_GROUP_HEADER_FILES
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNew.h
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceI.h
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.h
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
set (SOURCE_GROUP_SOURCE_FILES
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNew.cpp
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceI.cpp
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.cpp
 | 
			
		||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
list(APPEND CODE_HEADER_FILES
 | 
			
		||||
 
 | 
			
		||||
@@ -118,7 +118,7 @@ void RicRangeFilterNew::onActionTriggered(bool isChecked)
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void RicRangeFilterNew::setupActionLook(QAction* actionToSetup)
 | 
			
		||||
{
 | 
			
		||||
//    actionToSetup->setIcon(QIcon(":/Constraint16x16.png"));
 | 
			
		||||
    actionToSetup->setIcon(QIcon(":/CellFilter_Range.png"));
 | 
			
		||||
    actionToSetup->setText("New Range Filter");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,14 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (C) 2014 Ceetron Solutions AS, USFOS AS, AMOS - NTNU
 | 
			
		||||
//  Copyright (C) 2015-     Statoil ASA
 | 
			
		||||
//  Copyright (C) 2015-     Ceetron Solutions AS
 | 
			
		||||
// 
 | 
			
		||||
//  RPM is free software: you can redistribute it and/or modify
 | 
			
		||||
//  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.
 | 
			
		||||
// 
 | 
			
		||||
//  RPM is distributed in the hope that it will be useful, but WITHOUT ANY
 | 
			
		||||
//  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.
 | 
			
		||||
// 
 | 
			
		||||
@@ -16,38 +17,31 @@
 | 
			
		||||
//
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#include "EvcNewBoundaryConditionSelectedItemsFeature.h"
 | 
			
		||||
#include "RicRangeFilterNewSliceI.h"
 | 
			
		||||
 | 
			
		||||
#include "EvaApplication.h"
 | 
			
		||||
#include "RimCellRangeFilter.h"
 | 
			
		||||
#include "RimCellRangeFilterCollection.h"
 | 
			
		||||
 | 
			
		||||
#include "EvmNode.h"
 | 
			
		||||
#include "EvmProject.h"
 | 
			
		||||
 | 
			
		||||
#include "cafCmdExecCommandManager.h"
 | 
			
		||||
#include "cafCmdSelectionChangeExec.h"
 | 
			
		||||
#include "cafCmdFeatureManager.h"
 | 
			
		||||
#include "cafCmdSelectionHelper.h"
 | 
			
		||||
#include "cafSelectionManager.h"
 | 
			
		||||
 | 
			
		||||
#include "defaultfeatures/cafCmdAddItemFeature.h"
 | 
			
		||||
#include "defaultfeatures/cafCmdAddItemExec.h"
 | 
			
		||||
#include "defaultfeatures/cafCmdAddItemExecData.h"
 | 
			
		||||
 | 
			
		||||
#include <QAction>
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
CAF_CMD_SOURCE_INIT(EvcNewBoundaryConditionSelectedItemsFeature, "EvcNewBoundaryConditionSelectedItemsFeature");
 | 
			
		||||
CAF_CMD_SOURCE_INIT(RicRangeFilterNewSliceI, "RicRangeFilterNewSliceI");
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
bool EvcNewBoundaryConditionSelectedItemsFeature::isCommandEnabled()
 | 
			
		||||
bool RicRangeFilterNewSliceI::isCommandEnabled()
 | 
			
		||||
{
 | 
			
		||||
    std::vector<EvmNode*> selectedNodes;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedNodes, caf::SelectionManager::CURRENT);
 | 
			
		||||
    std::vector<RimCellRangeFilter*> selectedRangeFilter;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedRangeFilter);
 | 
			
		||||
 | 
			
		||||
    if (selectedNodes.size() > 0)
 | 
			
		||||
    std::vector<RimCellRangeFilterCollection*> selectedRangeFilterCollection;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedRangeFilterCollection);
 | 
			
		||||
 | 
			
		||||
    if (selectedRangeFilter.size() > 0 || selectedRangeFilterCollection.size() > 0)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -60,9 +54,11 @@ bool EvcNewBoundaryConditionSelectedItemsFeature::isCommandEnabled()
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void EvcNewBoundaryConditionSelectedItemsFeature::onActionTriggered(bool isChecked)
 | 
			
		||||
void RicRangeFilterNewSliceI::onActionTriggered(bool isChecked)
 | 
			
		||||
{
 | 
			
		||||
    EvmProject* proj = EvaApplication::instance()->project();
 | 
			
		||||
    // MODTODO
 | 
			
		||||
 | 
			
		||||
/*    EvmProject* proj = EvaApplication::instance()->project();
 | 
			
		||||
 | 
			
		||||
    std::vector<EvmNode*> selectedNodes;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedNodes, caf::SelectionManager::CURRENT);
 | 
			
		||||
@@ -106,13 +102,14 @@ void EvcNewBoundaryConditionSelectedItemsFeature::onActionTriggered(bool isCheck
 | 
			
		||||
 | 
			
		||||
        caf::CmdExecCommandManager::instance()->processExecuteCommandsAsMacro("New Boundary Conditions", commands);
 | 
			
		||||
    }
 | 
			
		||||
*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void EvcNewBoundaryConditionSelectedItemsFeature::setupActionLook(QAction* actionToSetup)
 | 
			
		||||
void RicRangeFilterNewSliceI::setupActionLook(QAction* actionToSetup)
 | 
			
		||||
{
 | 
			
		||||
    actionToSetup->setIcon(QIcon(":/Constraint16x16.png"));
 | 
			
		||||
    actionToSetup->setText("New I-slice range filter");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,14 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (C) 2014 Ceetron Solutions AS, USFOS AS, AMOS - NTNU
 | 
			
		||||
//  Copyright (C) 2015-     Statoil ASA
 | 
			
		||||
//  Copyright (C) 2015-     Ceetron Solutions AS
 | 
			
		||||
// 
 | 
			
		||||
//  RPM is free software: you can redistribute it and/or modify
 | 
			
		||||
//  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.
 | 
			
		||||
// 
 | 
			
		||||
//  RPM is distributed in the hope that it will be useful, but WITHOUT ANY
 | 
			
		||||
//  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.
 | 
			
		||||
// 
 | 
			
		||||
@@ -24,7 +25,7 @@
 | 
			
		||||
//==================================================================================================
 | 
			
		||||
/// 
 | 
			
		||||
//==================================================================================================
 | 
			
		||||
class EvcNewBoundaryConditionSelectedItemsFeature : public caf::CmdFeature
 | 
			
		||||
class RicRangeFilterNewSliceI : public caf::CmdFeature
 | 
			
		||||
{
 | 
			
		||||
    CAF_CMD_HEADER_INIT;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										115
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceJ.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceJ.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,115 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (C) 2015-     Statoil ASA
 | 
			
		||||
//  Copyright (C) 2015-     Ceetron Solutions AS
 | 
			
		||||
// 
 | 
			
		||||
//  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 "RicRangeFilterNewSliceJ.h"
 | 
			
		||||
 | 
			
		||||
#include "RimCellRangeFilter.h"
 | 
			
		||||
#include "RimCellRangeFilterCollection.h"
 | 
			
		||||
 | 
			
		||||
#include "cafSelectionManager.h"
 | 
			
		||||
 | 
			
		||||
#include <QAction>
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
CAF_CMD_SOURCE_INIT(RicRangeFilterNewSliceJ, "RicRangeFilterNewSliceJ");
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
bool RicRangeFilterNewSliceJ::isCommandEnabled()
 | 
			
		||||
{
 | 
			
		||||
    std::vector<RimCellRangeFilter*> selectedRangeFilter;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedRangeFilter);
 | 
			
		||||
 | 
			
		||||
    std::vector<RimCellRangeFilterCollection*> selectedRangeFilterCollection;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedRangeFilterCollection);
 | 
			
		||||
 | 
			
		||||
    if (selectedRangeFilter.size() > 0 || selectedRangeFilterCollection.size() > 0)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void RicRangeFilterNewSliceJ::onActionTriggered(bool isChecked)
 | 
			
		||||
{
 | 
			
		||||
    // MODTODO
 | 
			
		||||
 | 
			
		||||
/*    EvmProject* proj = EvaApplication::instance()->project();
 | 
			
		||||
 | 
			
		||||
    std::vector<EvmNode*> selectedNodes;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedNodes, caf::SelectionManager::CURRENT);
 | 
			
		||||
 | 
			
		||||
    caf::CmdAddItemFeature* addItemFeature = dynamic_cast<caf::CmdAddItemFeature*>(caf::CmdFeatureManager::instance()->getCommandFeature(caf::CmdAddItemFeature::idNameStatic()));
 | 
			
		||||
    assert(addItemFeature);
 | 
			
		||||
 | 
			
		||||
    if (selectedNodes.size() > 0)
 | 
			
		||||
    {
 | 
			
		||||
        caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&proj->boundaryConditions);
 | 
			
		||||
 | 
			
		||||
        std::vector<caf::CmdExecuteCommand*> commands;
 | 
			
		||||
        for (size_t i = 0; i < selectedNodes.size(); i++)
 | 
			
		||||
        {
 | 
			
		||||
            // Not allowed to add more than one BC
 | 
			
		||||
            if (proj->findBoundaryConditionForNode(selectedNodes[i]->id)) continue;
 | 
			
		||||
 | 
			
		||||
            std::vector<caf::PdmObjectHandle*> newSelection;
 | 
			
		||||
            newSelection.push_back(selectedNodes[i]);
 | 
			
		||||
            caf::CmdSelectionChangeExec* selectionChangeExec = caf::CmdSelectionHelper::createSelectionCommand(newSelection, caf::SelectionManager::CURRENT);
 | 
			
		||||
            commands.push_back(selectionChangeExec);
 | 
			
		||||
 | 
			
		||||
            int indexAfter = -1;
 | 
			
		||||
            caf::CmdAddItemExec* addItemExec = new caf::CmdAddItemExec(caf::SelectionManager::instance()->notificationCenter());
 | 
			
		||||
 | 
			
		||||
            caf::CmdAddItemExecData* data = addItemExec->commandData();
 | 
			
		||||
            data->m_rootObject = caf::PdmReferenceHelper::findRoot(&proj->nodalLoads);
 | 
			
		||||
            data->m_pathToField = caf::PdmReferenceHelper::referenceFromRootToField(data->m_rootObject, &proj->boundaryConditions);
 | 
			
		||||
            data->m_indexAfter = indexAfter;
 | 
			
		||||
 | 
			
		||||
            commands.push_back(addItemExec);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (commands.size() > 0)
 | 
			
		||||
        {
 | 
			
		||||
            // Add an empty selection when boundary conditions has been assigned
 | 
			
		||||
            std::vector<caf::PdmObjectHandle*> newSelection;
 | 
			
		||||
            caf::CmdSelectionChangeExec* selectionChangeExec = caf::CmdSelectionHelper::createSelectionCommand(newSelection, caf::SelectionManager::CURRENT);
 | 
			
		||||
            commands.push_back(selectionChangeExec);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        caf::CmdExecCommandManager::instance()->processExecuteCommandsAsMacro("New Boundary Conditions", commands);
 | 
			
		||||
    }
 | 
			
		||||
*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void RicRangeFilterNewSliceJ::setupActionLook(QAction* actionToSetup)
 | 
			
		||||
{
 | 
			
		||||
    actionToSetup->setText("New J-slice range filter");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										39
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceJ.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceJ.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (C) 2015-     Statoil ASA
 | 
			
		||||
//  Copyright (C) 2015-     Ceetron Solutions AS
 | 
			
		||||
// 
 | 
			
		||||
//  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 RicRangeFilterNewSliceJ : public caf::CmdFeature
 | 
			
		||||
{
 | 
			
		||||
    CAF_CMD_HEADER_INIT;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    // Overrides
 | 
			
		||||
    virtual bool isCommandEnabled();
 | 
			
		||||
    virtual void onActionTriggered( bool isChecked );
 | 
			
		||||
    virtual void setupActionLook( QAction* actionToSetup );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										114
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceK.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceK.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,114 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (C) 2015-     Statoil ASA
 | 
			
		||||
//  Copyright (C) 2015-     Ceetron Solutions AS
 | 
			
		||||
// 
 | 
			
		||||
//  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 "RicRangeFilterNewSliceK.h"
 | 
			
		||||
 | 
			
		||||
#include "RimCellRangeFilter.h"
 | 
			
		||||
#include "RimCellRangeFilterCollection.h"
 | 
			
		||||
 | 
			
		||||
#include "cafSelectionManager.h"
 | 
			
		||||
 | 
			
		||||
#include <QAction>
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
CAF_CMD_SOURCE_INIT(RicRangeFilterNewSliceK, "RicRangeFilterNewSliceK");
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
bool RicRangeFilterNewSliceK::isCommandEnabled()
 | 
			
		||||
{
 | 
			
		||||
    std::vector<RimCellRangeFilter*> selectedRangeFilter;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedRangeFilter);
 | 
			
		||||
 | 
			
		||||
    std::vector<RimCellRangeFilterCollection*> selectedRangeFilterCollection;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedRangeFilterCollection);
 | 
			
		||||
 | 
			
		||||
    if (selectedRangeFilter.size() > 0 || selectedRangeFilterCollection.size() > 0)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void RicRangeFilterNewSliceK::onActionTriggered(bool isChecked)
 | 
			
		||||
{
 | 
			
		||||
    // MODTODO
 | 
			
		||||
 | 
			
		||||
/*    EvmProject* proj = EvaApplication::instance()->project();
 | 
			
		||||
 | 
			
		||||
    std::vector<EvmNode*> selectedNodes;
 | 
			
		||||
    caf::SelectionManager::instance()->objectsByType(&selectedNodes, caf::SelectionManager::CURRENT);
 | 
			
		||||
 | 
			
		||||
    caf::CmdAddItemFeature* addItemFeature = dynamic_cast<caf::CmdAddItemFeature*>(caf::CmdFeatureManager::instance()->getCommandFeature(caf::CmdAddItemFeature::idNameStatic()));
 | 
			
		||||
    assert(addItemFeature);
 | 
			
		||||
 | 
			
		||||
    if (selectedNodes.size() > 0)
 | 
			
		||||
    {
 | 
			
		||||
        caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&proj->boundaryConditions);
 | 
			
		||||
 | 
			
		||||
        std::vector<caf::CmdExecuteCommand*> commands;
 | 
			
		||||
        for (size_t i = 0; i < selectedNodes.size(); i++)
 | 
			
		||||
        {
 | 
			
		||||
            // Not allowed to add more than one BC
 | 
			
		||||
            if (proj->findBoundaryConditionForNode(selectedNodes[i]->id)) continue;
 | 
			
		||||
 | 
			
		||||
            std::vector<caf::PdmObjectHandle*> newSelection;
 | 
			
		||||
            newSelection.push_back(selectedNodes[i]);
 | 
			
		||||
            caf::CmdSelectionChangeExec* selectionChangeExec = caf::CmdSelectionHelper::createSelectionCommand(newSelection, caf::SelectionManager::CURRENT);
 | 
			
		||||
            commands.push_back(selectionChangeExec);
 | 
			
		||||
 | 
			
		||||
            int indexAfter = -1;
 | 
			
		||||
            caf::CmdAddItemExec* addItemExec = new caf::CmdAddItemExec(caf::SelectionManager::instance()->notificationCenter());
 | 
			
		||||
 | 
			
		||||
            caf::CmdAddItemExecData* data = addItemExec->commandData();
 | 
			
		||||
            data->m_rootObject = caf::PdmReferenceHelper::findRoot(&proj->nodalLoads);
 | 
			
		||||
            data->m_pathToField = caf::PdmReferenceHelper::referenceFromRootToField(data->m_rootObject, &proj->boundaryConditions);
 | 
			
		||||
            data->m_indexAfter = indexAfter;
 | 
			
		||||
 | 
			
		||||
            commands.push_back(addItemExec);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (commands.size() > 0)
 | 
			
		||||
        {
 | 
			
		||||
            // Add an empty selection when boundary conditions has been assigned
 | 
			
		||||
            std::vector<caf::PdmObjectHandle*> newSelection;
 | 
			
		||||
            caf::CmdSelectionChangeExec* selectionChangeExec = caf::CmdSelectionHelper::createSelectionCommand(newSelection, caf::SelectionManager::CURRENT);
 | 
			
		||||
            commands.push_back(selectionChangeExec);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        caf::CmdExecCommandManager::instance()->processExecuteCommandsAsMacro("New Boundary Conditions", commands);
 | 
			
		||||
    }
 | 
			
		||||
*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
/// 
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void RicRangeFilterNewSliceK::setupActionLook(QAction* actionToSetup)
 | 
			
		||||
{
 | 
			
		||||
    actionToSetup->setText("New K-slice range filter");
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceK.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								ApplicationCode/Commands/RicRangeFilterNewSliceK.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (C) 2015-     Statoil ASA
 | 
			
		||||
//  Copyright (C) 2015-     Ceetron Solutions AS
 | 
			
		||||
// 
 | 
			
		||||
//  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 RicRangeFilterNewSliceK : public caf::CmdFeature
 | 
			
		||||
{
 | 
			
		||||
    CAF_CMD_HEADER_INIT;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    // Overrides
 | 
			
		||||
    virtual bool isCommandEnabled();
 | 
			
		||||
    virtual void onActionTriggered( bool isChecked );
 | 
			
		||||
    virtual void setupActionLook( QAction* actionToSetup );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -531,8 +531,11 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
 | 
			
		||||
        if (dynamic_cast<RimCellRangeFilterCollection*>(uiItems[0]))
 | 
			
		||||
        {
 | 
			
		||||
            actions.push_back(commandManager->action("RicRangeFilterNew"));
 | 
			
		||||
            actions.push_back(commandManager->action("RicRangeFilterNewSliceI"));
 | 
			
		||||
            actions.push_back(commandManager->action("RicRangeFilterNewSliceJ"));
 | 
			
		||||
            actions.push_back(commandManager->action("RicRangeFilterNewSliceK"));
 | 
			
		||||
        }
 | 
			
		||||
        if (dynamic_cast<RimCellRangeFilter*>(uiItems[0]))
 | 
			
		||||
        else if (dynamic_cast<RimCellRangeFilter*>(uiItems[0]))
 | 
			
		||||
        {
 | 
			
		||||
            actions.push_back(commandManager->action("RicRangeFilterNew"));
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user