#1078 Added context menu for well cells and well cell fence

This commit is contained in:
Magne Sjaastad 2017-01-26 17:52:13 +01:00
parent 8f4fa4592a
commit ccc7345706
3 changed files with 149 additions and 0 deletions

View File

@ -267,3 +267,122 @@ bool RicEclipseWellShowSpheresFeature::isCommandChecked()
}
CAF_CMD_SOURCE_INIT(RicEclipseWellShowWellCellsFeature, "RicEclipseWellShowWellCellsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipseWellShowWellCellsFeature::onActionTriggered(bool isChecked)
{
std::vector<RimEclipseWell*> selection = RicEclipseWellFeatureImpl::selectedWells();
for (RimEclipseWell* w : selection)
{
w->showWellCells.setValueWithFieldChanged(isChecked);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipseWellShowWellCellsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Show Well Cells");
actionToSetup->setCheckable(true);
actionToSetup->setChecked(isCommandChecked());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEclipseWellShowWellCellsFeature::isCommandEnabled()
{
RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection();
if (wellColl && !wellColl->showWellCells())
{
return false;
}
return RicEclipseWellFeatureImpl::isAnyWellSelected();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEclipseWellShowWellCellsFeature::isCommandChecked()
{
std::vector<RimEclipseWell*> selection = RicEclipseWellFeatureImpl::selectedWells();
if (selection.size() > 0)
{
RimEclipseWell* well = selection[0];
return well->showWellCells();
}
return false;
}
CAF_CMD_SOURCE_INIT(RicEclipseWellShowWellCellFenceFeature, "RicEclipseWellShowWellCellFenceFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipseWellShowWellCellFenceFeature::onActionTriggered(bool isChecked)
{
std::vector<RimEclipseWell*> selection = RicEclipseWellFeatureImpl::selectedWells();
for (RimEclipseWell* w : selection)
{
w->showWellCellFence.setValueWithFieldChanged(isChecked);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipseWellShowWellCellFenceFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Show Well Cell Fence");
actionToSetup->setCheckable(true);
actionToSetup->setChecked(isCommandChecked());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEclipseWellShowWellCellFenceFeature::isCommandEnabled()
{
RimEclipseWellCollection* wellColl = RicEclipseWellFeatureImpl::wellCollectionFromSelection();
if (wellColl && !(wellColl->showWellCells() || wellColl->showWellCellFence()))
{
return false;
}
return RicEclipseWellFeatureImpl::isAnyWellSelected();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEclipseWellShowWellCellFenceFeature::isCommandChecked()
{
std::vector<RimEclipseWell*> selection = RicEclipseWellFeatureImpl::selectedWells();
if (selection.size() > 0)
{
RimEclipseWell* well = selection[0];
return well->showWellCellFence();
}
return false;
}

View File

@ -77,3 +77,31 @@ protected:
virtual bool isCommandChecked() override;
};
//==================================================================================================
///
//==================================================================================================
class RicEclipseWellShowWellCellsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
virtual bool isCommandChecked() override;
};
//==================================================================================================
///
//==================================================================================================
class RicEclipseWellShowWellCellFenceFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
virtual bool isCommandChecked() override;
};

View File

@ -409,6 +409,8 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicEclipseWellShowHeadFeature";
commandIds << "RicEclipseWellShowPipeFeature";
commandIds << "RicEclipseWellShowSpheresFeature";
commandIds << "RicEclipseWellShowWellCellsFeature";
commandIds << "RicEclipseWellShowWellCellFenceFeature";
}
}