mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#632) Update application items when selection changes using a separate class
Added RiuSelectionChangedHandler Moved code from ViewerCommands into SelectionChangedHandler
This commit is contained in:
parent
ff6ea6cf0b
commit
a13376a8bf
@ -96,6 +96,8 @@ set( USER_INTERFACE_FILES
|
||||
UserInterface/RiuSelectionManager.cpp
|
||||
UserInterface/RiuSelectionColors.h
|
||||
UserInterface/RiuSelectionColors.cpp
|
||||
UserInterface/RiuSelectionChangedHandler.h
|
||||
UserInterface/RiuSelectionChangedHandler.cpp
|
||||
)
|
||||
|
||||
set( SOCKET_INTERFACE_FILES
|
||||
|
252
ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp
Normal file
252
ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp
Normal file
@ -0,0 +1,252 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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 "RiuSelectionChangedHandler.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigFemTimeHistoryResultAccessor.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigTimeHistoryResultAccessor.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuFemResultTextBuilder.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuResultTextBuilder.h"
|
||||
#include "RiuSelectionManager.h"
|
||||
#include "RiuTimeHistoryQwtPlot.h"
|
||||
|
||||
#include <QStatusBar>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSelectionChangedHandler::RiuSelectionChangedHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSelectionChangedHandler::~RiuSelectionChangedHandler()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::handleSelectionDeleted() const
|
||||
{
|
||||
RiuMainWindow::instance()->timeHistoryPlot()->deleteAllCurves();
|
||||
|
||||
updateResultInfo(NULL);
|
||||
|
||||
scheduleUpdateForAllVisibleViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item) const
|
||||
{
|
||||
addCurveFromSelectionItem(item);
|
||||
|
||||
updateResultInfo(item);
|
||||
|
||||
scheduleUpdateForAllVisibleViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* item) const
|
||||
{
|
||||
RiuMainWindow::instance()->timeHistoryPlot()->deleteAllCurves();
|
||||
|
||||
handleItemAppended(item);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuEclipseSelectionItem* eclipseSelectionItem) const
|
||||
{
|
||||
RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p();
|
||||
|
||||
if (eclipseView->cellResult()->hasDynamicResult() &&
|
||||
eclipseView->eclipseCase() &&
|
||||
eclipseView->eclipseCase()->reservoirData())
|
||||
{
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(eclipseView->cellResult()->porosityModel());
|
||||
|
||||
size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T;
|
||||
eclipseView->eclipseCase()->reservoirData()->results(porosityModel)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount);
|
||||
std::vector<QDateTime> timeStepDates = eclipseView->eclipseCase()->reservoirData()->results(porosityModel)->timeStepDates(scalarIndexWithMaxTimeStepCount);
|
||||
|
||||
RigTimeHistoryResultAccessor timeHistResultAccessor(eclipseView->eclipseCase()->reservoirData(),
|
||||
eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_cellIndex,
|
||||
eclipseView->cellResult()->scalarResultIndex(), porosityModel);
|
||||
|
||||
QString curveName = eclipseView->eclipseCase()->caseUserDescription();
|
||||
curveName += ", ";
|
||||
curveName += eclipseView->cellResult()->resultVariable();
|
||||
curveName += ", ";
|
||||
curveName += QString("Grid index %1").arg(eclipseSelectionItem->m_gridIndex);
|
||||
curveName += ", ";
|
||||
curveName += timeHistResultAccessor.topologyText();
|
||||
|
||||
std::vector<double> timeHistoryValues = timeHistResultAccessor.timeHistoryValues();
|
||||
CVF_ASSERT(timeStepDates.size() == timeHistoryValues.size());
|
||||
|
||||
RiuMainWindow::instance()->timeHistoryPlot()->addCurve(curveName, eclipseSelectionItem->m_color, timeStepDates, timeHistoryValues);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuGeoMechSelectionItem* geomSelectionItem) const
|
||||
{
|
||||
RimGeoMechView* geoMechView = geomSelectionItem->m_view.p();
|
||||
|
||||
if (geoMechView &&
|
||||
geoMechView->cellResult() &&
|
||||
geoMechView->cellResult()->hasResult() &&
|
||||
geoMechView->geoMechCase() &&
|
||||
geoMechView->geoMechCase()->geoMechData())
|
||||
{
|
||||
RigFemTimeHistoryResultAccessor timeHistResultAccessor(geoMechView->geoMechCase()->geoMechData(), geoMechView->cellResult->resultAddress(),
|
||||
geomSelectionItem->m_gridIndex, geomSelectionItem->m_cellIndex, geomSelectionItem->m_localIntersectionPoint);
|
||||
|
||||
QString curveName;
|
||||
curveName.append(geoMechView->geoMechCase()->caseUserDescription() + ", ");
|
||||
|
||||
caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = geoMechView->cellResult()->resultPositionType();
|
||||
curveName.append(resPosAppEnum.uiText() + ", ");
|
||||
curveName.append(geoMechView->cellResult()->resultFieldUiName()+ ", ") ;
|
||||
curveName.append(geoMechView->cellResult()->resultComponentUiName() + ":\n");
|
||||
curveName.append(timeHistResultAccessor.topologyText());
|
||||
|
||||
std::vector<double> timeHistoryValues = timeHistResultAccessor.timeHistoryValues();
|
||||
std::vector<double> frameTimes;
|
||||
for (size_t i = 0; i < timeHistoryValues.size(); i++)
|
||||
{
|
||||
frameTimes.push_back(i);
|
||||
}
|
||||
|
||||
CVF_ASSERT(frameTimes.size() == timeHistoryValues.size());
|
||||
|
||||
RiuMainWindow::instance()->timeHistoryPlot()->addCurve(curveName, geomSelectionItem->m_color, frameTimes, timeHistoryValues);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuSelectionItem* itemAdded) const
|
||||
{
|
||||
if (itemAdded->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(itemAdded);
|
||||
|
||||
addCurveFromSelectionItem(eclipseSelectionItem);
|
||||
}
|
||||
else if (itemAdded->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuGeoMechSelectionItem* geomSelectionItem = static_cast<const RiuGeoMechSelectionItem*>(itemAdded);
|
||||
|
||||
addCurveFromSelectionItem(geomSelectionItem);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::scheduleUpdateForAllVisibleViews() const
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj)
|
||||
{
|
||||
std::vector<RimView*> visibleViews;
|
||||
proj->allVisibleViews(visibleViews);
|
||||
|
||||
for (size_t i = 0; i < visibleViews.size(); i++)
|
||||
{
|
||||
visibleViews[i]->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAdded) const
|
||||
{
|
||||
QString resultInfo;
|
||||
QString pickInfo;
|
||||
|
||||
if (itemAdded != NULL)
|
||||
{
|
||||
if (itemAdded->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(itemAdded);
|
||||
|
||||
RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p();
|
||||
|
||||
RiuResultTextBuilder textBuilder(eclipseView, eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_cellIndex, eclipseView->currentTimeStep());
|
||||
textBuilder.setFace(eclipseSelectionItem->m_face);
|
||||
textBuilder.setNncIndex(eclipseSelectionItem->m_nncIndex);
|
||||
textBuilder.setIntersectionPoint(eclipseSelectionItem->m_localIntersectionPoint);
|
||||
|
||||
resultInfo = textBuilder.mainResultText();
|
||||
|
||||
pickInfo = textBuilder.topologyText(", ");
|
||||
}
|
||||
else if (itemAdded->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuGeoMechSelectionItem* geomSelectionItem = static_cast<const RiuGeoMechSelectionItem*>(itemAdded);
|
||||
|
||||
RimGeoMechView* geomView = geomSelectionItem->m_view.p();
|
||||
RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep());
|
||||
textBuilder.setIntersectionPoint(geomSelectionItem->m_localIntersectionPoint);
|
||||
|
||||
resultInfo = textBuilder.mainResultText();
|
||||
|
||||
pickInfo = textBuilder.topologyText(", ");
|
||||
}
|
||||
}
|
||||
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
mainWnd->statusBar()->showMessage(pickInfo);
|
||||
mainWnd->setResultInfo(resultInfo);
|
||||
}
|
47
ApplicationCode/UserInterface/RiuSelectionChangedHandler.h
Normal file
47
ApplicationCode/UserInterface/RiuSelectionChangedHandler.h
Normal file
@ -0,0 +1,47 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
class RiuSelectionItem;
|
||||
class RiuEclipseSelectionItem;
|
||||
class RiuGeoMechSelectionItem;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiuSelectionChangedHandler
|
||||
{
|
||||
public:
|
||||
RiuSelectionChangedHandler();
|
||||
~RiuSelectionChangedHandler();
|
||||
|
||||
void handleSelectionDeleted() const;
|
||||
void handleItemAppended(const RiuSelectionItem* item) const;
|
||||
void handleSetSelectedItem(const RiuSelectionItem* item) const;
|
||||
|
||||
private:
|
||||
void addCurveFromSelectionItem(const RiuSelectionItem* itemAdded) const;
|
||||
void addCurveFromSelectionItem(const RiuEclipseSelectionItem* selectionItem) const;
|
||||
void addCurveFromSelectionItem(const RiuGeoMechSelectionItem* selectionItem) const;
|
||||
|
||||
void scheduleUpdateForAllVisibleViews() const;
|
||||
void updateResultInfo(const RiuSelectionItem* itemAdded) const;
|
||||
};
|
||||
|
@ -20,6 +20,25 @@
|
||||
#include "RiuSelectionManager.h"
|
||||
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechView.h"
|
||||
|
||||
#include "RiuSelectionChangedHandler.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSelectionManager::RiuSelectionManager()
|
||||
: m_notificationCenter(new RiuSelectionChangedHandler)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSelectionManager::~RiuSelectionManager()
|
||||
{
|
||||
delete m_notificationCenter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -41,19 +60,23 @@ void RiuSelectionManager::selectedItems(std::vector<RiuSelectionItem*>& items) c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionManager::setSelectedItems(const std::vector<RiuSelectionItem*>& items)
|
||||
void RiuSelectionManager::appendItemToSelection(RiuSelectionItem* item)
|
||||
{
|
||||
CVF_ASSERT(m_selection.size() == 0);
|
||||
m_selection.push_back(item);
|
||||
|
||||
m_selection = items;
|
||||
m_notificationCenter->handleItemAppended(item);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionManager::appendItemToSelection(RiuSelectionItem* item)
|
||||
void RiuSelectionManager::setSelectedItem(RiuSelectionItem* item)
|
||||
{
|
||||
deleteAllItemsFromSelection();
|
||||
|
||||
m_selection.push_back(item);
|
||||
|
||||
m_notificationCenter->handleSetSelectedItem(item);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -61,12 +84,11 @@ void RiuSelectionManager::appendItemToSelection(RiuSelectionItem* item)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSelectionManager::deleteAllItems()
|
||||
{
|
||||
for (size_t i = 0; i < m_selection.size(); i++)
|
||||
{
|
||||
delete m_selection[i];
|
||||
}
|
||||
if (m_selection.size() == 0) return;
|
||||
|
||||
m_selection.clear();
|
||||
deleteAllItemsFromSelection();
|
||||
|
||||
m_notificationCenter->handleSelectionDeleted();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -80,10 +102,38 @@ bool RiuSelectionManager::isEmpty() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, cvf::Color3f color)
|
||||
void RiuSelectionManager::deleteAllItemsFromSelection()
|
||||
{
|
||||
for (size_t i = 0; i < m_selection.size(); i++)
|
||||
{
|
||||
delete m_selection[i];
|
||||
}
|
||||
|
||||
m_selection.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, size_t nncIndex, cvf::Color3f color, cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPoint)
|
||||
: m_view(view),
|
||||
m_gridIndex(gridIndex),
|
||||
m_cellIndex(cellIndex),
|
||||
m_color(color)
|
||||
m_nncIndex(nncIndex),
|
||||
m_color(color),
|
||||
m_face(face),
|
||||
m_localIntersectionPoint(localIntersectionPoint)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, size_t gridIndex, size_t cellIndex, cvf::Color3f color, const cvf::Vec3d& localIntersectionPoint)
|
||||
: m_view(view),
|
||||
m_gridIndex(gridIndex),
|
||||
m_cellIndex(cellIndex),
|
||||
m_color(color),
|
||||
m_localIntersectionPoint(localIntersectionPoint)
|
||||
{
|
||||
}
|
||||
|
@ -18,16 +18,20 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfColor3.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
class RimEclipseView;
|
||||
|
||||
class RiuSelectionChangedHandler;
|
||||
class RiuSelectionItem;
|
||||
class RimGeoMechView;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -37,27 +41,35 @@ class RiuSelectionItem;
|
||||
class RiuSelectionManager
|
||||
{
|
||||
public:
|
||||
RiuSelectionManager();
|
||||
~RiuSelectionManager();
|
||||
|
||||
static RiuSelectionManager* instance();
|
||||
|
||||
// Returns selected items
|
||||
// Selection manager owns the selection items and is responsible for delete
|
||||
// Selection manager owns the selection items
|
||||
void selectedItems(std::vector<RiuSelectionItem*>& items) const;
|
||||
|
||||
// Set vector of items as selected items in SelectionManager
|
||||
// SelectionManager takes ownership of the selection items
|
||||
void setSelectedItems(const std::vector<RiuSelectionItem*>& items);
|
||||
|
||||
// Append item to selected items in SelectionManager
|
||||
// Append item to selected items
|
||||
// SelectionManager takes ownership of the item
|
||||
void appendItemToSelection(RiuSelectionItem* item);
|
||||
|
||||
// Set one selected item
|
||||
// SelectionManager takes ownership of the item
|
||||
void setSelectedItem(RiuSelectionItem* item);
|
||||
|
||||
// Deletes all items in the SelectionManager
|
||||
void deleteAllItems();
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
private:
|
||||
void deleteAllItemsFromSelection();
|
||||
|
||||
private:
|
||||
std::vector < RiuSelectionItem* > m_selection;
|
||||
|
||||
RiuSelectionChangedHandler* m_notificationCenter;
|
||||
};
|
||||
|
||||
|
||||
@ -79,7 +91,7 @@ public:
|
||||
RiuSelectionItem() {}
|
||||
virtual ~RiuSelectionItem() {};
|
||||
|
||||
virtual RiuSelectionType type() = 0;
|
||||
virtual RiuSelectionType type() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -91,10 +103,12 @@ public:
|
||||
class RiuEclipseSelectionItem : public RiuSelectionItem
|
||||
{
|
||||
public:
|
||||
explicit RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, cvf::Color3f color);
|
||||
explicit RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, size_t nncIndex,
|
||||
cvf::Color3f color, cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPoint);
|
||||
|
||||
virtual ~RiuEclipseSelectionItem() {};
|
||||
|
||||
virtual RiuSelectionType type()
|
||||
virtual RiuSelectionType type() const
|
||||
{
|
||||
return ECLIPSE_SELECTION_OBJECT;
|
||||
}
|
||||
@ -103,7 +117,34 @@ public:
|
||||
caf::PdmPointer<RimEclipseView> m_view;
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
size_t m_nncIndex;
|
||||
cvf::Color3f m_color;
|
||||
cvf::StructGridInterface::FaceType m_face;
|
||||
cvf::Vec3d m_localIntersectionPoint;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuGeoMechSelectionItem : public RiuSelectionItem
|
||||
{
|
||||
public:
|
||||
explicit RiuGeoMechSelectionItem(RimGeoMechView* view, size_t gridIndex, size_t cellIndex, cvf::Color3f color, const cvf::Vec3d& localIntersectionPoint);
|
||||
virtual ~RiuGeoMechSelectionItem() {};
|
||||
|
||||
virtual RiuSelectionType type() const
|
||||
{
|
||||
return GEOMECH_SELECTION_OBJECT;
|
||||
}
|
||||
|
||||
public:
|
||||
caf::PdmPointer<RimGeoMechView> m_view;
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
cvf::Color3f m_color;
|
||||
cvf::Vec3d m_localIntersectionPoint;
|
||||
};
|
||||
|
||||
|
@ -25,14 +25,12 @@
|
||||
#include "Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h"
|
||||
#include "Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigTimeHistoryResultAccessor.h"
|
||||
|
||||
#include "RigFemTimeHistoryResultAccessor.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
@ -46,7 +44,6 @@
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
@ -55,12 +52,9 @@
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "RiuFemResultTextBuilder.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuResultTextBuilder.h"
|
||||
#include "RiuSelectionColors.h"
|
||||
#include "RiuSelectionManager.h"
|
||||
#include "RiuTimeHistoryQwtPlot.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
@ -347,7 +341,6 @@ void RiuViewerCommands::createSliceRangeFilter(int ijOrk)
|
||||
eclipseView->setSurfaceDrawstyle();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -458,8 +451,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
wellPath = wellPathSourceInfo->wellPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (firstNncHitPart && firstNncHitPart->sourceInfo())
|
||||
{
|
||||
@ -474,186 +465,55 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Compose a info text regarding the hit
|
||||
|
||||
QString pickInfo = "No hits";
|
||||
QString resultInfo = "";
|
||||
|
||||
if (cellIndex != cvf::UNDEFINED_SIZE_T || nncIndex != cvf::UNDEFINED_SIZE_T)
|
||||
if (cellIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
||||
|
||||
if (eclipseView)
|
||||
RiuSelectionManager::instance()->deleteAllItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
bool appendToSelection = false;
|
||||
if (keyboardModifiers & Qt::ControlModifier)
|
||||
{
|
||||
RiuResultTextBuilder textBuilder(eclipseView, gridIndex, cellIndex, eclipseView->currentTimeStep());
|
||||
textBuilder.setFace(face);
|
||||
textBuilder.setNncIndex(nncIndex);
|
||||
textBuilder.setIntersectionPoint(localIntersectionPoint);
|
||||
|
||||
resultInfo = textBuilder.mainResultText();
|
||||
|
||||
pickInfo = textBuilder.topologyText(", ");
|
||||
|
||||
addTimeHistoryCurve(eclipseView, gridIndex, cellIndex, keyboardModifiers);
|
||||
appendToSelection = true;
|
||||
}
|
||||
else if (geomView)
|
||||
|
||||
cvf::Color3f curveColor = RiuSelectionColors::curveColorFromTable();
|
||||
if (RiuSelectionManager::instance()->isEmpty() || !appendToSelection)
|
||||
{
|
||||
RiuFemResultTextBuilder textBuilder(geomView, (int)gridIndex, (int)cellIndex, geomView->currentTimeStep());
|
||||
//textBuilder.setFace(face);
|
||||
|
||||
textBuilder.setIntersectionPoint(localIntersectionPoint);
|
||||
curveColor = RiuSelectionColors::singleCurveColor();
|
||||
}
|
||||
|
||||
resultInfo = textBuilder.mainResultText();
|
||||
RiuSelectionItem* selItem = NULL;
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if (eclipseView)
|
||||
{
|
||||
selItem = new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, nncIndex, curveColor, face, localIntersectionPoint);
|
||||
}
|
||||
|
||||
pickInfo = textBuilder.topologyText(", ");
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
||||
if (geomView)
|
||||
{
|
||||
selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, localIntersectionPoint);
|
||||
}
|
||||
}
|
||||
|
||||
addTimeHistoryCurve(geomView, gridIndex, cellIndex, localIntersectionPoint, keyboardModifiers);
|
||||
if (appendToSelection)
|
||||
{
|
||||
RiuSelectionManager::instance()->appendItemToSelection(selItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuSelectionManager::instance()->setSelectedItem(selItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wellPath)
|
||||
{
|
||||
pickInfo = QString("Well path hit: %1").arg(wellPath->name());
|
||||
}
|
||||
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (cellIndex == cvf::UNDEFINED_SIZE_T &&
|
||||
!(keyboardModifiers & Qt::ControlModifier))
|
||||
{
|
||||
if (mainWnd->timeHistoryPlot()->isVisible())
|
||||
{
|
||||
// Delete all curves if no cell is hit
|
||||
mainWnd->timeHistoryPlot()->deleteAllCurves();
|
||||
|
||||
RiuSelectionManager::instance()->deleteAllItems();
|
||||
|
||||
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
mainWnd->statusBar()->showMessage(pickInfo);
|
||||
mainWnd->setResultInfo(resultInfo);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::addTimeHistoryCurve(RimEclipseView* eclipseView, size_t gridIndex, size_t cellIndex, Qt::KeyboardModifiers keyboardModifiers)
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (!mainWnd->timeHistoryPlot()->isVisible()) return;
|
||||
|
||||
if (eclipseView->cellResult()->hasDynamicResult() &&
|
||||
eclipseView->eclipseCase() &&
|
||||
eclipseView->eclipseCase()->reservoirData())
|
||||
{
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(eclipseView->cellResult()->porosityModel());
|
||||
|
||||
size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T;
|
||||
eclipseView->eclipseCase()->reservoirData()->results(porosityModel)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount);
|
||||
std::vector<QDateTime> timeStepDates = eclipseView->eclipseCase()->reservoirData()->results(porosityModel)->timeStepDates(scalarIndexWithMaxTimeStepCount);
|
||||
|
||||
RigTimeHistoryResultAccessor timeHistResultAccessor(eclipseView->eclipseCase()->reservoirData(), gridIndex, cellIndex, eclipseView->cellResult()->scalarResultIndex(), porosityModel);
|
||||
|
||||
QString curveName = eclipseView->eclipseCase()->caseUserDescription();
|
||||
curveName += ", ";
|
||||
curveName += eclipseView->cellResult()->resultVariable();
|
||||
curveName += ", ";
|
||||
curveName += QString("Grid index %1").arg(gridIndex);
|
||||
curveName += ", ";
|
||||
curveName += timeHistResultAccessor.topologyText();
|
||||
|
||||
std::vector<double> timeHistoryValues = timeHistResultAccessor.timeHistoryValues();
|
||||
CVF_ASSERT(timeStepDates.size() == timeHistoryValues.size());
|
||||
|
||||
|
||||
std::vector<RiuSelectionItem*> items;
|
||||
RiuSelectionManager::instance()->selectedItems(items);
|
||||
|
||||
bool isItemPartOfSelection = false;
|
||||
for (size_t i = 0; i < items.size(); i++)
|
||||
{
|
||||
RiuEclipseSelectionItem* eclSelItem = dynamic_cast<RiuEclipseSelectionItem*>(items[i]);
|
||||
if (eclSelItem &&
|
||||
eclSelItem->m_view == eclipseView &&
|
||||
eclSelItem->m_gridIndex == gridIndex &&
|
||||
eclSelItem->m_cellIndex == cellIndex)
|
||||
{
|
||||
isItemPartOfSelection = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isItemPartOfSelection)
|
||||
{
|
||||
if (!(keyboardModifiers & Qt::ControlModifier))
|
||||
{
|
||||
mainWnd->timeHistoryPlot()->deleteAllCurves();
|
||||
RiuSelectionManager::instance()->deleteAllItems();
|
||||
}
|
||||
|
||||
cvf::Color3f curveColor = RiuSelectionColors::curveColorFromTable();
|
||||
if (RiuSelectionManager::instance()->isEmpty())
|
||||
{
|
||||
curveColor = RiuSelectionColors::singleCurveColor();
|
||||
}
|
||||
|
||||
RiuSelectionManager::instance()->appendItemToSelection(new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, curveColor));
|
||||
|
||||
mainWnd->timeHistoryPlot()->addCurve(curveName, curveColor, timeStepDates, timeHistoryValues);
|
||||
|
||||
eclipseView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::addTimeHistoryCurve(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex, const cvf::Vec3d& localIntersectionPoint, Qt::KeyboardModifiers keyboardModifiers)
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (!mainWnd->timeHistoryPlot()->isVisible()) return;
|
||||
|
||||
if (geoMechView &&
|
||||
geoMechView->cellResult() &&
|
||||
geoMechView->cellResult()->hasResult() &&
|
||||
geoMechView->geoMechCase() &&
|
||||
geoMechView->geoMechCase()->geoMechData())
|
||||
{
|
||||
RigFemTimeHistoryResultAccessor timeHistResultAccessor(geoMechView->geoMechCase()->geoMechData(), geoMechView->cellResult->resultAddress(), gridIndex, cellIndex, localIntersectionPoint);
|
||||
|
||||
QString curveName;
|
||||
curveName.append(geoMechView->geoMechCase()->caseUserDescription() + ", ");
|
||||
|
||||
caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = geoMechView->cellResult()->resultPositionType();
|
||||
curveName.append(resPosAppEnum.uiText() + ", ");
|
||||
curveName.append(geoMechView->cellResult()->resultFieldUiName()+ ", ") ;
|
||||
curveName.append(geoMechView->cellResult()->resultComponentUiName() + ":\n");
|
||||
curveName.append(timeHistResultAccessor.topologyText());
|
||||
|
||||
std::vector<double> timeHistoryValues = timeHistResultAccessor.timeHistoryValues();
|
||||
std::vector<double> frameTimes;
|
||||
for (size_t i = 0; i < timeHistoryValues.size(); i++)
|
||||
{
|
||||
frameTimes.push_back(i);
|
||||
}
|
||||
|
||||
CVF_ASSERT(frameTimes.size() == timeHistoryValues.size());
|
||||
|
||||
cvf::Color3f curveColor = RiuSelectionColors::curveColorFromTable();
|
||||
QString pickInfo = QString("Well path hit: %1").arg(wellPath->name());
|
||||
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
|
||||
if (!(keyboardModifiers & Qt::ControlModifier))
|
||||
{
|
||||
mainWnd->timeHistoryPlot()->deleteAllCurves();
|
||||
RiuSelectionManager::instance()->deleteAllItems();
|
||||
}
|
||||
|
||||
mainWnd->timeHistoryPlot()->addCurve(curveName, curveColor, frameTimes, timeHistoryValues);
|
||||
mainWnd->statusBar()->showMessage(pickInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,8 +63,6 @@ private:
|
||||
void createSliceRangeFilter(int ijOrk);
|
||||
void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
void updateSelectionFromPickedPart(cvf::Part* part);
|
||||
void addTimeHistoryCurve(RimEclipseView* eclipseView, size_t gridIndex, size_t cellIndex, Qt::KeyboardModifiers keyboardModifiers);
|
||||
void addTimeHistoryCurve(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex, const cvf::Vec3d& localIntersectionPoint, Qt::KeyboardModifiers keyboardModifiers);
|
||||
|
||||
size_t m_currentGridIdx;
|
||||
size_t m_currentCellIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user