mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#396) Create main plot collection and well log plot collection if needed
Reading old project files may give projects without main plot collection and well plot collection. Those are now created in the command feature for adding a new well log plot, if needed.
This commit is contained in:
parent
4618f50e9e
commit
27f8f34538
@ -30,6 +30,8 @@
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewWellLogPlotFeature, "RicNewWellLogPlotFeature");
|
||||
|
||||
@ -38,7 +40,7 @@ CAF_CMD_SOURCE_INIT(RicNewWellLogPlotFeature, "RicNewWellLogPlotFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewWellLogPlotFeature::isCommandEnabled()
|
||||
{
|
||||
return wellLogPlotCollection() != NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -47,20 +49,19 @@ bool RicNewWellLogPlotFeature::isCommandEnabled()
|
||||
void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
|
||||
if (wellLogPlotColl)
|
||||
{
|
||||
RimWellLogPlot* plot = new RimWellLogPlot();
|
||||
wellLogPlotColl->wellLogPlots().push_back(plot);
|
||||
CVF_ASSERT(wellLogPlotColl);
|
||||
|
||||
RimWellLogPlotTrace* plotrace = new RimWellLogPlotTrace();
|
||||
plot->addTrace(plotrace);
|
||||
RimWellLogPlot* plot = new RimWellLogPlot();
|
||||
wellLogPlotColl->wellLogPlots().push_back(plot);
|
||||
|
||||
RimWellLogPlotTrace* plotrace = new RimWellLogPlotTrace();
|
||||
plot->addTrace(plotrace);
|
||||
|
||||
plot->setDescription(QString("Well Log Plot %1").arg(wellLogPlotCollection()->wellLogPlots.size()));
|
||||
plot->loadDataAndUpdate();
|
||||
plot->setDescription(QString("Well Log Plot %1").arg(wellLogPlotCollection()->wellLogPlots.size()));
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
RiaApplication::instance()->project()->updateConnectedEditors();
|
||||
RiuMainWindow::instance()->setCurrentObjectInTreeView(plot);
|
||||
}
|
||||
RiaApplication::instance()->project()->updateConnectedEditors();
|
||||
RiuMainWindow::instance()->setCurrentObjectInTreeView(plot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -74,10 +75,33 @@ void RicNewWellLogPlotFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogPlotCollection* RicNewWellLogPlotFeature::wellLogPlotCollection()
|
||||
RimMainPlotCollection* RicNewWellLogPlotFeature::mainPlotCollection()
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
RimMainPlotCollection* mainPlotCollection = project ? project->mainPlotCollection() : NULL;
|
||||
CVF_ASSERT(project);
|
||||
|
||||
return mainPlotCollection ? mainPlotCollection->wellLogPlotCollection() : NULL;
|
||||
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
|
||||
if (!mainPlotColl)
|
||||
{
|
||||
project->recreateMainPlotCollection();
|
||||
}
|
||||
|
||||
return project->mainPlotCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogPlotCollection* RicNewWellLogPlotFeature::wellLogPlotCollection()
|
||||
{
|
||||
RimMainPlotCollection* mainPlotColl = mainPlotCollection();
|
||||
CVF_ASSERT(mainPlotColl);
|
||||
|
||||
RimWellLogPlotCollection* wellLogPlotColl = mainPlotColl->wellLogPlotCollection();
|
||||
if (!wellLogPlotColl)
|
||||
{
|
||||
mainPlotColl->recreateWellLogPlotCollection();
|
||||
}
|
||||
|
||||
return mainPlotColl->wellLogPlotCollection();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimMainPlotCollection;
|
||||
class RimWellLogPlotCollection;
|
||||
|
||||
//==================================================================================================
|
||||
@ -37,5 +38,6 @@ protected:
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimWellLogPlotCollection* wellLogPlotCollection();
|
||||
RimMainPlotCollection* mainPlotCollection();
|
||||
RimWellLogPlotCollection* wellLogPlotCollection();
|
||||
};
|
||||
|
@ -36,10 +36,10 @@ RimMainPlotCollection::RimMainPlotCollection()
|
||||
CAF_PDM_InitField(&show, "Show", true, "Show plots", "", "", "");
|
||||
show.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wellLogPlotCollection, "WellLogPlotCollection", "", "", "", "");
|
||||
wellLogPlotCollection.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellLogPlotCollection, "WellLogPlotCollection", "", "", "", "");
|
||||
m_wellLogPlotCollection.uiCapability()->setUiHidden(true);
|
||||
|
||||
wellLogPlotCollection = new RimWellLogPlotCollection();
|
||||
m_wellLogPlotCollection = new RimWellLogPlotCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -47,7 +47,7 @@ RimMainPlotCollection::RimMainPlotCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimMainPlotCollection::~RimMainPlotCollection()
|
||||
{
|
||||
if (wellLogPlotCollection()) delete wellLogPlotCollection();
|
||||
if (m_wellLogPlotCollection()) delete m_wellLogPlotCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -64,3 +64,22 @@ caf::PdmFieldHandle* RimMainPlotCollection::objectToggleField()
|
||||
{
|
||||
return &show;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::recreateWellLogPlotCollection()
|
||||
{
|
||||
if (!wellLogPlotCollection())
|
||||
{
|
||||
m_wellLogPlotCollection = new RimWellLogPlotCollection();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogPlotCollection* RimMainPlotCollection::wellLogPlotCollection()
|
||||
{
|
||||
return m_wellLogPlotCollection();
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
RimMainPlotCollection();
|
||||
virtual ~RimMainPlotCollection();
|
||||
|
||||
caf::PdmChildField<RimWellLogPlotCollection*> wellLogPlotCollection;
|
||||
RimWellLogPlotCollection* wellLogPlotCollection();
|
||||
void recreateWellLogPlotCollection();
|
||||
|
||||
protected:
|
||||
|
||||
@ -46,7 +47,8 @@ protected:
|
||||
|
||||
private:
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
|
||||
private:
|
||||
caf::PdmChildField<RimWellLogPlotCollection*> m_wellLogPlotCollection;
|
||||
caf::PdmField<bool> show;
|
||||
};
|
||||
|
@ -937,3 +937,14 @@ RimLinkedViews* RimProject::findLinkedViewsGroupForView(RimView* view)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::recreateMainPlotCollection()
|
||||
{
|
||||
if (!mainPlotCollection())
|
||||
{
|
||||
mainPlotCollection = new RimMainPlotCollection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
void actionsBasedOnSelection(QMenu& contextMenu);
|
||||
|
||||
RimLinkedViews* findLinkedViewsGroupForView(RimView* view);
|
||||
void recreateMainPlotCollection();
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
|
Loading…
Reference in New Issue
Block a user