#4513 Add id to views

This commit is contained in:
Gaute Lindkvist 2019-07-15 11:43:22 +02:00
parent 439913b7b1
commit b7c4a54d9a
7 changed files with 97 additions and 17 deletions

View File

@ -204,16 +204,18 @@ public:
public:
void readFieldData (QTextStream& inputStream, caf::PdmObjectFactory* objectFactory, RicfMessages* errorMessageContainer) override
{
//m_field->xmlCapability()->assertValid();
typename FieldType::FieldDataType value;
RicfFieldReader<typename FieldType::FieldDataType>::readFieldData(value, inputStream, errorMessageContainer);
m_field->setValue(value);
typename FieldType::FieldDataType value;
RicfFieldReader<typename FieldType::FieldDataType>::readFieldData(value, inputStream, errorMessageContainer);
if (this->isIOWriteable())
{
m_field->setValue(value);
}
}
void writeFieldData(QTextStream& outputStream) const override
{
//m_field->xmlCapability()->assertValid();
RicfFieldWriter<typename FieldType::FieldDataType>::writeFieldData(m_field->value(), outputStream);
{
RicfFieldWriter<typename FieldType::FieldDataType>::writeFieldData(m_field->value(), outputStream);
}
private:

View File

@ -26,6 +26,7 @@
//--------------------------------------------------------------------------------------------------
RicfFieldHandle::RicfFieldHandle(caf::PdmFieldHandle* owner, bool giveOwnership)
{
m_IOWriteable = true;
m_owner = owner;
owner->addCapability(this, giveOwnership);
}

View File

@ -37,10 +37,19 @@ class QTextStream;
class RicfFieldHandle : public caf::PdmFieldCapability
{
public:
RicfFieldHandle(caf::PdmFieldHandle* owner , bool giveOwnership);
RicfFieldHandle(caf::PdmFieldHandle* owner, bool giveOwnership);
~RicfFieldHandle() override;
bool isIOWriteable() const
{
return m_IOWriteable;
}
void setIOWriteable(bool writeable)
{
m_IOWriteable = writeable;
}
virtual void readFieldData (QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer ) = 0;
@ -48,6 +57,7 @@ public:
private:
caf::PdmFieldHandle* m_owner;
bool m_IOWriteable;
};

View File

@ -118,11 +118,15 @@ Rim3dView::Rim3dView(void)
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", "");
RICF_InitField(&m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "");
CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", "");
CAF_PDM_InitField(&m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "");
RICF_InitField(&m_viewId, "ViewId", -1, "View ID", "", "", "");
m_viewId.uiCapability()->setUiReadOnly(true);
m_viewId.capability<RicfFieldHandle>()->setIOWriteable(false);
m_crossSectionVizModel = new cvf::ModelBasicList;
m_crossSectionVizModel->setName("CrossSectionModel");
@ -180,6 +184,22 @@ QString Rim3dView::name() const
return m_nameConfig->customName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int Rim3dView::id() const
{
return m_viewId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::setId(int id)
{
m_viewId = id;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -283,6 +303,8 @@ void Rim3dView::deleteViewWidget()
//--------------------------------------------------------------------------------------------------
void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_viewId);
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroupWithKeyword("Viewer", "ViewGroup");
viewGroup->add(&m_backgroundColor);

View File

@ -105,6 +105,10 @@ public:
void setName(const QString& name);
QString name() const;
int id() const;
void setId(int id);
// Implementation of RiuViewerToViewInterface
cvf::Color3f backgroundColor() const override { return m_backgroundColor(); }
@ -260,4 +264,5 @@ private:
caf::PdmField< cvf::Color3f > m_backgroundColor;
caf::PdmField<bool> m_showGridBox;
caf::PdmField<bool> m_showZScaleLabel;
caf::PdmField<int> m_viewId;
};

View File

@ -109,6 +109,9 @@ RimProject::RimProject(void)
CAF_PDM_InitField(&nextValidCaseGroupId, "NextValidCaseGroupId", 0, "Next Valid Case Group ID", "", "" ,"");
nextValidCaseGroupId.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&nextValidViewId, "NextValidViewId", 0, "Next Valid View ID", "", "", "");
nextValidViewId.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&oilFields, "OilFields", "Oil Fields", "", "", "");
oilFields.uiCapability()->setUiHidden(true);
@ -228,6 +231,7 @@ void RimProject::close()
nextValidCaseId = 0;
nextValidCaseGroupId = 0;
nextValidViewId = 0;
mainWindowCurrentModelIndexPath = "";
mainWindowTreeViewState = "";
plotWindowCurrentModelIndexPath = "";
@ -246,22 +250,22 @@ void RimProject::initScriptDirectories(const QString& scriptDirectories)
// Find largest used caseId read from file and make sure all cases have a valid caseId
{
int largestId = -1;
int largestCaseId = -1;
std::vector<RimCase*> cases;
allCases(cases);
for (size_t i = 0; i < cases.size(); i++)
{
if (cases[i]->caseId > largestId)
if (cases[i]->caseId > largestCaseId)
{
largestId = cases[i]->caseId;
largestCaseId = cases[i]->caseId;
}
}
if (largestId > this->nextValidCaseId)
if (largestCaseId > this->nextValidCaseId)
{
this->nextValidCaseId = largestId + 1;
this->nextValidCaseId = largestCaseId + 1;
}
// Assign case Id to cases with an invalid case Id
@ -306,6 +310,28 @@ void RimProject::initScriptDirectories(const QString& scriptDirectories)
}
}
}
int maxViewId = -1;
std::vector<Rim3dView*> views;
this->descendantsIncludingThisOfType(views);
for (Rim3dView* view : views)
{
maxViewId = std::max(maxViewId, view->id());
}
if (maxViewId >= this->nextValidViewId)
{
this->nextValidViewId = maxViewId + 1;
}
// Assign view id to views with invalid id
for (Rim3dView* view : views)
{
if (view->id() < 0)
{
assignViewIdToView(view);
}
}
}
@ -533,6 +559,18 @@ void RimProject::assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignViewIdToView(Rim3dView* view)
{
if (view)
{
view->setId(nextValidViewId);
nextValidViewId = nextValidViewId + 1;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -115,6 +115,7 @@ public:
void assignCaseIdToCase(RimCase* reservoirCase);
void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup);
void assignViewIdToView(Rim3dView* view);
void allCases(std::vector<RimCase*>& cases) const;
@ -196,8 +197,9 @@ private:
caf::PdmField<bool> m_subWindowsTiled3DWindow;
caf::PdmField<bool> m_subWindowsTiledPlotWindow;
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts
caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from scripts
caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from scripts
caf::PdmField<int> nextValidViewId; // Unique view ID within a project, used to identify a view from scripts
caf::PdmChildArrayField<RimEclipseCase*> casesObsolete; // obsolete
caf::PdmChildArrayField<RimIdenticalGridCaseGroup*> caseGroupsObsolete; // obsolete