ResInsight/ApplicationCode/Commands/RicRangeFilterNewExec.cpp

124 lines
4.4 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2014 Ceetron Solutions AS, USFOS AS, AMOS - NTNU
//
// RPM 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
// 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 "RicRangeFilterNewExec.h"
#include "RimCellRangeFilter.h"
#include "RimCellRangeFilterCollection.h"
#include "RimView.h"
#include "RiuMainWindow.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicRangeFilterNewExec::RicRangeFilterNewExec(RimCellRangeFilterCollection* rangeFilterCollection)
: CmdExecuteCommand(NULL)
{
2015-08-06 13:54:29 -05:00
m_iSlice = false;
m_jSlice = false;
m_kSlice = false;
m_iSliceStart = -1;
m_jSliceStart = -1;
m_kSliceStart = -1;
cellRangeFilterCollection = rangeFilterCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicRangeFilterNewExec::~RicRangeFilterNewExec()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicRangeFilterNewExec::name()
{
2015-08-06 13:54:29 -05:00
if (m_iSlice)
2015-08-07 01:37:29 -05:00
return "Create I Slice Filter";
2015-08-06 13:54:29 -05:00
else if (m_jSlice)
2015-08-07 01:37:29 -05:00
return "Create J Slice Filter";
2015-08-06 13:54:29 -05:00
else if (m_kSlice)
2015-08-07 01:37:29 -05:00
return "Create K Slice Filter";
2015-08-06 13:54:29 -05:00
2015-08-07 01:37:29 -05:00
return "Create Range Filter";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRangeFilterNewExec::redo()
{
assert(cellRangeFilterCollection);
2015-08-07 01:37:29 -05:00
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter();
cellRangeFilterCollection->rangeFilters.push_back(rangeFilter);
2015-08-07 01:37:29 -05:00
rangeFilter->setDefaultValues();
rangeFilter->name = QString("Range Filter (%1)").arg(cellRangeFilterCollection->rangeFilters().size());
if (m_iSlice)
{
2015-08-07 01:37:29 -05:00
rangeFilter->cellCountI = 1;
rangeFilter->name = QString("I Slice Filter (%1)").arg(cellRangeFilterCollection->rangeFilters().size());
}
if (m_jSlice)
{
2015-08-07 01:37:29 -05:00
rangeFilter->cellCountJ = 1;
rangeFilter->name = QString("J Slice Filter (%1)").arg(cellRangeFilterCollection->rangeFilters().size());
}
if (m_kSlice)
{
2015-08-07 01:37:29 -05:00
rangeFilter->cellCountK = 1;
rangeFilter->name = QString("K Slice Filter (%1)").arg(cellRangeFilterCollection->rangeFilters().size());
}
2015-08-07 01:37:29 -05:00
if (m_iSliceStart > -1) rangeFilter->startIndexI = m_iSliceStart;
if (m_jSliceStart > -1) rangeFilter->startIndexJ = m_jSliceStart;
if (m_kSliceStart > -1) rangeFilter->startIndexK = m_kSliceStart;
cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED);
cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
cellRangeFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(rangeFilter);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRangeFilterNewExec::undo()
{
assert(cellRangeFilterCollection);
cellRangeFilterCollection->rangeFilters.erase(cellRangeFilterCollection->rangeFilters.size() - 1);
cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED);
cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
cellRangeFilterCollection->updateConnectedEditors();
}