mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Initial commit of ResInsight version 0.4.8
This commit is contained in:
135
ApplicationCode/ProjectDataModel/RimResultSlot.cpp
Normal file
135
ApplicationCode/ProjectDataModel/RimResultSlot.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimReservoir.h"
|
||||
#include "RIMainWindow.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimResultSlot, "ResultSlot");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimResultSlot::RimResultSlot()
|
||||
{
|
||||
CAF_PDM_InitObject("Result Slot", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_legendConfigData, "ResultVarLegendDefinitionList", "", "", "", "");
|
||||
m_legendConfigData.setHidden(true);
|
||||
|
||||
legendConfig = new RimLegendConfig();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimResultSlot::~RimResultSlot()
|
||||
{
|
||||
delete legendConfig();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &resultVariable)
|
||||
{
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
changeLegendConfig(this->resultVariable());
|
||||
}
|
||||
|
||||
if (newValue != "None") if (m_reservoirView) m_reservoirView->animationMode = true;
|
||||
}
|
||||
|
||||
RimResultDefinition::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend)
|
||||
{
|
||||
if (this->legendConfig()->resultVariableName() == resultVarNameOfNewLegend) return;
|
||||
|
||||
std::list<caf::PdmPointer<RimLegendConfig> >::iterator it;
|
||||
bool found = false;
|
||||
for (it = m_legendConfigData.v().begin(); it != m_legendConfigData.v().end(); ++it)
|
||||
{
|
||||
if ((*it)->resultVariableName() == resultVarNameOfNewLegend)
|
||||
{
|
||||
RimLegendConfig* newLegend = *it;
|
||||
|
||||
m_legendConfigData.v().erase(it);
|
||||
m_legendConfigData.v().push_back(this->legendConfig());
|
||||
this->legendConfig = newLegend;
|
||||
RIMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Not found ?
|
||||
if (!found)
|
||||
{
|
||||
RimLegendConfig* newLegend = new RimLegendConfig;
|
||||
newLegend->setReservoirView(m_reservoirView);
|
||||
newLegend->resultVariableName = resultVarNameOfNewLegend;
|
||||
m_legendConfigData.v().push_back(this->legendConfig());
|
||||
this->legendConfig = newLegend;
|
||||
RIMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSlot::initAfterRead()
|
||||
{
|
||||
RimResultDefinition::initAfterRead();
|
||||
|
||||
if (this->legendConfig()->resultVariableName == "")
|
||||
{
|
||||
this->legendConfig()->resultVariableName = this->resultVariable();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSlot::setReservoirView(RimReservoirView* ownerReservoirView)
|
||||
{
|
||||
m_reservoirView = ownerReservoirView;
|
||||
this->legendConfig()->setReservoirView(ownerReservoirView);
|
||||
std::list<caf::PdmPointer<RimLegendConfig> >::iterator it;
|
||||
for (it = m_legendConfigData.v().begin(); it != m_legendConfigData.v().end(); ++it)
|
||||
{
|
||||
(*it)->setReservoirView(ownerReservoirView);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user