mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improved management of multiple legend overlay items
This commit is contained in:
parent
ce58846584
commit
0d6c6f2785
@ -221,8 +221,10 @@ void RimReservoirView::updateViewerWidget()
|
||||
this->cellResult()->legendConfig->recreateLegend();
|
||||
this->cellResult()->ternaryLegendConfig->recreateLegend();
|
||||
this->cellEdgeResult()->legendConfig->recreateLegend();
|
||||
m_viewer->setColorLegend1(this->cellResult()->legendConfig->legend());
|
||||
m_viewer->setColorLegend2(this->cellEdgeResult()->legendConfig->legend());
|
||||
|
||||
m_viewer->removeAllColorLegends();
|
||||
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
|
||||
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
|
||||
|
||||
if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON)
|
||||
{
|
||||
@ -1370,6 +1372,11 @@ void RimReservoirView::indicesToVisibleGrids(std::vector<size_t>* gridIndices)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoirView::updateLegends()
|
||||
{
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->removeAllColorLegends();
|
||||
}
|
||||
|
||||
if (!m_reservoir || !m_viewer || !m_reservoir->reservoirData() )
|
||||
{
|
||||
return;
|
||||
@ -1408,40 +1415,15 @@ void RimReservoirView::updateLegends()
|
||||
this->cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
|
||||
this->cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
||||
|
||||
m_viewer->setColorLegend1(this->cellResult()->legendConfig->legend());
|
||||
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
|
||||
this->cellResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(QString("Cell Results: \n") + this->cellResult()->resultVariable()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->cellResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
|
||||
this->cellResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
|
||||
m_viewer->setColorLegend1(NULL);
|
||||
}
|
||||
|
||||
if (this->cellEdgeResult()->hasResult())
|
||||
{
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax);
|
||||
this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero);
|
||||
|
||||
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero);
|
||||
this->cellEdgeResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax);
|
||||
|
||||
m_viewer->setColorLegend2(this->cellEdgeResult()->legendConfig->legend());
|
||||
this->cellEdgeResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_viewer->setColorLegend2(NULL);
|
||||
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
|
||||
this->cellEdgeResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
|
||||
|
||||
viewer()->removeOverlayItem(this->cellResult()->ternaryLegendConfig->legend());
|
||||
|
||||
size_t maxTimeStepCount = results->maxTimeStepCount();
|
||||
if (this->cellResult()->isTernarySaturationSelected() && maxTimeStepCount > 1)
|
||||
{
|
||||
@ -1496,9 +1478,28 @@ void RimReservoirView::updateLegends()
|
||||
|
||||
if (this->cellResult()->ternaryLegendConfig->legend())
|
||||
{
|
||||
viewer()->addOverlayItem(this->cellResult()->ternaryLegendConfig->legend());
|
||||
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->ternaryLegendConfig->legend());
|
||||
}
|
||||
}
|
||||
|
||||
if (this->cellEdgeResult()->hasResult())
|
||||
{
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax);
|
||||
this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero);
|
||||
|
||||
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero);
|
||||
this->cellEdgeResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax);
|
||||
|
||||
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
|
||||
this->cellEdgeResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
|
||||
this->cellEdgeResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -146,55 +146,6 @@ RiuViewer::~RiuViewer()
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::setColorLegend1(cvf::OverlayScalarMapperLegend* legend)
|
||||
{
|
||||
m_mainRendering->removeOverlayItem(m_legend1.p());
|
||||
|
||||
m_legend1 = legend;
|
||||
|
||||
this->updateLegends();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::setColorLegend2(cvf::OverlayScalarMapperLegend* legend)
|
||||
{
|
||||
m_mainRendering->removeOverlayItem(m_legend2.p());
|
||||
|
||||
m_legend2 = legend;
|
||||
|
||||
this->updateLegends();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::updateLegends()
|
||||
{
|
||||
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
|
||||
CVF_ASSERT(firstRendering);
|
||||
|
||||
firstRendering->removeOverlayItem(m_legend1.p());
|
||||
firstRendering->removeOverlayItem(m_legend2.p());
|
||||
|
||||
if (m_legend1.notNull())
|
||||
{
|
||||
m_legend1->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT);
|
||||
firstRendering->addOverlayItem(m_legend1.p());
|
||||
}
|
||||
|
||||
if (m_legend2.notNull())
|
||||
{
|
||||
m_legend2->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT);
|
||||
firstRendering->addOverlayItem(m_legend2.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -510,9 +461,6 @@ void RiuViewer::slotEndAnimation()
|
||||
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
|
||||
CVF_ASSERT(firstRendering);
|
||||
|
||||
firstRendering->removeOverlayItem(m_legend1.p());
|
||||
firstRendering->removeOverlayItem(m_legend2.p());
|
||||
|
||||
if (m_reservoirView) m_reservoirView->endAnimation();
|
||||
|
||||
caf::Viewer::slotEndAnimation();
|
||||
@ -530,8 +478,6 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex)
|
||||
|
||||
if (m_reservoirView) m_reservoirView->setCurrentTimeStep(frameIndex);
|
||||
|
||||
this->updateLegends();
|
||||
|
||||
caf::Viewer::slotSetCurrentFrame(frameIndex);
|
||||
}
|
||||
|
||||
@ -763,21 +709,6 @@ void RiuViewer::mousePressEvent(QMouseEvent* event)
|
||||
m_lastMousePressPosition = event->pos();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::addOverlayItem(cvf::OverlayItem* overlayItem)
|
||||
{
|
||||
m_renderingSequence->firstRendering()->addOverlayItem(overlayItem);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::removeOverlayItem(cvf::OverlayItem* overlayItem)
|
||||
{
|
||||
m_renderingSequence->firstRendering()->removeOverlayItem(overlayItem);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -798,3 +729,33 @@ void RiuViewer::slotHideFault()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::removeAllColorLegends()
|
||||
{
|
||||
for (size_t i = 0; i < m_visibleLegends.size(); i++)
|
||||
{
|
||||
m_mainRendering->removeOverlayItem(m_visibleLegends[i].p());
|
||||
}
|
||||
|
||||
m_visibleLegends.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend)
|
||||
{
|
||||
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
|
||||
CVF_ASSERT(firstRendering);
|
||||
|
||||
if (legend)
|
||||
{
|
||||
legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT);
|
||||
firstRendering->addOverlayItem(legend);
|
||||
|
||||
m_visibleLegends.push_back(legend);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,6 @@ public:
|
||||
RiuViewer(const QGLFormat& format, QWidget* parent);
|
||||
~RiuViewer();
|
||||
|
||||
void setColorLegend1(cvf::OverlayScalarMapperLegend* legend);
|
||||
void setColorLegend2(cvf::OverlayScalarMapperLegend* legend);
|
||||
void setDefaultView();
|
||||
cvf::Vec3d pointOfInterest();
|
||||
void setPointOfInterest(cvf::Vec3d poi);
|
||||
@ -67,8 +65,8 @@ public:
|
||||
|
||||
void showAnimationProgress(bool enable);
|
||||
|
||||
void addOverlayItem(cvf::OverlayItem* overlayItem);
|
||||
void removeOverlayItem(cvf::OverlayItem* overlayItem);
|
||||
void removeAllColorLegends();
|
||||
void addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend);
|
||||
|
||||
|
||||
public slots:
|
||||
@ -91,7 +89,6 @@ private slots:
|
||||
void slotHideFault();
|
||||
|
||||
private:
|
||||
void updateLegends();
|
||||
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
||||
|
||||
private:
|
||||
@ -108,9 +105,7 @@ private:
|
||||
QCDEStyle* m_progressBarStyle;
|
||||
|
||||
|
||||
cvf::ref<cvf::OverlayScalarMapperLegend> m_legend1;
|
||||
cvf::ref<cvf::OverlayScalarMapperLegend> m_legend2;
|
||||
|
||||
cvf::Collection<cvf::OverlayItem> m_visibleLegends;
|
||||
|
||||
caf::PdmPointer<RimReservoirView> m_reservoirView;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user