#2522 Mohr circle: Update plot on 3D view selection

This commit is contained in:
Rebecca Cox 2018-02-22 17:52:10 +01:00
parent d6974bfdba
commit 28efe4661d
5 changed files with 103 additions and 5 deletions

View File

@ -182,6 +182,7 @@ void RiuMainWindow::cleanupGuiCaseClose()
m_resultQwtPlot->deleteAllCurves();
if (m_relPermPlotPanel) m_relPermPlotPanel->clearPlot();
if (m_pvtPlotPanel) m_pvtPlotPanel->clearPlot();
if (m_mohrsCirclePlot) m_mohrsCirclePlot->clearPlot();
if (m_pdmUiPropertyView)
{
@ -915,6 +916,14 @@ RiuPvtPlotPanel* RiuMainWindow::pvtPlotPanel()
return m_pvtPlotPanel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMohrsCirclePlot* RiuMainWindow::mohrsCirclePlot()
{
return m_mohrsCirclePlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -118,6 +118,7 @@ public:
RiuResultQwtPlot* resultPlot();
RiuRelativePermeabilityPlotPanel* relativePermeabilityPlotPanel();
RiuPvtPlotPanel* pvtPlotPanel();
RiuMohrsCirclePlot* mohrsCirclePlot();
RiuMessagePanel* messagePanel();
void showProcessMonitorDockPanel();

View File

@ -20,6 +20,16 @@
#include "qwt_round_scale_draw.h"
#include "qwt_symbol.h"
#include "RiuSelectionManager.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "cvfAssert.h"
@ -72,6 +82,41 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, dou
redrawCircles();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem)
{
const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast<const RiuGeoMechSelectionItem*>(selectionItem);
RimGeoMechView* geoMechView = geoMechSelectionItem ? geoMechSelectionItem->m_view : nullptr;
bool mustClearPlot = true;
if (this->isVisible() && geoMechSelectionItem && geoMechView)
{
const size_t gridIndex = geoMechSelectionItem->m_gridIndex;
const size_t cellIndex = geoMechSelectionItem->m_cellIndex;
if (queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex))
{
mustClearPlot = false;
}
}
if (mustClearPlot)
{
this->clearPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::clearPlot()
{
deleteCircles();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -127,6 +172,39 @@ void RiuMohrsCirclePlot::deleteCircles()
m_mohrCirclesMarkers.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex)
{
if (!geoMechView) return false;
RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults();
if (!resultCollection) return false;
int frameIdx = geoMechView->currentTimeStep();
RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress();
//TODO: All tensors are calculated everytime this function is called. FIX
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors(currentAddress, 0, frameIdx);
RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex);
caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)];
for (int i = 1; i < 8; i++)
{
tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, i)];
}
caf::Ten3f elmTensor = tensorSumOfElmNodes * (1.0 / 8.0);
cvf::Vec3f principalDirs[3];
cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs);
setPrincipalsAndRedrawCircles(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]);
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -25,6 +25,8 @@
#include <array>
class RiuSelectionItem;
class RimGeoMechView;
//==================================================================================================
//
//
@ -41,6 +43,9 @@ public:
void setPrincipals(double p1, double p2, double p3);
void setPrincipalsAndRedrawCircles(double p1, double p2, double p3);
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
void clearPlot();
protected:
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
@ -48,6 +53,8 @@ protected:
void redrawCircles();
void deleteCircles();
bool queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex);
private:
struct MohrCircle
{

View File

@ -29,25 +29,26 @@
#include "RigTimeHistoryResultAccessor.h"
#include "RiuFemTimeHistoryResultAccessor.h"
#include "Rim2dIntersectionView.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "Rim2dIntersectionView.h"
#include "RimIntersection.h"
#include "RimProject.h"
#include "RiuFemResultTextBuilder.h"
#include "RiuMainWindow.h"
#include "RiuMohrsCirclePlot.h"
#include "RiuPvtPlotPanel.h"
#include "RiuPvtPlotUpdater.h"
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuResultQwtPlot.h"
#include "RiuResultTextBuilder.h"
#include "RiuSelectionManager.h"
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuPvtPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuPvtPlotUpdater.h"
#include <QStatusBar>
@ -107,6 +108,8 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item
RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater();
pvtPlotUpdater->updateOnSelectionChanged(item);
RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(item);
updateResultInfo(item);
scheduleUpdateForAllVisibleViews();