From 8eb8a6fd3ba3cde1fa290857d522d31543508d58 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 22 Feb 2017 13:09:31 +0100 Subject: [PATCH] #1248 Add namedObject and checkableNamedObject --- .../ProjectDataModel/CMakeLists_files.cmake | 4 ++ .../RimCheckableNamedObject.cpp | 61 +++++++++++++++++++ .../RimCheckableNamedObject.h | 43 +++++++++++++ .../ProjectDataModel/RimNamedObject.cpp | 61 +++++++++++++++++++ .../ProjectDataModel/RimNamedObject.h | 46 ++++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 ApplicationCode/ProjectDataModel/RimCheckableNamedObject.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimCheckableNamedObject.h create mode 100644 ApplicationCode/ProjectDataModel/RimNamedObject.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimNamedObject.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index ce7dd882ca..545016dacb 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -85,6 +85,8 @@ ${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h ${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h ${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h ${CEE_CURRENT_LIST_DIR}RimPropertyFilter.h +${CEE_CURRENT_LIST_DIR}RimNamedObject.h +${CEE_CURRENT_LIST_DIR}RimCheckableNamedObject.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -168,6 +170,8 @@ ${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp ${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp ${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp ${CEE_CURRENT_LIST_DIR}RimPropertyFilter.cpp +${CEE_CURRENT_LIST_DIR}RimNamedObject.cpp +${CEE_CURRENT_LIST_DIR}RimCheckableNamedObject.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimCheckableNamedObject.cpp b/ApplicationCode/ProjectDataModel/RimCheckableNamedObject.cpp new file mode 100644 index 0000000000..e69ba1e3e9 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCheckableNamedObject.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimCheckableNamedObject.h" + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCheckableNamedObject, "CheckableNamedObject"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCheckableNamedObject::RimCheckableNamedObject(void) +{ + CAF_PDM_InitField(&m_isChecked, "IsChecked", true, "Active", "", "", ""); + m_isChecked.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCheckableNamedObject::~RimCheckableNamedObject(void) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCheckableNamedObject::isChecked() const +{ + return m_isChecked(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCheckableNamedObject::setCheckState(bool checkState) +{ + m_isChecked = checkState; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCheckableNamedObject::objectToggleField() +{ + return &m_isChecked; +} diff --git a/ApplicationCode/ProjectDataModel/RimCheckableNamedObject.h b/ApplicationCode/ProjectDataModel/RimCheckableNamedObject.h new file mode 100644 index 0000000000..2bcfa73d58 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCheckableNamedObject.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimNamedObject.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCheckableNamedObject : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; +public: + RimCheckableNamedObject(void); + virtual ~RimCheckableNamedObject(void); + + bool isChecked() const; + void setCheckState(bool checkState); + +protected: + virtual caf::PdmFieldHandle* objectToggleField() override; + +private: + caf::PdmField m_isChecked; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimNamedObject.cpp b/ApplicationCode/ProjectDataModel/RimNamedObject.cpp new file mode 100644 index 0000000000..674fc3ef45 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimNamedObject.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimNamedObject.h" + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimNamedObject, "NamedObject"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimNamedObject::RimNamedObject(void) +{ + CAF_PDM_InitField(&m_name, "Name", QString(), "Name", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimNamedObject::~RimNamedObject(void) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimNamedObject::name() const +{ + return m_name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimNamedObject::setName(const QString& name) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimNamedObject::userDescriptionField() +{ + return &m_name; +} diff --git a/ApplicationCode/ProjectDataModel/RimNamedObject.h b/ApplicationCode/ProjectDataModel/RimNamedObject.h new file mode 100644 index 0000000000..4836df2b75 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimNamedObject.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmField.h" + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimNamedObject : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimNamedObject(void); + virtual ~RimNamedObject(void); + + QString name() const; + void setName(const QString& name); + +protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; + +private: + caf::PdmField m_name; +}; +