Skip to content

Commit

Permalink
(#632) Add Eclipse cell to selection and show in 3D view and time his…
Browse files Browse the repository at this point in the history
…tory plot

Consolidated remove of model based on name in RimView
Cleanup selection and time history plot when project is closed
  • Loading branch information
magnesj committed Nov 9, 2015
1 parent 963220d commit 7cd2cd0
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 46 deletions.
3 changes: 3 additions & 0 deletions ApplicationCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

#include "RiuMainWindow.h"
#include "RiuProcessMonitor.h"
#include "RiuSelectionManager.h"
#include "RiuViewer.h"

#include "cafAppEnum.h"
Expand Down Expand Up @@ -608,6 +609,8 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
}
}

RiuSelectionManager::instance()->deleteAllItems();

mainWnd->cleanupGuiBeforeProjectClose();

caf::EffectGenerator::clearEffectCache();
Expand Down
97 changes: 62 additions & 35 deletions ApplicationCode/ProjectDataModel/RimEclipseView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,42 @@

#include "RiaApplication.h"
#include "RiaPreferences.h"

#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"

#include "Rim3dOverlayInfoConfig.h"
#include "RimEclipseCase.h"
#include "RimCellEdgeColors.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimCellRangeFilterCollection.h"
#include "RimFaultCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseFaultColors.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RimFaultCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimEclipseCellColors.h"
#include "RimTernaryLegendConfig.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "RimWellPathCollection.h"

#include "RiuMainWindow.h"
#include "RiuSelectionManager.h"
#include "RiuViewer.h"

#include "RivReservoirPipesPartMgr.h"
#include "RivSingleCellPartGenerator.h"
#include "RivTernarySaturationOverlayItem.h"
#include "RivWellPathCollectionPartMgr.h"

#include "cafCadNavigation.h"
#include "cafCeetronPlusNavigation.h"
#include "cafFrameAnimationControl.h"
#include "cafPdmUiTreeOrdering.h"

#include "cvfDrawable.h"
#include "cvfModelBasicList.h"
Expand All @@ -61,9 +70,6 @@
#include <QMessageBox>

#include <limits.h>
#include "RimViewLinker.h"
#include "RimViewController.h"
#include "cafPdmUiTreeOrdering.h"



Expand Down Expand Up @@ -644,20 +650,8 @@ void RimEclipseView::updateCurrentTimeStep()
// Well pipes
// ----------
cvf::String wellPipeModelName = "WellPipeModel";
std::vector<cvf::Model*> wellPipeModels;
for (cvf::uint i = 0; i < frameScene->modelCount(); i++)
{
if (frameScene->model(i)->name() == wellPipeModelName)
{
wellPipeModels.push_back(frameScene->model(i));
}
}

for (size_t i = 0; i < wellPipeModels.size(); i++)
{
//printf("updateCurrentTimeStep: Remove WellPipeModel %i from frameScene, for frame %i\n", i, m_currentTimeStep.v());
frameScene->removeModel(wellPipeModels[i]);
}
this->removeModelByName(frameScene, wellPipeModelName);

cvf::ref<cvf::ModelBasicList> wellPipeModelBasicList = new cvf::ModelBasicList;
wellPipeModelBasicList->setName(wellPipeModelName);
Expand All @@ -680,6 +674,51 @@ void RimEclipseView::updateCurrentTimeStep()
mainGrid->characteristicIJCellSize(),
currentActiveCellInfo()->geometryBoundingBox(),
m_reservoirGridPartManager->scaleTransform());


{
// Actions related to highlight items in scene
//
// Removed highlight model by name
// Create new highlight model with name
// Create and add selected parts
// Modify with scaletransform()
// Add parts to model
// Add model to scene

cvf::String highlightModelName = "HighLightModel";

this->removeModelByName(frameScene, highlightModelName);

cvf::ref<cvf::ModelBasicList> highlightModelBasicList = new cvf::ModelBasicList;
highlightModelBasicList->setName(highlightModelName);

RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
std::vector<RiuSelectionItem*> items;
riuSelManager->selectedItems(items);
for (size_t i = 0; i < items.size(); i++)
{
RiuEclipseSelectionItem* eclipseSelItem = dynamic_cast<RiuEclipseSelectionItem*>(items[i]);
if (eclipseSelItem &&
eclipseSelItem->m_view)
{
CVF_ASSERT(eclipseSelItem->m_view->eclipseCase());
CVF_ASSERT(eclipseSelItem->m_view->eclipseCase()->reservoirData());

RivSingleCellPartGenerator partGen(eclipseSelItem->m_view->eclipseCase()->reservoirData(), eclipseSelItem->m_gridIndex, eclipseSelItem->m_cellIndex);

cvf::ref<cvf::Part> part = partGen.createPart(eclipseSelItem->m_color);
part->setTransform(this->scaleTransform());
part->setPriority(10000);

highlightModelBasicList->addPart(part.p());
}
}

highlightModelBasicList->updateBoundingBoxesRecursive();

frameScene->addModel(highlightModelBasicList.p());
}
}
}

Expand Down Expand Up @@ -1565,19 +1604,7 @@ void RimEclipseView::addWellPathsToScene(cvf::Scene* scene,
CVF_ASSERT(scaleTransform);

cvf::String wellPathModelName = "WellPathModel";
std::vector<cvf::Model*> wellPathModels;
for (cvf::uint i = 0; i < scene->modelCount(); i++)
{
if (scene->model(i)->name() == wellPathModelName)
{
wellPathModels.push_back(scene->model(i));
}
}

for (size_t i = 0; i < wellPathModels.size(); i++)
{
scene->removeModel(wellPathModels[i]);
}
this->removeModelByName(scene, wellPathModelName);

// Append static Well Paths to model
cvf::ref<cvf::ModelBasicList> wellPathModelBasicList = new cvf::ModelBasicList;
Expand Down
20 changes: 20 additions & 0 deletions ApplicationCode/ProjectDataModel/RimView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,23 @@ void RimView::replaceRangeFilterCollectionWithOverride()
this->uiCapability()->updateConnectedEditors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName)
{
std::vector<cvf::Model*> modelsToBeRemoved;
for (cvf::uint i = 0; i < scene->modelCount(); i++)
{
if (scene->model(i)->name() == modelName)
{
modelsToBeRemoved.push_back(scene->model(i));
}
}

for (size_t i = 0; i < modelsToBeRemoved.size(); i++)
{
scene->removeModel(modelsToBeRemoved[i]);
}
}

4 changes: 3 additions & 1 deletion ApplicationCode/ProjectDataModel/RimView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "cvfBase.h"
#include "cvfObject.h"


#include <QPointer>

class Rim3dOverlayInfoConfig;
Expand All @@ -49,6 +48,7 @@ namespace cvf
class BoundingBox;
class ModelBasicList;
class Scene;
class String;
class Transform;
}

Expand Down Expand Up @@ -151,6 +151,8 @@ class RimView : public caf::PdmObject
const cvf::BoundingBox& wellPathClipBoundingBox,
cvf::Transform* scaleTransform);

static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName);

virtual void createDisplayModel() = 0;
virtual void updateDisplayModelVisibility() = 0;
virtual void clampCurrentTimestep() = 0;
Expand Down
2 changes: 2 additions & 0 deletions ApplicationCode/UserInterface/RiuMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void RiuMainWindow::cleanupGuiBeforeProjectClose()

setPdmRoot(NULL);
setResultInfo("");

m_timeHistoryQwtPlot->deleteAllCurves();

if (m_pdmUiPropertyView)
{
Expand Down
8 changes: 8 additions & 0 deletions ApplicationCode/UserInterface/RiuSelectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ void RiuSelectionManager::setSelectedItems(const std::vector<RiuSelectionItem*>&
m_selection = items;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSelectionManager::appendItemToSelection(RiuSelectionItem* item)
{
m_selection.push_back(item);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions ApplicationCode/UserInterface/RiuSelectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class RiuSelectionManager
// SelectionManager takes ownership of the selection items
void setSelectedItems(const std::vector<RiuSelectionItem*>& items);

// Append item to selected items in SelectionManager
// SelectionManager takes ownership of the item
void appendItemToSelection(RiuSelectionItem* item);

// Deletes all items in the SelectionManager
void deleteAllItems();

Expand Down
7 changes: 3 additions & 4 deletions ApplicationCode/UserInterface/RiuTimeHistoryQwtPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RiuTimeHistoryQwtPlot::~RiuTimeHistoryQwtPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const cvf::Color3f& curveColor, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
{
CVF_ASSERT(dateTimes.size() == timeHistoryValues.size());

Expand Down Expand Up @@ -94,7 +94,6 @@ void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector
plotCurve->setLineSegmentStartStopIndices(filteredIntervals);
plotCurve->setTitle(curveName);

cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
plotCurve->setPen(QPen(QColor(curveColor.rByte(), curveColor.gByte(), curveColor.bByte())));

plotCurve->attach(this);
Expand All @@ -108,7 +107,7 @@ void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector<double>& frameTimes, const std::vector<double>& timeHistoryValues)
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const cvf::Color3f& curveColor, const std::vector<double>& frameTimes, const std::vector<double>& timeHistoryValues)
{
std::vector<QDateTime> dateTimes;

Expand All @@ -117,7 +116,7 @@ void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector
dateTimes.push_back(QwtDate::toDateTime(frameTimes[i]));
}

addCurve(curveName, dateTimes, timeHistoryValues);
addCurve(curveName, curveColor, dateTimes, timeHistoryValues);
}

//--------------------------------------------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions ApplicationCode/UserInterface/RiuTimeHistoryQwtPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
class QwtPlotCurve;
class QwtPlotGrid;

namespace cvf
{
class Color3f;
}

//==================================================================================================
//
//
Expand All @@ -35,8 +40,8 @@ class RiuTimeHistoryQwtPlot : public QwtPlot
RiuTimeHistoryQwtPlot(QWidget* parent = NULL);
virtual ~RiuTimeHistoryQwtPlot();

void addCurve(const QString& curveName, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
void addCurve(const QString& curveName, const std::vector<double>& frameTimes, const std::vector<double>& timeHistoryValues);
void addCurve(const QString& curveName, const cvf::Color3f& curveColor, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
void addCurve(const QString& curveName, const cvf::Color3f& curveColor, const std::vector<double>& frameTimes, const std::vector<double>& timeHistoryValues);

void deleteAllCurves();

Expand Down
41 changes: 37 additions & 4 deletions ApplicationCode/UserInterface/RiuViewerCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
#include <QMouseEvent>
#include <QStatusBar>
#include "RigFemTimeHistoryResultAccessor.h"
#include "RiuSelectionManager.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"

//==================================================================================================
//
Expand Down Expand Up @@ -531,6 +533,11 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
{
// Delete all curves if no cell is hit
mainWnd->timeHistoryPlot()->deleteAllCurves();

std::vector<RiuSelectionItem*> items;
RiuSelectionManager::instance()->deleteAllItems();

m_reservoirView->scheduleCreateDisplayModelAndRedraw();
}
}

Expand Down Expand Up @@ -567,10 +574,34 @@ void RiuViewerCommands::addTimeHistoryCurve(RimEclipseView* eclipseView, size_t
curveName += timeHistResultAccessor.topologyText();

std::vector<double> timeHistoryValues = timeHistResultAccessor.timeHistoryValues();

CVF_ASSERT(timeStepDates.size() == timeHistoryValues.size());

mainWnd->timeHistoryPlot()->addCurve(curveName, timeStepDates, timeHistoryValues);

cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();

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)
{
RiuSelectionManager::instance()->appendItemToSelection(new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, curveColor));

mainWnd->timeHistoryPlot()->addCurve(curveName, curveColor, timeStepDates, timeHistoryValues);

eclipseView->scheduleCreateDisplayModelAndRedraw();
}
}
}

Expand Down Expand Up @@ -607,9 +638,11 @@ void RiuViewerCommands::addTimeHistoryCurve(RimGeoMechView* geoMechView, size_t
}

CVF_ASSERT(frameTimes.size() == timeHistoryValues.size());

cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();

RiuMainWindow* mainWnd = RiuMainWindow::instance();
mainWnd->timeHistoryPlot()->addCurve(curveName, frameTimes, timeHistoryValues);
mainWnd->timeHistoryPlot()->addCurve(curveName, curveColor, frameTimes, timeHistoryValues);
}
}

Expand Down

0 comments on commit 7cd2cd0

Please sign in to comment.