#2426 Add working legends to 2D intersection Views. Refactor to make legend update code work from a separate view with separate legend configs. Make sure legend and results are updated as the main view is updated. Adjust legendconfig->setTitle to use QString

This commit is contained in:
Jacob Støren
2018-02-01 17:45:22 +01:00
parent a4eb16883b
commit 29ac24f3dd
29 changed files with 428 additions and 225 deletions

View File

@@ -23,6 +23,7 @@
#include "RiuViewer.h"
#include "RimGridView.h"
#include "RivIntersectionPartMgr.h"
#include "RivTernarySaturationOverlayItem.h"
#include "cvfPart.h"
#include "cvfModelBasicList.h"
@@ -32,6 +33,8 @@
#include "RimEclipseCellColors.h"
#include "RimGeoMechView.h"
#include "RimGeoMechCellColors.h"
#include "RimLegendConfig.h"
#include "RimTernaryLegendConfig.h"
#include <QDateTime>
@@ -52,6 +55,18 @@ Rim2dIntersectionView::Rim2dIntersectionView(void)
CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", "");
m_intersection.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
m_legendConfig.uiCapability()->setUiHidden(true);
m_legendConfig.uiCapability()->setUiTreeChildrenHidden(true);
m_legendConfig.xmlCapability()->disableIO();
m_legendConfig = new RimLegendConfig();
CAF_PDM_InitFieldNoDefault(&m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Legend Definition", "", "", "");
m_ternaryLegendConfig.uiCapability()->setUiTreeHidden(true);
m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden(true);
m_ternaryLegendConfig.xmlCapability()->disableIO();
m_ternaryLegendConfig = new RimTernaryLegendConfig();
m_showWindow = false;
m_scaleTransform = new cvf::Transform();
m_intersectionVizModel = new cvf::ModelBasicList;
@@ -274,6 +289,12 @@ void Rim2dIntersectionView::createDisplayModel()
void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection<cvf::Part>* parts)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::onTimeStepChanged()
{
}
//--------------------------------------------------------------------------------------------------
///
@@ -287,23 +308,88 @@ void Rim2dIntersectionView::clampCurrentTimestep()
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::updateCurrentTimeStep()
{
updateLegends();
if ((this->hasUserRequestedAnimation() && this->hasResults()))
{
m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep);
m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep,
m_legendConfig->scalarMapper(),
m_ternaryLegendConfig()->scalarMapper());
}
else
{
m_flatIntersectionPartMgr->applySingleColorEffect();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::updateLegends()
{
if (m_viewer)
{
m_viewer->removeAllColorLegends();
}
if (!hasResults()) return ;
cvf::OverlayItem* legend = nullptr;
RimEclipseView * eclView = nullptr;
m_intersection->firstAncestorOrThisOfType(eclView);
if (eclView)
{
m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig());
m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig());
eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig());
if ( eclView->cellResult()->isTernarySaturationSelected() )
{
m_ternaryLegendConfig()->setTitle("Cell Result:");
legend = m_ternaryLegendConfig()->legend();
}
else
{
m_legendConfig()->setTitle("Cell Result:" + eclView->cellResult()->resultVariableUiShortName());
legend = m_legendConfig()->legend();
}
}
RimGeoMechView * geoView = nullptr;
m_intersection->firstAncestorOrThisOfType(geoView);
if (geoView)
{
m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig());
geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep());
legend = m_legendConfig()->legend();
}
if ( legend )
{
m_viewer->addColorLegendToBottomLeftCorner(legend);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::onTimeStepChanged()
void Rim2dIntersectionView::resetLegendsInViewer()
{
m_viewer->showAxisCross(false);
m_viewer->showAnimationProgress(true);
m_viewer->showHistogram(false);
m_viewer->showInfoText(false);
m_viewer->setMainScene(new cvf::Scene());
m_viewer->enableNavigationRotation(false);
m_ternaryLegendConfig()->recreateLegend();
m_legendConfig()->recreateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -332,20 +418,6 @@ cvf::Transform* Rim2dIntersectionView::scaleTransform()
return m_scaleTransform.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::resetLegendsInViewer()
{
m_viewer->showAxisCross(false);
m_viewer->showAnimationProgress(true);
m_viewer->showHistogram(false);
m_viewer->showInfoText(false);
m_viewer->setMainScene(new cvf::Scene());
m_viewer->enableNavigationRotation(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------