From ba0ded23c3dbad08f29a4b2190c6fe104642042d Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Mar 2020 13:38:57 +0100 Subject: [PATCH] #5671 Move caf::PdmFieldScriptability into cafPdmCvf --- .../ProjectDataModel/Rim3dView.cpp | 1 + Fwk/AppFwk/cafPdmCvf/CMakeLists.txt | 3 + .../cafPdmFieldIOScriptabilityCvfColor3.cpp | 77 +++++++++++++++++++ .../cafPdmFieldIOScriptabilityCvfColor3.h | 55 +++++++++++++ .../cafPdmFieldIOScriptability.cpp | 36 --------- .../cafPdmFieldIOScriptability.h | 15 ---- 6 files changed, 136 insertions(+), 51 deletions(-) create mode 100644 Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.cpp create mode 100644 Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.h diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index b60d8cf7d5..c0187b8f4c 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -52,6 +52,7 @@ #include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" #include "cafPdmFieldIOScriptability.h" +#include "cafPdmFieldIOScriptabilityCvfColor3.h" #include "cvfCamera.h" #include "cvfModelBasicList.h" diff --git a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt index 2d065bc0b0..bc77a3eee2 100644 --- a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt +++ b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt @@ -28,6 +28,8 @@ add_library( ${PROJECT_NAME} cafPdmXmlColor3f.cpp cafPdmXmlColor3f.h cafPdmFieldCvfColor.h + cafPdmFieldIOScriptabilityCvfColor3.h + cafPdmFieldIOScriptabilityCvfColor3.cpp cafPdmCoreVec3d.h cafPdmUiCoreVec3d.cpp @@ -62,6 +64,7 @@ target_include_directories(${PROJECT_NAME} target_link_libraries ( ${PROJECT_NAME} cafUserInterface LibCore + cafPdmScripting ${QT_LIBRARIES} ) diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.cpp b/Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.cpp new file mode 100644 index 0000000000..8f5eec3c94 --- /dev/null +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.cpp @@ -0,0 +1,77 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) Ceetron Solutions 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 <> +// 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 <> +// for more details. +// +//################################################################################################## +#include "cafPdmFieldIOScriptabilityCvfColor3.h" + +#include + +using namespace caf; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmFieldScriptabilityIOHandler::writeToField(cvf::Color3f& fieldValue, + QTextStream& inputStream, + caf::PdmScriptIOMessages* errorMessageContainer, + bool stringsAreQuoted) +{ + QString fieldStringValue; + PdmFieldScriptabilityIOHandler::writeToField(fieldStringValue, + inputStream, + errorMessageContainer, + stringsAreQuoted); + + QColor qColor(fieldStringValue); + if (qColor.isValid()) + { + fieldValue = cvf::Color3f(qColor.redF(), qColor.greenF(), qColor.blueF()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmFieldScriptabilityIOHandler::readFromField(const cvf::Color3f& fieldValue, + QTextStream& outputStream, + bool quoteStrings, + bool quoteNonBuiltin) +{ + QColor qColor(fieldValue.rByte(), fieldValue.gByte(), fieldValue.bByte()); + QString fieldStringValue = qColor.name(); + PdmFieldScriptabilityIOHandler::readFromField(fieldStringValue, outputStream, quoteStrings); +} + + + diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.h b/Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.h new file mode 100644 index 0000000000..604815d553 --- /dev/null +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmFieldIOScriptabilityCvfColor3.h @@ -0,0 +1,55 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) Ceetron Solutions 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 <> +// 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 <> +// for more details. +// +//################################################################################################## +#include "cafPdmFieldIOScriptability.h" + +#include "cvfColor3.h" + + +namespace caf +{ +template <> +struct PdmFieldScriptabilityIOHandler +{ + static void writeToField(cvf::Color3f& fieldValue, + QTextStream& inputStream, + PdmScriptIOMessages* errorMessageContainer, + bool stringsAreQuoted = true); + static void readFromField(const cvf::Color3f& fieldValue, + QTextStream& outputStream, + bool quoteStrings = true, + bool quoteNonBuiltins = false); +}; +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.cpp b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.cpp index dfc76084e1..31a5eb258f 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.cpp +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.cpp @@ -35,8 +35,6 @@ //################################################################################################## #include "cafPdmFieldIOScriptability.h" -#include - using namespace caf; //-------------------------------------------------------------------------------------------------- @@ -185,37 +183,3 @@ void PdmFieldScriptabilityIOHandler::readFromField( const bool& fieldValu // Lower-case true/false is used in the documentation. outputStream << ( fieldValue ? "true" : "false" ); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmFieldScriptabilityIOHandler::writeToField( cvf::Color3f& fieldValue, - QTextStream& inputStream, - caf::PdmScriptIOMessages* errorMessageContainer, - bool stringsAreQuoted ) -{ - QString fieldStringValue; - PdmFieldScriptabilityIOHandler::writeToField( fieldStringValue, - inputStream, - errorMessageContainer, - stringsAreQuoted ); - - QColor qColor( fieldStringValue ); - if ( qColor.isValid() ) - { - fieldValue = cvf::Color3f( qColor.redF(), qColor.greenF(), qColor.blueF() ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmFieldScriptabilityIOHandler::readFromField( const cvf::Color3f& fieldValue, - QTextStream& outputStream, - bool quoteStrings, - bool quoteNonBuiltin ) -{ - QColor qColor( fieldValue.rByte(), fieldValue.gByte(), fieldValue.bByte() ); - QString fieldStringValue = qColor.name(); - PdmFieldScriptabilityIOHandler::readFromField( fieldStringValue, outputStream, quoteStrings ); -} diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.h b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.h index c7a7b1a0bc..7288729a69 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldIOScriptability.h @@ -41,8 +41,6 @@ #include "cafPdmPtrField.h" #include "cafPdmScriptIOMessages.h" -#include "cvfColor3.h" - #include #include #include @@ -154,19 +152,6 @@ struct PdmFieldScriptabilityIOHandler bool quoteNonBuiltins = false ); }; -template <> -struct PdmFieldScriptabilityIOHandler -{ - static void writeToField( cvf::Color3f& fieldValue, - QTextStream& inputStream, - PdmScriptIOMessages* errorMessageContainer, - bool stringsAreQuoted = true ); - static void readFromField( const cvf::Color3f& fieldValue, - QTextStream& outputStream, - bool quoteStrings = true, - bool quoteNonBuiltins = false ); -}; - template struct PdmFieldScriptabilityIOHandler> {