Completed IJK-slice commands

This commit is contained in:
Magne Sjaastad 2015-08-06 20:54:29 +02:00
parent 1f60ef76c9
commit dc1bbe0bab
4 changed files with 45 additions and 130 deletions

View File

@ -29,9 +29,13 @@
RicRangeFilterNewExec::RicRangeFilterNewExec(caf::NotificationCenter* notificationCenter) RicRangeFilterNewExec::RicRangeFilterNewExec(caf::NotificationCenter* notificationCenter)
: CmdExecuteCommand(notificationCenter) : CmdExecuteCommand(notificationCenter)
{ {
m_iSlice = -1; m_iSlice = false;
m_jSlice = -1; m_jSlice = false;
m_kSlice = -1; m_kSlice = false;
m_iSliceStart = -1;
m_jSliceStart = -1;
m_kSliceStart = -1;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -39,7 +43,14 @@ RicRangeFilterNewExec::RicRangeFilterNewExec(caf::NotificationCenter* notificati
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RicRangeFilterNewExec::name() QString RicRangeFilterNewExec::name()
{ {
return "New Range Filter"; if (m_iSlice)
return "Add I-slice Filter";
else if (m_jSlice)
return "Add J-slice Filter";
else if (m_kSlice)
return "Add K-slice Filter";
return "Add Range Filter";
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -18,10 +18,12 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RicRangeFilterNewSliceI.h" #include "RicRangeFilterNewSliceI.h"
#include "RicRangeFilterNewExec.h"
#include "RimCellRangeFilter.h" #include "RimCellRangeFilter.h"
#include "RimCellRangeFilterCollection.h" #include "RimCellRangeFilterCollection.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include <QAction> #include <QAction>
@ -56,53 +58,19 @@ bool RicRangeFilterNewSliceI::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicRangeFilterNewSliceI::onActionTriggered(bool isChecked) void RicRangeFilterNewSliceI::onActionTriggered(bool isChecked)
{ {
// MODTODO std::vector<RimCellRangeFilterCollection*> selectedRangeFilterCollection;
caf::SelectionManager::instance()->objectsByType(&selectedRangeFilterCollection);
/* EvmProject* proj = EvaApplication::instance()->project(); if (selectedRangeFilterCollection.size() == 1)
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); RimCellRangeFilterCollection* rangeFilterCollection = selectedRangeFilterCollection[0];
std::vector<caf::CmdExecuteCommand*> commands; RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(NULL);
for (size_t i = 0; i < selectedNodes.size(); i++) filterExec->cellRangeFilterCollection = rangeFilterCollection;
{ filterExec->m_iSlice = true;
// Not allowed to add more than one BC
if (proj->findBoundaryConditionForNode(selectedNodes[i]->id)) continue;
std::vector<caf::PdmObjectHandle*> newSelection; caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
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);
}
*/
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -18,10 +18,12 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RicRangeFilterNewSliceJ.h" #include "RicRangeFilterNewSliceJ.h"
#include "RicRangeFilterNewExec.h"
#include "RimCellRangeFilter.h" #include "RimCellRangeFilter.h"
#include "RimCellRangeFilterCollection.h" #include "RimCellRangeFilterCollection.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include <QAction> #include <QAction>
@ -56,53 +58,19 @@ bool RicRangeFilterNewSliceJ::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicRangeFilterNewSliceJ::onActionTriggered(bool isChecked) void RicRangeFilterNewSliceJ::onActionTriggered(bool isChecked)
{ {
// MODTODO std::vector<RimCellRangeFilterCollection*> selectedRangeFilterCollection;
caf::SelectionManager::instance()->objectsByType(&selectedRangeFilterCollection);
/* EvmProject* proj = EvaApplication::instance()->project(); if (selectedRangeFilterCollection.size() == 1)
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); RimCellRangeFilterCollection* rangeFilterCollection = selectedRangeFilterCollection[0];
std::vector<caf::CmdExecuteCommand*> commands; RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(NULL);
for (size_t i = 0; i < selectedNodes.size(); i++) filterExec->cellRangeFilterCollection = rangeFilterCollection;
{ filterExec->m_jSlice = true;
// Not allowed to add more than one BC
if (proj->findBoundaryConditionForNode(selectedNodes[i]->id)) continue;
std::vector<caf::PdmObjectHandle*> newSelection; caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
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);
}
*/
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,8 @@
#include <QAction> #include <QAction>
#include <vector> #include <vector>
#include "RicRangeFilterNewExec.h"
#include "cafCmdExecCommandManager.h"
CAF_CMD_SOURCE_INIT(RicRangeFilterNewSliceK, "RicRangeFilterNewSliceK"); CAF_CMD_SOURCE_INIT(RicRangeFilterNewSliceK, "RicRangeFilterNewSliceK");
@ -56,53 +58,19 @@ bool RicRangeFilterNewSliceK::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicRangeFilterNewSliceK::onActionTriggered(bool isChecked) void RicRangeFilterNewSliceK::onActionTriggered(bool isChecked)
{ {
// MODTODO std::vector<RimCellRangeFilterCollection*> selectedRangeFilterCollection;
caf::SelectionManager::instance()->objectsByType(&selectedRangeFilterCollection);
/* EvmProject* proj = EvaApplication::instance()->project(); if (selectedRangeFilterCollection.size() == 1)
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); RimCellRangeFilterCollection* rangeFilterCollection = selectedRangeFilterCollection[0];
std::vector<caf::CmdExecuteCommand*> commands; RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(NULL);
for (size_t i = 0; i < selectedNodes.size(); i++) filterExec->cellRangeFilterCollection = rangeFilterCollection;
{ filterExec->m_kSlice = true;
// Not allowed to add more than one BC
if (proj->findBoundaryConditionForNode(selectedNodes[i]->id)) continue;
std::vector<caf::PdmObjectHandle*> newSelection; caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
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);
}
*/
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------