mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Integrated changes for framework
Pdm fields can contain a forward declared Pdm object without the include file VizFwk: Added VertexColoring shader to be able to use per vertex color used from drawableGeo::setColorArray()
This commit is contained in:
@@ -31,5 +31,6 @@ add_library( ${PROJECT_NAME}
|
||||
cafPdmUiOrdering.h
|
||||
cafPdmUiTreeOrdering.cpp
|
||||
cafPdmUiTreeOrdering.h
|
||||
|
||||
cafPdmUiTreeEditorHandle.h
|
||||
cafPdmUiTreeEditorHandle.cpp
|
||||
)
|
||||
|
||||
@@ -171,7 +171,7 @@ class PdmField <DataType*> : public PdmFieldHandle
|
||||
{
|
||||
typedef DataType* DataTypePtr;
|
||||
public:
|
||||
PdmField() : PdmFieldHandle() { m_fieldValue = NULL; }
|
||||
PdmField() : PdmFieldHandle() { }
|
||||
PdmField(const PdmField& other);
|
||||
PdmField(const DataTypePtr& fieldValue);
|
||||
virtual ~PdmField();
|
||||
|
||||
@@ -292,7 +292,7 @@ void caf::PdmField<DataType*>::readFieldData(QXmlStreamReader& xmlStream)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dynamic_cast<DataType *>(obj) == NULL)
|
||||
if (obj->classKeyword() != className)
|
||||
{
|
||||
assert(false); // Inconsistency in the factory. It creates objects of wrong type from the ClassKeyword
|
||||
|
||||
@@ -341,7 +341,7 @@ void caf::PdmField<DataType*>::readFieldData(QXmlStreamReader& xmlStream)
|
||||
template<typename DataType >
|
||||
void caf::PdmField<DataType*>::writeFieldData(QXmlStreamWriter& xmlStream)
|
||||
{
|
||||
if (m_fieldValue == NULL) return;
|
||||
if (m_fieldValue.rawPtr() == NULL) return;
|
||||
|
||||
QString className = m_fieldValue.rawPtr()->classKeyword();
|
||||
|
||||
@@ -397,7 +397,7 @@ template<typename DataType >
|
||||
caf::PdmField<DataType*>::~PdmField()
|
||||
{
|
||||
if (!m_fieldValue.isNull()) m_fieldValue.rawPtr()->removeParentField(this);
|
||||
m_fieldValue = NULL;
|
||||
m_fieldValue.setRawPtr(NULL);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -553,7 +553,6 @@ size_t PdmPointersField<DataType*>::count(const DataType* pointer) const
|
||||
template<typename DataType>
|
||||
void PdmPointersField<DataType*>::clear()
|
||||
{
|
||||
|
||||
this->removeThisAsParentField();
|
||||
m_pointers.clear();
|
||||
}
|
||||
@@ -567,7 +566,7 @@ void PdmPointersField<DataType*>::deleteAllChildObjects()
|
||||
size_t index;
|
||||
for (index = 0; index < m_pointers.size(); ++index)
|
||||
{
|
||||
delete(m_pointers[index]);
|
||||
delete(m_pointers[index].rawPtr());
|
||||
}
|
||||
|
||||
m_pointers.clear();
|
||||
@@ -579,7 +578,11 @@ void PdmPointersField<DataType*>::deleteAllChildObjects()
|
||||
template<typename DataType>
|
||||
void PdmPointersField<DataType*>::erase(size_t index)
|
||||
{
|
||||
if (m_pointers[index]) m_pointers[index]->removeParentField(this);
|
||||
if (m_pointers[index])
|
||||
{
|
||||
m_pointers[index]->removeParentField(this);
|
||||
}
|
||||
|
||||
m_pointers.erase(m_pointers.begin() + index);
|
||||
}
|
||||
|
||||
@@ -589,21 +592,23 @@ void PdmPointersField<DataType*>::erase(size_t index)
|
||||
template<typename DataType>
|
||||
void PdmPointersField<DataType*>::removeChildObject(PdmObject* object)
|
||||
{
|
||||
DataType* pointer = dynamic_cast<DataType*>(object);
|
||||
|
||||
size_t index;
|
||||
std::vector< PdmPointer<DataType> > tempPointers;
|
||||
|
||||
tempPointers = m_pointers;
|
||||
m_pointers.clear();
|
||||
for (index = 0; index < tempPointers.size(); ++index)
|
||||
|
||||
for (size_t index = 0; index < tempPointers.size(); ++index)
|
||||
{
|
||||
if (tempPointers[index] != pointer)
|
||||
if (tempPointers[index].rawPtr() != object)
|
||||
{
|
||||
m_pointers.push_back(tempPointers[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tempPointers[index]) tempPointers[index]->removeParentField(this);
|
||||
if (tempPointers[index].rawPtr())
|
||||
{
|
||||
tempPointers[index].rawPtr()->removeParentField(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,12 +623,12 @@ template<typename DataType>
|
||||
typename std::vector< PdmPointer<DataType> >::iterator it;
|
||||
for (it = m_pointers.begin(); it != m_pointers.end(); ++it)
|
||||
{
|
||||
if (*it == NULL) continue;
|
||||
if (it->rawPtr() == NULL) continue;
|
||||
|
||||
QString className = (*it)->classKeyword();
|
||||
QString className = it->rawPtr()->classKeyword();
|
||||
|
||||
xmlStream.writeStartElement("", className);
|
||||
(*it)->writeFields(xmlStream);
|
||||
it->rawPtr()->writeFields(xmlStream);
|
||||
xmlStream.writeEndElement();
|
||||
}
|
||||
}
|
||||
@@ -661,9 +666,7 @@ template<typename DataType>
|
||||
continue;
|
||||
}
|
||||
|
||||
currentObject = dynamic_cast<DataType *> (obj);
|
||||
|
||||
if (currentObject == NULL)
|
||||
if (obj->classKeyword() != className)
|
||||
{
|
||||
assert(false); // There is an inconsistency in the factory. It creates objects of type not matching the ClassKeyword
|
||||
|
||||
@@ -678,8 +681,11 @@ template<typename DataType>
|
||||
continue;
|
||||
}
|
||||
|
||||
currentObject->readFields(xmlStream);
|
||||
this->push_back(currentObject);
|
||||
obj->readFields(xmlStream);
|
||||
|
||||
m_pointers.push_back(PdmPointer<DataType>());
|
||||
m_pointers.back().setRawPtr(obj);
|
||||
obj->addParentField(this);
|
||||
|
||||
// Jump off the end element, and head for next start element (or the final EndElement of the field)
|
||||
// Qt reports a character token between EndElements and StartElements so skip it
|
||||
@@ -700,7 +706,7 @@ void PdmPointersField<DataType*>::childObjects(std::vector<PdmObject*>* objects)
|
||||
size_t i;
|
||||
for (i = 0; i < m_pointers.size(); ++i)
|
||||
{
|
||||
objects->push_back(m_pointers[i]);
|
||||
objects->push_back(m_pointers[i].rawPtr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,7 +721,7 @@ void PdmPointersField<DataType*>::removeThisAsParentField()
|
||||
{
|
||||
if (!it->isNull())
|
||||
{
|
||||
(*it)->removeParentField(this);
|
||||
it->rawPtr()->removeParentField(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ PdmUiTreeOrdering* PdmObject::uiTreeOrdering(QString uiConfigName /*= ""*/)
|
||||
}
|
||||
}
|
||||
|
||||
expandUiTree(uiTreeOrdering, uiConfigName);
|
||||
addUiTreeChildren(uiTreeOrdering, uiConfigName);
|
||||
return uiTreeOrdering;
|
||||
}
|
||||
|
||||
@@ -429,13 +429,13 @@ PdmUiTreeOrdering* PdmObject::uiTreeOrdering(QString uiConfigName /*= ""*/)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmObject::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigName /*= "" */)
|
||||
void PdmObject::addUiTreeChildren(PdmUiTreeOrdering* root, QString uiConfigName /*= "" */)
|
||||
{
|
||||
if (!root) return;
|
||||
|
||||
if ( root->childCount() == 0)
|
||||
if ( root->childCount() == 0) // This means that no one has tried to expand it.
|
||||
{
|
||||
if (!root->isSubTreeDefined() && root->dataObject())
|
||||
if (!root->ignoreSubTree() && root->dataObject())
|
||||
{
|
||||
|
||||
if (root->m_field && !root->m_field->isUiChildrenHidden(uiConfigName))
|
||||
@@ -449,7 +449,7 @@ void PdmObject::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigName /*= "
|
||||
}
|
||||
else
|
||||
{
|
||||
root->dataObject()->defineUiTreeOrdering(*root, uiConfigName);
|
||||
root->object()->defineUiTreeOrdering(*root, uiConfigName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -457,9 +457,9 @@ void PdmObject::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigName /*= "
|
||||
for (int cIdx = 0; cIdx < root->childCount(); ++cIdx)
|
||||
{
|
||||
PdmUiTreeOrdering* child = dynamic_cast<PdmUiTreeOrdering*>(root->child(cIdx));
|
||||
if (!child->isSubTreeDefined())
|
||||
if (!child->ignoreSubTree())
|
||||
{
|
||||
expandUiTree(child);
|
||||
addUiTreeChildren(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ private:
|
||||
|
||||
private:
|
||||
/// Recursive function to traverse and create a Ui tree representation of the object hierarchy
|
||||
static void expandUiTree( PdmUiTreeOrdering* root, QString uiConfigName = "" );
|
||||
static void addUiTreeChildren( PdmUiTreeOrdering* root, QString uiConfigName = "" );
|
||||
|
||||
private:
|
||||
std::multiset<PdmFieldHandle*> m_parentFields;
|
||||
|
||||
@@ -59,6 +59,8 @@ QWidget* PdmUiObjectEditorHandle::getOrCreateWidget(QWidget* parent)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiObjectEditorHandle::setPdmObject(PdmObject* object)
|
||||
{
|
||||
cleanupBeforeSettingPdmObject();
|
||||
|
||||
this->bindToPdmItem(object);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual QWidget* createWidget(QWidget* parent) = 0;
|
||||
virtual void cleanupBeforeSettingPdmObject() {};
|
||||
|
||||
protected:
|
||||
QPointer<QWidget> m_widget;
|
||||
|
||||
76
Fwk/AppFwk/cafProjectDataModel/cafPdmUiTreeEditorHandle.cpp
Normal file
76
Fwk/AppFwk/cafProjectDataModel/cafPdmUiTreeEditorHandle.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafPdmUiTreeEditorHandle.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiTreeEditorHandle::getOrCreateWidget(QWidget* parent)
|
||||
{
|
||||
if (m_widget.isNull())
|
||||
{
|
||||
m_widget = this->createWidget(parent);
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeEditorHandle::setPdmItemRoot(PdmUiItem* root)
|
||||
{
|
||||
cleanupBeforeSettingPdmObject();
|
||||
|
||||
this->bindToPdmItem(root);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiItem* PdmUiTreeEditorHandle::pdmItemRoot()
|
||||
{
|
||||
return this->pdmItem();
|
||||
}
|
||||
|
||||
} //End of namespace caf
|
||||
|
||||
78
Fwk/AppFwk/cafProjectDataModel/cafPdmUiTreeEditorHandle.h
Normal file
78
Fwk/AppFwk/cafProjectDataModel/cafPdmUiTreeEditorHandle.h
Normal file
@@ -0,0 +1,78 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
#include "cafPdmUiEditorHandle.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class PdmObject;
|
||||
|
||||
//==================================================================================================
|
||||
/// Abstract class to handle editors for complete PdmObjects
|
||||
//==================================================================================================
|
||||
|
||||
class PdmUiTreeEditorHandle: public PdmUiEditorHandle
|
||||
{
|
||||
public:
|
||||
PdmUiTreeEditorHandle() {}
|
||||
~PdmUiTreeEditorHandle() {}
|
||||
|
||||
QWidget* getOrCreateWidget(QWidget* parent);
|
||||
QWidget* widget() { return m_widget; }
|
||||
|
||||
void setPdmItemRoot(PdmUiItem* root);
|
||||
PdmUiItem* pdmItemRoot();
|
||||
|
||||
protected:
|
||||
virtual QWidget* createWidget(QWidget* parent) = 0;
|
||||
virtual void cleanupBeforeSettingPdmObject() {};
|
||||
|
||||
protected:
|
||||
QPointer<QWidget> m_widget;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // End of namespace caf
|
||||
|
||||
@@ -65,7 +65,11 @@ namespace caf
|
||||
PdmUiTreeOrdering* PdmUiTreeOrdering::add(const QString & title, const QString& iconResourceName)
|
||||
{
|
||||
PdmUiTreeOrdering* to = new PdmUiTreeOrdering(this, -1, NULL);
|
||||
to->m_uiInfo = new PdmUiItemInfo(title, QIcon(iconResourceName));
|
||||
|
||||
to->m_uiItem = new PdmUiItem();
|
||||
to->m_uiItem->setUiName(title);
|
||||
to->m_uiItem->setUiIcon(QIcon(iconResourceName));
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
@@ -98,7 +102,7 @@ namespace caf
|
||||
{
|
||||
PdmUiTreeOrdering* child = dynamic_cast<PdmUiTreeOrdering*>(this->child(cIdx));
|
||||
|
||||
if (child->dataObject() == object)
|
||||
if (child->object() == object)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -112,15 +116,27 @@ namespace caf
|
||||
/// Creates an new PdmUiTreeOrdering item, and adds it to parent. If position is -1, it is added
|
||||
/// at the end of parents existing child list.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent /*= NULL*/, int position /*= -1*/, PdmObject* dataObject /*= NULL*/) : UiTreeItem< PdmPointer<PdmObject> >(parent, position, dataObject),
|
||||
PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent /*= NULL*/, int position /*= -1*/, PdmObject* dataObject /*= NULL*/) : PdmUiTreeItem(parent, position, this),
|
||||
m_field(NULL),
|
||||
m_uiInfo(NULL),
|
||||
m_forgetRemainingFields(false),
|
||||
m_isSubTreeDefined(false)
|
||||
m_isToIgnoreSubTree(false),
|
||||
m_uiItem(NULL),
|
||||
m_object(dataObject)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiTreeOrdering::~PdmUiTreeOrdering()
|
||||
{
|
||||
if (m_uiItem)
|
||||
{
|
||||
delete m_uiItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //End of namespace caf
|
||||
|
||||
@@ -49,16 +49,19 @@ namespace caf
|
||||
class PdmObject;
|
||||
class PdmFieldHandle;
|
||||
|
||||
//typedef UiTreeItem<PdmPointer<PdmObject> > PdmUiTreeItem;
|
||||
class PdmUiTreeOrdering;
|
||||
|
||||
typedef UiTreeItem<PdmUiTreeOrdering* > PdmUiTreeItem;
|
||||
|
||||
//==================================================================================================
|
||||
/// Class storing a tree structure representation of some PdmObject hierarchy to be used for tree views in the Gui
|
||||
//==================================================================================================
|
||||
|
||||
class PdmUiTreeOrdering : public UiTreeItem< PdmPointer<PdmObject> >
|
||||
class PdmUiTreeOrdering : public UiTreeItem< PdmUiTreeOrdering* >
|
||||
{
|
||||
public:
|
||||
PdmUiTreeOrdering(PdmUiTreeOrdering* parent = NULL, int position = -1, PdmObject* dataObject = NULL);
|
||||
~PdmUiTreeOrdering();
|
||||
|
||||
void add(PdmFieldHandle * field);
|
||||
void add(PdmObject* object);
|
||||
@@ -67,23 +70,26 @@ public:
|
||||
/// If the rest of the fields containing children is supposed to be omitted, setForgetRemainingFileds to true.
|
||||
void setForgetRemainingFields(bool val) { m_forgetRemainingFields = val; }
|
||||
/// To stop the tree generation at this level, setSubTreeDefined to true
|
||||
void setSubTreeDefined(bool isSubTreeDefined ) { m_isSubTreeDefined = isSubTreeDefined; }
|
||||
void setIgnoreSubTree(bool doIgnoreSubTree ) { m_isToIgnoreSubTree = doIgnoreSubTree; }
|
||||
|
||||
PdmObject* object() const { return m_object; }
|
||||
PdmFieldHandle* field() const { return m_field; }
|
||||
PdmUiItem* uiItem() const { return m_uiItem; }
|
||||
|
||||
private:
|
||||
friend class PdmObject;
|
||||
bool forgetRemainingFields() const { return m_forgetRemainingFields; }
|
||||
bool isSubTreeDefined() const { return m_isSubTreeDefined; }
|
||||
bool ignoreSubTree() const { return m_isToIgnoreSubTree; }
|
||||
bool containsField(const PdmFieldHandle* field);
|
||||
bool containsObject(const PdmObject* object);
|
||||
|
||||
private:
|
||||
PdmPointer<PdmObject> m_object;
|
||||
PdmFieldHandle* m_field;
|
||||
PdmUiItemInfo* m_uiInfo;
|
||||
PdmUiItem* m_uiItem;
|
||||
|
||||
bool m_forgetRemainingFields;
|
||||
bool m_isSubTreeDefined;
|
||||
bool m_isToIgnoreSubTree;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user